public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: db_home setting in nsswitch.conf is ignored.
Date: Thu, 23 Jul 2015 08:57:00 -0000	[thread overview]
Message-ID: <20150723085752.GA29506@calimero.vinschen.de> (raw)
In-Reply-To: <143607434.20150723005320@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 4044 bytes --]

On Jul 23 00:53, Andrey Repin wrote:
> Greetings, Shaun Martin!
> 
> >> Is HOME set in the Windows environment already?  If so, this
> >> might interact with the setting in /etc/nsswitch.conf, which *only*
> >> works for entries taken from the passwd DB (getpwnam, getpwuid calls).
> >> 
> >> How do you start mintty?  It should be started with a single parameter,
> >> a dash, e.g.:
> >> 
> >>   C:\cygwin64\bin\mintty.exe -
> 
> > Yes, HOME is set in the Windows environment and I am not able to change it.
> 
> How so?...

I think admins can disallow changing your default user environment via
policy.  But that only means you can't change the env for the *first*
process in a process tree.  See below.

> > With the "SET" command in a Windows command prompt I can see:
> 
> > HOME=SERVER/USERS5:USERS\SHAUN
> 
> That's suspicious. So many symbols not allowed to be there.

I agree.

For a start, this behaviour of Cygwin has not chaged since at least
2002:

When being started from a non-Cygwin process (e.g. cmd, explorer),
Cygwin checks if the environment variable $HOME is already set.  If so,
it uses it verbatim.  Otherwise, it generates a value for $HOME
from the user's passwd DB entry or, if that fails for some reason,
falls back to generate a POSIX path from $HOMEDIR/$HOMEDRIVE.

The above value of $HOME is really a problem here.  Not only that
it exists and doesn't actually reflect your HOME, it's also not
starting with a slash and thus is evaluated as a *relative* path.
Therefore your resulting HOME will depend on the current directory
you're starting the Cygwin process from.

The fact that your actual home directory in the passwd DB is set
differently doesn't matter anymore then.  I.e., the output of

  $ getent passwd <your-account>

will very likely show something different as pw_dir entry.

On a second look into your OP, I'm also a bit puzzled about the
settings you made in /etc/nsswitch.conf.  No offense meant, but
it seem you just used some arbitrary settings without actually
reading what they mean and how to configure them (e.g. cygwin, desc).

Is there a problem understanding
https://cygwin.com/cygwin-ug-net/ntsec.html?  I'm always grateful for
hints how to improve the docs, even more so for patches to the docs.

> > When you say it only works for entries taken from passwd DB, does that
> > mean I need to create a "/etc/passwd" file in order to change the
> > "db_home" directory with nsswitch.conf?
> 
> No, she said that it only works if Cygwin has to retrieve these records from
> DB. If the information is already available, it will be used as is.

Right.

> > I'm starting mintty with the shortcut generated by the installer:
> 
> > C:\Users\shaun\Apps\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
> 
> System properties - Advanced - Environment.
> Remove the HOME variable. It shouldn't be there for Windows to begin with.
> If that wouldn't work, talk to your domain admin, explain the situation and
> ask to resolve the conflict.
> If Cygwin is a necessary part of your workflow, there's a Cygwin-specific
> schema available which can be installed in domain to help facilitate provision
> of the necessary Cygwin-specific information.

Alternatively (if your admin is a BOFH), you can always drop HOME from
your powershell env before starting a Cygwin process.

Even more alternatively, what Cygwin *could* do in an upcoming version
is to check the incoming $HOME for validity, i.e., is it an absolute
POSIX path and does it resolve to an existing directory.  If not,
ignore it and try the entry from the passwd DB.

However, I'm rather reluctant to do that.  For one your case is a first.
Such a change could also have surprising side effects.  Maybe just
checking for a leading slash would work in most environments, but
still...


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-07-23  8:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 19:28 Shaun Martin
2015-07-22 22:05 ` Andrey Repin
2015-07-23  8:57   ` Corinna Vinschen [this message]
2015-07-24 12:19     ` Buchbinder, Barry (NIH/NIAID) [E]
2015-07-24 16:05       ` Andrey Repin
  -- strict thread matches above, loose matches on Subject: below --
2015-07-23 13:39 Shaun Martin
2015-07-22 15:36 Shaun Martin
2015-07-22 16:57 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150723085752.GA29506@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).