[git commit] chmod: correctly report changed modes

Denys Vlasenko vda.linux at googlemail.com
Thu Sep 16 22:39:21 UTC 2021


commit: https://git.busybox.net/busybox/commit/?id=2df4e0a3707ff3b70398177e9e001070e47ca9c5
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Chmod used to incorrectly report as changed even files for which the
mode did not change. This was caused by extra bits in the st_mode, that
were not present when parsed from passed argument in the form of octal
number.

Patch by Wolf <wolf at wolfsden.cz>.

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/chmod.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/coreutils/chmod.c b/coreutils/chmod.c
index e260adab2..8e3e1387e 100644
--- a/coreutils/chmod.c
+++ b/coreutils/chmod.c
@@ -88,7 +88,8 @@ static int FAST_FUNC fileAction(struct recursive_state *state,
 
 	if (chmod(fileName, newmode) == 0) {
 		if (OPT_VERBOSE
-		 || (OPT_CHANGED && statbuf->st_mode != newmode)
+		 || (OPT_CHANGED
+		     && (statbuf->st_mode & 07777) != (newmode & 07777))
 		) {
 			printf("mode of '%s' changed to %04o (%s)\n", fileName,
 				newmode & 07777, bb_mode_string(newmode)+1);


More information about the busybox-cvs mailing list