#include <lustre_mds.h>
#include <lustre_fid.h>
#include <lustre_lmv.h>
+#include <lustre_idmap.h>
#include "mdd_internal.h"
if (rc != 0)
RETURN(rc);
- /* sgid check */
+ /* sgid check */
if (pattr->la_mode & S_ISGID) {
+ struct lu_ucred *uc = lu_ucred(env);
+
cattr->la_gid = pattr->la_gid;
+
+ /* Directories are special, and always inherit S_ISGID */
if (S_ISDIR(cattr->la_mode)) {
cattr->la_mode |= S_ISGID;
cattr->la_valid |= LA_MODE;
+ } else if ((cattr->la_mode & (S_ISGID | S_IXGRP))
+ == (S_ISGID | S_IXGRP) &&
+ !lustre_in_group_p(uc,
+ (cattr->la_valid & LA_GID) ?
+ cattr->la_gid : pattr->la_gid) &&
+ !md_capable(uc, CFS_CAP_FSETID)) {
+ cattr->la_mode &= ~S_ISGID;
+ cattr->la_valid |= LA_MODE;
}
}
}
run_test 419 "Verify open file by name doesn't crash kernel"
+test_420()
+{
+ [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
+ skip "Need MDS version at least 2.12.53"
+
+ local SAVE_UMASK=$(umask)
+ local dir=$DIR/$tdir
+ local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
+
+ mkdir -p $dir
+ umask 0000
+ mkdir -m03777 $dir/testdir
+ ls -dn $dir/testdir
+ local dirperms=$(ls -dn $dir/testdir | awk '{print $1}')
+ [ $dirperms == "drwxrwsrwt" ] ||
+ error "incorrect perms on $dir/testdir"
+
+ $PDSH ${uname}@localhost "PATH=$LUSTRE/tests:\$PATH; \
+ openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
+ ls -n $dir/testdir/testfile
+ local fileperms=$(ls -n $dir/testdir/testfile | awk '{print $1}')
+ [ $fileperms == "-rwxr-xr-x" ] ||
+ error "incorrect perms on $dir/testdir/testfile"
+
+ umask $SAVE_UMASK
+}
+run_test 420 "clear SGID bit on non-directories for non-members"
+
prep_801() {
[[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
[[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&