Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Change directory on invocation of zsh



* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> [20041017 18:28]:
> On Sun, 17 Oct 2004, Michael Prokop wrote:
> > * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> [20041017 10:13]:

> > >   if (( EUID == 0 )); then
> > >      export HOME=/root
> > >   else
> > >      export HOME=/home/$LOGNAME
> > >   fi

> > /etc/zsh/zshrc:cd:22: no such file or directory: /home/LOGIN
> > $ echo $LOGNAME
> > LOGIN

> Hm.  This means that one of the following occurred:

> - getlogin() returned "LOGIN"

> - getlogin() returned empty or null, and getpwuid() returned an entry for
>   the user named "LOGIN"

[.../rungetty-1.2]$ grep LOGIN rungetty.c
#ifndef _PATH_LOGIN
#define _PATH_LOGIN "/bin/login"
#define LOGIN " login: "        /* login prompt */
  strncpy (ut.ut_user, "LOGIN", sizeof (ut.ut_user));
  ut.ut_type = LOGIN_PROCESS;
  write (1, LOGIN, sizeof (LOGIN) - 1);
      execl (_PATH_LOGIN, _PATH_LOGIN, "-f", autologin_name, NULL);
      execl (_PATH_LOGIN, _PATH_LOGIN, "--", logname, NULL);
  error ("%s: can't exec " _PATH_LOGIN ": %s", tty, sys_errlist[errno]);
[.../rungetty-1.2]$

> I'd have to guess this is a side-effect of autologin?  Does it run as the
> user "LOGIN"?

This seems to be a side-effect of rungetty's autologin, yes.
rungetty should run as user root or as the user specified in
/etc/inittab, in my case this is user 'grml':

4:2345:respawn:/sbin/rungetty tty4 -u grml -g grml --autologin grml /bin/zsh

I'm in contact with the debian maintainer of the rungetty-package.

> > I can't find the reason for this behaviour (inittab entries are the
> > same and behaviour seems to change when booting system serveral
> > times), but using `id -un` instead of $LOGNAME seems to fix it.

> If you can't figure out how to get it to be consistent, I'd suggest adding
> to /etc/zsh/zshenv this snippet:

>   [[ $LOGNAME == LOGIN ]] && LOGNAME=$(id -un)

> Do that before the EUID/HOME snippet.  Other things may be depending on 
> LOGNAME being set correctly, too.

Thanks, works like a charme!

regards,
(-: Michael



Messages sorted by: Reverse Date, Date, Thread, Author