diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-04-02 19:04:02 +0100 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2013-02-20 15:59:08 +0100 |
commit | 4a6fb6768aada05e456b2e8cbbcf5660637564ce (patch) | |
tree | bb59afe108548b44a07104b499c3b7e0a68719f2 /lib/mount.c | |
parent | 29e1d592d014f7ccb001d62d1c818df54095c46f (diff) |
libfuse: use O_CLOEXEC flag when opening /dev/fuse device
Diffstat (limited to 'lib/mount.c')
-rw-r--r-- | lib/mount.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/mount.c b/lib/mount.c index 01f64da..4f74841 100644 --- a/lib/mount.c +++ b/lib/mount.c @@ -406,6 +406,10 @@ static int fuse_mount_fusermount(const char *mountpoint, struct mount_opts *mo, return rv; } +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, const char *mnt_opts) { @@ -442,7 +446,7 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, return -2; } - fd = open(devname, O_RDWR); + fd = open(devname, O_RDWR | O_CLOEXEC); if (fd == -1) { if (errno == ENODEV || errno == ENOENT) fprintf(stderr, "fuse: device not found, try 'modprobe fuse' first\n"); @@ -451,6 +455,8 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, devname, strerror(errno)); return -1; } + if (!O_CLOEXEC) + fcntl(fd, F_SETFD, FD_CLOEXEC); snprintf(tmp, sizeof(tmp), "fd=%i,rootmode=%o,user_id=%i,group_id=%i", fd, stbuf.st_mode & S_IFMT, getuid(), getgid()); |