From owner-freebsd-current Sat Apr 21 12: 7:29 2001 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 8E73937B422 for ; Sat, 21 Apr 2001 12:07:23 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id FAA05064; Sun, 22 Apr 2001 05:07:14 +1000 Date: Sun, 22 Apr 2001 05:06:16 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Paul Herman Cc: freebsd-current@FreeBSD.ORG Subject: Re: /bin/df set-gid operator In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, 21 Apr 2001, Paul Herman wrote: > This brings up a slightly related question: Now that "cooked" block > devices have been abolished, wouldn't it be a good idea to get rid of > the quick mount(2)/umount(2) of /tmp/df.XXXXXX to stat the file > system? Something like the following patch. No. This code is just unreachable because it still hasn't be changed to mount "raw" block devices. Note that in 4.4BSD, the mount(2)/unmount(2) code works without df being setgid operator provided group operator can read the devices, since mount(2) doesn't require superuser privilege in 4.4BSD. In FreeBSD, mount privilege is controlled by the vfs.usermount sysctl (default: off), so df must still be setgid operator to work on devices. The mount() method is better because can work on work on all types of filesystems that the kernel understands, while ufs_df() only works for ufs. Untested fixes: Index: df.c =================================================================== RCS file: /home/ncvs/src/bin/df/df.c,v retrieving revision 1.24 diff -c -2 -r1.24 df.c *** df.c 2000/06/03 20:17:39 1.24 --- df.c 2001/04/21 18:52:52 *************** *** 108,112 **** void usage __P((void)); ! int aflag = 0, hflag, iflag, nflag; struct ufs_args mdev; --- 108,112 ---- void usage __P((void)); ! int aflag, hflag, iflag, nflag; struct ufs_args mdev; *************** *** 120,125 **** long mntsize; int ch, err, i, maxwidth, rv, width; ! char *mntpt, *mntpath, **vfslist; vfslist = NULL; while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1) --- 120,126 ---- long mntsize; int ch, err, i, maxwidth, rv, width; ! char *fstype, *mntpath, *mntpt, **vfslist; + fstype = "ufs"; vfslist = NULL; while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1) *************** *** 163,166 **** --- 164,168 ---- if (vfslist != NULL) errx(1, "only one -t option may be specified."); + fstype = optarg; vfslist = makevfslist(optarg); break; *************** *** 206,213 **** continue; } ! } else if ((stbuf.st_mode & S_IFMT) == S_IFCHR) { ! rv = ufs_df(*argv, maxwidth) || rv; ! continue; ! } else if ((stbuf.st_mode & S_IFMT) == S_IFBLK) { if ((mntpt = getmntpt(*argv)) == 0) { mdev.fspec = *argv; --- 208,212 ---- continue; } ! } else if (S_ISBLK(stbuf.st_mode) || S_ISCHR(stbuf.st_mode)) { if ((mntpt = getmntpt(*argv)) == 0) { mdev.fspec = *argv; *************** *** 225,229 **** continue; } ! if (mount("ufs", mntpt, MNT_RDONLY, &mdev) != 0) { rv = ufs_df(*argv, maxwidth) || rv; --- 224,228 ---- continue; } ! if (mount(fstype, mntpt, MNT_RDONLY, &mdev) != 0) { rv = ufs_df(*argv, maxwidth) || rv; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message