[Linux-cluster] patch for gfs, add suiddir option for mount

Ken Preslan kpreslan at redhat.com
Fri Jul 16 22:20:36 UTC 2004


On Fri, Jul 16, 2004 at 12:47:49PM +0400, ????? ????????? wrote:
> Hi linux-cluster,
> 
> I apologize for the previous letter, here full patch
> 
> suiddir option for mount
> man 8 mount (FreeBSD)
> 
> <patch ommited>

You're patch didn't actually follow the FreeBSD man page's description
of suiddir.  From:

http://www.freebsd.org/cgi/man.cgi?query=mount&sektion=8&apropos=0&manpath=FreeBSD+5.2-RELEASE+and+Ports

  A directory on the mounted file system will respond to
  the SUID bit being set, by setting the owner of any new
  files to be the same as the owner of the directory.  New
  directories will inherit the bit from their parents.
  Execute bits are removed from the file, and it will not
  be given to root.

Note the last sentence.


The below patch is acceptable to me.  Is it ok with you?


diff -urN crap1/gfs-kernel/src/gfs/gfs_ioctl.h crap2/gfs-kernel/src/gfs/gfs_ioctl.h
--- crap1/gfs-kernel/src/gfs/gfs_ioctl.h	24 Jun 2004 08:53:27 -0000	1.1
+++ crap2/gfs-kernel/src/gfs/gfs_ioctl.h	16 Jul 2004 22:13:05 -0000
@@ -213,6 +213,7 @@
 	unsigned int ar_num_glockd;
 
 	int ar_posixacls;	/* Enable posix acls */
+	int ar_suiddir;         /* suiddir support */
 };
 
 #endif /* ___GFS_IOCTL_DOT_H__ */
diff -urN crap1/gfs-kernel/src/gfs/inode.c crap2/gfs-kernel/src/gfs/inode.c
--- crap1/gfs-kernel/src/gfs/inode.c	16 Jul 2004 22:07:02 -0000	1.3
+++ crap2/gfs-kernel/src/gfs/inode.c	16 Jul 2004 22:13:05 -0000
@@ -1132,16 +1132,26 @@
 	struct posix_acl *acl = NULL;
 	struct gfs_alloc *al;
 	struct gfs_inode *ip;
-	unsigned int gid;
+	unsigned int uid, gid;
 	int alloc_required;
 	int error;
 
+	if (sdp->sd_args.ar_suiddir &&
+	    (dip->i_di.di_mode & S_ISUID) &&
+	    dip->i_di.di_uid) {
+		if (type == GFS_FILE_DIR)
+			mode |= S_ISUID;
+		else if (dip->i_di.di_uid != current->fsuid)
+			mode &= ~07111;
+		uid = dip->i_di.di_uid;
+	} else
+		uid = current->fsuid;
+
 	if (dip->i_di.di_mode & S_ISGID) {
 		if (type == GFS_FILE_DIR)
 			mode |= S_ISGID;
 		gid = dip->i_di.di_gid;
-	}
-	else
+	} else
 		gid = current->fsgid;
 
 	error = gfs_setup_new_acl(dip, type, &mode, &acl);
@@ -1150,13 +1160,11 @@
 
 	al = gfs_alloc_get(dip);
 
-	error = gfs_quota_lock_m(dip,
-				 current->fsuid,
-				 gid);
+	error = gfs_quota_lock_m(dip, uid, gid);
 	if (error)
 		goto fail;
 
-	error = gfs_quota_check(dip, current->fsuid, gid);
+	error = gfs_quota_check(dip, uid, gid);
 	if (error)
 		goto fail_gunlock_q;
 
@@ -1206,13 +1214,13 @@
 	if (error)
 		goto fail_end_trans;
 
-	error = make_dinode(dip, gl, inum, type, mode, current->fsuid, gid);
+	error = make_dinode(dip, gl, inum, type, mode, uid, gid);
 	if (error)
 		goto fail_end_trans;
 
 	al->al_ul = gfs_trans_add_unlinked(sdp, GFS_LOG_DESC_IDA,
 					   &(struct gfs_inum){0, inum->no_addr});
-	gfs_trans_add_quota(sdp, +1, current->fsuid, gid);
+	gfs_trans_add_quota(sdp, +1, uid, gid);
 
 	/* Gfs_inode_get() can't fail here.  But then again, it shouldn't be
 	   here (it should be in gfs_createi()).  Gfs_init_acl() has no
diff -urN crap1/gfs-kernel/src/gfs/mount.c crap2/gfs-kernel/src/gfs/mount.c
--- crap1/gfs-kernel/src/gfs/mount.c	24 Jun 2004 08:53:28 -0000	1.1
+++ crap2/gfs-kernel/src/gfs/mount.c	16 Jul 2004 22:13:05 -0000
@@ -128,6 +128,9 @@
 		else if (!strcmp(x, "acl"))
 			args->ar_posixacls = TRUE;
 
+		else if (!strcmp(x, "suiddir"))
+			args->ar_suiddir = TRUE;
+
 		/*  Unknown  */
 
 		else {


-- 
Ken Preslan <kpreslan at redhat.com>




More information about the Linux-cluster mailing list