Slight fix so that temporary directories are specific to the account which

owns them.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21097 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2005-04-12 17:01:30 +00:00
parent 96bffbd7e9
commit 2e6a507ad5
2 changed files with 21 additions and 6 deletions

View file

@ -17,6 +17,10 @@
for developers that NSConnection will be changing the same way. for developers that NSConnection will be changing the same way.
These changes discussed a year or two ago (mostly with Alexander), These changes discussed a year or two ago (mostly with Alexander),
but nobody ever actually implemented them. but nobody ever actually implemented them.
* Source/NSPathUtilities.m: Make temporary directory name based on
uid so that it is consistent on a unix system where there are
multiple named accounts with the same user id (essentially all
aliases for a single account).
2005-04-05 Adam Fedor <fedor@gnu.org> 2005-04-05 Adam Fedor <fedor@gnu.org>

View file

@ -1079,13 +1079,22 @@ NSTemporaryDirectory(void)
#endif #endif
if ((perm != 0700 && perm != 0600) || owner != uid) if ((perm != 0700 && perm != 0600) || owner != uid)
{ {
NSString *secure;
/*
* The name of the secure subdirectory reflects the user ID rather
* than the user name, since it is possible to have an account with
* lots of names on a unix system (ie multiple entries in the password
* file but a single userid). The private directory is secure within
* the account, not to a particular user name.
*/
secure = [NSString stringWithFormat: @"GNUstepSecure%d", uid];
tempDirName
= [baseTempDirName stringByAppendingPathComponent: secure];
/* /*
NSLog(@"Temporary directory (%@) may be insecure ... attempting to " NSLog(@"Temporary directory (%@) may be insecure ... attempting to "
@"add secure subdirectory", tempDirName); @"add secure subdirectory", tempDirName);
*/ */
tempDirName
= [baseTempDirName stringByAppendingPathComponent: NSUserName()];
if ([manager fileExistsAtPath: tempDirName] == NO) if ([manager fileExistsAtPath: tempDirName] == NO)
{ {
NSNumber *p = [NSNumber numberWithInt: 0700]; NSNumber *p = [NSNumber numberWithInt: 0700];
@ -1096,7 +1105,8 @@ NSTemporaryDirectory(void)
attributes: attr] == NO) attributes: attr] == NO)
{ {
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"Attempt to create a secure temporary directory (%@) failed.", format:
@"Attempt to create a secure temporary directory (%@) failed.",
tempDirName]; tempDirName];
return nil; /* Not reached. */ return nil; /* Not reached. */
} }
@ -1112,7 +1122,8 @@ NSTemporaryDirectory(void)
if ((perm != 0700 && perm != 0600) || owner != uid) if ((perm != 0700 && perm != 0600) || owner != uid)
{ {
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"Attempt to create a secure temporary directory (%@) failed.", format:
@"Attempt to create a secure temporary directory (%@) failed.",
tempDirName]; tempDirName];
return nil; /* Not reached. */ return nil; /* Not reached. */
} }