Subject: Re: lib/25077: getcwd() doesn't work if a parent directory isn't readable
To: None <email@example.com>
From: Simon Burge <firstname.lastname@example.org>
Date: 04/07/2004 16:30:22
> >Number: 25077
> >Category: lib
> >Synopsis: getcwd() doesn't work if a parent directory isn't readable
> Getcwd() returns ``Permission denied'' if a parent directory isn't
> readable (it's not +r, only +x), even if the current directory is.
> It may break several userland applications.
SUSv3 (and thus probably POSIX) says:
The getcwd() function shall fail if:
Read or search permission was denied for a component of the
If a program is operating in a directory where some
(grand)parent directory does not permit reading, getcwd() may
fail, as in most implementations it must read the directory to
determine the name of the file. This can occur if search, but
not read, permission is granted in an intermediate directory,
or if the program is placed in that directory by some more
privileged process (for example, login). Including the [EACCES]
error condition makes the reporting of the error consistent and
warns the application writer that getcwd() can fail for reasons
beyond the control of the application writer or user. Some
implementations can avoid this occurrence (for example, by
implementing getcwd() using pwd, where pwd is a set-user-root
process), thus the error was made optional. Since this volume of
IEEE Std 1003.1-2001 permits the addition of other errors, this
would be a common addition and yet one that applications could
not be expected to deal with without this addition.
> Has it got to be fixed, anyway?
I would say "no" personally.
Simon Burge <email@example.com>
NetBSD Support and Service: http://www.wasabisystems.com/