From 46b3ebbb16b246b676e753220e8ea22a60d7d102 Mon Sep 17 00:00:00 2001 From: szaka Date: Fri, 11 Apr 2008 01:02:40 +0000 Subject: [PATCH] unprivileged mount may failed because suppl. groups were dropped too early --- libfuse-lite/fusermount.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libfuse-lite/fusermount.c b/libfuse-lite/fusermount.c index 5fdcad9c..c7964f01 100644 --- a/libfuse-lite/fusermount.c +++ b/libfuse-lite/fusermount.c @@ -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 */