On Tue, Aug 29, 2023 at 09:41:34AM +0200, Marcus MERIGHI wrote: > Hello, > > thanks for taking a look! My reproducer is at the end. > > What I missed to state: this is on amd64, > OpenBSD 7.3-current (GENERIC.MP) #1356: Mon Aug 28 09:35:30 MDT 2023 > > kern...@gmail.com (George Koehler), 2023.08.28 (Mon) 22:01 (CEST): > > On Mon, 28 Aug 2023 12:42:39 +0200 > > Marcus MERIGHI <mcmer-open...@tor.at> wrote: > > > > > My complete crontab(5) entry reads: > > > > > > /usr/bin/find ~/ -maxdepth 1 -fstype local -name "*.core" -delete > > > > > > Now I get error messages saying "Access Denied" for directories that > > > find(1) should not access due to "-maxdepth 1". > > > > I can't produce such errors. I observe that -maxdepth 1 and -delete > > work well together. There's no bug unless someone can provide more > > specific instructions to produce the error. > > $ cd /tmp > $ mkdir -p foo/bar/baz > $ chmod a= foo/bar/baz > $ cd foo > $ find . -maxdepth 1 -fstype local -name "*.core" > $ find . -maxdepth 1 -fstype local -name "*.core" -delete > find: ./bar/baz: Permission denied
The "-fstype local" is not needed to reproduce the issue, and the "-delete" may be replaced by anything that causes a depth-first traversal of the directory tree, such as the "-d" option or the "-depth" primary. The way that OpenBSD implements the non-standard "-maxdepth" primary is slightly different to how e.g. GNU find implements it, in how it plays with a depth-first operation. In OpenBSD find, a depth-first traversal is not limited by "-maxdepth" in the same way as in GNU find, it's just that the primary will not match anything beneath the specified depth. This is why the error message is generated in the example above (and not when using GNU find); find tries to find a leaf directory first, and *then* applies the primaries to the found pathnames. Or so I presume. It's IMHO not an actual bug (seeing as the primary in question is not standard to start with), just unexpected behaviour (that may be worth changing). > > Marcus -- Andreas (Kusalananda) Kähäri SciLifeLab, NBIS, ICM Uppsala University, Sweden .