[systemd-devel] systemd-consoled: invoking login shells

Jonathan de Boyne Pollard j.deboynepollard-newsgroups at ntlworld.com
Fri Dec 13 10:14:42 PST 2013


In your terminal_run_child() function you invoke the (login) shell for the
terminal as, effectively, "$SHELL" "-il".  Don't do that.  Distributions such
as Debian have spent a fair while getting rid of bashisms from the init system
and here you are putting more of them in.  (-:

  https://wiki.debian.org/BootProcessSpeedup#Using_a_faster_system_shell

-l is not supported by the Korn shell for starters; and the irony is that you
don't need either it or -i at all.

The purpose of -i is to force a shell to think that it is interactive if it
doesn't automatically detect that it is.  Shells automatically detect that
they are interactive by looking at their standard file descriptors and using
isatty()/tcgetattr().  You're running your shells with standard input, output,
and error attached to the slave side of a pseudo-terminal.  Of course they are
going to be autodetected as interactive.  There's no need at all to use -i.

Moreover the universal protocol, that all shells support because they have to,
for telling a shell that it is a login shell is the one that is used by
login(1): prepend a dash to the value of argv[0].  So do that.  You can
probably nick the code right out of login.c from util-linux.  (Beware that it
isn't portable, because it uses PATH_MAX unconditionally, and won't work on
operating systems such as Debian Hurd where there is no maximum path length.
But you're only targetting Linux distributions and not worrying about Debian
FreeBSD, Arch Hurd, or Debian Hurd, you say.)  When invoking a login shell, you
in fact only need an argv[0] and NULL.


More information about the systemd-devel mailing list