Use hMainProc where appropriate, throughout.
* environ.cc (spenv::retrieve): Add debugging statements. * pinfo.cc (set_myself): Don't call strace.hello if already stracing. * strace.cc (strace): Move NO_COPY keyword so that it will actually take effect.
This commit is contained in:
parent
834224ab85
commit
03a2ce9a36
@ -1,3 +1,12 @@
|
||||
2002-06-19 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
Use hMainProc where appropriate, throughout.
|
||||
* environ.cc (spenv::retrieve): Add debugging statements.
|
||||
|
||||
* pinfo.cc (set_myself): Don't call strace.hello if already stracing.
|
||||
* strace.cc (strace): Move NO_COPY keyword so that it will actually
|
||||
take effect.
|
||||
|
||||
2002-06-19 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* uinfo.cc (cygheap_user::ontherange): Call NetUserGetInfo() only with
|
||||
|
@ -58,16 +58,16 @@ static NO_COPY win_env conv_envvars[] =
|
||||
cygwin_posix_to_win32_path_list,
|
||||
cygwin_win32_to_posix_path_list_buf_size,
|
||||
cygwin_posix_to_win32_path_list_buf_size},
|
||||
{NL ("HOME="), NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
|
||||
return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("HOME="), NULL, NULL, cygwin_conv_to_full_posix_path,
|
||||
cygwin_conv_to_full_win32_path, return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("LD_LIBRARY_PATH="), NULL, NULL, cygwin_conv_to_full_posix_path,
|
||||
cygwin_conv_to_full_win32_path, return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("TMPDIR="), NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
|
||||
return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("TMP="), NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
|
||||
return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("TEMP="), NULL, NULL, cygwin_conv_to_full_posix_path, cygwin_conv_to_full_win32_path,
|
||||
return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("TMPDIR="), NULL, NULL, cygwin_conv_to_full_posix_path,
|
||||
cygwin_conv_to_full_win32_path, return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("TMP="), NULL, NULL, cygwin_conv_to_full_posix_path,
|
||||
cygwin_conv_to_full_win32_path, return_MAX_PATH, return_MAX_PATH},
|
||||
{NL ("TEMP="), NULL, NULL, cygwin_conv_to_full_posix_path,
|
||||
cygwin_conv_to_full_win32_path, return_MAX_PATH, return_MAX_PATH},
|
||||
{NULL, 0, NULL, NULL, NULL, NULL, 0, 0}
|
||||
};
|
||||
|
||||
@ -780,19 +780,31 @@ spenv::retrieve (bool no_envblock, const char *const envname)
|
||||
{
|
||||
if (envname && !strncasematch (envname, name, namelen))
|
||||
return NULL;
|
||||
|
||||
debug_printf ("no_envblock %d", no_envblock);
|
||||
|
||||
if (from_cygheap)
|
||||
{
|
||||
const char *p;
|
||||
if (!cygheap->user.issetuid ())
|
||||
if (cygheap->user.issetuid ())
|
||||
debug_printf ("calculating for setuid");
|
||||
else
|
||||
{
|
||||
debug_printf ("calculating for non-setuid");
|
||||
if (!envname)
|
||||
{
|
||||
debug_printf ("not adding %s to windows environment", name);
|
||||
return NULL; /* No need to force these into the
|
||||
environment */
|
||||
}
|
||||
|
||||
if (no_envblock)
|
||||
{
|
||||
debug_printf ("duping existing value for '%s'", name);
|
||||
return cstrdup1 (envname);/* Don't really care what it's set to
|
||||
if we're calling a cygwin program */
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate (potentially) value for given environment variable. */
|
||||
p = (cygheap->user.*from_cygheap) ();
|
||||
@ -801,6 +813,7 @@ spenv::retrieve (bool no_envblock, const char *const envname)
|
||||
char *s = (char *) cmalloc (HEAP_1_STR, namelen + strlen (p) + 1);
|
||||
strcpy (s, name);
|
||||
(void) strcpy (s + namelen, p);
|
||||
debug_printf ("using computed value for '%s'", name);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -814,7 +827,11 @@ spenv::retrieve (bool no_envblock, const char *const envname)
|
||||
char *p = (char *) cmalloc (HEAP_1_STR, namelen + ++vallen);
|
||||
strcpy (p, name);
|
||||
if (GetEnvironmentVariable (name, p + namelen, vallen))
|
||||
{
|
||||
debug_printf ("using value from GetEnvironmentVariable for '%s'",
|
||||
envname);
|
||||
return p;
|
||||
}
|
||||
else
|
||||
cfree (p);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ read_etc_group ()
|
||||
cygsid tg;
|
||||
DWORD siz;
|
||||
|
||||
if (OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &ptok))
|
||||
if (OpenProcessToken (hMainProc, TOKEN_QUERY, &ptok))
|
||||
{
|
||||
if (GetTokenInformation (ptok, TokenPrimaryGroup, &tg,
|
||||
sizeof tg, &siz)
|
||||
|
@ -168,7 +168,7 @@ read_etc_passwd ()
|
||||
cygsid tu, tg;
|
||||
DWORD siz;
|
||||
|
||||
if (OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &ptok))
|
||||
if (OpenProcessToken (hMainProc, TOKEN_QUERY, &ptok))
|
||||
{
|
||||
if (GetTokenInformation (ptok, TokenUser, &tu, sizeof tu,
|
||||
&siz)
|
||||
|
@ -63,6 +63,7 @@ set_myself (pid_t pid, HANDLE h)
|
||||
|
||||
(void) GetModuleFileName (NULL, myself->progname,
|
||||
sizeof(myself->progname));
|
||||
if (!strace.active)
|
||||
strace.hello ();
|
||||
return;
|
||||
}
|
||||
|
@ -726,8 +726,10 @@ verify_token (HANDLE token, cygsid &usersid, cygsid &pgrpsid, BOOL * pintern)
|
||||
debug_printf ("malloc (my_grps) failed.");
|
||||
else if (!GetTokenInformation (token, TokenGroups, my_grps, size, &size))
|
||||
debug_printf ("GetTokenInformation(my_token, TokenGroups): %E\n");
|
||||
else ret = sid_in_token_groups (my_grps, pgrpsid);
|
||||
if (my_grps) free (my_grps);
|
||||
else
|
||||
ret = sid_in_token_groups (my_grps, pgrpsid);
|
||||
if (my_grps)
|
||||
free (my_grps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -784,7 +786,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
|
||||
owner.Owner = usersid;
|
||||
|
||||
/* Retrieve authentication id and group list from own process. */
|
||||
if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &my_token))
|
||||
if (!OpenProcessToken (hMainProc, TOKEN_QUERY, &my_token))
|
||||
debug_printf ("OpenProcessToken(my_token): %E\n");
|
||||
else
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ details. */
|
||||
#define PROTECT(x) x[sizeof(x)-1] = 0
|
||||
#define CHECK(x) if (x[sizeof(x)-1] != 0) { small_printf("array bound exceeded %d\n", __LINE__); ExitProcess(1); }
|
||||
|
||||
class NO_COPY strace strace;
|
||||
class strace NO_COPY strace;
|
||||
|
||||
#ifndef NOSTRACE
|
||||
|
||||
|
@ -1978,8 +1978,7 @@ seteuid32 (__uid32_t uid)
|
||||
sav_impersonated = cygheap->user.impersonated;
|
||||
|
||||
RevertToSelf();
|
||||
if (!OpenProcessToken (GetCurrentProcess (),
|
||||
TOKEN_QUERY | TOKEN_ADJUST_DEFAULT, &ptok))
|
||||
if (!OpenProcessToken (hMainProc, TOKEN_QUERY | TOKEN_ADJUST_DEFAULT, &ptok))
|
||||
{
|
||||
__seterrno ();
|
||||
goto failed;
|
||||
@ -1991,13 +1990,13 @@ seteuid32 (__uid32_t uid)
|
||||
debug_printf("Process token %sverified", process_ok ? "" : "not ");
|
||||
if (process_ok)
|
||||
{
|
||||
if (cygheap->user.token == INVALID_HANDLE_VALUE ||
|
||||
!cygheap->user.impersonated)
|
||||
if (cygheap->user.issetuid ())
|
||||
cygheap->user.impersonated = FALSE;
|
||||
else
|
||||
{
|
||||
CloseHandle (ptok);
|
||||
return 0; /* No change */
|
||||
}
|
||||
else cygheap->user.impersonated = FALSE;
|
||||
}
|
||||
|
||||
if (!process_ok && cygheap->user.token != INVALID_HANDLE_VALUE)
|
||||
@ -2007,7 +2006,9 @@ seteuid32 (__uid32_t uid)
|
||||
& sav_token_is_internal_token);
|
||||
debug_printf("Thread token %d %sverified",
|
||||
cygheap->user.token, token_ok?"":"not ");
|
||||
if (token_ok)
|
||||
if (!token_ok)
|
||||
cygheap->user.token = INVALID_HANDLE_VALUE;
|
||||
else
|
||||
{
|
||||
/* Return if current token is valid */
|
||||
if (cygheap->user.impersonated)
|
||||
@ -2018,7 +2019,6 @@ seteuid32 (__uid32_t uid)
|
||||
return 0; /* No change */
|
||||
}
|
||||
}
|
||||
else cygheap->user.token = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* Set process def dacl to allow access to impersonated token */
|
||||
@ -2152,9 +2152,7 @@ setegid32 (__gid32_t gid)
|
||||
"TokenPrimaryGroup): %E");
|
||||
RevertToSelf ();
|
||||
}
|
||||
if (!OpenProcessToken (GetCurrentProcess (),
|
||||
TOKEN_ADJUST_DEFAULT,
|
||||
&ptok))
|
||||
if (!OpenProcessToken (hMainProc, TOKEN_ADJUST_DEFAULT, &ptok))
|
||||
debug_printf ("OpenProcessToken(): %E\n");
|
||||
else
|
||||
{
|
||||
|
@ -43,8 +43,7 @@ internal_getlogin (cygheap_user &user)
|
||||
|
||||
/* Try to get the SID either from current process and
|
||||
store it in user.psid */
|
||||
if (!OpenProcessToken (GetCurrentProcess (),
|
||||
TOKEN_ADJUST_DEFAULT | TOKEN_QUERY,
|
||||
if (!OpenProcessToken (hMainProc, TOKEN_ADJUST_DEFAULT | TOKEN_QUERY,
|
||||
&ptok))
|
||||
system_printf ("OpenProcessToken(): %E\n");
|
||||
else if (!GetTokenInformation (ptok, TokenUser, &tu, sizeof tu, &siz))
|
||||
|
Loading…
x
Reference in New Issue
Block a user