Richard Gooch writes:
> Alexander Viro writes:
> > 
> > 
> > On Sun, 25 Jun 2000, Richard Gooch wrote:
> > 
> > >   Hi, Al. Recent kernels have a problem with unmounting via the device
> > > file. If I do:
> > > 
> > > # mknod /mydev b ...
> > > # mount -n /mydev /mnt
> > > # /tmp/kumount /mydev
> > > Error unmounting: /mydev        Invalid argument
> > > 
> > > This used to work. Note that kumount only does a call to umount(2).
> >
> >  Shot with explicit permission from Linus. It was an ancient
> > rudiment of v7->Minix->Linux 0.10 lineage and had been replaced by
> > better mechanism in 0.9<something>. It makes no sense for NFS or any
> > other non-block fs, it's makes no sense if you may have multiple
> > mounts; other Unices had dropped it since long. Since umount(8) did
> > not use it since _very_ long...
> > Do it by the mountpoint.
> 
> I'll agree that unmounting by the mountpoint is the sane choice,
> but it seems that umount -a is doing it via the device. That's the
> behaviour I see and a cursory glance at the source confirms this
> (util-linux-2.10m).
> 
> In addition, shutdown(8) from util-linux also prefers to unmount via
> the device (for when umount -a fails).
> 
> Sigh. Looks like I'll have to do more digging. If this was a general
> problem there would be screams all over the place.

OK, I've tracked down the problems. Actually, there were two
problems. Firstly, I've got shutdown(8) installed suid-root for the
admin group. That's fine, until it does umount -a, at which point
umount(8) bitches about not being root (uid != euid). So then
shutdown(8) tries to unmount manually. The second problem then gets
exposed, which is that it tries to unmount the device and not the
mount point.

Andries: I've attached a patch that fixes these problems. Could you
please apply it?

                                Regards,

                                        Richard....
Permanent: [EMAIL PROTECTED]
Current:   [EMAIL PROTECTED]
===============================================================================
diff -urN util-linux-2.10m/login-utils/shutdown.c util-linux/login-utils/shutdown.c
--- util-linux-2.10m/login-utils/shutdown.c     Mon Mar 20 16:18:38 2000
+++ util-linux/login-utils/shutdown.c   Sun Jun 25 22:37:40 2000
@@ -127,7 +127,7 @@
         textdomain(PACKAGE);
 
 #ifndef DEBUGGING
-       if(geteuid()) {
+       if(setreuid(0, 0)) {
                fprintf(stderr, _("%s: Only root can shut a system down.\n"),
                        argv[0]);
                exit(1);
@@ -581,8 +581,7 @@
        }
        n = 0;
        while (n < 100 && (mnt = getmntent(mtab))) {
-               mntlist[n++] = strdup(mnt->mnt_fsname[0] == '/' ?
-                       mnt->mnt_fsname : mnt->mnt_dir);
+               mntlist[n++] = strdup(mnt->mnt_dir);
        }
        endmntent(mtab);
 
@@ -594,7 +593,8 @@
                printf("umount %s\n", filesys);
 #else
                if (umount(mntlist[i]) < 0)
-                       printf(_("shutdown: Couldn't umount %s\n"), filesys);
+                       printf(_("shutdown: Couldn't umount %s\t%s\n"),
+                              filesys, ERRSTRING);
 #endif
        }
 }

Reply via email to