Whamcloud - gitweb
LU-1519 llite: Add a mount flag to clarify DAC handling
authorJohn L. Hammond <jhammond@tacc.utexas.edu>
Fri, 15 Jun 2012 21:14:06 +0000 (16:14 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Sep 2012 04:16:05 +0000 (00:16 -0400)
Add a mount flag to control use of OBD_IOC_FID2PATH by processes
without CFS_CAP_DAC_READ_SEARCH.

Change-Id: Ibbca25ad511d80e245716d27fca4287979667db6
Signed-off-by: John L. Hammond <jhammond@tacc.utexas.edu>
Reviewed-on: http://review.whamcloud.com/3104
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: wangdi <di.wang@whamcloud.com>
Reviewed-by: Keith Mannthey <keith@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/doc/mount.lustre.8
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c

index 969a450..06cce14 100644 (file)
@@ -93,6 +93,13 @@ Enable mount/umount console messages.
 .TP
 .BI noverbose
 Disable mount/umount console messages.
+.TP
+.BI user_fid2path
+Enable FID to path translation by regular users.
+.TP
+.BI nouser_fid2path
+Disable FID to path translation by regular users.  Root and process with
+CAP_DAC_READ_SEARCH can still perform FID to path translation.
 .PP
 In addition to the standard mount options and backing disk type
 (e.g. ext3) options listed in
index f985625..1554eca 100644 (file)
@@ -1466,7 +1466,7 @@ out_free:
                                     sizeof(struct ioc_changelog));
                 RETURN(rc);
         case OBD_IOC_FID2PATH:
-                RETURN(ll_fid2path(ll_i2mdexp(inode), (void *)arg));
+               RETURN(ll_fid2path(inode, (void *)arg));
         case LL_IOC_HSM_CT_START:
                 rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg,
                                     sizeof(struct lustre_kernelcomm));
index 96379d6..f793d52 100644 (file)
@@ -1678,12 +1678,17 @@ out:
        RETURN(rc);
 }
 
-int ll_fid2path(struct obd_export *exp, void *arg)
+int ll_fid2path(struct inode *inode, void *arg)
 {
+       struct obd_export *exp = ll_i2mdexp(inode);
         struct getinfo_fid2path *gfout, *gfin;
         int outsize, rc;
         ENTRY;
 
+       if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) &&
+           !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH))
+               RETURN(-EPERM);
+
         /* Need to get the buflen */
         OBD_ALLOC_PTR(gfin);
         if (gfin == NULL)
@@ -1895,7 +1900,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                 RETURN(0);
         }
         case OBD_IOC_FID2PATH:
-                RETURN(ll_fid2path(ll_i2mdexp(inode), (void *)arg));
+               RETURN(ll_fid2path(inode, (void *)arg));
         case LL_IOC_DATA_VERSION: {
                 struct ioc_data_version idv;
                 int rc;
index 0c9f6d6..a6c1221 100644 (file)
@@ -396,6 +396,7 @@ enum stats_track_type {
 #define LL_SBI_AGL_ENABLED     0x8000 /* enable agl */
 #define LL_SBI_VERBOSE        0x10000 /* verbose mount/umount */
 #define LL_SBI_LAYOUT_LOCK    0x20000 /* layout lock support */
+#define LL_SBI_USER_FID2PATH  0x40000 /* allow fid2path by unprivileged users */
 
 /* default value for ll_sb_info->contention_time */
 #define SBI_DEFAULT_CONTENTION_SECONDS     60
@@ -779,7 +780,7 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
 int ll_merge_lvb(struct inode *inode);
 int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg);
 int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg);
-int ll_fid2path(struct obd_export *exp, void *arg);
+int ll_fid2path(struct inode *inode, void *arg);
 
 /* llite/dcache.c */
 
index 23b04d1..7305317 100644 (file)
@@ -803,6 +803,16 @@ static int ll_options(char *options, int *flags)
                         *flags |= tmp;
                         goto next;
                 }
+               tmp = ll_set_opt("user_fid2path", s1, LL_SBI_USER_FID2PATH);
+               if (tmp) {
+                       *flags |= tmp;
+                       goto next;
+               }
+               tmp = ll_set_opt("nouser_fid2path", s1, LL_SBI_USER_FID2PATH);
+               if (tmp) {
+                       *flags &= ~tmp;
+                       goto next;
+               }
 
                 tmp = ll_set_opt("checksum", s1, LL_SBI_CHECKSUM);
                 if (tmp) {
@@ -2325,6 +2335,9 @@ int ll_show_options(struct seq_file *seq, struct vfsmount *vfs)
         if (sbi->ll_flags & LL_SBI_LAZYSTATFS)
                 seq_puts(seq, ",lazystatfs");
 
+       if (sbi->ll_flags & LL_SBI_USER_FID2PATH)
+               seq_puts(seq, ",user_fid2path");
+
         RETURN(0);
 }