🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #1019

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

#1019
From: Tim Wright
Date: Fri, 12 Oct 1990 16:21
32 lines
1806 bytes
In <23012:Oct1019:12:2790@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:

>In article <1990Oct9.122813.1329@cbnews.att.com> jbr0@cbnews.att.com (joseph.a.brownlee) writes:
>  [ why is getpwd() implemented as `pwd` in System V? ]

>Because there's no getwd() system call to have the kernel do the job.
>Unless you have some sort of privileges, you won't be able to figure
>out the current directory when any higher directory is unreadable.

>---Dan

Well I can't speak for all System V's but all the ones I have used don't
have /bin/pwd suid anyway so that's no excuse. It would still be *massively*
more efficient to do the work pwd does in a library call (i.e. stat back
up the tree), than it is to fork and exec another command ! It just looks
like people were very lazy (it couldn't have been that difficult to copy
the pwd code to the library).

$ cd junk
$ chmod 700 junk
$ chown somebody_else junk
$ pwd
pwd: cannot stat .!

Yuk !

Tim
--
Tim Wright, Dell Computer Corp. (UK) | Email address
Dell Computer Corp. (UK), Bracknell  | Domain: tim@dell.co.uk
Tel: +44-344-860456                  | Uucp: ...!ukc!delluk!tim
"What's the problem? You've got an IQ of six thousand, haven't you?"
Technical Details
Message-ID: <tim.655748499@holly>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!axion!delluk!tim
References: <1977@sixhub.UUCP> <1990Oct7.001518.14216@diku.dk> <1990Oct9.122813.1329@cbnews.att.com> <23012:Oct1019:12:2790@kramden.acf.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!axion!delluk!tim
From: tim@delluk.uucp (Tim Wright)
Newsgroups: comp.unix.programmer
Subject: Re: Why use pwd(1) for getpwd(3C)? (Re: Why use find?)
Message-ID: <tim.655748499@holly>
Date: 12 Oct 90 16:21:39 GMT
References: <1977@sixhub.UUCP> <1990Oct7.001518.14216@diku.dk> <1990Oct9.122813.1329@cbnews.att.com> <23012:Oct1019:12:2790@kramden.acf.nyu.edu>
Sender: usenet@delluk.uucp (Usenet posting login)
Organization: Dell Computer Corp., Bracknell, UK
Lines: 32