1#!/bin/sh 2# see if chgrp can change the group of a symlink 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_ chgrp 21require_membership_in_two_groups_ 22 23set _ $groups; shift 24g1=$1 25g2=$2 26 27touch f 28ln -s f symlink 29 30chgrp -h $g2 symlink 2> /dev/null 31set _ $(ls -ln symlink) 32g=$5 33test "$g" = $g2 || 34 skip_ "your system doesn't support changing the owner or group" \ 35 "of a symbolic link." 36 37 38chgrp $g1 f 39set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 40 41chgrp -h $g2 symlink || fail=1 42set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 43set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 44 45# This should not change the group of f. 46chgrp -h $g2 symlink || fail=1 47set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 48set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 49 50chgrp $g2 f 51set _ $(ls -ln f); g=$5; test "$g" = $g2 || fail=1 52 53# This *should* change the group of f. 54# Though note that the diagnostic you'd get with -c is misleading in that 55# it says the 'group of 'symlink'' has been changed. 56chgrp --dereference $g1 symlink 57set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 58set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 59 60Exit $fail 61