Pass "allow owner override" flags from NFSD down to actual FS.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

   NFSD does its own internal checks to possibly override restrictive file mode
   for file owner already, to allow writing into (opened) file with some
   restrictive mode (like 0000). But it does not pass this info down to
   actual filesystems, and if that filesystem is also doing permission checks
   in open, such an open would fail at FS-level.
   (I thought of making an example with NFS exported with NFS, but this appears
    to be not allowed, so I choose different example).
   For example Lustre is contacting its metadata server for every open, and
   metadata server does permission checks for open, obviously.

   I wonder if something like the patch below can be useful for any other
   distributed FS now in use and ultimately to end up accepted into vanilla
   tree?


--- linux-2.6.16/include/asm-generic/fcntl.h.orig	2006-04-22 23:09:57.000000000 +0300
+++ linux-2.6.16/include/asm-generic/fcntl.h	2006-04-22 23:10:58.000000000 +0300
@@ -52,6 +52,9 @@
 #ifndef O_NDELAY
 #define O_NDELAY	O_NONBLOCK
 #endif
+#ifndef O_OWNER_OVERRIDE
+#define O_OWNER_OVERRIDE 02000000
+#endif
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get close_on_exec */
--- linux-2.6.16/include/linux/fs.h.orig	2006-04-22 23:02:22.000000000 +0300
+++ linux-2.6.16/include/linux/fs.h	2006-04-22 23:06:22.000000000 +0300
@@ -265,6 +265,7 @@ typedef void (dio_iodone_t)(struct kiocb
 #define ATTR_KILL_SUID	2048
 #define ATTR_KILL_SGID	4096
 #define ATTR_FILE	8192
+#define ATTR_OWNER_OVERRIDE	16384
 
 /*
  * This is the Inode Attributes structure, used for notify_change().  It
--- linux-2.6.16/fs/nfsd/vfs.c.orig	2006-04-22 23:03:49.000000000 +0300
+++ linux-2.6.16/fs/nfsd/vfs.c	2006-04-22 23:11:34.000000000 +0300
@@ -341,9 +341,10 @@ nfsd_setattr(struct svc_rqst *rqstp, str
 	if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
 		iap->ia_valid |= ATTR_KILL_SGID;
 
-	/* Change the attributes. */
+	/* Change the attributes. Allow owner of file to change attributes
+	 * even if mode does not permit so. */
 
-	iap->ia_valid |= ATTR_CTIME;
+	iap->ia_valid |= ATTR_CTIME | ATTR_OWNER_OVERRIDE;
 
 	err = nfserr_notsync;
 	if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
@@ -640,7 +641,7 @@ nfsd_open(struct svc_rqst *rqstp, struct
 {
 	struct dentry	*dentry;
 	struct inode	*inode;
-	int		flags = O_RDONLY|O_LARGEFILE, err;
+	int		flags = O_RDONLY|O_LARGEFILE|O_OWNER_OVERRIDE, err;
 
 	/*
 	 * If we get here, then the client has already done an "open",
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux