aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar Miklos Szeredi <miklos@szeredi.hu>2001-12-20 15:38:05 +0000
committerGravatar Miklos Szeredi <miklos@szeredi.hu>2001-12-20 15:38:05 +0000
commitfe25def3344095825738deba119e1400b8e2315f (patch)
treea277304923d54e0495558c1e4e6720c2c114d78d /util
parent2e50d4376f3124a87d5723ae66c09fa71c7ecf88 (diff)
permission checking implemented
Diffstat (limited to 'util')
-rw-r--r--util/fusermount.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/util/fusermount.c b/util/fusermount.c
index ee51269..94f435f 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
@@ -264,7 +264,7 @@ static void restore_privs()
}
static int do_mount(const char *dev, const char *mnt, const char *type,
- mode_t rootmode, int fd)
+ mode_t rootmode, int fd, int fuseflags)
{
int res;
struct fuse_mount_data data;
@@ -282,7 +282,7 @@ static int do_mount(const char *dev, const char *mnt, const char *type,
data.fd = fd;
data.rootmode = rootmode;
data.uid = getuid();
- data.flags = 0;
+ data.flags = fuseflags;
res = mount(dev, mnt, type, flags, &data);
if(res == -1)
@@ -332,7 +332,7 @@ static int check_perm(const char *mnt, struct stat *stbuf)
return 0;
}
-static int mount_fuse(const char *mnt)
+static int mount_fuse(const char *mnt, int flags)
{
int res;
int fd;
@@ -364,7 +364,7 @@ static int mount_fuse(const char *mnt)
return -1;
}
- res = do_mount(dev, mnt, type, stbuf.st_mode & S_IFMT, fd);
+ res = do_mount(dev, mnt, type, stbuf.st_mode & S_IFMT, fd, flags);
if(res == -1)
return -1;
@@ -401,7 +401,9 @@ static void usage()
"%s: [options] mountpoint [program [args ...]]\n"
"Options:\n"
" -h print help\n"
- " -u unmount\n",
+ " -u unmount\n"
+ " -p check default permissions on files\n"
+ " -x allow other users to access the files (only for root)\n",
progname);
exit(1);
}
@@ -419,6 +421,7 @@ int main(int argc, char *argv[])
char mypath[PATH_MAX];
char *unmount_cmd;
char verstr[128];
+ int flags = 0;
progname = argv[0];
@@ -435,6 +438,19 @@ int main(int argc, char *argv[])
unmount = 1;
break;
+ case 'p':
+ flags |= FUSE_DEFAULT_PERMISSIONS;
+ break;
+
+ case 'x':
+ if(getuid() != 0) {
+ fprintf(stderr, "%s: option %s is allowed only for root\n",
+ progname, argv[a]);
+ exit(1);
+ }
+ flags |= FUSE_ALLOW_OTHER;
+ break;
+
default:
fprintf(stderr, "%s: Unknown option %s\n", progname, argv[a]);
exit(1);
@@ -474,7 +490,7 @@ int main(int argc, char *argv[])
userprog = argv + a;
numargs = argc - a;
- fd = mount_fuse(mnt);
+ fd = mount_fuse(mnt, flags);
if(fd == -1)
exit(1);