Xref: utzoo comp.unix.wizards:15378 comp.databases:2265 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.wizards,comp.databases Subject: Re: getcwd() and friends. Message-ID: <1388@auspex.auspex.com> Date: 5 Apr 89 05:09:12 GMT References: <3675@ficc.uu.net> <14689@rpp386.Dallas.TX.US> <811@mtxinu.UUCP> Reply-To: guy@auspex.auspex.com (Guy Harris) Followup-To: comp.unix.wizards Organization: Auspex Systems, Santa Clara Lines: 45 >Worse than that, the permission required to open a directory is "r" >(since one may not open a directory for writing), whereas the >permission required to change to one is "x". Hence, Unix protection >would be completely violated by the existance of fchdir(). Oh dearie me. From SunOS 4.0: NAME chdir - change current working directory SYNOPSIS int chdir (path) char *path; int fchdir (fd) int fd; DESCRIPTION chdir() and fchdir cause a directory to become the current working directory, that is, the starting point for pathnames not beginning with `/'. In order for a directory to become the current directory, a process must have execute (search) access to the directory. The path argument to chdir() points to the pathname of a directory. The fd argument to fchdir is the open file descriptor of a directory. RETURN VALUE Upon successful completion, a value of 0 is returned. Oth- erwise, a value of -1 is returned and errno is set to indi- cate the error. WARNING fchdir is provided as a performance enhancement and is guaranteed to fail under certain conditions. In particular, if auditing is active the call will never succeed, and EIN- VAL will be returned. Applications which use this system call must be coded to detect this failure and switch to using chdir() from that point on. Fortunately, "fchdir" requires you to have execute permission on the directory in question, so you're safe there, even if it won't let you change to some directories to which you could otherwise change....