Skip to content

Commit

Permalink
Merge pull request #18 from yaneurabeya/fix-linux
Browse files Browse the repository at this point in the history
pjdfstest: fix linux support
  • Loading branch information
ngie authored Apr 3, 2017
2 parents e852807 + 76ccf14 commit 5153abe
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
22 changes: 22 additions & 0 deletions tests/chown/00.t
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,33 @@ done
# when non-super-user calls chown(2) successfully, set-uid and set-gid bits may
# be removed, except when both uid and gid are equal to -1.
for type in regular dir fifo block char socket symlink; do
#
# Linux makes a destinction for behavior when an executable file vs a
# non-executable file. From chmod(2):
#
# When the owner or group of an executable file are changed by an
# unprivileged user the S_ISUID and S_ISGID mode bits are cleared.
#
# I believe in this particular case, the behavior's bugged.
#
if [ "${type}" = "dir" -a "${os}" = "Linux" ]; then
_todo_msg="Linux doesn't clear the SGID/SUID bits for directories, despite the description noted"
else
_todo_msg=
fi
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}

expect 0 chown ${n0} 65534 65533
expect 0 chmod ${n0} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65532 stat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555,65534,65532 stat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- chown ${n0} -1 65533
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65533 stat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
Expand All @@ -237,13 +253,17 @@ for type in regular dir fifo block char socket symlink; do
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 06555,65534,65533 stat ${n1} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 chown ${n1} 65534 65532
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65532 stat ${n0} mode,uid,gid
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65532 stat ${n1} mode,uid,gid
expect 0 chmod ${n1} 06555
expect 06555,65534,65532 stat ${n0} mode,uid,gid
expect 06555,65534,65532 stat ${n1} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- chown ${n1} -1 65533
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65533 stat ${n0} mode,uid,gid
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65533 stat ${n1} mode,uid,gid
expect 0 chmod ${n1} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
Expand Down Expand Up @@ -271,6 +291,7 @@ for type in regular dir fifo block char socket symlink; do
fi
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 lchown ${n0} 65534 65532
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65532 lstat ${n0} mode,uid,gid
if supported lchmod; then
expect 0 lchmod ${n0} 06555
Expand All @@ -279,6 +300,7 @@ for type in regular dir fifo block char socket symlink; do
fi
expect 06555,65534,65532 lstat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- lchown ${n0} -1 65533
[ -n "${_todo_msg}" ] && todo "Linux" "${_todo_msg}"
expect 0555,65534,65533 lstat ${n0} mode,uid,gid
if supported lchmod; then
expect 0 lchmod ${n0} 06555
Expand Down
24 changes: 19 additions & 5 deletions tests/open/24.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@
# vim: filetype=sh noexpandtab ts=8 sw=8
# $FreeBSD: head/tools/regression/pjdfstest/tests/open/24.t 211352 2010-08-15 21:24:17Z pjd $

desc="open returns EOPNOTSUPP when trying to open UNIX domain socket"

dir=`dirname $0`
. ${dir}/../misc.sh

# POSIX doesn't explicitly state the errno for open(2)'ing sockets.
case ${os} in
Darwin|FreeBSD)
expected_error=EOPNOTSUPP
;;
Linux)
expected_error=ENXIO
;;
*)
echo "1..0 # SKIP: unsupported OS: ${os}"
exit 0
;;
esac

desc="open returns $expected_error when trying to open UNIX domain socket"

echo "1..5"

n0=`namegen`

expect 0 bind ${n0}
expect "EOPNOTSUPP" open ${n0} O_RDONLY
expect "EOPNOTSUPP" open ${n0} O_WRONLY
expect "EOPNOTSUPP" open ${n0} O_RDWR
expect $expected_error open ${n0} O_RDONLY
expect $expected_error open ${n0} O_WRONLY
expect $expected_error open ${n0} O_RDWR
expect 0 unlink ${n0}

0 comments on commit 5153abe

Please sign in to comment.