Mail Archives: cygwin-developers/2001/10/28/05:43:18
On Fri, Oct 26, 2001 at 03:04:34PM -0400, Christopher Faylor wrote:
> On Fri, Oct 26, 2001 at 02:39:02PM -0400, Earnie Boyd wrote:
> >Christopher Faylor wrote:
> >>
> >> On Fri, Oct 26, 2001 at 08:01:03PM +0200, Corinna Vinschen wrote:
> >> >I like that idea.
> >> >
> >> >Should we add these lines to the generated profile?
> >>
> >> Doesn't bash do this for you automatically, somehow?
> >
> >I just checked and yes it does. However I believe that would only be
> >for --login.
> >
> >> Having /etc/profile do this for you seems wrong.
> >
> >Yes, perhaps Cygwin should do it in dll initialization.
>
> Sure. Why not? We've got all of the info. This shouldn't be too hard.
> We already do this with HOMEDRIVE, etc.
>
> I can't think of anything that it would hurt and it might help other
> things.
Like that?
* uinfo.cc (internal_getlogin): Set environment variable
$HOME from either /etc/passwd or $HOMEDRIVE/$HOMEPATH if
necessary.
Index: uinfo.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/uinfo.cc,v
retrieving revision 1.56
diff -u -p -r1.56 uinfo.cc
--- uinfo.cc 2001/10/22 18:31:00 1.56
+++ uinfo.cc 2001/10/28 10:42:08
@@ -33,6 +33,7 @@ details. */
struct passwd *
internal_getlogin (cygheap_user &user)
{
+ char buf[512];
char username[UNLEN + 1];
DWORD username_len = UNLEN + 1;
struct passwd *pw = NULL;
@@ -47,7 +48,6 @@ internal_getlogin (cygheap_user &user)
{
LPWKSTA_USER_INFO_1 wui;
NET_API_STATUS ret;
- char buf[512];
char *env;
user.set_logsrv (NULL);
@@ -212,7 +212,28 @@ internal_getlogin (cygheap_user &user)
}
}
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
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin AT cygwin DOT com
Red Hat, Inc.
- Raw text -