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

Dave Eisen dkeisen at Gang-of-Four.Stanford.EDU
Fri Oct 12 02:57:33 AEST 1990


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).

Another possibility is pointed up by the snippet from our man page for getwd:

 
       *  Getwd changes directories (uses the system call chdir) to figure out
          which directory you are in. If there is an error, getwd may not be
          able to change back to the directory you were in when you called it.
          If this occurs, any files created will be in the wrong place.

Or what if the permissions on your current directory have changed since it
became your current directory and you can't chdir back to it?

These problems go away if getwd is done by a different process. 


--
Dave Eisen                      	    Home: (415) 323-9757
dkeisen at Gang-of-Four.Stanford.EDU           Office: (415) 967-5644
1447 N. Shoreline Blvd.
Mountain View, CA 94043



More information about the Comp.unix.programmer mailing list