From: Luca Boccassi Date: Wed, 23 Dec 2020 19:42:40 +0000 (+0000) Subject: Debian: fix autologin X-Git-Tag: v9~15^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F596%2Fhead;p=thirdparty%2Fmkosi.git Debian: fix autologin For some reason, PAM on Debian really wants the full path to the console device in its rules. eg, this fails: auth sufficient pam_succeed_if.so tty = ttyS0 But this works: auth sufficient pam_succeed_if.so tty = /dev/ttyS0 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index d405c4b5b..82b17392b 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2867,6 +2867,9 @@ def set_autologin(args: CommandLineArguments, root: str, do_run_build_script: bo if do_run_build_script or for_cache or not args.autologin: return + # On Debian, PAM wants the full path to the console device or it will refuse access + device_prefix = "/dev/" if args.distribution is Distribution.debian else "" + override_dir = os.path.join(root, "etc/systemd/system/console-getty.service.d") os.makedirs(override_dir, mode=0o755, exist_ok=True) @@ -2884,7 +2887,7 @@ def set_autologin(args: CommandLineArguments, root: str, do_run_build_script: bo os.chmod(override_file, 0o644) - pam_add_autologin(root, "pts/0") + pam_add_autologin(root, f"{device_prefix}pts/0") override_dir = os.path.join(root, "etc/systemd/system/serial-getty@ttyS0.service.d") os.makedirs(override_dir, mode=0o755, exist_ok=True) @@ -2903,7 +2906,7 @@ def set_autologin(args: CommandLineArguments, root: str, do_run_build_script: bo os.chmod(override_file, 0o644) - pam_add_autologin(root, "ttyS0") + pam_add_autologin(root, f"{device_prefix}ttyS0") override_dir = os.path.join(root, "etc/systemd/system/getty@tty1.service.d") os.makedirs(override_dir, mode=0o755, exist_ok=True) @@ -2922,7 +2925,7 @@ def set_autologin(args: CommandLineArguments, root: str, do_run_build_script: bo os.chmod(override_file, 0o644) - pam_add_autologin(root, "tty1") + pam_add_autologin(root, f"{device_prefix}tty1") def set_serial_terminal(args: CommandLineArguments, root: str, do_run_build_script: bool, for_cache: bool) -> None: