FS#70408 - [mkinitcpio] Add hook for unlocking root account
Attached to Project:
Arch Linux
Opened by Nils (nlswrnr) - Sunday, 11 April 2021, 11:05 GMT
Last edited by Jelle van der Waa (jelly) - Monday, 18 September 2023, 17:44 GMT
Opened by Nils (nlswrnr) - Sunday, 11 April 2021, 11:05 GMT
Last edited by Jelle van der Waa (jelly) - Monday, 18 September 2023, 17:44 GMT
|
Details
Description:
Right now the root account is locked in the initramfs. Locking root makes sense in most situations, but when working on early boot code like initramfs hooks, it prevents access to the emergency shell and therefore helpful logs. Attached you will find a patch that adds a `shadow` hook that overwrites the `/etc/shadow` file in the initramfs with the one from the actual main OS, effectively unlocking the root account with the same password as the main OS. This hook should only be enabled when debugging other initramfs hooks, and should otherwise remain disabled. |
This task depends upon
Closed by Jelle van der Waa (jelly)
Monday, 18 September 2023, 17:44 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/m kinitcpio/mkinitcpio/issues/205
Monday, 18 September 2023, 17:44 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/m kinitcpio/mkinitcpio/issues/205
I a few kernel parameters, like `systemd.debug_shell` and `emergency`, and none of them worked, but I didn't try `init=/bin/sh`. If it really works even before the root FS has been mounted, then this hook is indeed useless.
It doesn't.
Edit:rdinit= would, but that also bypasses everything init in the initrd does, so it's not as useful.
[1] https://github.com/archlinux/svntogit-packages/commit/7952a4228333c57926884fbd49526a8cfe2eaea1
[2] https://github.com/archlinux/svntogit-packages/commit/776743d220cbb56e9abca2cc8bcef3a0ab7c8d0a
[1] https://wiki.archlinux.org/index.php/General_troubleshooting#Recovery_shells
Side note: I don't really get what locking root account in initramfs achieves in terms of system security.
That aside, one can write a simple sd-shadow hook that reintroduces the shadow.initramfs behavior with ease, this would be useful to debug a systemd initramfs by reading the journals and such that would otherwise be lost after reboot, but that is all there is to it.
For the standard busybox it's just useless tho, since it doesn't care what shadow has to say.
The main issue with "break=premount' and "break=postmount" is that the when you do non-trivial boot setups, like with UEFI stubs, you can't edit the kernel cmdline if there is a regression in anything initrd related. This leaves you in a pickle if you could solve it with a shell but have that refused. Rebuilding the UEFI executable for the "break=" parameters is a bit annoying compared to having the root account unlockable if needed.
If so the code systemd uses to create minimal passwd, shadow and group files could be made common and reused?
Then there is the question of does whatever unlocks the root account need to copy the system's shadow to the initrd or is it sufficient to unlock the root account with an empty password or roots current password?
@loqs that is the best approach, to make busybox based use sulogin and reuse code for passwd group and shadow.
Next a shadow hook that will do the [1]old behavior of /etc/shadow.initramfs or locked.
Finishing with an announcement so everyone catches up the news, and add the shadow hook if wanted.
This makes both initramfs implementations equal in that sense, and the shadow hook will work on both.
...
Now, to the reason for the [2]revert, how frequent can the initramfs spontaneously fail that an unlocked root is a bad idea?
I really can't replicate that danger under normal circumstances, typically it will succeed always or fail always when something is wrong...
If something bad in the system can cause systemd based to spontaneously fail, I wouldn't be surprised that it would also cause the busybox based one to fail as well.
[1] https://github.com/archlinux/svntogit-packages/commit/7952a4228333c57926884fbd49526a8cfe2eaea1
[2] https://github.com/archlinux/svntogit-packages/commit/776743d220cbb56e9abca2cc8bcef3a0ab7c8d0a
I dislike the idea of having root password hash leaked in initramfs same as I dislike the idea of having to boot from livecd when initramfs breaks because it was decided debugging it from the inside impossible. I think asking people to rebuild their initramfs when they can't boot isn't helpful but I don't mind if systemd hook users are satisfied with it as long as busybox is untouched.
@loqs I think it's weird they use two different systems, yes. But I'd rather just want `shadow` to include `/etc/shadow.initramfs` and leave the other details for the busybox implementation.
If this hook is currently going to only apply to systemd should it not be provided by the systemd package instead of mkinitcpio?
[1] https://github.com/archlinux/svntogit-packages/commit/776743d220cbb56e9abca2cc8bcef3a0ab7c8d0a