Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorPierre Humblet <phumblet@phumblet.no-ip.org>2004-11-20 22:09:19 +0300
committerPierre Humblet <phumblet@phumblet.no-ip.org>2004-11-20 22:09:19 +0300
commite70bea195b50a129b90a2706d9d7225bc8b68107 (patch)
treeb5f82c0146d36c583753fb2bac2dd1c3a2e373e3 /winsup
parent0f0fcb042a8e8a80433d7b372cf5a1a3b603d55f (diff)
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')
-rw-r--r--winsup/cygwin/ChangeLog14
-rw-r--r--winsup/cygwin/cygheap.h8
-rw-r--r--winsup/cygwin/registry.cc34
-rw-r--r--winsup/cygwin/registry.h4
-rw-r--r--winsup/cygwin/shared.cc10
-rw-r--r--winsup/cygwin/syscalls.cc17
-rw-r--r--winsup/cygwin/uinfo.cc7
7 files changed, 55 insertions, 39 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 671f76b28..a490bf225 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,17 @@
+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.
+
2004-11-11 Christopher Faylor <cgf@timesys.com>
* include/cygwin/version.h: Bump DLL minor number to 13.
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 2feff8518..9e86519dd 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -206,6 +206,14 @@ public:
internal_token = NO_IMPERSONATION;
}
}
+ char * get_windows_id (char * buf)
+ {
+ if (wincap.is_winnt ())
+ return effec_cygsid.string (buf);
+ else
+ return strcpy (buf, name ());
+ }
+
const char *cygheap_user::test_uid (char *&, const char *, size_t)
__attribute__ ((regparm (3)));
};
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);
}
}
diff --git a/winsup/cygwin/registry.h b/winsup/cygwin/registry.h
index f0c807941..651eb95a9 100644
--- a/winsup/cygwin/registry.h
+++ b/winsup/cygwin/registry.h
@@ -39,5 +39,5 @@ public:
};
/* Evaluates path to the directory of the local user registry hive */
-char *__stdcall get_registry_hive_path (const PSID psid, char *path);
-void __stdcall load_registry_hive (PSID psid);
+char *__stdcall get_registry_hive_path (const char *name, char *path);
+void __stdcall load_registry_hive (const char *name);
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 65adc3e27..86c66a44a 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -161,15 +161,7 @@ user_shared_initialize (bool reinit)
}
if (!cygwin_user_h)
- {
- if (wincap.has_security ())
- {
- cygpsid tu (cygheap->user.sid ());
- tu.string (name);
- }
- else
- strcpy (name, cygheap->user.name ());
- }
+ cygheap->user.get_windows_id (name);
user_shared = (user_info *) open_shared (name, USER_VERSION,
cygwin_user_h, sizeof (user_info),
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 619eda382..fded062f8 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2008,13 +2008,16 @@ seteuid32 (__uid32_t uid)
user_groups &groups = cygheap->user.groups;
HANDLE ptok, new_token = INVALID_HANDLE_VALUE;
struct passwd * pw_new;
- bool token_is_internal, issamesid;
+ bool token_is_internal, issamesid = false;
char dacl_buf[MAX_DACL_LEN (5)];
TOKEN_DEFAULT_DACL tdacl = {};
pw_new = internal_getpwuid (uid);
if (!wincap.has_security () && pw_new)
+ {
+ load_registry_hive (pw_new->pw_name);
goto success_9x;
+ }
if (!usersid.getfrompw (pw_new))
{
set_errno (EINVAL);
@@ -2082,7 +2085,8 @@ seteuid32 (__uid32_t uid)
if (new_token != ptok)
{
/* Avoid having HKCU use default user */
- load_registry_hive (usersid);
+ char name[128];
+ load_registry_hive (usersid.string (name));
/* Try setting owner to same value as user. */
if (!SetTokenInformation (new_token, TokenOwner,
@@ -2106,16 +2110,17 @@ seteuid32 (__uid32_t uid)
cygheap->user.set_sid (usersid);
cygheap->user.current_token = new_token == ptok ? NO_IMPERSONATION
: new_token;
- if (!issamesid) /* MS KB 199190 */
- RegCloseKey (HKEY_CURRENT_USER);
cygheap->user.reimpersonate ();
- if (!issamesid)
- user_shared_initialize (true);
success_9x:
cygheap->user.set_name (pw_new->pw_name);
myself->uid = uid;
groups.ischanged = FALSE;
+ if (!issamesid) /* MS KB 199190 */
+ {
+ RegCloseKey (HKEY_CURRENT_USER);
+ user_shared_initialize (true);
+ }
return 0;
failed:
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 1b3206ba6..ceab9099c 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -419,11 +419,10 @@ cygheap_user::env_userprofile (const char *name, size_t namelen)
return puserprof;
char userprofile_env_buf[CYG_MAX_PATH + 1];
+ char win_id[UNLEN + 1]; /* Large enough for SID */
+
cfree_and_set (puserprof, almost_null);
- /* FIXME: Should this just be setting a puserprofile like everything else? */
- const char *myname = winname ();
- if (myname && strcasematch (myname, "SYSTEM")
- && get_registry_hive_path (sid (), userprofile_env_buf))
+ if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf))
puserprof = cstrdup (userprofile_env_buf);
return puserprof;