From acb4d36c3c91ffc076e76bd11ef8064bd51b4716 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 2 Jul 2004 16:20:45 +0000 Subject: [PATCH] minor features --- ChangeLog | 13 ++++++++++++- kernel/inode.c | 16 +++++++++++++++- lib/helper.c | 29 +++++++++++++++++------------ util/fusermount.c | 5 ----- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14ce894..fe3bfdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,10 +7,21 @@ * Fix revalidate time setting for newly created inodes + * Remove uid==0 check for '-x' option in fusermount (kernel checks + this) + + * fuse_main() only installs handlers for signals (out of INT, HUP, + TERM, PIPE), for which no handler has yet been installed + + * Add module option 'user_allow_other' which if set to non-zero + will allow non root user to specify the 'allow_other' mount option + ('-x' option of fusermount) + 2004-07-01 Miklos Szeredi * Change passing fuse include dir to 2.6 kernel make system more - robust (hopefully fixes problems seen on SuSE 9.1) + robust (fixes compile problems seen on SuSE 9.1 with updated 2.6 + kernel) 2004-06-30 Miklos Szeredi diff --git a/kernel/inode.c b/kernel/inode.c index d94b3b2..f0ad932 100644 --- a/kernel/inode.c +++ b/kernel/inode.c @@ -22,6 +22,19 @@ #include "compat/parser.h" #endif + +static int user_allow_other; + +#ifdef KERNEL_2_6 +#include +module_param(user_allow_other, int, 0); +#else +MODULE_PARM(user_allow_other, "i"); +#endif + +MODULE_PARM_DESC(user_allow_other, "Allow non root user to specify the \"allow_other\" mount option"); + + #define FUSE_SUPER_MAGIC 0x65735546 #ifndef KERNEL_2_6 @@ -309,7 +322,8 @@ static int fuse_read_super(struct super_block *sb, void *data, int silent) if (!parse_fuse_opt((char *) data, &d)) return -EINVAL; - if ((d.flags & FUSE_ALLOW_OTHER) && !capable(CAP_SYS_ADMIN)) + if (!user_allow_other && (d.flags & FUSE_ALLOW_OTHER) && + current->uid != 0) return -EPERM; sb->s_blocksize = PAGE_CACHE_SIZE; diff --git a/lib/helper.c b/lib/helper.c index cd3cfea..526fadd 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -50,30 +50,35 @@ static void exit_handler() fuse_exit(fuse); } -static void set_signal_handlers() +static void set_one_signal_handler(int signal, void (*handler)(int)) { struct sigaction sa; + struct sigaction old_sa; - sa.sa_handler = exit_handler; + sa.sa_handler = handler; sigemptyset(&(sa.sa_mask)); sa.sa_flags = 0; - if (sigaction(SIGHUP, &sa, NULL) == -1 || - sigaction(SIGINT, &sa, NULL) == -1 || - sigaction(SIGTERM, &sa, NULL) == -1) { - - perror("Cannot set exit signal handlers"); + if (sigaction(signal, NULL, &old_sa) == -1) { + perror("FUSE: cannot get old signal handler"); exit(1); } - - sa.sa_handler = SIG_IGN; - - if (sigaction(SIGPIPE, &sa, NULL) == -1) { - perror("Cannot set ignored signals"); + + if (old_sa.sa_handler == SIG_DFL && + sigaction(signal, &sa, NULL) == -1) { + perror("Cannot set signal handler"); exit(1); } } +static void set_signal_handlers() +{ + set_one_signal_handler(SIGHUP, exit_handler); + set_one_signal_handler(SIGINT, exit_handler); + set_one_signal_handler(SIGTERM, exit_handler); + set_one_signal_handler(SIGPIPE, SIG_IGN); +} + static int fuse_start(int fuse_fd, int flags, int multithreaded, int background, const struct fuse_operations *op) { diff --git a/util/fusermount.c b/util/fusermount.c index e837eb2..93d9f52 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -551,11 +551,6 @@ int main(int argc, char *argv[]) break; case 'x': - if(getuid() != 0) { - fprintf(stderr, "%s: option %s is allowed only for root\n", - progname, argv[a]); - exit(1); - } opts.allow_other = 1; break; -- 2.30.2