To: None <tjw00@bayarea.net>
From: None <gwing@primenet.com.au>
List: netbsd-bugs
Date: 03/06/1997 16:52:34
-----BEGIN PGP SIGNED MESSAGE-----
"Thomas J. Wye" <tjw00@bayarea.net> writes:
:>Synopsis: <File permission break Bourne Shell CGI scripts>
:getcwd() failed: Permission denied
getcwd() uses opendir()/readdir() on successive "../" all the way back
to the root. If a parent directory isn't readable you can't get the cwd
for it. There is an extension to that relating to mount points.
If your perl scripts work, then that just indicates that perl doesn't try
to do a getcwd() during initialisation.
sh tries to do it to initialise its variable : PWD
I don't know what it did before.
There's a patch at the bottom, you can use, to make it silently continue
though its behaviour on failed getcwd() is now different from /bin/pwd
I have no idea what any standards may indicate on the matter.
Here are a couple of examples:
1)
% mkdir t
% mkdir t/t
% chmod 111 t
% cd t/t
% /bin/pwd
pwd: Permission denied
2)
# ls -ld /src
drwx------ 5 root wheel 512 Mar 5 14:56 /src/
# mount /src
# ls -ld /src
drwxr-xr-x 5 root wheel 512 Mar 5 14:56 /src/
% cd /src # I'm not root here
% /bin/pwd
pwd: Permission denied
% ls -ld ..
ls: ..: Permission denied
*** /usr/src/bin/sh/cd.c Sat Jan 11 23:07:07 1997
- --- /usr/obj/bin/sh/cd.c Thu Mar 6 16:44:18 1997
***************
*** 324,331 ****
*/
#if defined(__NetBSD__) || defined(__svr4__)
if (getcwd(buf, sizeof(buf)) == NULL)
! error("getcwd() failed: %s", strerror(errno));
! curdir = savestr(buf);
#else
{
char *p;
- --- 324,332 ----
*/
#if defined(__NetBSD__) || defined(__svr4__)
if (getcwd(buf, sizeof(buf)) == NULL)
! curdir = savestr(".");
! else
! curdir = savestr(buf);
#else
{
char *p;
- --
Geoff Wing [mason@primenet.com.au] Technical Manager
Phone : +61-3-9818 2977 PrimeNet - Internet Consultancy
Facsimile: +61-3-9819 3788 Web : <URL:http://www.primenet.com.au/>
Mobile : 0412 162 441
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv
iQCVAwUBMx5boOkZdFsUTaLFAQFOuwP/VnIYWQiutR9WUmsvrLNQgd/hsI+aOHXd
CLGXn41k73fJQNxULA3iLGh2frjDo6HLTc1ez7lsJ4qLgYqv2RLAZU+zlRUACcLd
69vZsQfbarO+VJJlfyMrL1IF8iBHW6ZRJsyhrU499LdHBw8T7cYlr/9JD7Kc+NOx
V/BlOdUb9X4=
=aHGR
-----END PGP SIGNATURE-----