fuse/fuse-0003-Fix-mounting-FUSE-fs-into-current-working-directory.patch
Peter Lemenkov a353eb8e76 Fix mounting FUSE fs into current working directory
See rhbz #622255 for additional details:

https://bugzilla.redhat.com/show_bug.cgi?id=622255

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2010-10-27 17:11:42 +04:00

126 lines
3.5 KiB
Diff

From d8bdebc639a84fa280153a466d4bb420fc9572bc Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Wed, 27 Oct 2010 16:29:45 +0400
Subject: [PATCH 3/3] Fix mounting FUSE fs into current working directory
See rhbz #622255 for bug description:
https://bugzilla.redhat.com/622255
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
lib/mount_util.c | 75 +++++++++++++-----------------------------------------
1 files changed, 18 insertions(+), 57 deletions(-)
diff --git a/lib/mount_util.c b/lib/mount_util.c
index 33e6697..b9a0895 100644
--- a/lib/mount_util.c
+++ b/lib/mount_util.c
@@ -54,8 +54,8 @@ static int mtab_needs_update(const char *mnt)
return 1;
}
-static int add_mount_legacy(const char *progname, const char *fsname,
- const char *mnt, const char *type, const char *opts)
+static int add_mount(const char *progname, const char *fsname,
+ const char *mnt, const char *type, const char *opts, int is_legacy)
{
int res;
int status;
@@ -76,6 +76,14 @@ static int add_mount_legacy(const char *progname, const char *fsname,
goto out_restore;
}
if (res == 0) {
+ /*
+ * Hide output, because old versions don't support
+ * --no-canonicalize
+ */
+ int fd = open("/dev/null", O_RDONLY);
+ dup2(fd, 1);
+ dup2(fd, 2);
+
char templ[] = "/tmp/fusermountXXXXXX";
char *tmp;
@@ -99,59 +107,12 @@ static int add_mount_legacy(const char *progname, const char *fsname,
exit(1);
}
rmdir(tmp);
- execl("/bin/mount", "/bin/mount", "-i", "-f", "-t", type,
- "-o", opts, fsname, mnt, NULL);
- fprintf(stderr, "%s: failed to execute /bin/mount: %s\n",
- progname, strerror(errno));
- exit(1);
- }
- res = waitpid(res, &status, 0);
- if (res == -1)
- fprintf(stderr, "%s: waitpid: %s\n", progname, strerror(errno));
-
- if (status != 0)
- res = -1;
-
- out_restore:
- sigprocmask(SIG_SETMASK, &oldmask, NULL);
-
- return res;
-}
-
-static int add_mount(const char *progname, const char *fsname,
- const char *mnt, const char *type, const char *opts)
-{
- int res;
- int status;
- sigset_t blockmask;
- sigset_t oldmask;
-
- sigemptyset(&blockmask);
- sigaddset(&blockmask, SIGCHLD);
- res = sigprocmask(SIG_BLOCK, &blockmask, &oldmask);
- if (res == -1) {
- fprintf(stderr, "%s: sigprocmask: %s\n", progname, strerror(errno));
- return -1;
- }
-
- res = fork();
- if (res == -1) {
- fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno));
- goto out_restore;
- }
- if (res == 0) {
- /*
- * Hide output, because old versions don't support
- * --no-canonicalize
- */
- int fd = open("/dev/null", O_RDONLY);
- dup2(fd, 1);
- dup2(fd, 2);
-
- sigprocmask(SIG_SETMASK, &oldmask, NULL);
- setuid(geteuid());
- execl("/bin/mount", "/bin/mount", "--no-canonicalize", "-i",
- "-f", "-t", type, "-o", opts, fsname, mnt, NULL);
+ if(is_legacy)
+ execl("/bin/mount", "/bin/mount", "-i",
+ "-f", "-t", type, "-o", opts, fsname, mnt, NULL);
+ else
+ execl("/bin/mount", "/bin/mount", "--no-canonicalize", "-i",
+ "-f", "-t", type, "-o", opts, fsname, mnt, NULL);
fprintf(stderr, "%s: failed to execute /bin/mount: %s\n",
progname, strerror(errno));
exit(1);
@@ -177,9 +138,9 @@ int fuse_mnt_add_mount(const char *progname, const char *fsname,
if (!mtab_needs_update(mnt))
return 0;
- res = add_mount(progname, fsname, mnt, type, opts);
+ res = add_mount(progname, fsname, mnt, type, opts, 0);
if (res == -1)
- res = add_mount_legacy(progname, fsname, mnt, type, opts);
+ res = add_mount(progname, fsname, mnt, type, opts, 1);
return res;
}
--
1.7.3.1