summaryrefslogtreecommitdiffstats
path: root/mount/mount.c
diff options
context:
space:
mode:
authorKarel Zak2009-09-30 16:54:17 +0200
committerKarel Zak2009-09-30 16:54:17 +0200
commit3d1b35b62dd15282162c21895c25b297768dcbb6 (patch)
treefaa9951f9795a06e7e18611dbb59dc8bfed347a9 /mount/mount.c
parentbuild-sys: add --disable-makeinstall-setuid (diff)
downloadkernel-qcow2-util-linux-3d1b35b62dd15282162c21895c25b297768dcbb6.tar.gz
kernel-qcow2-util-linux-3d1b35b62dd15282162c21895c25b297768dcbb6.tar.xz
kernel-qcow2-util-linux-3d1b35b62dd15282162c21895c25b297768dcbb6.zip
mount: more verbose "mount: only root can do that" message
> [chroot-i486] root:/$ whoami > root > [chroot-i486] root:/$ mkdir -p /dev1 > [chroot-i486] root:/$ mount --move /dev /dev1 > mount: only root can do that Reported-by: Gilles Espinasse <g.esp@free.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/mount.c')
-rw-r--r--mount/mount.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/mount/mount.c b/mount/mount.c
index e8cb54992..23d70cb14 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -2205,12 +2205,18 @@ main(int argc, char *argv[]) {
if (((uid_t)0 == ruid) && (ruid == euid)) {
restricted = 0;
}
- }
- if (restricted &&
- (types || options || readwrite || nomtab || mount_all ||
- fake || mounttype || (argc + specseen) != 1)) {
- die (EX_USAGE, _("mount: only root can do that"));
+ if (restricted &&
+ (types || options || readwrite || nomtab || mount_all ||
+ fake || mounttype || (argc + specseen) != 1)) {
+
+ if (ruid == 0 && euid != 0)
+ /* user is root, but setuid to non-root */
+ die (EX_USAGE, _("mount: only root can do that "
+ "(effective UID is %d)"), euid);
+
+ die (EX_USAGE, _("mount: only root can do that"));
+ }
}
atexit(unlock_mtab);