Re: /tmp v. /tmp/501/TemporaryItems

2004-01-18 Thread Paul McCann
Hi John,
you wrote...

 Can someone please tell me if there's any reason not to write files 
 in /private/tmp rather than in /tmp/501/TemporaryItems ?
 
 drwxrwxrwt   29 root  wheel   986 18 Jan 21:49 tmp
 drwxr-xr-x   13 jdwheel   442 18 Jan 21:30 TemporaryItems
 
 So far as jd and admin there's never been a problem, but would there 
 be a problem if I were a user with fewer privileges?

The big difference between the two locations seems to be that anyone can
read the files you drop into /tmp, while the files in /tmp/501 are
protected from prying eyes. You can of course change the permissions on
files that you make in /tmp so as to shield the contents (or change your
umask), but you have the additional problem of not being able to
overwrite a temp file owned by someone else. See File::Temp (standard
module) for a nice, safe interface to the whole temporary file business.

With regards to writing there's no problem: as per the permissions
above, anyone can drop a file into the /tmp directory, but only the
owner (or an admin using sudo or suchlike) can delete it.

Cheers,
Paul



Re: /tmp v. /tmp/501/TemporaryItems

2004-01-18 Thread Chris Nandor
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (John Delacour) 
wrote:

 Can someone please tell me if there's any reason not to write files 
 in /private/tmp rather than in /tmp/501/TemporaryItems ?
 
 drwxrwxrwt   29 root  wheel   986 18 Jan 21:49 tmp
 drwxr-xr-x   13 jdwheel   442 18 Jan 21:30 TemporaryItems
 
 So far as jd and admin there's never been a problem, but would there 
 be a problem if I were a user with fewer privileges?

/tmp/501/TemporaryItems/ is your personal temporary items folder.  Witness:

$ perl -MMac::Files -le '
  print FindFolder(kOnSystemDisk, kTemporaryFolderType)'
/private/tmp/502/TemporaryItems

$ sudo -u maintenance perl -MMac::Files -le '
  print FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder)'
/private/tmp/501/TemporaryItems

$ sudo -u guestuser perl -MMac::Files -le '
  print FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder)'
/private/tmp/503/TemporaryItems


So when Mac apps use the standard Mac OS API to create temp files, that's 
the path they get, and if you want to restrict temp files to a particular 
user, then feel free to do the same.  Of course, you don't necessarily need 
to use Mac::Files and FindFolder, you can probably create the path yourself, 
though I wouldn't recommend that personally.

See man Mac::Files for details, or point your browser to:

  file:///Developer/Documentation/Carbon/Reference/Folder_Manager/index.html

See especially FindFolder under Functions, and Folder Type Constants and 
Disk and Domain Constants under Constants.

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/