1 From e8b56ebd536e82b15542a00c888109471936bfda Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
3 Date: Fri, 24 Sep 2021 20:57:41 +0100
4 Subject: [PATCH] chmod: fix exit status when ignoring symlinks
6 * src/chmod.c: Reorder enum so CH_NOT_APPLIED
7 can be treated as a non error.
8 * tests/chmod/ignore-symlink.sh: A new test.
9 * tests/local.mk: Reference the new test.
10 * NEWS: Mention the bug fix.
11 Fixes https://bugs.gnu.org/50784
14 tests/chmod/ignore-symlink.sh | 31 +++++++++++++++++++++++++++++++
16 4 files changed, 40 insertions(+), 2 deletions(-)
17 create mode 100755 tests/chmod/ignore-symlink.sh
19 diff --git a/src/chmod.c b/src/chmod.c
20 index 37b04f500..57ac47f33 100644
23 @@ -44,8 +44,8 @@ struct change_status
30 CH_NO_CHANGE_REQUESTED,
33 @@ -322,7 +322,7 @@ process_file (FTS *fts, FTSENT *ent)
35 fts_set (fts, ent, FTS_SKIP);
37 - return CH_NO_CHANGE_REQUESTED <= ch.status;
38 + return CH_NOT_APPLIED <= ch.status;
41 /* Recursively change the modes of the specified FILES (the last entry
42 diff --git a/tests/chmod/ignore-symlink.sh b/tests/chmod/ignore-symlink.sh
44 index 000000000..5ce3de816
46 +++ b/tests/chmod/ignore-symlink.sh
49 +# Test for proper exit code of chmod on a processed symlink.
51 +# Copyright (C) 2021 Free Software Foundation, Inc.
53 +# This program is free software: you can redistribute it and/or modify
54 +# it under the terms of the GNU General Public License as published by
55 +# the Free Software Foundation, either version 3 of the License, or
56 +# (at your option) any later version.
58 +# This program is distributed in the hope that it will be useful,
59 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
60 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61 +# GNU General Public License for more details.
63 +# You should have received a copy of the GNU General Public License
64 +# along with this program. If not, see <https://www.gnu.org/licenses/>.
66 +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
69 +mkdir dir || framework_failure_
70 +touch dir/f || framework_failure_
71 +ln -s f dir/l || framework_failure_
73 +# This operation ignores symlinks but should succeed.
74 +chmod u+w -R dir 2> out || fail=1
76 +compare /dev/null out || fail=1
79 diff --git a/tests/local.mk b/tests/local.mk
80 index 228d0e368..b5b893fb7 100644
83 @@ -456,6 +456,7 @@ all_tests = \
84 tests/chmod/c-option.sh \
85 tests/chmod/equal-x.sh \
86 tests/chmod/equals.sh \
87 + tests/chmod/ignore-symlink.sh \
88 tests/chmod/inaccessible.sh \
89 tests/chmod/octal.sh \
90 tests/chmod/setgid.sh \