Sticky /tmp, bug in getwd(3)?

Daniel Ehrlich ehrlich at cs.psu.edu
Wed Feb 7 03:38:40 AEST 1990


In article <4500 at brazos.Rice.edu> moj at mirfak.utu.fi (Matti Jokinen) writes:

> X-Sun-Spots-Digest: Volume 9, Issue 15, message 8 of 20

> In order to increase security I set the sticky bit on the directories
> /tmp, /var/tmp and /var/spool/mail.  One consequence was that small files
> started to accumulate in /tmp; the names of the files are of the form
> .getwdaNNNNN, where NNNNN is obviously a process number.  It is not
> difficult to guess that the files are created by getwd(3), but I don't
> understand why they are not removed.  The result of getwd seems to be
> unaffected.

> My SunOS version is 4.0.3.

The /tmp/.getwdNNNNN files are used as a cache by getwd(3).  From the man
page getwd:

FILES
     /tmp/.getwd         It exists for the sole  purpose  of  the
                         getwd()   library   routine;   no  other
                         software should depend on its  existence
                         or contents.

If the getwd routine decides that it needs to recreate the .getwd file,
for what ever reason, it will not be able to unlink it if the sticky bit
is set on /tmp and the user running the program is not the owner of the
.getwd file.  So, bottom line is, you can not set the sticky bit on /tmp
unless you are willing to periodically clean out the .getwdNNNNN files
that accumulate.

I do not know if we have Sun or AT&T to thank for this one.  :-)

Dan Ehrlich <ehrlich at cs.psu.edu>
Voice: +1 814 863 1142	FAX: +1 814 865 3176



More information about the Comp.sys.sun mailing list