Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: pwd in perl Message-ID: <1990Aug10.220614.12305@iwarp.intel.com> Date: 10 Aug 90 22:06:14 GMT References: <1990Aug10.205437.21409@uvaarpa.Virginia.EDU> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 29 In-Reply-To: marc@mit.edu In article <1990Aug10.205437.21409@uvaarpa.Virginia.EDU>, marc@mit writes: | |> Another thing that I don't think has been mentioned, is that you might | |> be in a directory whose parent directory you have no access to. In | |> this case reading ..'s files until you find . will not work. This is | |> why pwd must be setuid root, so that it can do the appropriate checks. | | If you have no access to the parent, how did you get to where you are | now? I think it's a safe assumption that you can read all the | directories up to the root. My system makes this assumption; /bin/pwd | is not setuid root. I think a lot of programs probably depend on | getwd() working. Here, if getwd ()doesn't work, the shell won't even | do the right thing. You can have 'x' access and no 'r' access. On your system, /bin/pwd would fail in this case, and so would any call to getwd() or the Perl routine that's been published (or anything from user-level non-setuid code). I think that's why /bin/pwd is setuid on some machines. (Interesting... it's not setuid on Sunos4.1 either) I agree with Larry, though. chop($pwd = `pwd`) is portable and fast, and there are more important features for Larry to add (I know, I've been writing about them for a week now :-). print "Just another Perl hacker," -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/