Why use pwd(1) for getpwd(3C)? (Re: Why use find?)

Don Lewis del at thrush.mlb.semi.harris.com
Fri Oct 12 08:18:53 AEST 1990


In article <2714A558.14A8 at marob.masa.com> cowan at marob.masa.com (John Cowan) 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).
>>
>Try saying 'chmod u-rwx .' and then '/bin/pwd'.  You'll probably get
>something like "pwd: can't stat .", at least that's what I get.
>(This assumes your system doesn't have a built-in get[p]wd() call.
>If it does, all bets are off.)
>
>/bin/pwd should be setuid root so that it doesn't get this error.

If the current directory (or another directory higher in the tree) is
not publicly readable and lives on an NFS mounted filesystem which
maps root to nobody, then making /bin/pwd setuid root will break it.
In this case running /bin/pwd as the real user will work.
-- 
Don "Truck" Lewis                      Harris Semiconductor
Internet:  del at mlb.semi.harris.com     PO Box 883   MS 62A-028
Phone:     (407) 729-5205              Melbourne, FL  32901



More information about the Comp.unix.programmer mailing list