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
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2000-07-02 14:17:44 +0400
committerCorinna Vinschen <corinna@vinschen.de>2000-07-02 14:17:44 +0400
commit0c4d2abd9966366b5e215ae64ce3b620efca9335 (patch)
tree62f506a304925c9d2707c73ce5c340daedff8338 /winsup/cygwin/uinfo.cc
parentc570d680fb3ffcfc973d13e56eabd143b0940cb3 (diff)
* winsup.h: Define MAX_SID_LEN and new MAX_HOST_NAME.
* fork.cc (fork): Use above defines instead of numerical constants. * shared.cc (sec_user): Ditto. * shared.h (class pinfo): Ditto. * syscall.cc (seteuid): Ditto. * spawn.cc (_spawnve): Ditto. Eliminate conditional. (spawn_guts): Set child->uid = USHRT_MAX when user context will be changed in child process. * uinfo.cc (uinfo_init): Check for myself->uid instead of myself->psid to avoid reloading of /etc/passwd on process startup if ntsec is off. Use above defines instead of numerical constants. * security.cc: Move define for MAX_SID_LEN to winsup.h.
Diffstat (limited to 'winsup/cygwin/uinfo.cc')
-rw-r--r--winsup/cygwin/uinfo.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index b35fbc65a..31378a5e6 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -106,7 +106,7 @@ internal_getlogin (struct pinfo *pi)
else if (!GetTokenInformation (ptok, TokenUser, (LPVOID) &tu,
sizeof tu, &siz))
debug_printf ("GetTokenInformation(): %E");
- else if (!(ret = CopySid (40, (PSID) pi->sidbuf,
+ else if (!(ret = CopySid (MAX_SID_LEN, (PSID) pi->sidbuf,
((TOKEN_USER *) &tu)->User.Sid)))
debug_printf ("Couldn't retrieve SID from access token!");
/* Close token only if it's a result from OpenProcessToken(). */
@@ -135,7 +135,7 @@ internal_getlogin (struct pinfo *pi)
if (ret)
{
struct passwd *pw;
- char psidbuf[40];
+ char psidbuf[MAX_SID_LEN];
PSID psid = (PSID) psidbuf;
pi->psid = (PSID) pi->sidbuf;
@@ -172,11 +172,9 @@ uinfo_init ()
myself->token = INVALID_HANDLE_VALUE;
myself->impersonated = TRUE;
- /* If psid is non null, the process is forked or spawned from
- another cygwin process without changing the user context.
- So all user infos in myself as well as the environment are
- (perhaps) valid. */
- if (!myself->psid)
+ /* If uid is USHRT_MAX, the process is started from a non cygwin
+ process or the user context was changed in spawn.cc */
+ if (myself->uid == USHRT_MAX)
if ((p = getpwnam (username = internal_getlogin (myself))) != NULL)
{
myself->uid = p->pw_uid;