Running 'lfs project' on a bad symlink reports an error:
# ln -s foo /myth/tmp/projid-900/symlink
# lfs project -p 1000 /myth/tmp/projid-900/symlink
lfs: failed to stat '/myth/tmp/projid-900/symlink':
No such file or directory
# ln -s symlink3 /myth/tmp/projid-900/symlink3
# lfs project -p 1000 /myth/tmp/projid-900/symlink3
lfs: failed to stat '/myth/tmp/projid-900/symlink3':
Too many levels of symbolic links
Opening the symlink with open(O_NOFOLLOW) avoids following the
symlink and allows the project ID to be set on the symlink itself.
Fixes:
501e5b2c8a ("LU-18027 lfs: lfs find handling special files")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ibe0504c63270306a68329d8b165e7b83276695c8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59905
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
touch $dir1/file
ln -s $dir1/file $dir1/file_link
+ ln -s bad $dir1/bad_link
+ ln -s self $dir1/self_link
mkfifo $dir1/fifo
$LFS project -srp $TSTPRJID $dir1 >&/dev/null ||
error "set project should succeed"
used=$(getquota -p $TSTPRJID global curinodes)
- [ $used -eq 4 ] || error "expected 4 got $used"
+ (( $used == 6 )) || error "expected 4 got $used"
$LFS project -rC $dir1 >&/dev/null ||
error "clear project should succeed"
used=$(getquota -p $TSTPRJID global curinodes)
- [ $used -eq 0 ] || error "expected 0 got $used"
+ (( $used == 0 )) || error "expected 0 got $used"
}
run_test 64 "lfs project on non dir/files should succeed"
strncpy(bname_path, pathname, PATH_MAX);
dname = dirname(dname_path);
bname = basename(bname_path);
- fd = open(dname, O_RDONLY | O_NOCTTY | O_NDELAY);
+ fd = open(dname, O_RDONLY | O_NOCTTY | O_NDELAY | O_NOFOLLOW);
if (fd < 0) {
ret = -errno;
goto out;