temporary directory improvement

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35393 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-08-10 14:31:28 +00:00
parent dc55974ec8
commit 982982f631
2 changed files with 14 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2012-08-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPathUtilities.m:
Fix permissions on temporary directory rarther than just failing ...
suggestion by Wolfgang.
2012-08-10 Richard Frith-Macdonald <rfm@gnu.org> 2012-08-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m: ([-createDirectoryAtPath:attributes:]) * Source/NSFileManager.m: ([-createDirectoryAtPath:attributes:])

View file

@ -1989,6 +1989,10 @@ NSTemporaryDirectory(void)
if ((perm != 0700 && perm != 0600) || owner != uid) if ((perm != 0700 && perm != 0600) || owner != uid)
{ {
NSString *secure; NSString *secure;
NSNumber *p = [NSNumber numberWithInt: 0700];
attr = [NSDictionary dictionaryWithObject: p
forKey: NSFilePosixPermissions];
/* /*
* The name of the secure subdirectory reflects the user ID rather * The name of the secure subdirectory reflects the user ID rather
@ -2003,10 +2007,6 @@ NSTemporaryDirectory(void)
if ([manager fileExistsAtPath: tempDirName] == NO) if ([manager fileExistsAtPath: tempDirName] == NO)
{ {
NSNumber *p = [NSNumber numberWithInt: 0700];
attr = [NSDictionary dictionaryWithObject: p
forKey: NSFilePosixPermissions];
if ([manager createDirectoryAtPath: tempDirName if ([manager createDirectoryAtPath: tempDirName
withIntermediateDirectories: YES withIntermediateDirectories: YES
attributes: attr attributes: attr
@ -2017,6 +2017,10 @@ NSTemporaryDirectory(void)
return nil; return nil;
} }
} }
else
{
[manager changeFileAttributes: attr atPath: tempDirName];
}
/* /*
* Check that the new directory is really secure. * Check that the new directory is really secure.