1#!/bin/sh 2# Verify that chmod's --changes (-c) option works. 3 4# Copyright (C) 2000-2023 Free Software Foundation, Inc. 5 6# This program is free software: you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation, either version 3 of the License, or 9# (at your option) any later version. 10 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <https://www.gnu.org/licenses/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ chmod 21 22umask 0 23file=f 24touch $file || framework_failure_ 25chmod 444 $file || framework_failure_ 26 27skip_if_setgid_ 28 29 30chmod u=rwx $file || fail=1 31chmod -c g=rwx $file > out || fail=1 32chmod -c g=rwx $file > empty || fail=1 33 34compare /dev/null empty || fail=1 35case "$(cat out)" in 36 "mode of 'f' changed from 0744 "?rwxr--r--?" to 0774 "?rwxrwxr--?) ;; 37 *) cat out; fail=1 ;; 38esac 39 40# From V5.1.0 to 8.22 this would stat the wrong file and 41# give an erroneous ENOENT diagnostic 42mkdir -p a/b || framework_failure_ 43# chmod g+s might fail as detailed in setgid.sh 44# but we don't care about those edge cases here 45chmod g+s a/b 46# This should never warn, but it did when special 47# bits are set on b (the common case under test) 48chmod -c -R g+w a 2>err 49compare /dev/null err || fail=1 50 51Exit $fail 52