mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-31 11:30:56 +08:00
Patch suggested by Ian Ray <ian.ray@nokia.com>:
* syscalls.cc (seteuid): Unset environment variables HOMEDRIVE and HOMEPATH before calling internal_getlogin(). * uinfo.cc (internal_getlogin): Use default HOMEPATH and HOMEDRIVE from environment if both are present, else query NetUserGetInfo().
This commit is contained in:
parent
333d609843
commit
65d1068cb8
@ -1,3 +1,11 @@
|
|||||||
|
2001-10-22 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
Patch suggested by Ian Ray <ian.ray@nokia.com>:
|
||||||
|
* syscalls.cc (seteuid): Unset environment variables HOMEDRIVE and
|
||||||
|
HOMEPATH before calling internal_getlogin().
|
||||||
|
* uinfo.cc (internal_getlogin): Use default HOMEPATH and HOMEDRIVE
|
||||||
|
from environment if both are present, else query NetUserGetInfo().
|
||||||
|
|
||||||
2001-10-22 Corinna Vinschen <corinna@vinschen.de>
|
2001-10-22 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* net.cc (get_2k_ifconf): Change multiple IP address naming scheme
|
* net.cc (get_2k_ifconf): Change multiple IP address naming scheme
|
||||||
|
@ -2031,6 +2031,11 @@ seteuid (uid_t uid)
|
|||||||
retrieving user's SID. */
|
retrieving user's SID. */
|
||||||
user.token = cygheap->user.impersonated ? cygheap->user.token
|
user.token = cygheap->user.impersonated ? cygheap->user.token
|
||||||
: INVALID_HANDLE_VALUE;
|
: INVALID_HANDLE_VALUE;
|
||||||
|
/* Unsetting these both env vars is necessary to get NetUserGetInfo()
|
||||||
|
called in internal_getlogin (). Otherwise the wrong path is used
|
||||||
|
after a user switch, probably. */
|
||||||
|
unsetenv ("HOMEDRIVE");
|
||||||
|
unsetenv ("HOMEPATH");
|
||||||
struct passwd *pw_cur = internal_getlogin (user);
|
struct passwd *pw_cur = internal_getlogin (user);
|
||||||
if (pw_cur != pw_new)
|
if (pw_cur != pw_new)
|
||||||
{
|
{
|
||||||
|
@ -78,22 +78,31 @@ internal_getlogin (cygheap_user &user)
|
|||||||
user.set_logsrv (buf + 2);
|
user.set_logsrv (buf + 2);
|
||||||
setenv ("LOGONSERVER", buf, 1);
|
setenv ("LOGONSERVER", buf, 1);
|
||||||
}
|
}
|
||||||
|
debug_printf ("Domain: %s, Logon Server: %s, Windows Username: %s",
|
||||||
|
user.domain (), user.logsrv (), user.name ());
|
||||||
|
|
||||||
|
/* NetUserGetInfo() can be slow in NT domain environment, thus we
|
||||||
|
* only obtain HOMEDRIVE and HOMEPATH if they are not already set
|
||||||
|
* in the environment. */
|
||||||
|
if (!getenv ("HOMEPATH") || !getenv ("HOMEDRIVE"))
|
||||||
|
{
|
||||||
LPUSER_INFO_3 ui = NULL;
|
LPUSER_INFO_3 ui = NULL;
|
||||||
WCHAR wuser[UNLEN + 1];
|
WCHAR wuser[UNLEN + 1];
|
||||||
|
|
||||||
/* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
|
sys_mbstowcs (wuser, user.name (), sizeof (wuser) / sizeof (*wuser));
|
||||||
after changing user context! */
|
if ((ret = NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui)))
|
||||||
sys_mbstowcs (wuser, user.name (), UNLEN + 1);
|
{
|
||||||
if (NetUserGetInfo (NULL, wuser, 3, (LPBYTE *) &ui) && user.logsrv ())
|
if (user.logsrv ())
|
||||||
{
|
{
|
||||||
WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
|
WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
|
||||||
strcat (strcpy (buf, "\\\\"), user.logsrv ());
|
strcat (strcpy (buf, "\\\\"), user.logsrv ());
|
||||||
sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);
|
|
||||||
ui = NULL;
|
sys_mbstowcs (wlogsrv, buf,
|
||||||
if (NetUserGetInfo (wlogsrv, wuser, 3, (LPBYTE *) &ui))
|
sizeof (wlogsrv) / sizeof(*wlogsrv));
|
||||||
ui = NULL;
|
ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui);
|
||||||
}
|
}
|
||||||
if (ui)
|
}
|
||||||
|
if (!ret)
|
||||||
{
|
{
|
||||||
sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
|
sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
|
||||||
if (!buf[0])
|
if (!buf[0])
|
||||||
@ -113,10 +122,10 @@ internal_getlogin (cygheap_user &user)
|
|||||||
setenv ("HOMEPATH", buf + 2, 1);
|
setenv ("HOMEPATH", buf + 2, 1);
|
||||||
buf[2] = '\0';
|
buf[2] = '\0';
|
||||||
setenv ("HOMEDRIVE", buf, 1);
|
setenv ("HOMEDRIVE", buf, 1);
|
||||||
|
}
|
||||||
|
if (ui)
|
||||||
NetApiBufferFree (ui);
|
NetApiBufferFree (ui);
|
||||||
}
|
}
|
||||||
debug_printf ("Domain: %s, Logon Server: %s, Windows Username: %s",
|
|
||||||
user.domain (), user.logsrv (), user.name ());
|
|
||||||
|
|
||||||
if (allow_ntsec)
|
if (allow_ntsec)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user