From 8a7adccbdb23ae6fee82840ef41d17d5e568a8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 19 Aug 2022 16:43:45 +0200 Subject: various: try to use DEFAULT_USER_SHELL for root too /bin/sh as a shell is punishing. There is no good reason to make the occasional root login unpleasant. Since /bin/sh is usually /bin/bash in compat mode, i.e. if one is available, the other will be too, /bin/bash is almost as good as a default. But to avoid a regression in the situation where /bin/bash (or DEFAULT_USER_SHELL) is not installed, we check with access() and fall back to /bin/sh. This should make this change in behaviour less risky. (FWIW, e.g. Fedora/RHEL use /bin/bash as default for root.) This is a follow-up of sorts for 53350c7bbade8c5f357aa3d1029ef9b2208ea675, which added the default-user-shell option, but most likely with the idea of using /bin/bash less ;) Fixes #24369. --- test/test-execute/exec-specifier.service | 2 +- test/test-execute/exec-specifier@.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/test-execute') diff --git a/test/test-execute/exec-specifier.service b/test/test-execute/exec-specifier.service index ae8b2428bc..321d0e338a 100644 --- a/test/test-execute/exec-specifier.service +++ b/test/test-execute/exec-specifier.service @@ -26,7 +26,7 @@ ExecStart=sh -c 'test %U = $$(id -u)' ExecStart=sh -c 'test %g = $$(id -gn)' ExecStart=sh -c 'test %G = $$(id -g)' ExecStart=test %h = /root -ExecStart=sh -c 'test %s = /bin/sh' +ExecStart=sh -c 'test -x %s' ExecStart=sh -c 'test %m = $$(cat /etc/machine-id)' ExecStart=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')' ExecStart=sh -c 'test %H = $$(uname -n)' diff --git a/test/test-execute/exec-specifier@.service b/test/test-execute/exec-specifier@.service index 5e30efce4c..46c8503f1d 100644 --- a/test/test-execute/exec-specifier@.service +++ b/test/test-execute/exec-specifier@.service @@ -23,7 +23,7 @@ ExecStart=sh -c 'test %U = $$(id -u)' ExecStart=sh -c 'test %g = $$(id -gn)' ExecStart=sh -c 'test %G = $$(id -g)' ExecStart=test %h = /root -ExecStart=sh -c 'test %s = /bin/sh' +ExecStart=sh -c 'test -x %s' ExecStart=sh -c 'test %m = $$(cat /etc/machine-id)' ExecStart=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')' ExecStart=sh -c 'test %H = $$(uname -n)' -- cgit v1.2.1