Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jun 2005 04:54:38 -0700 (PDT)
From:      "Loren M. Lang" <lorenl@alzatex.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/81989: [PATCH] mount_msdosfs When a mask, but no dirmask specified, add X bits to dirmask.
Message-ID:  <200506071154.j57BscEW001526@fbsd.ddns.alzatex.cc>
Resent-Message-ID: <200506071200.j57C0wxE090273@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         81989
>Category:       bin
>Synopsis:       [PATCH] mount_msdosfs When a mask, but no dirmask specified, add X bits to dirmask.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 07 12:00:57 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Loren M. Lang
>Release:        FreeBSD 5.4-RELEASE-p1 i386
>Organization:
Alzatex, Inc.
>Environment:
System: FreeBSD fbsd.ddns.alzatex.cc 5.4-RELEASE-p1 FreeBSD 5.4-RELEASE-p1 #6: Tue Jun 7 04:04:28 PDT 2005 root@:/usr/obj/usr/src/sys/IPSEC-NG i386


	
>Description:
	Currently, when a file mask is set, but no directory mask, it sets
the directory mask to the file mask.  Or when no mask it set at all, it uses
the permissions on the mount point for both the directory and file mask.
This patch causes mount_msdosfs to enable the access(X) bit for the directory
mask everywhere either a read or write permission is set.  This allows me
to set a file mask with -m 644 or by changing the permissions on the mount
point to 644 and have directories work correctly with the corresponding 755
permissions.

	This behavior mimics how mount_smbfs currently responds for smb
network mounts.

>How-To-Repeat:
	The following two commands would get a permission error:

	mount_msdosfs -m 644 /dev/fd0 /mnt/floppy
	ls /mnt/floppy

>Fix:

	

--- mount_msdosfs.patch begins here ---
--- sbin/mount_msdosfs/mount_msdosfs.c.orig	Sat Jun  4 02:49:28 2005
+++ sbin/mount_msdosfs/mount_msdosfs.c	Tue Jun  7 03:48:53 2005
@@ -81,6 +81,7 @@
 static mode_t	a_mask(char *);
 static void	usage(void) __dead2;
 static int	set_charset(struct msdosfs_args *);
+static mode_t	set_dirxbit(mode_t);
 
 int
 main(int argc, char **argv)
@@ -186,7 +187,7 @@
 		usage();
 
 	if (set_mask && !set_dirmask) {
-		args.dirmask = args.mask;
+		args.dirmask = set_dirxbit(args.mask);
 		set_dirmask = 1;
 	}
 	else if (set_dirmask && !set_mask) {
@@ -231,15 +232,30 @@
 			args.uid = sb.st_uid;
 		if (!set_gid)
 			args.gid = sb.st_gid;
-		if (!set_mask)
-			args.mask = args.dirmask =
-				sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+		if (!set_mask) {
+			args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+			args.dirmask = set_dirxbit(args.mask);
+		}
 	}
 
 	if (mount("msdosfs", mntpath, mntflags, &args) < 0)
 		err(EX_OSERR, "%s", dev);
 
 	exit (0);
+}
+
+static mode_t
+set_dirxbit(m)
+	mode_t m;
+{
+	if(m & (S_IRUSR|S_IWUSR))
+		m |= S_IXUSR;
+	if(m & (S_IRGRP|S_IWGRP))
+		m |= S_IXGRP;
+	if(m & (S_IROTH|S_IWOTH))
+		m |= S_IXOTH;
+
+	return m;
 }
 
 gid_t
--- mount_msdosfs.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506071154.j57BscEW001526>