1

Arch Linux /usr/lib/initcpio/busybox is owned by package mkinitcpio-busybox 1.27.2-1 and is configured low on features, for example CONFIG_FEATURE_USE_INITTAB is not set.

In a custom initramfs, containing that busybox, I managed to get ssh network logins that do source /etc/profile working. Also there is an ash shell prompt visible on the VGA monitor.

However that "vga" shell doesn't source /etc/profile. Q:Difference between Login Shell and Non-Login Shell? makes me think that this shell is not a login shell. That shell is started by /init:

exec setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'

Regression:

  • exec setsid sh -c 'exec sh -i </dev/tty1 >/dev/tty1 2>&1'
  • exec setsid sh -c 'exec sh - </dev/tty1 >/dev/tty1 2>&1'
  • exec setsid sh -c 'exec -sh </dev/tty1 >/dev/tty1 2>&1'

How to make this busybox ash shell to source /etc/profile and/or make it an (auto) login shell?

2

Conventionally, a shell acts as a login shell if it is invoked with a command name beginning with -. exec -sh would work is you had an executable called -sh in the path. BusyBox ash also supports the -l option, so you can run sh -l.

When you log in, the login program (or sshd, or whatever is handling the login) takes care of running the user's shell with a leading - in the command name (the command name doesn't have to be the same as the name of the executable, it's just a very common convention which login violates on purpose). Here, “whatever is handling the login” is your mini-script, so you have to take care of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.