aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorPierre Humblet <phumblet@phumblet.no-ip.org>2003-09-10 02:12:26 +0000
committerPierre Humblet <phumblet@phumblet.no-ip.org>2003-09-10 02:12:26 +0000
commit7119fc0d0b59a8fe8e5a6f25dd3b8162a8b8337a (patch)
treee4fc18abafcb54f10c1ce52cb71947c5cca4e3c3 /winsup/cygwin/syscalls.cc
parent3a767b69fdb767a7a154a4840dfcf06ce5c5c48b (diff)
downloadnewlib-7119fc0d0b59a8fe8e5a6f25dd3b8162a8b8337a.zip
newlib-7119fc0d0b59a8fe8e5a6f25dd3b8162a8b8337a.tar.gz
newlib-7119fc0d0b59a8fe8e5a6f25dd3b8162a8b8337a.tar.bz2
2003-09-09 Pierre Humblet <pierre.humblet@ieee.org>
* shared_info.h: Include security.h. (open_shared): Add psa argument. (user_shared_initialize): New declaration. * security.h: Add _SECURITY_H guard. (sec_user): Use sec_none in the no ntsec case. * spawn.cc (spawn_guts): Remove call to load_registry_hive. * syscalls (seteuid32): If warranted, call load_registry_hive, user_shared_initialize and RegCloseKey(HKEY_CURRENT_USER). * shared.cc (user_shared_initialize): New. (open_shared): Add and use psa argument. (memory_init): Move mount table initialization to user_shared_initialize. Call it.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index d153842..b325347 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2076,9 +2076,9 @@ seteuid32 (__uid32_t uid)
user_groups &groups = cygheap->user.groups;
HANDLE ptok, new_token = INVALID_HANDLE_VALUE;
struct passwd * pw_new;
- PSID origpsid, psid2 = NO_SID;
- BOOL token_is_internal;
-
+ cygpsid origpsid, psid2 (NO_SID);
+ BOOL token_is_internal, issamesid;
+
pw_new = internal_getpwuid (uid);
if (!wincap.has_security () && pw_new)
goto success_9x;
@@ -2154,6 +2154,9 @@ seteuid32 (__uid32_t uid)
}
else if (new_token != ptok)
{
+ /* Avoid having HKCU use default user */
+ load_registry_hive (usersid);
+
/* Try setting owner to same value as user. */
if (!SetTokenInformation (new_token, TokenOwner,
&usersid, sizeof usersid))
@@ -2168,10 +2171,16 @@ seteuid32 (__uid32_t uid)
}
CloseHandle (ptok);
+ issamesid = (usersid == (psid2 = cygheap->user.sid ()));
cygheap->user.set_sid (usersid);
cygheap->user.current_token = new_token == ptok ? INVALID_HANDLE_VALUE
- : new_token;
+ : new_token;
+ if (!issamesid) /* MS KB 199190 */
+ RegCloseKey(HKEY_CURRENT_USER);
cygheap->user.reimpersonate ();
+ if (!issamesid)
+ user_shared_initialize ();
+
success_9x:
cygheap->user.set_name (pw_new->pw_name);
myself->uid = uid;