if [ $UID -ne 0 ]; then
log "running as non-root uid $UID"
RUNAS_ID="$UID"
+ RUNAS_GID=`id -g $USER`
RUNAS=""
else
RUNAS_ID=${RUNAS_ID:-500}
- RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+ RUNAS_GID=${RUNAS_GID:-$RUNAS_ID}
+ RUNAS=${RUNAS:-"runas -u $RUNAS_ID -g $RUNAS_GID"}
fi
PDSH=${PDSH:-no_dsh}
do_node $CLIENT1 mcreate $file
pre=$(get_version $CLIENT1 $file)
- do_node $CLIENT1 chown $RUNAS_ID $file
+ do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
post=$(get_version $CLIENT1 $file)
if (($pre == $post)); then
error "version not changed: pre $pre, post $post"
do_node $CLIENT1 mcreate $file
pre=$(get_version $CLIENT1 $file)
- do_node $CLIENT1 chown :$RUNAS_ID $file
+ do_node $CLIENT1 chgrp $RUNAS_GID $file
post=$(get_version $CLIENT1 $file)
if (($pre == $post)); then
error "version not changed: pre $pre, post $post"
do_node $CLIENT1 mcreate $file
replay_barrier $SINGLEMDS
- do_node $CLIENT2 chown :$RUNAS_ID $MOUNT2/$tfile
- do_node $CLIENT1 chown $RUNAS_ID $file
+ do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
+ do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
zconf_umount $CLIENT2 $MOUNT2
facet_failover $SINGLEMDS
do_node $CLIENT1 mcreate $file
replay_barrier $SINGLEMDS
- do_node $CLIENT2 chown $RUNAS_ID $MOUNT2/$tfile
- do_node $CLIENT1 chown :$RUNAS_ID $file
+ do_node $CLIENT2 chown $RUNAS_ID:$RUNAS_GID $MOUNT2/$tfile
+ do_node $CLIENT1 chgrp $RUNAS_GID $file
zconf_umount $CLIENT2 $MOUNT2
facet_failover $SINGLEMDS
do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
replay_barrier $SINGLEMDS
- do_node $CLIENT2 chown :$RUNAS_ID $MOUNT2/$tfile
+ do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
do_node $CLIENT1 chmod 666 $file
zconf_umount $CLIENT2 $MOUNT2
facet_failover $SINGLEMDS
replay_barrier $SINGLEMDS
do_node $CLIENT1 chmod 666 $DIR/$tfile-a # R
do_node $CLIENT2 chmod 666 $DIR1/$tfile-b # R
- do_node $CLIENT2 chown :$RUNAS_ID $DIR2/$tfile-a # U
- do_node $CLIENT1 chown $RUNAS_ID $DIR/$tfile-a # J
+ do_node $CLIENT2 chgrp $RUNAS_GID $DIR2/$tfile-a # U
+ do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-a # J
do_node $CLIENT2 truncate $DIR2/$tfile-b 1 # U
- do_node $CLIENT2 chown :$RUNAS_ID $DIR1/$tfile-b # R
- do_node $CLIENT1 chown $RUNAS_ID $DIR/$tfile-b # R
+ do_node $CLIENT2 chgrp $RUNAS_GID $DIR1/$tfile-b # R
+ do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-b # R
zconf_umount $CLIENT2 $MOUNT2
facet_failover $SINGLEMDS
do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$UID -g \\\#$UID \
$DIR1/$tfile-a || error "$DIR/$tfile-a: unexpected state"
- do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$RUNAS_ID -g \\\#$RUNAS_ID \
+ do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$RUNAS_ID -g \\\#$RUNAS_GID \
$DIR1/$tfile-b || error "$DIR/$tfile-b: unexpected state"
zconf_umount $CLIENT2 $MOUNT1
$DEBUG_OFF
myUID=$RUNAS_ID
+ myGID=$RUNAS_GID
myRUNAS=$RUNAS
- FAIL_ON_ERROR=false check_runas_id_ret $myUID $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
- chown $myUID:$myUID $DBENCHDIR
+ FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
+ { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
+ chown $myUID:$myGID $DBENCHDIR
local duration=""
[ "$SLOW" = "no" ] && duration=" -t 120"
if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
$DEBUG_OFF
myUID=$RUNAS_ID
+ myGID=$RUNAS_GID
myRUNAS=$RUNAS
- FAIL_ON_ERROR=false check_runas_id_ret $myUID $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
- chown $myUID:$myUID $BONDIR
- $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myUID -d$BONDIR
+ FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
+ { myRUNAS="" && myUID=$UID && myGID=`id -$USER`; }
+ chown $myUID:$myGID $BONDIR
+ $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myGID -d$BONDIR
$DEBUG_ON
}
run_test bonnie "bonnie++"
# $SPACE was calculated with all OSTs
$DEBUG_OFF
myUID=$RUNAS_ID
+ myGID=$RUNAS_GID
myRUNAS=$RUNAS
- FAIL_ON_ERROR=false check_runas_id_ret $myUID $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
- chown $myUID:$myUID $IOZDIR
+ FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
+ { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
+ chown $myUID:$myGID $IOZDIR
$myRUNAS iozone $IOZONE_OPTS -s $SIZE -f $IOZFILE 2>&1 | tee $IOZLOG
tail -1 $IOZLOG | grep -q complete || \
{ error "iozone (1) failed" && return 1; }
# $RUNAS_ID may get set incorrectly somewhere else
[ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
-check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
+check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
build_test_filter
$RUNAS mkdir $DIR/d6g/d || error
chmod g+s $DIR/d6g/d || error
mkdir $DIR/d6g/d/subdir
- $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
+ $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
}
run_test 6g "Is new dir in sgid dir inheriting group?"
test_6h() { # bug 7331
[ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
touch $DIR/f6h || error "touch failed"
- chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
- $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
- $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/f6h || error
+ chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
+ $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
+ $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
}
run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
test_22() {
WDIR=$DIR/$tdir
mkdir -p $WDIR
- chown $RUNAS_ID $WDIR
+ chown $RUNAS_ID:$RUNAS_GID $WDIR
(cd $WDIR || error "cd $WDIR failed";
$RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
$RUNAS tar xf -)
ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
$CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
- $CHECKSTAT -u \#$RUNAS_ID $WDIR/etc || error "checkstat -u failed"
+ $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
}
run_test 22 "unpack tar archive as non-root user ==============="
setup_56 $NUMFILES $NUMDIRS
- chgrp $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
+ chgrp $RUNAS_GID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
EXPECTED=$NUMFILES
- NUMS="`$LFIND -gid $RUNAS_ID $TDIR | wc -l`"
+ NUMS="`$LFIND -gid $RUNAS_GID $TDIR | wc -l`"
[ $NUMS -eq $EXPECTED ] || \
error "lfs find -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
- NUMS="`$LFIND ! -gid $RUNAS_ID $TDIR | wc -l`"
+ NUMS="`$LFIND ! -gid $RUNAS_GID $TDIR | wc -l`"
[ $NUMS -eq $EXPECTED ] || \
error "lfs find ! -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
[ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
# Check that testing environment is properly set up. Skip if not
- FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
+ FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
skip_env "User $RUNAS_ID does not exist - skipping"
return 0
}
# $RUNAS_ID may get set incorrectly somewhere else
[ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
-check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
+check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
build_test_filter
chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
$RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
- setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
+ setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
$RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
- setfacl -m u:$RUNAS_ID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
+ setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
$RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
- setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
+ setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
$RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
- setfacl -x u:$RUNAS_ID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
+ setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
$RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
rm -rf $DIR1/$tdir