zsh does not start in $HOME

Hello!

We are currently migrating from NIS to LDAP and have therefore both
services running. To distinguish between them, LDAP accounts have their
home directory set to /ldaphome/username.

This works with bash, but every time we start a zsh, the user's pwd is
/home/username:

| $ bash
| $ pwd
| /ldaphome/username
| $ echo $HOME
| /ldaphome/username
| $ zsh
| % pwd
| /home/username

How does zsh determine its home directory and why does it not use $HOME?

The version is 4.3.4 (Ubuntu Hardy).

TIA
 Stephan
Peter Stephenson | 8 Sep 10:51
Favicon

Re: zsh does not start in $HOME

On Mon, 8 Sep 2008 10:09:18 +0200
Stephan Windmüller <stephan.windmueller <at> cs.tu-dortmund.de> wrote:
> We are currently migrating from NIS to LDAP and have therefore both
> services running. To distinguish between them, LDAP accounts have their
> home directory set to /ldaphome/username.
> 
> This works with bash, but every time we start a zsh, the user's pwd is
> /home/username:
> 
> | $ bash
> | $ pwd
> | /ldaphome/username
> | $ echo $HOME
> | /ldaphome/username
> | $ zsh
> | % pwd
> | /home/username

zsh doesn't change directory internally when it starts, regardless of where
the home directory is.  They're not symbolic links, are they?  Otherwise
start with "zsh -x" and see what it's executing.

--

-- 
Peter Stephenson <pws <at> csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

Re: zsh does not start in $HOME

On Mon, 08. Sep 2008, Peter Stephenson wrote:

> zsh doesn't change directory internally when it starts, regardless of where
> the home directory is.

Here it does:

| % pwd
| /ldaphome/username
| % zsh
| % pwd
| /home/username

But it does not when I start zsh from another directory:

| % pwd
| /tmp
| % zsh
| % pwd
| /tmp

This happens with an empty .zshrc.

> They're not symbolic links, are they?

No, there are two mountpoints.

> Otherwise start with "zsh -x" and see what it's executing.

I am receiving a lot of output, but that does not contain any lines with
(Continue reading)

Bart Schaefer | 8 Sep 16:39

Re: zsh does not start in $HOME

On Sep 8, 11:18am, Stephan Windmüller wrote:
}
} On Mon, 08. Sep 2008, Peter Stephenson wrote:
} 
} > zsh doesn't change directory internally when it starts, regardless of where
} > the home directory is.
} 
} Here it does:
} 
} | % pwd
} | /ldaphome/username
} | % zsh
} | % pwd
} | /home/username

What does /bin/pwd say?  Or "pwd -L"?

} > They're not symbolic links, are they?
} 
} No, there are two mountpoints.

Is /home/username a symbolic link to /ldaphome/username?  What's the
value of $HOME both before and after starting zsh?

} This happens with an empty .zshrc.

Are /etc/z* also empty?  Since you say you get a lot of output ...

} > Otherwise start with "zsh -x" and see what it's executing.
} 
(Continue reading)

Stephan Windmüller | 15 Sep 15:32

Re: zsh does not start in $HOME

On Mon, 08. Sep 2008, Bart Schaefer wrote:

> } | % pwd
> } | /ldaphome/username
> } | % zsh
> } | % pwd
> } | /home/username
> What does /bin/pwd say?  Or "pwd -L"?

This is interesting. /bin/pwd shows "/ldaphome/username".

"pwd -L" shows the same as "pwd": "/home/username".

Regards
 Stephan
Attachment (smime.p7s): application/x-pkcs7-signature, 2321 bytes
Bart Schaefer | 15 Sep 16:34

Re: zsh does not start in $HOME

On Sep 15,  3:32pm, Stephan Windmüller wrote:
}
} This is interesting. /bin/pwd shows "/ldaphome/username".
} 
} "pwd -L" shows the same as "pwd": "/home/username".

That indicates to me that:

-- there is a symlink from /home/username to /ldaphome/username
-- /etc/passwd says the home directory is /home/username

What does "pwd -P" say?

You may want to try "setopt CHASE_LINKS".

Stephan Windmüller | 16 Sep 09:27

Re: zsh does not start in $HOME

On Mon, 15. Sep 2008, Bart Schaefer wrote:

> } This is interesting. /bin/pwd shows "/ldaphome/username".
> } 
> } "pwd -L" shows the same as "pwd": "/home/username".
> 
> That indicates to me that:
> -- there is a symlink from /home/username to /ldaphome/username

No, both are separate directories.

> -- /etc/passwd says the home directory is /home/username

/etc/passwd does not contain an entry for my user.

> What does "pwd -P" say?

It gives the correct "ldaphome".

> You may want to try "setopt CHASE_LINKS".

When I set this, pwd shows the correct directory, but according to the
prompt I am still in /home.

- Stephan
Attachment (smime.p7s): application/x-pkcs7-signature, 2321 bytes
Peter Stephenson | 16 Sep 11:38
Favicon

Re: zsh does not start in $HOME

On Tue, 16 Sep 2008 09:27:57 +0200
Stephan Windmüller <stephan.windmueller <at> cs.tu-dortmund.de> wrote:
> > What does "pwd -P" say?
> 
> It gives the correct "ldaphome".
> 
> > You may want to try "setopt CHASE_LINKS".
> 
> When I set this, pwd shows the correct directory, but according to the
> prompt I am still in /home.

Further thoughts that may or may not have anything to do with it (i) is
there an unreadable directory in the hierarchy above the directory you want
to be in (ii) is there a symbolic link in the hierarchy above the directory
you want to be in (which in both cases would have to be the immediately
higher level here)?

--

-- 
Peter Stephenson <pws <at> csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

Stephan Windmüller | 16 Sep 11:48

Re: zsh does not start in $HOME

On Tue, 16. Sep 2008, Peter Stephenson wrote:

> Further thoughts that may or may not have anything to do with it (i) is
> there an unreadable directory in the hierarchy above the directory you want
> to be in (ii) is there a symbolic link in the hierarchy above the directory
> you want to be in (which in both cases would have to be the immediately
> higher level here)?

The only directory above is "/" and the mode is 755.

- Stephan
Attachment (smime.p7s): application/x-pkcs7-signature, 2321 bytes
Bart Schaefer | 16 Sep 16:59

Re: zsh does not start in $HOME

On Sep 16,  9:27am, Stephan Windmüller wrote:
}
} /etc/passwd does not contain an entry for my user.

Well, the NIS passwd map then, or the LDAP entry for your user, or ...
What's "print $HOME" say?  Zsh has to be getting /home/username from
this code in Src/init.c:

    if ((pswd = getpwuid(cached_uid))) {
        if (emulation == EMULATE_ZSH)
            home = metafy(pswd->pw_dir, -1, META_DUP);
        cached_username = ztrdup(pswd->pw_name);
    }

It then initializes $PWD from $HOME, and "pwd" without the -P simply
prints $PWD.

} On Mon, 15. Sep 2008, Bart Schaefer wrote:
} > That indicates to me that:
} > -- there is a symlink from /home/username to /ldaphome/username
} 
} No, both are separate directories.

There's a test ispwd() which checks to see whether the directory named
by $HOME is the same as the current directory, which it does by calling
stat() and examining the inode and device numbers.  This test has to be
returning success, so zsh disputes your assertion.

Run stat or zstat on the two directories and look at the device and
inode numbers.
(Continue reading)


Gmane