From 3d1b35b62dd15282162c21895c25b297768dcbb6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 30 Sep 2009 16:54:17 +0200 Subject: [PATCH] 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 Signed-off-by: Karel Zak --- mount/mount.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mount/mount.c b/mount/mount.c index e8cb5499..23d70cb1 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); -- 2.39.5