* cygheap.h (cygheap_user): Add static members to hold home{drive,path} info.
* uinfo.cc (cygheap_user::ontherange): Use static class members for local HOME* storage.
This commit is contained in:
parent
9a771b2961
commit
a77d35f7d2
|
@ -1,3 +1,10 @@
|
||||||
|
2002-06-14 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* cygheap.h (cygheap_user): Add static members to hold home{drive,path}
|
||||||
|
info.
|
||||||
|
* uinfo.cc (cygheap_user::ontherange): Use static class members for
|
||||||
|
local HOME* storage.
|
||||||
|
|
||||||
2002-06-14 Christopher Faylor <cgf@redhat.com>
|
2002-06-14 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* cygheap.cc (cygheap_user::set_logsrv): Remove.
|
* cygheap.cc (cygheap_user::set_logsrv): Remove.
|
||||||
|
|
|
@ -105,6 +105,10 @@ class cygheap_user
|
||||||
char *homepath; /* User's home path */
|
char *homepath; /* User's home path */
|
||||||
PSID psid; /* buffer for user's SID */
|
PSID psid; /* buffer for user's SID */
|
||||||
PSID orig_psid; /* Remains intact even after impersonation */
|
PSID orig_psid; /* Remains intact even after impersonation */
|
||||||
|
static char homedrive_env_buf[3]; /* Where the HOMEDRIVE environment variable
|
||||||
|
info may live. */
|
||||||
|
static char homepath_env_buf[MAX_PATH + 1]; /* Where the HOMEPATH environment
|
||||||
|
variable info may live. */
|
||||||
public:
|
public:
|
||||||
__uid32_t orig_uid; /* Remains intact even after impersonation */
|
__uid32_t orig_uid; /* Remains intact even after impersonation */
|
||||||
__gid32_t orig_gid; /* Ditto */
|
__gid32_t orig_gid; /* Ditto */
|
||||||
|
|
|
@ -188,11 +188,12 @@ cuserid (char *src)
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char cygheap_user::homepath_env_buf[MAX_PATH + 1];
|
||||||
|
char cygheap_user::homedrive_env_buf[3];
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
||||||
{
|
{
|
||||||
static char buf[MAX_PATH + 1];
|
|
||||||
static char homedrive_buf[3];
|
|
||||||
LPUSER_INFO_3 ui = NULL;
|
LPUSER_INFO_3 ui = NULL;
|
||||||
WCHAR wuser[UNLEN + 1];
|
WCHAR wuser[UNLEN + 1];
|
||||||
NET_API_STATUS ret;
|
NET_API_STATUS ret;
|
||||||
|
@ -202,13 +203,13 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
||||||
char *p;
|
char *p;
|
||||||
if ((p = getenv ("HOMEDRIVE")))
|
if ((p = getenv ("HOMEDRIVE")))
|
||||||
{
|
{
|
||||||
memcpy (homedrive_buf, p, 2);
|
memcpy (homedrive_env_buf, p, 2);
|
||||||
homedrive = homedrive_buf;
|
homedrive = homedrive_env_buf;
|
||||||
}
|
}
|
||||||
if ((p = getenv ("HOMEPATH")))
|
if ((p = getenv ("HOMEPATH")))
|
||||||
{
|
{
|
||||||
strcpy (buf, p);
|
strcpy (homepath_env_buf, p);
|
||||||
homepath = buf;
|
homepath = homepath_env_buf;
|
||||||
}
|
}
|
||||||
if ((p = getenv ("HOME")))
|
if ((p = getenv ("HOME")))
|
||||||
debug_printf ("HOME is already in the environment %s", p);
|
debug_printf ("HOME is already in the environment %s", p);
|
||||||
|
@ -224,6 +225,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
||||||
else if (homedrive && homepath)
|
else if (homedrive && homepath)
|
||||||
{
|
{
|
||||||
char home[MAX_PATH];
|
char home[MAX_PATH];
|
||||||
|
char buf[MAX_PATH + 1];
|
||||||
strcpy (buf, homedrive);
|
strcpy (buf, homedrive);
|
||||||
strcat (buf, homepath);
|
strcat (buf, homepath);
|
||||||
cygwin_conv_to_full_posix_path (buf, home);
|
cygwin_conv_to_full_posix_path (buf, home);
|
||||||
|
@ -238,7 +240,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
||||||
if (!pw)
|
if (!pw)
|
||||||
pw = getpwnam (name ());
|
pw = getpwnam (name ());
|
||||||
if (pw && pw->pw_dir && *pw->pw_dir)
|
if (pw && pw->pw_dir && *pw->pw_dir)
|
||||||
cygwin_conv_to_full_win32_path (pw->pw_dir, buf);
|
cygwin_conv_to_full_win32_path (pw->pw_dir, homepath_env_buf);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sys_mbstowcs (wuser, name (), sizeof (wuser) / sizeof (*wuser));
|
sys_mbstowcs (wuser, name (), sizeof (wuser) / sizeof (*wuser));
|
||||||
|
@ -247,23 +249,24 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
||||||
if (env_logsrv ())
|
if (env_logsrv ())
|
||||||
{
|
{
|
||||||
WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
|
WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
|
||||||
strcpy (buf, env_logsrv ());
|
strcpy (homepath_env_buf, env_logsrv ());
|
||||||
sys_mbstowcs (wlogsrv, buf, sizeof (wlogsrv) / sizeof(*wlogsrv));
|
sys_mbstowcs (wlogsrv, homepath_env_buf,
|
||||||
|
sizeof (wlogsrv) / sizeof(*wlogsrv));
|
||||||
ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui);
|
ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
|
sys_wcstombs (homepath_env_buf, ui->usri3_home_dir, MAX_PATH);
|
||||||
if (!buf[0])
|
if (!homepath_env_buf[0])
|
||||||
{
|
{
|
||||||
sys_wcstombs (buf, ui->usri3_home_dir_drive, MAX_PATH);
|
sys_wcstombs (homepath_env_buf, ui->usri3_home_dir_drive, MAX_PATH);
|
||||||
if (buf[0])
|
if (homepath_env_buf[0])
|
||||||
strcat (buf, "\\");
|
strcat (homepath_env_buf, "\\");
|
||||||
else if (!GetSystemDirectory (buf, MAX_PATH))
|
else if (!GetSystemDirectory (homepath_env_buf, MAX_PATH))
|
||||||
strcpy (buf, "c:\\");
|
strcpy (homepath_env_buf, "c:\\");
|
||||||
else if ((p = strchr (buf, '\\')))
|
else if ((p = strchr (homepath_env_buf, '\\')))
|
||||||
p[1] = '\0';
|
p[1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,18 +274,18 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
||||||
NetApiBufferFree (ui);
|
NetApiBufferFree (ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[1] != ':')
|
if (homepath_env_buf[1] != ':')
|
||||||
{
|
{
|
||||||
homedrive_buf[0] = homedrive_buf[1] = '\0';
|
homedrive_env_buf[0] = homedrive_env_buf[1] = '\0';
|
||||||
homepath = buf;
|
homepath = homepath_env_buf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
homedrive_buf[0] = buf[0];
|
homedrive_env_buf[0] = homepath_env_buf[0];
|
||||||
homedrive_buf[1] = buf[1];
|
homedrive_env_buf[1] = homepath_env_buf[1];
|
||||||
homepath = buf + 2;
|
homepath = homepath_env_buf + 2;
|
||||||
}
|
}
|
||||||
homedrive = homedrive_buf;
|
homedrive = homedrive_env_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (what)
|
switch (what)
|
||||||
|
|
Loading…
Reference in New Issue