Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001392 [1003.1(2016/18)/Issue7+TC2] Shell and Utilities Editorial Clarification Requested 2020-08-14 12:55 2020-08-21 17:12
Reporter mohd_akram View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Mohamed Akram
Organization
User Reference
Section find
Page Number 2797
Line Number 91951-91956
Interp Status ---
Final Accepted Text
Summary 0001392: find(1): clarify whether -perm ops - and + should follow chmod
Description Currently, BSD/macOS find(1) behave like chmod when it comes to the - and + operators of -perm:

$ umask
0022
$ touch file
$ chmod +w file
$ find file -perm -+w
file

GNU find behaves differently (https://savannah.gnu.org/bugs/?58654): [^]

$ umask
0002
$ touch file
$ chmod +w
$ find file -perm -+w

GNU find treats = and + as equivalent, while BSD find doesn't (which is IMO more useful).
Desired Action Clarify the behavior of find(1) -perm with respect to the - and + operators.
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0004925)
joerg (reporter)
2020-08-15 11:15

My interpretation of the standard matches the one from BSD even though that differs from Solaris. But Solaris uses the man page text from POSIX....

BTW: libfind behaves the same as BSD with this detail.

Given that the standard mentions the mask, I believe it is exact enough.
(0004926)
geoffclare (manager)
2020-08-19 09:22

> Given that the standard mentions the mask, I believe it is exact enough.

I disagree. It only mentions the mask in the statement about '=':
'=' shall set the appropriate mode bits, without regard to the contents of the file mode creation mask of the process.
It does not mention the mask in the statements about '+' and '-', therefore it is implicitly unspecified whether the mask is used for those.

I think we should issue a "standard is silent" interpretation, thus allowing both behaviours for Issue 7, but we should make a change in Issue 8 to require the BSD behaviour.
(0004929)
joerg (reporter)
2020-08-19 10:32

Given that the find man page points to chmod(1) and that it explicitly mentions '=' to differ somehow from '+', I see this as a hint that -perm must behave similar to chmod(1) which includes the file creation mask.

BTW: When I wrote my parser in July 2004 for libfind, I did not check existing find implementations but only the POSIX standard. The background for writing libfindhas been the missing usability of gfind and find from Solaris at that time. So the behavior of libfind is just a consequence of following the standard and what is expected for orthogonal behavior.

Regardless of the way you interpret this, we seem to basically agree that the libfind/BSD behavior is the right way to go for the future.

P.S. The Solaris implementation behaves the same as gfind for this detail, but I am happy to change this.
(0004930)
geoffclare (manager)
2020-08-19 11:32
edited on: 2020-08-19 11:34

Re: Note: 0004929

1. The find man page only points to chmod for the "format" of the mode operand, i.e. the syntax not the semantics.

2. '=' and '+' do indeed differ, but only in that '=' is required to ignore the mask whereas '+' can either use it or ignore it.

3. I'm not sure there is even a hint here; readers not sufficiently familiar with standardese might think so, but those experienced in interpreting the standard should see that there is nothing at all said about the mask in relation to '+'. Anyway, a "hint" is not a requirement.

(0004941)
mohd_akram (reporter)
2020-08-21 16:47
edited on: 2020-08-21 16:53

I think the title I put should be tweaked - the issue is actually + and = (- seems to behave the same due to the 000 starting point). I had posted the = example in the filed GNU bug but forgot about it - hopefully this link will work: https://savannah.gnu.org/bugs/?58654 [^]

On macOS:

$ chmod =w file
$ find file -perm =w
file

On Fedora:

$ chmod =w file
$ find file -perm =w

It seems that macOS does not ignore the mask even with =, mimicking chmod's behavior. It feels like it would be simpler to defer to chmod in both syntax and semantics because the "symbolic_mode" operand is fairly complicated. This could entail removing the "without regard to the contents of the file mode creation mask of the process" clause (letting "appropriate" do all the heavy-lifting instead) and adding at the end that it is "implementation-defined whether + and = ignore the file mode creation mask when `who` is not specified".

(0004942)
shware_systems (reporter)
2020-08-21 17:12

Yes, link works this time :-)

- Issue History
Date Modified Username Field Change
2020-08-14 12:55 mohd_akram New Issue
2020-08-14 12:55 mohd_akram Name => Mohamed Akram
2020-08-14 12:55 mohd_akram Section => find
2020-08-14 12:55 mohd_akram Page Number => 2797
2020-08-14 12:55 mohd_akram Line Number => 91951-91956
2020-08-15 11:15 joerg Note Added: 0004925
2020-08-16 21:16 mohd_akram Issue Monitored: mohd_akram
2020-08-19 09:22 geoffclare Note Added: 0004926
2020-08-19 10:32 joerg Note Added: 0004929
2020-08-19 11:32 geoffclare Note Added: 0004930
2020-08-19 11:34 geoffclare Note Edited: 0004930
2020-08-21 16:47 mohd_akram Note Added: 0004941
2020-08-21 16:50 mohd_akram Note Edited: 0004941
2020-08-21 16:53 mohd_akram Note Edited: 0004941
2020-08-21 17:12 shware_systems Note Added: 0004942


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker