From: John L. Hammond Date: Fri, 15 Jun 2012 21:14:06 +0000 (-0500) Subject: LU-1519 llite: Add a mount flag to clarify DAC handling X-Git-Tag: 2.3.51~68 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=e3cdb7dd1262469621c94b6da5c0d645590afdd1 LU-1519 llite: Add a mount flag to clarify DAC handling 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 Reviewed-on: http://review.whamcloud.com/3104 Tested-by: Hudson Tested-by: Maloo Reviewed-by: wangdi Reviewed-by: Keith Mannthey Reviewed-by: Andreas Dilger --- diff --git a/lustre/doc/mount.lustre.8 b/lustre/doc/mount.lustre.8 index 969a450..06cce14 100644 --- a/lustre/doc/mount.lustre.8 +++ b/lustre/doc/mount.lustre.8 @@ -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 diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index f985625..1554eca 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -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)); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 96379d6..f793d52 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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; diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 0c9f6d6..a6c1221 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -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 */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 23b04d1..7305317 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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); }