public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Tollerton <rich.tollerton@ni.com>
To: util-linux@vger.kernel.org
Cc: Richard Tollerton <rich.tollerton@ni.com>
Subject: [PATCH] mount: Fix -t in listing mode when run as non-root
Date: Thu, 3 Jan 2013 00:05:34 -0600	[thread overview]
Message-ID: <1357193134-26828-1-git-send-email-rich.tollerton@ni.com> (raw)

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index e29e34c..fed96eb 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -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);
 
-- 
1.8.1


             reply	other threads:[~2013-01-03  6:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-03  6:05 Richard Tollerton [this message]
2013-01-09 13:51 ` [PATCH] mount: Fix -t in listing mode when run as non-root Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357193134-26828-1-git-send-email-rich.tollerton@ni.com \
    --to=rich.tollerton@ni.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox