]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: Fix -t in listing mode when run as non-root
authorRichard Tollerton <rich.tollerton@ni.com>
Thu, 3 Jan 2013 06:05:34 +0000 (00:05 -0600)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Jan 2013 13:47:25 +0000 (14:47 +0100)
Presently, libmount-mount completely prohibits the use of -t by non-root
users.  This breaks using -t in listing mode as a user, which represents
a regression against mount-deprecated, macosx and presumably *BSD.

This commit fixes the issue by deferring the mnt_context_is_restricted
check for -t until we know we're not in listing mode.

Signed-off-by: Rich Tollerton <rich.tollerton@ni.com>
sys-utils/mount.c

index e29e34cfd30104aa027701bf278c2cc65fe06214..fed96eb7bef9a492d9302892bd7af679f19ea417 100644 (file)
@@ -800,7 +800,7 @@ int main(int argc, char **argv)
 
                /* only few options are allowed for non-root users */
                if (mnt_context_is_restricted(cxt) &&
-                   !strchr("hlLUVvpris", c) &&
+                   !strchr("hlLUVvprist", c) &&
                    c != MOUNT_OPT_TARGET &&
                    c != MOUNT_OPT_SOURCE)
                        exit_non_root(option_to_longopt(c, longopts));
@@ -950,6 +950,11 @@ int main(int argc, char **argv)
                goto done;
        }
 
+       /* Non-root users are allowed to use -t to print_all(),
+          but not to mount */
+       if (mnt_context_is_restricted(cxt) && types)
+               exit_non_root("types");
+
        if (oper && (types || all || mnt_context_get_source(cxt)))
                usage(stderr);