]> err.no Git - util-linux/commitdiff
mount: more verbose "mount: only root can do that" message
authorKarel Zak <kzak@redhat.com>
Wed, 30 Sep 2009 14:54:17 +0000 (16:54 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 30 Sep 2009 14:54:17 +0000 (16:54 +0200)
> [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>
mount/mount.c

index e8cb5499232d7f96530c55f54f91f2cfff87dbec..23d70cb14ce7a46d0c160150a973a38bd8c1099d 100644 (file)
@@ -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);