bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #58654] -perm -+w does not behave like chmod (POSIX)


From: Andreas Metzler
Subject: [bug #58654] -perm -+w does not behave like chmod (POSIX)
Date: Fri, 26 Jun 2020 01:09:35 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0

Follow-up Comment #2, bug #58654 (project findutils):

[comment #0 Mohamed Akram:]
[...]
> Per POSIX, find should find file because it satisfies +w given the current
umask. The umask should only be ignored if u/g/o are specified or if = is
used. This is the same behavior as chmod. GNU find seems to always ignore the
umask.

Afaict current POSIX (Open Group Base Specifications Issue 7, 2018) does not
say what you claim. There is no mention of respecting umask at all, all mode
specifications start with 0000:


-perm [...] To start, a template shall be assumed with all file mode bits
cleared. An op symbol of '+' shall set the appropriate mode bits in the
template; '-' shall clear the appropriate bits; '=' shall set the appropriate
mode bits, without regard to the contents of the file mode creation mask of
the process. The op symbol of '-' cannot be the first character of mode; this
avoids ambiguity with the optional leading <hyphen-minus>. Since the initial
mode is all bits off, there are not any symbolic modes that need to use '-' as
the first character.

If the <hyphen-minus> is omitted, the primary shall evaluate as true when the
file permission bits exactly match the value of the resulting template.

Otherwise, if mode is prefixed by a <hyphen-minus>, the primary shall evaluate
as true if at least all the bits in the resulting template are set in the file
permission bits.


Which seems to be exactly what find does:

ametzler@argenau:/tmp/xxx$ LANG=C ls -l
total 0
--w--w--w- 1 ametzler ametzler 0 Jun 26 07:05 0222
-rw-r--r-- 1 ametzler ametzler 0 Jun 26 07:05 0644
-rw-rw-rw- 1 ametzler ametzler 0 Jun 26 07:05 0666
ametzler@argenau:/tmp/xxx$ find -perm +w
./0222
ametzler@argenau:/tmp/xxx$ find -perm -+w
./0222
./0666


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58654>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]