Why use pwd(1) for getpwd(3C)? (Re: Why use find?)
Conor P. Cahill
cpcahil at virtech.uucp
Fri Oct 12 00:06:54 AEST 1990
In article <14976 at hydra.gatech.EDU> gt0178a at prism.gatech.EDU (Jim Burns) writes:
>in article <1990Oct10.231857.11668 at virtech.uucp>, cpcahil at virtech.uucp (Conor P. Cahill) says:
>> I don't know the reason for making it a call to popen(), one reason may
>> have been security (pwd could be a setuid pgm and do things that a
>> function call couldn't).
>
>Not on my system (see below).
Note that I said "could have been". There are no systems that I know of
that have pwd as setuid, I am just saying that from the way it was
architectured (pipe to another program) implies that they a reason may
have been that some version in the past may have required that pwd
be setuid. I know this is not the case for UNIX > V6, but I don't
know what went on before that.
>And what about those shells that have pwd
>builtin? My shell's pwd seems to work fine, and the shell isn't setuid
>either.
The shells that have pwd built-in usually don't run getpwd()/getcwd() to
get the directory each time. They run it once at start up time and then
keep track of where they go. This causes problems if you run pwd (the
shell built-in) from a directory that you got to via a symbolic link
and it gives you the incorrect information (whereas /bin/pwd will give
you the right stuff).
--
Conor P. Cahill (703)430-9247 Virtual Technologies, Inc.,
uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160
Sterling, VA 22170
More information about the Comp.unix.programmer
mailing list