fix for failure to load global defaults

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34026 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-10-19 13:32:50 +00:00
parent 5d9f6c805c
commit d074288f00
2 changed files with 37 additions and 30 deletions

View file

@ -1,3 +1,9 @@
2011-10-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPathUtilities.m
Fix failure to load global defaults when system layout/config is
locked down (problem reported by Julian Mayer).
2011-10-18 Richard Frith-Macdonald <rfm@gnu.org> 2011-10-18 Richard Frith-Macdonald <rfm@gnu.org>
* standalone.conf: example configuration file for a standalone * standalone.conf: example configuration file for a standalone

View file

@ -751,9 +751,12 @@ GNUstepConfig(NSDictionary *newConfig)
{ {
if (newConfig == nil) if (newConfig == nil)
{ {
NSString *file = nil; NSString *file = nil;
BOOL fromEnvironment = YES; NSString *path;
BOOL bareDirectory = NO; NSEnumerator *e;
NSString *defs;
BOOL fromEnvironment = YES;
BOOL bareDirectory = NO;
conf = [[NSMutableDictionary alloc] initWithCapacity: 32]; conf = [[NSMutableDictionary alloc] initWithCapacity: 32];
@ -786,8 +789,8 @@ GNUstepConfig(NSDictionary *newConfig)
|| [file hasPrefix: @"../"] == YES) || [file hasPrefix: @"../"] == YES)
{ {
Class c = [NSProcessInfo class]; Class c = [NSProcessInfo class];
NSString *path = GSPrivateSymbolPath (c, 0);
path = GSPrivateSymbolPath (c, 0);
// Remove library name from path // Remove library name from path
path = [path stringByDeletingLastPathComponent]; path = [path stringByDeletingLastPathComponent];
if ([file hasPrefix: @"./"] == YES) if ([file hasPrefix: @"./"] == YES)
@ -831,46 +834,44 @@ GNUstepConfig(NSDictionary *newConfig)
} }
#endif #endif
} }
if (bareDirectory == YES) if (bareDirectory == YES)
{ {
/* Set the directory name, but don't try to read file.
*/
gnustepConfigPath = RETAIN(file); gnustepConfigPath = RETAIN(file);
} }
else else
{ {
NSEnumerator *e;
NSString *defs;
NSString *path;
gnustepConfigPath gnustepConfigPath
= RETAIN([file stringByDeletingLastPathComponent]); = RETAIN([file stringByDeletingLastPathComponent]);
ParseConfigurationFile(file, conf, nil); ParseConfigurationFile(file, conf, nil);
if (nil != [conf objectForKey: @"GNUSTEP_EXTRA"]) if (nil != [conf objectForKey: @"GNUSTEP_EXTRA"])
{ {
NSLog(@"Warning: use of GNUSTEP_EXTRA in your GNUstep.conf file is deprecated. Please use a GlobalDefaults.plist instead.\n"); NSLog(@"Warning: use of GNUSTEP_EXTRA in your GNUstep.conf file is deprecated. Please use a GlobalDefaults.plist instead.\n");
} }
/* Merge in any values from property lists in the
* GlobalDefaults directory.
*/
path = [gnustepConfigPath stringByAppendingPathComponent:
@"GlobalDefaults"];
e = [[MGR() directoryContentsAtPath: path] objectEnumerator];
while ((defs = [e nextObject]) != nil)
{
if ([[defs pathExtension] isEqualToString: @"plist"])
{
defs = [path stringByAppendingPathComponent: defs];
addDefaults(defs, conf);
}
}
/* And merge in value from GloablDefaults.plist
*/
defs = [gnustepConfigPath stringByAppendingPathComponent:
@"GlobalDefaults.plist"];
addDefaults(defs, conf);
} }
/* Merge in any values from property lists in the
* GlobalDefaults directory.
*/
path = [gnustepConfigPath stringByAppendingPathComponent:
@"GlobalDefaults"];
e = [[MGR() directoryContentsAtPath: path] objectEnumerator];
while ((defs = [e nextObject]) != nil)
{
if ([[defs pathExtension] isEqualToString: @"plist"])
{
defs = [path stringByAppendingPathComponent: defs];
addDefaults(defs, conf);
}
}
/* And merge in value from GlobalDefaults.plist
*/
defs = [gnustepConfigPath stringByAppendingPathComponent:
@"GlobalDefaults.plist"];
addDefaults(defs, conf);
} }
else else
{ {