From af1a179b4f33f9b24e9f77a4d47aa7301ff269e2 Mon Sep 17 00:00:00 2001 From: Dermot Bradley Date: Sun, 19 Jul 2026 17:51:42 +0100 Subject: [PATCH] Add support for config setting to enable/disable UTMP-related files creation during boot. musl libc does not natively support UTMP and so some musl-basd distros may not make use of/update UTMP files (i.e. Alpine in the scenario where the utmps package in not installed or configured). Other Linux distros, especially those using systemd, may be making use of wtmpdb (via systemd-login) as an alternative. Therefore it makes sense to provide a configuration setting to prevent OpenRC from creating utmp-related files. --- conf.d/bootmisc | 3 +++ init.d/bootmisc.in | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/conf.d/bootmisc b/conf.d/bootmisc index dd5b08e01..dda96dfc1 100644 --- a/conf.d/bootmisc +++ b/conf.d/bootmisc @@ -13,3 +13,6 @@ log_dmesg="YES" # This may be useful if you need to compare the current boot to the # previous one. #previous_dmesg=no + +# Whether utmp/wtmp files should be created during boot +#disable_utmp_creation="no" diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index 33f676a6f..841027589 100644 --- a/init.d/bootmisc.in +++ b/init.d/bootmisc.in @@ -190,14 +190,16 @@ start() fi if checkpath -W /var/run; then - ebegin "Creating user login records" - local xtra= - [ "$RC_UNAME" = NetBSD ] && xtra=x - for x in "" $xtra; do - mkutmp /var/run/utmp$x - done - [ -e /var/log/wtmp ] || mkutmp /var/log/wtmp - eend 0 + if ! yesno ${disable_utmp_creation:-no}; then + ebegin "Creating user login records" + local xtra= + [ "$RC_UNAME" = NetBSD ] && xtra=x + for x in "" $xtra; do + mkutmp /var/run/utmp$x + done + [ -e /var/log/wtmp ] || mkutmp /var/log/wtmp + eend 0 + fi mountinfo -q -f tmpfs /var/run || cleanup_var_run_dir fi @@ -243,7 +245,7 @@ stop() { # Write a halt record if we're shutting down if [ "$RC_RUNLEVEL" = shutdown ]; then - if [ "$RC_UNAME" = Linux ]; then + if [ "$RC_UNAME" = Linux ] && ! yesno ${disable_utmp_creation:-no}; then if [ -x /sbin/halt ]; then halt -w else