mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Restore some reverted changes. Tidy up a bit
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22021 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
15de84b232
commit
398d3a9e77
5 changed files with 150 additions and 134 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2005-11-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSProcessInfo.m:
|
||||||
|
* Source/NSUserDefaults.m:
|
||||||
|
Restore revertyed changes for code where class initialisation order
|
||||||
|
is not a factor.
|
||||||
|
* Source/NSUser.m: Delete unused file
|
||||||
|
* GNUmakefile: Don't try to build NSUser.m
|
||||||
|
|
||||||
2005-11-15 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-11-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
Revert last changes ... discovered some apps where ordering of
|
Revert last changes ... discovered some apps where ordering of
|
||||||
|
|
|
@ -214,7 +214,6 @@ NSUnarchiver.m \
|
||||||
NSUndoManager.m \
|
NSUndoManager.m \
|
||||||
NSURL.m \
|
NSURL.m \
|
||||||
NSURLHandle.m \
|
NSURLHandle.m \
|
||||||
NSUser.m \
|
|
||||||
NSUserDefaults.m \
|
NSUserDefaults.m \
|
||||||
NSValue.m \
|
NSValue.m \
|
||||||
NSXMLParser.m \
|
NSXMLParser.m \
|
||||||
|
|
|
@ -174,7 +174,7 @@ static NSString *localLibs = nil;
|
||||||
/* Internal function prototypes. */
|
/* Internal function prototypes. */
|
||||||
/* ============================= */
|
/* ============================= */
|
||||||
|
|
||||||
NSDictionary* GNUstepConfig(void);
|
NSMutableDictionary* GNUstepConfig(NSDictionary *newConfig, NSString *userName);
|
||||||
|
|
||||||
static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict);
|
static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict);
|
||||||
|
|
||||||
|
@ -350,21 +350,25 @@ static void ExtractValuesFromConfig(NSDictionary *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function to return the system-wide configuration
|
* Function to return a mutable copy of the configuration,
|
||||||
|
* either the system wide config, or (if a userName was provided)
|
||||||
|
* the config for a specific user.
|
||||||
|
* If newConfig is not nil, it is used to set a new system wide
|
||||||
|
* configuration.
|
||||||
*/
|
*/
|
||||||
NSDictionary*
|
NSMutableDictionary*
|
||||||
GNUstepConfig(void)
|
GNUstepConfig(NSDictionary *newConfig, NSString *userName)
|
||||||
{
|
{
|
||||||
static NSDictionary *config = nil;
|
static NSDictionary *config = nil;
|
||||||
|
NSMutableDictionary *conf = nil;
|
||||||
|
BOOL changedSystemConfig = NO;
|
||||||
|
|
||||||
if (config == nil)
|
[gnustep_global_lock lock];
|
||||||
|
if (config == nil || (newConfig != nil && [config isEqual: newConfig] == NO))
|
||||||
{
|
{
|
||||||
[gnustep_global_lock lock];
|
NS_DURING
|
||||||
if (config == nil)
|
|
||||||
{
|
{
|
||||||
NSMutableDictionary *conf = nil;
|
if (newConfig == nil)
|
||||||
|
|
||||||
NS_DURING
|
|
||||||
{
|
{
|
||||||
NSString *file = nil;
|
NSString *file = nil;
|
||||||
|
|
||||||
|
@ -401,98 +405,110 @@ GNUstepConfig(void)
|
||||||
gnustepConfigPath = [file stringByDeletingLastPathComponent];
|
gnustepConfigPath = [file stringByDeletingLastPathComponent];
|
||||||
RETAIN(gnustepConfigPath);
|
RETAIN(gnustepConfigPath);
|
||||||
ParseConfigurationFile(file, conf);
|
ParseConfigurationFile(file, conf);
|
||||||
|
|
||||||
/* System admins may force the user and defaults paths by
|
|
||||||
* setting GNUSTEP_USER_CONFIG_FILE to be an empty string.
|
|
||||||
* If they simply don't define it at all, we assign a default.
|
|
||||||
*/
|
|
||||||
if ([conf objectForKey: @"GNUSTEP_USER_CONFIG_FILE"] == nil)
|
|
||||||
{
|
|
||||||
NSString *tmp;
|
|
||||||
|
|
||||||
tmp = [NSString stringWithCString:\
|
|
||||||
STRINGIFY(GNUSTEP_USER_CONFIG_FILE)];
|
|
||||||
[conf setObject: tmp forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
|
||||||
}
|
|
||||||
config = [conf copy];
|
|
||||||
DESTROY(conf);
|
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
else
|
||||||
{
|
{
|
||||||
[gnustep_global_lock unlock];
|
conf = [newConfig mutableCopy];
|
||||||
config = nil;
|
|
||||||
DESTROY(conf);
|
|
||||||
[localException raise];
|
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
/* System admins may force the user and defaults paths by
|
||||||
|
* setting GNUSTEP_USER_CONFIG_FILE to be an empty string.
|
||||||
|
* If they simply don't define it at all, we assign a default.
|
||||||
|
*/
|
||||||
|
if ([conf objectForKey: @"GNUSTEP_USER_CONFIG_FILE"] == nil)
|
||||||
|
{
|
||||||
|
NSString *tmp;
|
||||||
|
|
||||||
|
tmp = [NSString stringWithCString:\
|
||||||
|
STRINGIFY(GNUSTEP_USER_CONFIG_FILE)];
|
||||||
|
[conf setObject: tmp forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
||||||
|
}
|
||||||
|
if (config != nil)
|
||||||
|
{
|
||||||
|
changedSystemConfig = YES;
|
||||||
|
}
|
||||||
|
config = [conf copy];
|
||||||
|
DESTROY(conf);
|
||||||
}
|
}
|
||||||
[gnustep_global_lock unlock];
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[gnustep_global_lock unlock];
|
||||||
|
config = nil;
|
||||||
|
DESTROY(conf);
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
}
|
}
|
||||||
return config;
|
[gnustep_global_lock unlock];
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if (changedSystemConfig == YES)
|
||||||
* Function to return the configuration for the named user
|
{
|
||||||
*/
|
/*
|
||||||
static NSDictionary*
|
* The main configuration was changed by passing in a dictionary to
|
||||||
GNUstepUserConfig(NSString *name)
|
* this function, so we need to reset the path utilities system to use
|
||||||
{
|
* any new values from the config.
|
||||||
NSMutableDictionary *conf;
|
*/
|
||||||
NSString *file;
|
ShutdownPathUtilities();
|
||||||
NSString *home;
|
InitialisePathUtilities();
|
||||||
|
}
|
||||||
|
|
||||||
conf = [GNUstepConfig() mutableCopy];
|
#ifdef HAVE_GETEUID
|
||||||
file = RETAIN([conf objectForKey: @"GNUSTEP_USER_CONFIG_FILE"]);
|
if (userName != nil)
|
||||||
home = NSHomeDirectoryForUser(name);
|
{
|
||||||
ParseConfigurationFile([home stringByAppendingPathComponent: file], conf);
|
/*
|
||||||
/*
|
* A program which is running setuid cannot be trusted
|
||||||
* We don't let the user config file override the GNUSTEP_USER_CONFIG_FILE
|
* to pick up user specific config, so we clear the userName
|
||||||
* variable ... that would be silly/pointless.
|
* to force the system configuration to be returned rather
|
||||||
*/
|
* than a per-user config.
|
||||||
[conf setObject: file forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
*/
|
||||||
RELEASE(file);
|
if (getuid() != geteuid())
|
||||||
return AUTORELEASE(conf);
|
{
|
||||||
|
userName = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (config != nil && userName != nil)
|
||||||
|
{
|
||||||
|
NSString *file;
|
||||||
|
NSString *home;
|
||||||
|
|
||||||
|
conf = AUTORELEASE([config mutableCopy]);
|
||||||
|
file = RETAIN([conf objectForKey: @"GNUSTEP_USER_CONFIG_FILE"]);
|
||||||
|
home = NSHomeDirectoryForUser(userName);
|
||||||
|
ParseConfigurationFile([home stringByAppendingPathComponent: file], conf);
|
||||||
|
/*
|
||||||
|
* We don't let the user config file override the GNUSTEP_USER_CONFIG_FILE
|
||||||
|
* variable ... that would be silly/pointless.
|
||||||
|
*/
|
||||||
|
[conf setObject: file forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
||||||
|
RELEASE(file);
|
||||||
|
return conf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return AUTORELEASE([config mutableCopy]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise all things required by this module */
|
/* Initialise all things required by this module */
|
||||||
static void InitialisePathUtilities(void)
|
static void InitialisePathUtilities(void)
|
||||||
{
|
{
|
||||||
NSMutableDictionary *userConfig = nil;
|
|
||||||
|
|
||||||
if (gnustepSystemRoot != nil)
|
if (gnustepSystemRoot != nil)
|
||||||
{
|
{
|
||||||
return; // Protect from multiple calls
|
return; // Protect from multiple calls
|
||||||
}
|
}
|
||||||
|
|
||||||
[gnustep_global_lock lock];
|
|
||||||
|
|
||||||
/* Set up our root paths */
|
/* Set up our root paths */
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
BOOL shouldLoadUserConfig = YES;
|
NSString *userName;
|
||||||
|
NSMutableDictionary *config;
|
||||||
|
|
||||||
userConfig = [GNUstepConfig() mutableCopy];
|
[gnustep_global_lock lock];
|
||||||
ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(NSUserName()));
|
userName = NSUserName();
|
||||||
#ifdef HAVE_GETEUID
|
config = GNUstepConfig(nil, userName);
|
||||||
/*
|
ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(userName));
|
||||||
* A program which is running setuid cannot be trusted
|
ExtractValuesFromConfig(config);
|
||||||
* to pick up user specific config.
|
|
||||||
*/
|
|
||||||
if (getuid() != geteuid())
|
|
||||||
{
|
|
||||||
shouldLoadUserConfig = NO;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (shouldLoadUserConfig == YES)
|
|
||||||
{
|
|
||||||
NSString *file;
|
|
||||||
|
|
||||||
file = [gnustepUserHome stringByAppendingPathComponent:
|
|
||||||
[userConfig objectForKey: @"GNUSTEP_USER_CONFIG_FILE"]];
|
|
||||||
ParseConfigurationFile(file, userConfig);
|
|
||||||
}
|
|
||||||
ExtractValuesFromConfig(userConfig);
|
|
||||||
DESTROY(userConfig);
|
|
||||||
|
|
||||||
[gnustep_global_lock unlock];
|
[gnustep_global_lock unlock];
|
||||||
}
|
}
|
||||||
|
@ -500,7 +516,6 @@ static void InitialisePathUtilities(void)
|
||||||
{
|
{
|
||||||
/* unlock then re-raise the exception */
|
/* unlock then re-raise the exception */
|
||||||
[gnustep_global_lock unlock];
|
[gnustep_global_lock unlock];
|
||||||
DESTROY(userConfig);
|
|
||||||
[localException raise];
|
[localException raise];
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
@ -872,21 +887,31 @@ NSUserName(void)
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
if (theUserName == nil)
|
if (theUserName == nil)
|
||||||
{
|
{
|
||||||
const unichar *loginName = 0;
|
/* Use the LOGNAME environment variable if set. */
|
||||||
/* The GetUserName function returns the current user name */
|
theUserName = [[[NSProcessInfo processInfo] environment]
|
||||||
unichar buf[1024];
|
objectForKey: @"LOGNAME"];
|
||||||
DWORD n = 1024;
|
if ([theUserName length] > 0)
|
||||||
|
{
|
||||||
if (GetEnvironmentVariableW(L"LOGNAME", buf, 1024) != 0 && buf[0] != '\0')
|
RETAIN(theUserName);
|
||||||
loginName = buf;
|
}
|
||||||
else if (GetUserNameW(buf, &n) != 0 && buf[0] != '\0')
|
|
||||||
loginName = buf;
|
|
||||||
if (loginName)
|
|
||||||
theUserName = [[NSString alloc] initWithCharacters: loginName
|
|
||||||
length: wcslen(loginName)];
|
|
||||||
else
|
else
|
||||||
[NSException raise: NSInternalInconsistencyException
|
{
|
||||||
format: @"Unable to determine current user name"];
|
/* The GetUserName function returns the current user name */
|
||||||
|
unichar buf[1024];
|
||||||
|
DWORD n = 1024;
|
||||||
|
|
||||||
|
if (GetUserNameW(buf, &n) != 0 && buf[0] != '\0')
|
||||||
|
{
|
||||||
|
theUserName = [[NSString alloc] initWithCharacters: buf
|
||||||
|
length: wcslen(buf)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
theUserName = nil;
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"Unable to determine current user name"];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Set olduid to some invalid uid that we could never start off running
|
/* Set olduid to some invalid uid that we could never start off running
|
||||||
|
@ -1041,7 +1066,7 @@ GSDefaultsRootForUser(NSString *userName)
|
||||||
{
|
{
|
||||||
NSDictionary *config;
|
NSDictionary *config;
|
||||||
|
|
||||||
config = GNUstepUserConfig(userName);
|
config = GNUstepConfig(nil, userName);
|
||||||
defaultsDir = [config objectForKey: @"GNUSTEP_USER_DEFAULTS_DIR"];
|
defaultsDir = [config objectForKey: @"GNUSTEP_USER_DEFAULTS_DIR"];
|
||||||
if (defaultsDir == nil)
|
if (defaultsDir == nil)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/** Implementation of login-related functions for GNUstep
|
|
||||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
|
||||||
Created: May 1996
|
|
||||||
|
|
||||||
This file is part of the GNUstep Base Library.
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
|
||||||
License along with this library; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
|
||||||
|
|
||||||
<title>NSUser class reference</title>
|
|
||||||
$Date$ $Revision$
|
|
||||||
*/
|
|
||||||
|
|
|
@ -627,27 +627,36 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
||||||
#endif
|
#endif
|
||||||
if (currLang == nil)
|
if (currLang == nil)
|
||||||
{
|
{
|
||||||
const char *env_list;
|
|
||||||
NSString *env;
|
NSString *env;
|
||||||
|
|
||||||
env_list = getenv("LANGUAGES");
|
env = [[[NSProcessInfo processInfo] environment]
|
||||||
if (env_list != 0)
|
objectForKey: @"LANGUAGES"];
|
||||||
|
if (env != nil)
|
||||||
{
|
{
|
||||||
env = [NSStringClass stringWithCString: env_list];
|
|
||||||
currLang = [env componentsSeparatedByString: @";"];
|
currLang = [env componentsSeparatedByString: @";"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currLang != nil)
|
if (currLang != nil)
|
||||||
{
|
{
|
||||||
if ([currLang containsObject: @""] == YES)
|
NSMutableArray *a = [currLang mutableCopy];
|
||||||
{
|
unsigned c = [a count];
|
||||||
NSMutableArray *a = [currLang mutableCopy];
|
|
||||||
|
|
||||||
[a removeObject: @""];
|
while (c-- > 0)
|
||||||
currLang = (NSArray*)AUTORELEASE(a);
|
{
|
||||||
|
NSString *s = [[a objectAtIndex: c] stringByTrimmingSpaces];
|
||||||
|
|
||||||
|
if ([s length] == 0)
|
||||||
|
{
|
||||||
|
[a removeObjectAtIndex: c];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[a replaceObjectAtIndex: c withObject: s];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[userLanguages addObjectsFromArray: currLang];
|
[userLanguages addObjectsFromArray: a];
|
||||||
|
RELEASE(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if "English" is included. We do this to make sure all the
|
/* Check if "English" is included. We do this to make sure all the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue