delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2001/10/29/07:20:48

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Date: Mon, 29 Oct 2001 13:10:55 +0100
From: Corinna Vinschen <vinschen AT redhat DOT com>
To: cygwin-developers AT cygwin DOT Com
Subject: Re: [mathew DOT boorman AT au DOT cmg DOT com: /etc/profile /etc/passwd and HOME]
Message-ID: <20011029131055.G891@cygbert.vinschen.de>
Reply-To: cygdev <cygwin-developers AT cygwin DOT Com>
Mail-Followup-To: cygwin-developers AT cygwin DOT Com
References: <20011026200103 DOT B7622 AT cygbert DOT vinschen DOT de> <20011026140728 DOT A347 AT redhat DOT com> <3BD9ADC6 DOT BF581E7F AT yahoo DOT com> <20011026150434 DOT A1308 AT redhat DOT com> <20011028114254 DOT A2432 AT cygbert DOT vinschen DOT de>
Mime-Version: 1.0
User-Agent: Mutt/1.2.5i
In-Reply-To: <20011028114254.A2432@cygbert.vinschen.de>; from vinschen@redhat.com on Sun, Oct 28, 2001 at 11:42:54AM +0100

On Sun, Oct 28, 2001 at 11:42:54AM +0100, Corinna Vinschen wrote:
> On Fri, Oct 26, 2001 at 03:04:34PM -0400, Christopher Faylor wrote:
> > >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.

I checked it in since I heard no objections.

Corinna

> 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.

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019