From: Karel Zak Date: Wed, 30 Sep 2009 14:54:17 +0000 (+0200) Subject: mount: more verbose "mount: only root can do that" message X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d1b35b62dd15282162c21895c25b297768dcbb6;p=util-linux 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 --- 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);