Applied, thanks
On Thu, Sep 16, 2021 at 2:03 AM Wolf <[email protected]> wrote: > > 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. > --- > Before the patch: > > +$ mkdir /tmp/q > +$ busybox chmod -c 0600 /tmp/q > mode of '/tmp/q' changed to 0600 (rw-------) > +$ busybox chmod -c 0600 /tmp/q > mode of '/tmp/q' changed to 0600 (rw-------) > > After the patch: > > +$ mkdir /tmp/r > +$ ./busybox chmod -c 0600 /tmp/r > mode of '/tmp/r' changed to 0600 (rw-------) > +$ ./busybox chmod -c 0600 /tmp/r > > I also took the liberty of changing the non-protable 07777 used in the > printf to the MODE_BITS define introduced in this commit. I can send v2 > without it if it's not desirable. > > coreutils/chmod.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/coreutils/chmod.c b/coreutils/chmod.c > index e260adab2..3b11538c3 100644 > --- a/coreutils/chmod.c > +++ b/coreutils/chmod.c > @@ -57,6 +57,8 @@ > #define OPT_QUIET (IF_DESKTOP(option_mask32 & 8) IF_NOT_DESKTOP(0)) > #define OPT_STR "R" IF_DESKTOP("vcf") > > +#define MODE_BITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) > + > /* coreutils: > * chmod never changes the permissions of symbolic links; the chmod > * system call cannot change their permissions. This is not a problem > @@ -88,10 +90,11 @@ 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 & MODE_BITS) != (newmode & > MODE_BITS)) > ) { > printf("mode of '%s' changed to %04o (%s)\n", > fileName, > - newmode & 07777, bb_mode_string(newmode)+1); > + newmode & MODE_BITS, > bb_mode_string(newmode)+1); > } > return TRUE; > } > -- > 2.33.0 > > _______________________________________________ > busybox mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/busybox _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
