Paul Eggert <[EMAIL PROTECTED]> wrote:
> Jim Meyering <[EMAIL PROTECTED]> writes:
>
>> * chdir-safer.c (chdir_no_follow): Remove unnecessary
>> test of S_ISDIR (sb_init.st_mode).
>
> I had noticed that problem along with some others with chdir-safer.c.
> I installed the following patch to clean up the other issues I saw.
Thanks!
I recognize the value of the added open-with-O_WRONLY,
but note that it's wasted on modern Linux systems.
I've checked in one more little change:
2005-12-26 Jim Meyering <[EMAIL PROTECTED]>
* chdir-safer.c (chdir_no_follow): Move declaration of local,
sb2, `down' into the scope where it is used.
Note that on some systems this function also fails when DIR
is a writable-yet-unreadable directory.
Index: lib/chdir-safer.c
===================================================================
RCS file: /fetish/cu/lib/chdir-safer.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -u -r1.6 -r1.7
--- lib/chdir-safer.c 25 Dec 2005 21:38:43 -0000 1.6
+++ lib/chdir-safer.c 26 Dec 2005 18:53:58 -0000 1.7
@@ -45,9 +45,12 @@
/* Like chdir, but fail if DIR is a symbolic link to a directory (or
similar funny business), or if DIR is neither readable nor
- writeable. This avoids a minor race condition between when a
- directory is created or statted and when the process chdirs into
- it. */
+ writable. This avoids a minor race condition between when a
+ directory is created or statted and when the process chdirs into it.
+
+ On some systems, a writable yet unreadable directory cannot be
+ opened via open with O_WRONLY. For example, on Linux 2.6, the
+ open syscall fails with EISDIR. */
int
chdir_no_follow (char const *dir)
{
@@ -70,11 +73,10 @@ chdir_no_follow (char const *dir)
if (! O_NOFOLLOW)
{
struct stat sb1;
- struct stat sb2;
-
result = lstat (dir, &sb1);
if (result == 0)
{
+ struct stat sb2;
result = fstat (fd, &sb2);
if (result == 0 && ! SAME_INODE (sb1, sb2))
{
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils