From 8931cdbfdad34945f0f541e1d1e66f599cb62124 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 8 Mar 2012 19:00:27 -0800 Subject: chmod: add notations +40, 00440, etc. * NEWS: Document this. * doc/perm.texi (Operator Numeric Modes): New section. (Numeric Modes, Directory Setuid and Setgid): Document new behavior. * src/chmod.c (usage): Document new behavior. (main): Support new options -0, -1, etc. * tests/chmod/setgid: Test these new features. --- tests/chmod/setgid | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tests/chmod') diff --git a/tests/chmod/setgid b/tests/chmod/setgid index eaa9351fd..081c36e0d 100755 --- a/tests/chmod/setgid +++ b/tests/chmod/setgid @@ -1,6 +1,7 @@ #!/bin/sh # Make sure GNU chmod works the same way as those of Solaris, HPUX, AIX -# wrt directories with the setgid bit set. +# on directories with the setgid bit set. Also, check that the GNU octal +# notations work. # Copyright (C) 2001-2012 Free Software Foundation, Inc. @@ -21,7 +22,7 @@ print_ver_ chmod umask 0 -mkdir d || framework_failure_ +mkdir -m 755 d || framework_failure_ chmod g+s d 2> /dev/null && env -- test -g d || { @@ -40,9 +41,24 @@ chmod g+s d 2> /dev/null && env -- test -g d || env -- test -g d || skip_ 'cannot create setgid directories' +for mode in \ + + - g-s 00755 000755 =755 -2000 -7022 755 0755 \ + +2000 -5022 =7777,-5022 +do + chmod $mode d || fail=1 -chmod 755 d + case $mode in + g-s | 00*755 | =755 | -2000 | -7022) + expected_mode=drwxr-xr-x ;; + *) expected_mode=drwxr-sr-x ;; + esac + ls_output=`ls -ld d` + case $ls_output in + $expected_mode*) ;; + *) fail=1 ;; + esac -case `ls -ld d` in drwxr-sr-x*);; *) fail=1;; esac + chmod =2755 d || fail=1 +done Exit $fail -- cgit v1.2.3-54-g00ecf