diff options
author | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2004-11-20 19:09:19 +0000 |
---|---|---|
committer | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2004-11-20 19:09:19 +0000 |
commit | e70bea195b50a129b90a2706d9d7225bc8b68107 (patch) | |
tree | b5f82c0146d36c583753fb2bac2dd1c3a2e373e3 /winsup/cygwin/registry.cc | |
parent | 0f0fcb042a8e8a80433d7b372cf5a1a3b603d55f (diff) | |
download | cygnal-e70bea195b50a129b90a2706d9d7225bc8b68107.tar.gz cygnal-e70bea195b50a129b90a2706d9d7225bc8b68107.tar.bz2 cygnal-e70bea195b50a129b90a2706d9d7225bc8b68107.zip |
2004-11-20 Pierre Humblet <pierre.humblet@ieee.org>
* cygheap.h (cygheap_user::get_windows_id): New method.
* registry.h (get_registry_hive_path): Change argument type.
(load_registry_hive): Ditto.
* registry.cc (get_registry_hive_path): Change argument type and take
Win9x keys into account.
(load_registry_hive): Ditto.
* uinfo.cc (cygheap_user::env_userprofile): Use get_windows_id, even
for SYSTEM.
* shared.cc (user_shared_initialize): Use get_windows_id.
* syscalls.cc (seteuid32): Load the registry hive and reload the user
shared also on Win9x.
Diffstat (limited to 'winsup/cygwin/registry.cc')
-rw-r--r-- | winsup/cygwin/registry.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc index bf80245a7..1ff84b7d8 100644 --- a/winsup/cygwin/registry.cc +++ b/winsup/cygwin/registry.cc @@ -194,18 +194,16 @@ reg_key::~reg_key () } char * -get_registry_hive_path (const PSID psid, char *path) +get_registry_hive_path (const char *name, char *path) { - char sid[256]; char key[256]; HKEY hkey; - if (!psid || !path) + if (!name || !path) return NULL; - cygpsid csid (psid); - csid.string (sid); - strcpy (key,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\"); - strcat (key, sid); + __small_sprintf (key, "SOFTWARE\\Microsoft\\Windows%s\\CurrentVersion\\ProfileList\\", + wincap.is_winnt ()?" NT":""); + strcat (key, name); if (!RegOpenKeyExA (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey)) { char buf[256]; @@ -224,31 +222,31 @@ get_registry_hive_path (const PSID psid, char *path) } void -load_registry_hive (PSID psid) +load_registry_hive (const char * name) { - char sid[256]; char path[CYG_MAX_PATH + 1]; HKEY hkey; LONG ret; - if (!psid) + if (!name) return; /* Check if user hive is already loaded. */ - cygpsid csid (psid); - csid.string (sid); - if (!RegOpenKeyExA (HKEY_USERS, sid, 0, KEY_READ, &hkey)) + if (!RegOpenKeyExA (HKEY_USERS, name, 0, KEY_READ, &hkey)) { - debug_printf ("User registry hive for %s already exists", sid); + debug_printf ("User registry hive for %s already exists", name); RegCloseKey (hkey); return; } /* This is only called while deimpersonated */ set_process_privilege (SE_RESTORE_NAME); - if (get_registry_hive_path (psid, path)) + if (get_registry_hive_path (name, path)) { - strcat (path, "\\NTUSER.DAT"); - if ((ret = RegLoadKeyA (HKEY_USERS, sid, path)) != ERROR_SUCCESS) - debug_printf ("Loading user registry hive for %s failed: %d", sid, ret); + if (wincap.is_winnt ()) + strcat (path, "\\NTUSER.DAT"); + else + strcat (path, "\\USER.DAT"); + if ((ret = RegLoadKeyA (HKEY_USERS, name, path)) != ERROR_SUCCESS) + debug_printf ("Loading user registry hive for %s failed: %d", name, ret); } } |