Date: Sun, 7 Oct 2007 03:26:48 +0800 (KRAST) From: Eugene Grosbein <eugen@grosbein.pp.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/116980: [patch] [msdosfs] mount_msdosfs(8) resets some flags for 'update' mount Message-ID: <200710061926.l96JQmtE036306@grosbein.pp.ru> Resent-Message-ID: <200710061930.l96JU1VZ038076@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 116980 >Category: bin >Synopsis: [patch] [msdosfs] mount_msdosfs(8) resets some flags for 'update' mount >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Oct 06 19:30:00 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Eugene Grosbein >Release: FreeBSD 6.2-STABLE i386 >Organization: Svyaz-Service JSC >Environment: System: FreeBSD grosbein.pp.ru 6.2-STABLE FreeBSD 6.2-STABLE #2: Sun Sep 16 16:54:23 KRAST 2007 eu@grosbein.pp.ru:/home/obj/usr/local/src/sys/DADV i386 >Description: "mount -t msdosfs -u -o rw" resets uid, gid, mask and dirmask to defauls but should keep current values. >How-To-Repeat: 1. Create FS with a file: # dd if=/dev/zero bs=1k count=1440 of=image # mdconfig -a -t vnode -f image # newfs_msdos -f 1440 /dev/md0 # mount_msdosfs /dev/md0 /mnt/tmp # touch /mnt/tmp/file # umount /mnt/tmp 2. Mount it with convenient flags, so directories are searchable and files are not executable, and read-only: # mount_msdosfs -o ro -M 755 -m 644 /dev/md0 /mnt/tmp Make sure it works, file is not executable: # ls -l /mnt/tmp total 0 -rw-r--r-- 1 root wheel 0 Oct 7 03:05 file Now remount it read-write and see that mask has been reset: # mount -u -o rw /mnt/tmp # ls -l /mnt/tmp total 0 -rwxr-xr-x 1 root wheel 0 Oct 7 03:05 file >Fix: mount_msdosfs(8) should not set defaults for update. --- sbin/mount_msdosfs/mount_msdosfs.c.orig 2007-09-24 20:36:51.000000000 +0800 +++ sbin/mount_msdosfs/mount_msdosfs.c 2007-10-07 03:15:40.000000000 +0800 @@ -69,7 +69,7 @@ struct iovec *iov = NULL; int iovlen = 0; struct stat sb; - int c, mntflags, set_gid, set_uid, set_mask, set_dirmask; + int c, mntflags, set_gid, set_uid, set_mask, set_dirmask, update = 0; char *dev, *dir, mntpath[MAXPATHLEN], *csp; char fstype[] = "msdosfs"; char *cs_dos = NULL; @@ -133,6 +133,7 @@ *p = '\0'; val = p + 1; } + update = update || !strcmp(optarg, "update"); build_iovec(&iov, &iovlen, optarg, val, -1); } break; @@ -165,13 +166,15 @@ if (optind + 2 != argc) usage(); - if (set_mask && !set_dirmask) { - dirmask = mask; - set_dirmask = 1; - } - else if (set_dirmask && !set_mask) { - mask = dirmask; - set_mask = 1; + if (!update) { + if (set_mask && !set_dirmask) { + dirmask = mask; + set_dirmask = 1; + } + else if (set_dirmask && !set_mask) { + mask = dirmask; + set_mask = 1; + } } dev = argv[optind]; @@ -195,26 +198,36 @@ (void)checkpath(dir, mntpath); (void)rmslashes(dev, dev); - if (!set_gid || !set_uid || !set_mask) { + if (!update && (!set_gid || !set_uid || !set_mask)) { if (stat(mntpath, &sb) == -1) err(EX_OSERR, "stat %s", mntpath); - - if (!set_uid) + if (!set_uid) { uid = sb.st_uid; - if (!set_gid) + set_uid = 1; + } + if (!set_gid) { gid = sb.st_gid; - if (!set_mask) + set_gid = 1; + } + if (!set_mask) { mask = dirmask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); + set_mask = set_dirmask = 1; + } } build_iovec(&iov, &iovlen, "fstype", fstype, -1); build_iovec(&iov, &iovlen, "fspath", mntpath, -1); build_iovec(&iov, &iovlen, "from", dev, -1); - build_iovec_argf(&iov, &iovlen, "uid", "%d", uid); - build_iovec_argf(&iov, &iovlen, "gid", "%u", gid); - build_iovec_argf(&iov, &iovlen, "mask", "%u", mask); - build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask); + + if (set_uid) + build_iovec_argf(&iov, &iovlen, "uid", "%d", uid); + if (set_gid) + build_iovec_argf(&iov, &iovlen, "gid", "%u", gid); + if (set_mask) + build_iovec_argf(&iov, &iovlen, "mask", "%u", mask); + if (set_dirmask) + build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask); if (nmount(iov, iovlen, mntflags) < 0) err(1, "%s", dev); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710061926.l96JQmtE036306>