* uinfo.cc (internal_getlogin): Set environment variable $HOME
from either /etc/passwd or $HOMEDRIVE/$HOMEPATH if necessary.
This commit is contained in:
parent
711ded6d28
commit
ac19c8dcf6
@ -1,3 +1,8 @@
|
|||||||
|
2001-10-29 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* uinfo.cc (internal_getlogin): Set environment variable $HOME
|
||||||
|
from either /etc/passwd or $HOMEDRIVE/$HOMEPATH if necessary.
|
||||||
|
|
||||||
2001-10-29 Christopher Faylor <cgf@redhat.com>
|
2001-10-29 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* fhandler.h (fhandler_serial::fhandler_serial): Change to only accept
|
* fhandler.h (fhandler_serial::fhandler_serial): Change to only accept
|
||||||
|
@ -33,6 +33,7 @@ details. */
|
|||||||
struct passwd *
|
struct passwd *
|
||||||
internal_getlogin (cygheap_user &user)
|
internal_getlogin (cygheap_user &user)
|
||||||
{
|
{
|
||||||
|
char buf[512];
|
||||||
char username[UNLEN + 1];
|
char username[UNLEN + 1];
|
||||||
DWORD username_len = UNLEN + 1;
|
DWORD username_len = UNLEN + 1;
|
||||||
struct passwd *pw = NULL;
|
struct passwd *pw = NULL;
|
||||||
@ -47,7 +48,6 @@ internal_getlogin (cygheap_user &user)
|
|||||||
{
|
{
|
||||||
LPWKSTA_USER_INFO_1 wui;
|
LPWKSTA_USER_INFO_1 wui;
|
||||||
NET_API_STATUS ret;
|
NET_API_STATUS ret;
|
||||||
char buf[512];
|
|
||||||
char *env;
|
char *env;
|
||||||
|
|
||||||
user.set_logsrv (NULL);
|
user.set_logsrv (NULL);
|
||||||
@ -212,7 +212,28 @@ internal_getlogin (cygheap_user &user)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug_printf ("Cygwins Username: %s", user.name ());
|
debug_printf ("Cygwins Username: %s", user.name ());
|
||||||
return pw ?: getpwnam(user.name ());
|
if (!pw)
|
||||||
|
pw = getpwnam(user.name ());
|
||||||
|
if (!getenv ("HOME"))
|
||||||
|
{
|
||||||
|
const char *homedrive, *homepath;
|
||||||
|
if (pw && pw->pw_dir && *pw->pw_dir)
|
||||||
|
{
|
||||||
|
setenv ("HOME", pw->pw_dir, 1);
|
||||||
|
debug_printf ("Set HOME (from /etc/passwd) to %s", pw->pw_dir);
|
||||||
|
}
|
||||||
|
else if ((homedrive = getenv ("HOMEDRIVE"))
|
||||||
|
&& (homepath = getenv ("HOMEPATH")))
|
||||||
|
{
|
||||||
|
char home[MAX_PATH];
|
||||||
|
strcpy (buf, homedrive);
|
||||||
|
strcat (buf, homepath);
|
||||||
|
cygwin_conv_to_full_posix_path (buf, home);
|
||||||
|
setenv ("HOME", home, 1);
|
||||||
|
debug_printf ("Set HOME (from HOMEDRIVE/HOMEPATH) to %s", home);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user