unprivileged mount may failed because suppl. groups were dropped too early

master
szaka 2008-04-11 01:02:40 +00:00
parent 5de5fc1421
commit 46b3ebbb16
1 changed files with 7 additions and 8 deletions

View File

@ -54,13 +54,6 @@ static const char *get_user_name(void)
int drop_privs(void)
{
if (!geteuid()) {
if (setgroups(0, NULL) < 0) {
perror("priv drop: setgroups failed");
return -1;
}
}
if (!getegid()) {
gid_t new_gid = getgid();
@ -606,8 +599,14 @@ static int mount_fuse(const char *mnt, const char *opts)
if (restore_privs())
goto err;
if (geteuid() == 0) {
if (setgroups(0, NULL) == -1) {
perror("priv drop: setgroups failed");
goto err;
}
res = add_mount(source, mnt, type, mnt_opts);
if (res == -1) {
umount2(mnt, 2); /* lazy umount */