From 7b094eccd23ab67c39c4569ffd8e0ce7533038bb Mon Sep 17 00:00:00 2001 From: Kaz Kyheku Date: Fri, 7 Feb 2020 23:15:25 -0800 Subject: chmod: setuid/setgid bit bugfix and new tests. * sysif.c (chmod_wrap): Again, related to the = operator, we must not punch a hole in the suid and sgid bits for all non-directory objects. This was based on a misinterpretation of some coreutils documentation, and doesn't match the actual behavior. Rather, if the owner is a target (including implicitly) then we mask out suid; and if the group owner is a targe, then we mask out sgid. Thus when we are doing a permission set not targetting the owner we don't touch suid, and similarly for the group owner and setgid. * tests/018/chmod.tl: Failed test diagnostics now identify which mode string was used. Some existing tests involving the suid/sgid bits have to be revised because this commit reflects a correction in the requirements. One new test is added. --- tests/018/chmod.tl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/018/chmod.tl b/tests/018/chmod.tl index 16b96ad0..f815548c 100644 --- a/tests/018/chmod.tl +++ b/tests/018/chmod.tl @@ -19,8 +19,8 @@ (let* ((st (stat tgt)) (m (logand st.mode #xFFF))) (unless (eql m exp) - (error "failed to set mode: expected ~s, actual ~s" - expected (enc-perm m)))))) + (error "failed to set mode with ~s: expected ~s, actual ~s" + mode expected (enc-perm m)))))) (remove-path tgt) (with-stream (s (open-file tgt "w"))) @@ -32,10 +32,11 @@ (cht "------------" "g+s" "-g----------") (cht "------------" "+t" "--t---------") (cht "sgtrwxrwxrwx" "=" "------------") -(cht "sgtrwxrwxrwx" "u=" "--t---rwxrwx") -(cht "sgtrwxrwxrwx" "g=" "--trwx---rwx") -(cht "sgtrwxrwxrwx" "o=" "---rwxrwx---") +(cht "sgtrwxrwxrwx" "u=" "-gt---rwxrwx") +(cht "sgtrwxrwxrwx" "g=" "s-trwx---rwx") +(cht "sgtrwxrwxrwx" "o=" "sg-rwxrwx---") (cht "------------" "u+s,g+s" "sg----------") (cht "------------" "u+r,g+r,o+r,+t,+s" "sgtr--r--r--") (cht "------------" "+rwx,g-r+w,o-r+w" "---rwx-wx-wx") (cht "---------rwx" "u=rwsx" "s--rwx---rwx") +(cht "---------rwx" "u=rwsx,g=rwx,go-x" "s--rwxrw-rw-") -- cgit v1.2.3