diff --git a/ChangeLog b/ChangeLog index 135988350..7323096dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,10 @@ for developers that NSConnection will be changing the same way. These changes discussed a year or two ago (mostly with Alexander), 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 diff --git a/Source/NSPathUtilities.m b/Source/NSPathUtilities.m index 6255b6dc2..0c60c23c9 100644 --- a/Source/NSPathUtilities.m +++ b/Source/NSPathUtilities.m @@ -1015,7 +1015,7 @@ NSTemporaryDirectory(void) /* * If the user has supplied a directory name in the TEMP or TMP * environment variable, attempt to use that unless we already - * have a tem porary directory specified. + * have a temporary directory specified. */ if (baseTempDirName == nil) { @@ -1079,13 +1079,22 @@ NSTemporaryDirectory(void) #endif 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 " @"add secure subdirectory", tempDirName); */ - - tempDirName - = [baseTempDirName stringByAppendingPathComponent: NSUserName()]; if ([manager fileExistsAtPath: tempDirName] == NO) { NSNumber *p = [NSNumber numberWithInt: 0700]; @@ -1096,7 +1105,8 @@ NSTemporaryDirectory(void) attributes: attr] == NO) { [NSException raise: NSGenericException - format: @"Attempt to create a secure temporary directory (%@) failed.", + format: + @"Attempt to create a secure temporary directory (%@) failed.", tempDirName]; return nil; /* Not reached. */ } @@ -1112,7 +1122,8 @@ NSTemporaryDirectory(void) if ((perm != 0700 && perm != 0600) || owner != uid) { [NSException raise: NSGenericException - format: @"Attempt to create a secure temporary directory (%@) failed.", + format: + @"Attempt to create a secure temporary directory (%@) failed.", tempDirName]; return nil; /* Not reached. */ }