Mail Archives: cygwin/2001/10/05/07:14:57
------_=_NextPart_000_01C14D8E.B88C9400
Content-Type: text/plain;
charset="iso-8859-1"
Hi,
Apologies for the word-wrap in previous post, I'll try again...
Blue skies,
.Ian.
<<uinfo.cc-changelog>>
<<uinfo.cc-patch>>
------_=_NextPart_000_01C14D8E.B88C9400
Content-Type: application/octet-stream;
name="uinfo.cc-changelog"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="uinfo.cc-changelog"
Tue Oct 2 16:44 2001 Ian Ray <ran_iay AT yahoo DOT com>=0A=
=0A=
* uinfo.cc (internal_getlogin): use default HOMEPATH and HOMEDRIVE=0A=
from environment if both are present, else query NetUserGetInfo;=0A=
this is a performance optimization.=0A=
=0A=
=0A=
------_=_NextPart_000_01C14D8E.B88C9400
Content-Type: application/octet-stream;
name="uinfo.cc-patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="uinfo.cc-patch"
--- uinfo.cc-orig Tue Oct 2 16:18:09 2001=0A=
+++ uinfo.cc Tue Oct 2 16:53:34 2001=0A=
@@ -76,28 +76,48 @@ internal_getlogin (cygheap_user &user)=0A=
user.set_logsrv (buf + 2);=0A=
setenv ("LOGONSERVER", buf, 1);=0A=
}=0A=
+=0A=
LPUSER_INFO_3 ui =3D NULL;=0A=
- WCHAR wuser[UNLEN + 1];=0A=
- WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];=0A=
=0A=
- /* HOMEDRIVE and HOMEPATH are wrong most of the time, too,=0A=
- after changing user context! */=0A=
- sys_mbstowcs (wuser, user.name (), UNLEN + 1);=0A=
- wlogsrv[0] =3D '\0';=0A=
- if (user.logsrv ())=0A=
- {=0A=
- strcat (strcpy (buf, "\\\\"), user.logsrv ());=0A=
- sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);=0A=
+ /*=0A=
+ * NetUserGetInfo() can be slow in NT domain environment, thus =
we=0A=
+ * only obtain HOMEDRIVE and HOMEPATH if they are not already =
set=0A=
+ * in the environment.=0A=
+ */=0A=
+ if (!getenv ("HOMEPATH") || !getenv ("HOMEDRIVE"))=0A=
+ {=0A=
+ WCHAR wuser[UNLEN + 1];=0A=
+=0A=
+ sys_mbstowcs (wuser, user.name (), =
sizeof(wuser)/sizeof(*wuser));=0A=
+ ret =3D NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui);=0A=
+=0A=
+ if (ret)=0A=
+ {=0A=
+ if (user.logsrv ())=0A=
+ {=0A=
+ WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];=0A=
+ strcat (strcpy (buf, "\\\\"), user.logsrv ());=0A=
+=0A=
+ sys_mbstowcs (wlogsrv, buf, sizeof(wlogsrv)/sizeof(*wlogsrv));=0A=
+ ret =3D NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui);=0A=
+ }=0A=
+ }=0A=
+ }=0A=
+ else=0A=
+ {=0A=
+ ret =3D 1;=0A=
}=0A=
- if (!NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui)=0A=
- || (wlogsrv[0] && !NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE =
*)&ui)))=0A=
+=0A=
+ if (ret =3D=3D 0)=0A=
{=0A=
sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);=0A=
if (!buf[0])=0A=
{=0A=
sys_wcstombs (buf, ui->usri3_home_dir_drive, MAX_PATH);=0A=
if (buf[0])=0A=
- strcat (buf, "\\");=0A=
+ {=0A=
+ strcat (buf, "\\");=0A=
+ }=0A=
else=0A=
{=0A=
env =3D getenv ("SYSTEMDRIVE");=0A=
@@ -110,8 +130,14 @@ internal_getlogin (cygheap_user &user)=0A=
setenv ("HOMEPATH", buf + 2, 1);=0A=
buf[2] =3D '\0';=0A=
setenv ("HOMEDRIVE", buf, 1);=0A=
+ }=0A=
+=0A=
+ if (ui)=0A=
+ {=0A=
NetApiBufferFree (ui);=0A=
+ ui =3D NULL;=0A=
}=0A=
+=0A=
debug_printf ("Domain: %s, Logon Server: %s, Windows Username: =
%s",=0A=
user.domain (), user.logsrv (), user.name ());=0A=
=0A=
------_=_NextPart_000_01C14D8E.B88C9400
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------_=_NextPart_000_01C14D8E.B88C9400--
- Raw text -