Subject: kern/21538: msdosfs: differrent masks for files and directories
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wilbour@linuxfaq.cz>
List: netbsd-bugs
Date: 05/11/2003 19:33:24
>Number: 21538
>Category: kern
>Synopsis: msdosfs: differrent masks for files and directories
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 11 19:34:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: pavel arnost
>Release: 1.6.1
>Organization:
>Environment:
NetBSD arnost.clnet.cz 1.6.1 NetBSD 1.6.1 (GENERIC) #0: Sat May 3 23:59:45 CEST 2003 id9848949@arnost.clnet.cz:/usr/src/sys/arch/i386/compile/GENERIC i386
>Description:
there's no way how to set different permission masks for files and directories
>How-To-Repeat:
>Fix:
this patch adds -M mount option, which is used as permission mask for directories; it's based on FreeBSD PR #35699
cvs diff against current:
Index: sbin/mount_msdos/mount_msdos.8
===================================================================
RCS file: /cvsroot/src/sbin/mount_msdos/mount_msdos.8,v
retrieving revision 1.25
diff -b -u -r1.25 mount_msdos.8
--- sbin/mount_msdos/mount_msdos.8 2003/02/25 10:35:02 1.25
+++ sbin/mount_msdos/mount_msdos.8 2003/05/11 19:17:44
@@ -44,6 +44,7 @@
.Op Fl u Ar uid
.Op Fl g Ar gid
.Op Fl m Ar mask
+.Op Fl M Ar mask
.Op Fl s
.Op Fl l
.Op Fl 9
@@ -98,9 +99,20 @@
for more information about octal file modes.)
Only the nine low-order bits of
.Ar mask
-are used.
+are used. The value of
+.Ar -M
+is used if it is supplied and
+.Ar -m
+is omitted.
The default mask is taken from the
directory on which the file system is being mounted.
+.It Fl M Ar mask
+Specify the maximum file permissions for directories
+in the file system. The value of
+.Ar -m
+is used if it is supplied and
+.Ar -M
+is omitted. See description of previous option for details.
.It Fl s
Force behaviour to
ignore and not generate Win'95 long filenames.
Index: sbin/mount_msdos/mount_msdos.c
===================================================================
RCS file: /cvsroot/src/sbin/mount_msdos/mount_msdos.c,v
retrieving revision 1.28
diff -b -u -r1.28 mount_msdos.c
--- sbin/mount_msdos/mount_msdos.c 2003/05/03 15:37:08 1.28
+++ sbin/mount_msdos/mount_msdos.c 2003/05/11 19:17:45
@@ -86,13 +86,13 @@
{
struct msdosfs_args args;
struct stat sb;
- int c, mntflags, set_gid, set_uid, set_mask;
+ int c, mntflags, set_gid, set_uid, set_mask, set_dirmask;
char *dev, *dir, ndir[MAXPATHLEN+1];
- mntflags = set_gid = set_uid = set_mask = 0;
+ mntflags = set_gid = set_uid = set_mask = set_dirmask = 0;
(void)memset(&args, '\0', sizeof(args));
- while ((c = getopt(argc, argv, "Gsl9u:g:m:o:")) != -1) {
+ while ((c = getopt(argc, argv, "Gsl9u:g:m:M:o:")) != -1) {
switch (c) {
case 'G':
args.flags |= MSDOSFSMNT_GEMDOSFS;
@@ -118,6 +118,10 @@
args.mask = a_mask(optarg);
set_mask = 1;
break;
+ case 'M':
+ args.dirmask = a_mask(optarg);
+ set_dirmask = 1;
+ break;
case 'o':
getmntopts(optarg, mopts, &mntflags, 0);
break;
@@ -131,6 +135,15 @@
if (optind + 2 != argc)
usage();
+ if (set_mask && !set_dirmask) {
+ args.dirmask = args.mask;
+ set_dirmask = 1;
+ }
+ else if (set_dirmask && !set_mask) {
+ args.mask = args.dirmask;
+ set_mask = 1;
+ }
+
dev = argv[optind];
dir = argv[optind + 1];
if (dir[0] != '/') {
@@ -158,7 +171,8 @@
if (!set_gid)
args.gid = sb.st_gid;
if (!set_mask)
- args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+ args.mask = args.dirmask =
+ sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
}
if (mount(MOUNT_MSDOS, dir, mntflags, &args) < 0)
Index: sys/fs/msdosfs/msdosfs_vfsops.c
===================================================================
RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfs_vfsops.c,v
retrieving revision 1.4
diff -b -u -r1.4 msdosfs_vfsops.c
--- sys/fs/msdosfs/msdosfs_vfsops.c 2003/04/16 21:44:19 1.4
+++ sys/fs/msdosfs/msdosfs_vfsops.c 2003/05/11 19:17:49
@@ -146,6 +146,7 @@
pmp->pm_gid = argp->gid;
pmp->pm_uid = argp->uid;
pmp->pm_mask = argp->mask & ALLPERMS;
+ pmp->pm_dirmask = argp->dirmask & ALLPERMS;
pmp->pm_flags |= argp->flags & MSDOSFSMNT_MNTOPT;
/*
@@ -202,7 +203,7 @@
args.flags = 0;
args.uid = 0;
args.gid = 0;
- args.mask = 0777;
+ args.mask = args.dirmask = 0777;
if ((error = msdosfs_mountfs(rootvp, mp, p, &args)) != 0) {
mp->mnt_op->vfs_refcount--;
Index: sys/fs/msdosfs/msdosfs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfs_vnops.c,v
retrieving revision 1.2
diff -b -u -r1.2 msdosfs_vnops.c
--- sys/fs/msdosfs/msdosfs_vnops.c 2003/02/25 10:29:12 1.2
+++ sys/fs/msdosfs/msdosfs_vnops.c 2003/05/11 19:17:55
@@ -263,7 +263,7 @@
mode = S_IRWXU|S_IRWXG|S_IRWXO;
else
mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- return (vaccess(ap->a_vp->v_type, mode & pmp->pm_mask,
+ return (vaccess(ap->a_vp->v_type, mode & (vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask ),
pmp->pm_uid, pmp->pm_gid, ap->a_mode, ap->a_cred));
}
@@ -309,6 +309,8 @@
else
mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vap->va_mode = mode & pmp->pm_mask;
+ vap->va_mode = mode &
+ (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);
vap->va_uid = pmp->pm_uid;
vap->va_gid = pmp->pm_gid;
vap->va_nlink = 1;
Index: sys/fs/msdosfs/msdosfsmount.h
===================================================================
RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfsmount.h,v
retrieving revision 1.2
diff -b -u -r1.2 msdosfsmount.h
--- sys/fs/msdosfs/msdosfsmount.h 2003/02/01 06:23:41 1.2
+++ sys/fs/msdosfs/msdosfsmount.h 2003/05/11 19:17:56
@@ -55,7 +55,8 @@
struct export_args export; /* network export information */
uid_t uid; /* uid that owns msdosfs files */
gid_t gid; /* gid that owns msdosfs files */
- mode_t mask; /* mask to be applied for msdosfs perms */
+ mode_t mask; /* file mask to be applied for msdosfs perms */
+ mode_t dirmask; /* dir mask to be applied for msdosfs perms */
int flags; /* see below */
};
@@ -91,7 +92,10 @@
dev_t pm_dev; /* block special device mounted */
uid_t pm_uid; /* uid to set as owner of the files */
gid_t pm_gid; /* gid to set as owner of the files */
- mode_t pm_mask; /* mask to and with file protection bits */
+ mode_t pm_mask; /* mask to and with file protection bits
+ for files */
+ mode_t pm_dirmask; /* mask to and with file protection bits
+ for directories */
struct vnode *pm_devvp; /* vnode for block device mntd */
struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */
u_long pm_FATsecs; /* actual number of fat sectors */
>Release-Note:
>Audit-Trail:
>Unformatted: