Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Mar 2012 07:10:02 GMT
From:      Matthew Story <matthewstory@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/166056: [patch][bin] find fails with .: permission denied,  even when using absolute paths
Message-ID:  <201203140710.q2E7A2eT093172@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/166056; it has been noted by GNATS.

From: Matthew Story <matthewstory@gmail.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/166056: [patch][bin] find fails with .: permission denied,
 even when using absolute paths
Date: Wed, 14 Mar 2012 03:06:48 -0400

 --20cf307ca01a78e21704bb2e9e78
 Content-Type: multipart/alternative; boundary=20cf307ca01a78e21204bb2e9e76
 
 --20cf307ca01a78e21204bb2e9e76
 Content-Type: text/plain; charset=ISO-8859-1
 
 On Tue, Mar 13, 2012 at 3:19 PM, Matthew Story <matthewstory@gmail.com>wrote:
 
 > On Tue, Mar 13, 2012 at 3:08 PM, Matthew Story <matthewstory@gmail.com>wrote:
 >
 >> >Fix:
 >> apply patch (patch was made against -CURRENT).  patch will warn if it
 >> cannot open ".", and set the FTL_NOCHDIR flag before proceeding, below
 >> cases demonstrate functionality with&without the -exec flag
 >>
 >
 > Embarrassingly enough, my patch breaks -execdir ... I will follow-up with
 > a correction that doesn't break -execdir.  Apologies for not being more
 > thorough in my testing.
 >
 
 I have resolved the -execdir issue with my patch, and also resolved an
 issue with -execdir not functioning properly with the -L option, as
 FTS_LOGICAL sets FTS_NOCHDIR during fts_open(3):
 
 from: libc/gen/fts.c
  145     /* Logical walks turn on NOCHDIR; symbolic links are too hard. */
  146     if (ISSET(FTS_LOGICAL))
  147         SET(FTS_NOCHDIR);
 
 It also sets FTS_NOCHDIR if it cannot open "." O_RDONLY.  the man-page for
 fts is silent on these two issues, I'll file a separate PR to document that.
 
 There also seems to be an issue with find -execdir ... {} + wherein it
 executes with cwd of the last entry (if plan->e_ppos is maxed out), or with
 wd of the find process (if called by finish_execplus), my expectation for
 this behavior would be to execute with arguments grouped by parent
 directory.  I preserved the existing behavior, as it is not as trivial as
 fixing the -L behavior ... I will open another PR for this behavior.
 
 new patch attached, viewable via http here:
 
 http://axe0.blackskyresearch.net/patches/matt/find.no_dotfd.patch.txt
 
 
 
 -- 
 regards,
 matt
 
 --20cf307ca01a78e21204bb2e9e76
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 On Tue, Mar 13, 2012 at 3:19 PM, Matthew Story <span dir=3D"ltr">&lt;<a hre=
 f=3D"mailto:matthewstory@gmail.com">matthewstory@gmail.com</a>&gt;</span> w=
 rote:<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=
 =3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 <div class=3D"im">On Tue, Mar 13, 2012 at 3:08 PM, Matthew Story <span dir=
 =3D"ltr">&lt;<a href=3D"mailto:matthewstory@gmail.com" target=3D"_blank">ma=
 tthewstory@gmail.com</a>&gt;</span> wrote:</div><div class=3D"gmail_quote">=
 <div class=3D"im">
 <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
 x #ccc solid;padding-left:1ex">
 
 &gt;Fix:<br>
 apply patch (patch was made against -CURRENT). =A0patch will warn if it can=
 not open &quot;.&quot;, and set the FTL_NOCHDIR flag before proceeding, bel=
 ow cases demonstrate functionality with&amp;without the -exec flag<br></blo=
 ckquote>
 
 <div><br></div></div><div>Embarrassingly enough, my patch breaks -execdir .=
 .. I will follow-up with a correction that doesn&#39;t break -execdir. =A0A=
 pologies for not being more thorough in my testing.</div></div></blockquote=
 >
 <div><br></div><div>I have resolved the -execdir issue with my patch, and a=
 lso resolved an issue with -execdir not functioning properly with the -L op=
 tion, as FTS_LOGICAL sets FTS_NOCHDIR during fts_open(3):</div><div><br>
 </div><div>from: libc/gen/fts.c</div><div>=A0145 =A0 =A0 /* Logical walks t=
 urn on NOCHDIR; symbolic links are too hard. */</div><div>=A0146 =A0 =A0 if=
  (ISSET(FTS_LOGICAL))</div><div>=A0147 =A0 =A0 =A0 =A0 SET(FTS_NOCHDIR);</d=
 iv><div><br></div>
 <div>It also sets FTS_NOCHDIR if it cannot open &quot;.&quot; O_RDONLY. =A0=
 the man-page for fts is silent on these two issues, I&#39;ll file a separat=
 e PR to document that.</div><div><br></div><div>There also seems to be an i=
 ssue with find -execdir ... {} + wherein it executes with cwd of the last e=
 ntry (if plan-&gt;e_ppos is maxed out), or with wd of the find process (if =
 called by finish_execplus), my expectation for this behavior would be to ex=
 ecute with arguments grouped by parent directory. =A0I preserved the existi=
 ng behavior, as it is not as trivial as fixing the -L behavior ... I will o=
 pen another PR for this behavior.</div>
 <div><br></div><div>new patch attached, viewable via http here:</div><div><=
 br></div><div><a href=3D"http://axe0.blackskyresearch.net/patches/matt/find=
 .no_dotfd.patch.txt">http://axe0.blackskyresearch.net/patches/matt/find.no_=
 dotfd.patch.txt</a><br>
 </div></div><br><br clear=3D"all"><div><br></div>-- <br>regards,<br>matt<br=
 >
 
 --20cf307ca01a78e21204bb2e9e76--
 --20cf307ca01a78e21704bb2e9e78
 Content-Type: text/plain; charset=US-ASCII; name="find.no_dotfd.patch.txt"
 Content-Disposition: attachment; filename="find.no_dotfd.patch.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_gzs0yp900
 
 SW5kZXg6IGZ1bmN0aW9uLmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gZnVuY3Rpb24uYwkocmV2aXNpb24gMjMy
 OTUwKQorKysgZnVuY3Rpb24uYwkod29ya2luZyBjb3B5KQpAQCAtNTAsNiArNTAsNyBAQAogI2lu
 Y2x1ZGUgPGRpcmVudC5oPgogI2luY2x1ZGUgPGVyci5oPgogI2luY2x1ZGUgPGVycm5vLmg+Cisj
 aW5jbHVkZSA8ZmNudGwuaD4KICNpbmNsdWRl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3RmZCA9IG9wZW4oIi4iLCBPX1JET05MWSwgMCkpIDwgMCkgeworCQl3
 YXJuKCIuIik7CisJCWZ0c29wdGlvbnMgfD0gRlRTX05PQ0hESVI7CisJfQogCiAJZXhpdChmaW5k
 X2V4ZWN1dGUoZmluZF9mb3JtcGxhbihhcmd2KSwgc3RhcnQpKTsKIH0K
 --20cf307ca01a78e21704bb2e9e78--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203140710.q2E7A2eT093172>