Subject: Re: per-user /tmp
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-security
Date: 02/04/2007 20:34:47
On Feb 4, 2007, at 7:06 PM, YAMAMOTO Takashi wrote:

> is it how mac's /private/tmp is used?
> if you follow their naming, it's better to follow their semantics as  
> well.

OS X's /private/tmp is kind of a hold-over from NeXTSTEP -- IIRC, / 
private on NeXTSTEP was intended to be "private to this  
machine" (think of shared /).  On OS X, /tmp is simply a symlink to / 
private/tmp.

That said, OS X does have per-user temporary space:

thorpej-mbp:thorpej$ cd /tmp/
thorpej-mbp:thorpej$ ls -la
total 108
   0 drwxrwxrwt  7 root     wheel    374 Feb  4 20:17 ./
   0 drwxr-xr-x@ 7 root     wheel    238 Nov 30 16:01 ../
   0 drwx------  2 thorpej  wheel    102 Jan 31  
21:03 .KerberosLogin-501-/
   0 drwxr-xr-x  2 thorpej  wheel     68 Feb  2 15:00 .XcodeSCMTemp/
100 -rw-------  1 thorpej  wheel  99758 Feb  1 11:53 45c24548c72f1
   0 drwx------  2 thorpej  wheel    102 Feb  4 20:04 501/
   0 srwxrwxrwx  1 root     wheel      0 Feb  3 20:50 ARD_ABJMMRT=
   4 -rw-r--r--  1 thorpej  wheel   1577 Feb  3 22:37 foo
   0 drwxr-xr-x  2 thorpej  wheel    102 Feb  3 21:30  
hsperfdata_thorpej/
   0 drwx------  2 thorpej  wheel    102 Jan 31 21:01  
launchd-130.2WnVur/
   4 -rw-r--r--  1 root     wheel    255 Feb  3 10:37 mds-UUID- 
tokenID.plist
thorpej-mbp:thorpej$


Note the "501" directory -- that's my UID, and in there we find:

thorpej-mbp:thorpej$ ls -la
total 0
0 drwx------  2 thorpej  wheel  102 Feb  4 20:04 ./
0 drwxrwxrwt  7 root     wheel  374 Feb  4 20:17 ../
0 srw-------  1 thorpej  wheel    0 Jan 31 21:02  
nl.uu.phil.SSHAgent.socket=
thorpej-mbp:thorpej$


Now, for Mac apps, there is API that tells the app where its temp  
space is, e.g. FindFolder(..., kTemporaryFolderType, ...) in Carbon.

-- thorpej