Subject: kern/16778: msdosfs -m mount option restricts directory permissions too much
To: None <gnats-bugs@gnats.netbsd.org>
From: Johan Danielsson <joda@pdc.kth.se>
List: netbsd-bugs
Date: 05/12/2002 18:25:08
>Number: 16778
>Category: kern
>Synopsis: msdosfs -m mount option restricts directory permissions too much
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 12 09:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Johan Danielsson
>Release: NetBSD 1.5ZA
>Organization:
>Environment:
<The following information is extracted from your kernel. Please>
<append output of "ldd", "ident" where relevant (multiple lines).>
System: NetBSD blubb.pdc.kth.se 1.5ZA NetBSD 1.5ZA (BLUBB) #410: Sat Mar 9 18:04:50 CET 2002 joda@blubb.pdc.kth.se:/usr/misc/src/netbsd/netbsd-cvs/src/sys/arch/i386/compile/BLUBB i386
Architecture: i386
Machine: i386
>Description:
Mounting a MS-DOS filesystem with -m 644 results in directories having
mode 644 too; this isn't very useful.
>How-To-Repeat:
>Fix:
This didn't result in too many bricks:
--- msdosfs_vnops.c 2002/03/17 23:58:09 1.121
+++ msdosfs_vnops.c 2002/05/12 16:18:48
@@ -226,6 +226,38 @@
return (0);
}
+static mode_t
+msdosfs_getmode(struct denode *dep);
+
+static mode_t
+msdosfs_getmode(dep)
+ struct denode *dep;
+{
+ struct msdosfsmount *pmp = dep->de_pmp;
+ mode_t mode;
+
+ if ((dep->de_Attributes & ATTR_READONLY) == 0)
+ mode = S_IRWXU|S_IRWXG|S_IRWXO;
+ else
+ mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
+
+ mode &= pmp->pm_mask;
+
+ if (dep->de_Attributes & ATTR_DIRECTORY) {
+ /* if this is directory, give search permissions to
+ anyone that can read or write */
+ if(mode & (S_IRUSR|S_IWUSR))
+ mode |= S_IXUSR;
+ if(mode & (S_IRGRP|S_IWGRP))
+ mode |= S_IXGRP;
+ if(mode & (S_IROTH|S_IWOTH))
+ mode |= S_IXOTH;
+ }
+
+ return mode;
+}
+
+
int
msdosfs_access(v)
void *v;
@@ -258,11 +290,7 @@
}
}
- if ((dep->de_Attributes & ATTR_READONLY) == 0)
- 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, msdosfs_getmode(dep),
pmp->pm_uid, pmp->pm_gid, ap->a_mode, ap->a_cred));
}
@@ -279,7 +307,6 @@
struct denode *dep = VTODE(ap->a_vp);
struct msdosfsmount *pmp = dep->de_pmp;
struct vattr *vap = ap->a_vap;
- mode_t mode;
struct timespec ts;
u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
u_long fileid;
@@ -303,11 +330,7 @@
fileid += dep->de_diroffset / sizeof(struct direntry);
}
vap->va_fileid = fileid;
- if ((dep->de_Attributes & ATTR_READONLY) == 0)
- mode = S_IRWXU|S_IRWXG|S_IRWXO;
- else
- mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- vap->va_mode = mode & pmp->pm_mask;
+ vap->va_mode = msdosfs_getmode(dep);
vap->va_uid = pmp->pm_uid;
vap->va_gid = pmp->pm_gid;
vap->va_nlink = 1;
>Release-Note:
>Audit-Trail:
>Unformatted:
Subject:
From: joda
X-send-pr-version: 3.95
<Please check that the above is correct for the bug being reported,>
<and append source date of snapshot, if applicable (one line).>