Several cleanups for rc-local-generator (#36953)

This commit is contained in:
Yu Watanabe
2025-04-03 04:05:45 +09:00
committed by GitHub
8 changed files with 25 additions and 17 deletions

View File

@@ -11,7 +11,7 @@
<!ENTITY MEMORY_ACCOUNTING_DEFAULT "{{ 'yes' if MEMORY_ACCOUNTING_DEFAULT else 'no' }}">
<!ENTITY KILL_USER_PROCESSES "{{ 'yes' if KILL_USER_PROCESSES else 'no' }}">
<!ENTITY DEBUGTTY "{{DEBUGTTY}}">
<!ENTITY RC_LOCAL_PATH "{{RC_LOCAL_PATH}}">
<!ENTITY SYSTEM_SYSVRCLOCAL_PATH "{{SYSTEM_SYSVRCLOCAL_PATH}}">
<!ENTITY HIGH_RLIMIT_NOFILE "{{HIGH_RLIMIT_NOFILE}}">
<!ENTITY DEFAULT_DNSSEC_MODE "{{DEFAULT_DNSSEC_MODE_STR}}">
<!ENTITY DEFAULT_DNS_OVER_TLS_MODE "{{DEFAULT_DNS_OVER_TLS_MODE_STR}}">

View File

@@ -1071,7 +1071,10 @@ manpages = [
'8',
['systemd-random-seed'],
'ENABLE_RANDOMSEED'],
['systemd-rc-local-generator', '8', ['rc-local.service'], 'HAVE_SYSV_COMPAT'],
['systemd-rc-local-generator',
'8',
['rc-local.service'],
'HAVE_SYSV_COMPAT HAVE_SYSV_RC_LOCAL'],
['systemd-remount-fs.service', '8', ['systemd-remount-fs'], ''],
['systemd-repart', '8', ['systemd-repart.service'], 'ENABLE_REPART'],
['systemd-resolved.service', '8', ['systemd-resolved'], 'ENABLE_RESOLVE'],

View File

@@ -6,7 +6,7 @@
]>
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
<refentry id="systemd-rc-local-generator" conditional='HAVE_SYSV_COMPAT'>
<refentry id="systemd-rc-local-generator" conditional='HAVE_SYSV_COMPAT HAVE_SYSV_RC_LOCAL'>
<refentryinfo>
<title>systemd-rc-local-generator</title>
<productname>systemd</productname>
@@ -20,7 +20,7 @@
<refnamediv>
<refname>systemd-rc-local-generator</refname>
<refname>rc-local.service</refname>
<refpurpose>Compatibility generator and service to start <filename>&RC_LOCAL_PATH;</filename> during boot</refpurpose>
<refpurpose>Compatibility generator and service to start <filename>&SYSTEM_SYSVRCLOCAL_PATH;</filename> during boot</refpurpose>
</refnamediv>
<refsynopsisdiv>
@@ -32,7 +32,7 @@
<title>Description</title>
<para><command>systemd-rc-local-generator</command> is a generator that checks whether
<filename>&RC_LOCAL_PATH;</filename> exists and is executable, and if it is, pulls the
<filename>&SYSTEM_SYSVRCLOCAL_PATH;</filename> exists and is executable, and if it is, pulls the
<filename>rc-local.service</filename> unit into the boot process. This unit is responsible for running
this script during late boot. The script is run after <filename>network.target</filename>, but in
parallel with most other regular system services.</para>
@@ -53,7 +53,7 @@ Wants=network-online.target
After=network-online.target
</programlisting>
<para>Support for <filename>&RC_LOCAL_PATH;</filename> is provided for compatibility with specific
<para>Support for <filename>&SYSTEM_SYSVRCLOCAL_PATH;</filename> is provided for compatibility with specific
System V systems only. However, it is strongly recommended to avoid using this script today, and instead
provide proper unit files with appropriate dependencies for any scripts to run during the boot process.
Note that the path to the script is set at compile time and varies between distributions.</para>
@@ -66,7 +66,7 @@ After=network-online.target
<title>Notes</title>
<para>On systems with SELinux, when creating the file, make sure to set the appropriate context, e.g.
with "<command>sudo restorecon -v &RC_LOCAL_PATH;</command>".
with "<command>sudo restorecon -v &SYSTEM_SYSVRCLOCAL_PATH;</command>".
</para>
</refsect1>

View File

@@ -94,6 +94,8 @@ sysvinit_path = get_option('sysvinit-path')
sysvrcnd_path = get_option('sysvrcnd-path')
conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
description : 'SysV init scripts and rcN.d links are supported')
sysvrclocal_path = get_option('rc-local')
conf.set10('HAVE_SYSV_RC_LOCAL', sysvrclocal_path != '')
conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
if get_option('hibernate') and not get_option('initrd')
@@ -260,7 +262,6 @@ conf.set_quoted('PREFIX', prefixdir)
conf.set_quoted('PREFIX_NOSLASH', prefixdir_noslash)
conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
conf.set_quoted('SSHCONFDIR', sshconfdir)
conf.set_quoted('SSHDCONFDIR', sshdconfdir)
conf.set_quoted('SHELLPROFILEDIR', shellprofiledir)
@@ -301,6 +302,7 @@ conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
conf.set_quoted('SYSTEM_SYSVRCLOCAL_PATH', sysvrclocal_path)
conf.set_quoted('SYSUSERS_DIR', sysusersdir)
conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
@@ -2928,6 +2930,7 @@ summary({
'lib directory' : libdir,
'SysV init scripts' : sysvinit_path,
'SysV rc?.d directories' : sysvrcnd_path,
'SysV rc.local script' : sysvrclocal_path,
'PAM modules directory' : pamlibdir,
'PAM configuration directory' : pamconfdir,
'ssh server configuration directory' : sshdconfdir,
@@ -2944,7 +2947,6 @@ summary({
'bash completions directory' : bashcompletiondir,
'zsh completions directory' : zshcompletiondir,
'private shared lib version tag' : shared_lib_tag,
'extra start script' : get_option('rc-local'),
'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
get_option('debug-tty')),
'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),

View File

@@ -45,8 +45,8 @@ option('sysvinit-path', type : 'string', value : '/etc/init.d',
description : 'the directory where the SysV init scripts are located')
option('sysvrcnd-path', type : 'string', value : '/etc/rc.d',
description : 'the base directory for SysV rcN.d directories')
option('rc-local', type : 'string',
value : '/etc/rc.local')
option('rc-local', type : 'string', value : '/etc/rc.local',
description : 'path to SysV rc.local script')
option('initrd', type : 'boolean',
description : 'install services for use when running systemd in initrd')
option('compat-mutable-uid-boundaries', type : 'boolean', value : false,

View File

@@ -3,7 +3,10 @@
executables += [
generator_template + {
'name' : 'systemd-rc-local-generator',
'conditions' : ['HAVE_SYSV_COMPAT'],
'sources' : files('rc-local-generator.c'),
'conditions' : [
'HAVE_SYSV_COMPAT',
'HAVE_SYSV_RC_LOCAL',
],
},
]

View File

@@ -64,7 +64,7 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
return EXIT_SUCCESS;
}
if (check_executable(RC_LOCAL_PATH) >= 0) {
if (check_executable(SYSTEM_SYSVRCLOCAL_PATH) >= 0) {
log_debug("Automatically adding rc-local.service.");
r = add_symlink("rc-local.service", "multi-user.target");

View File

@@ -8,16 +8,16 @@
# (at your option) any later version.
# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if {{RC_LOCAL_PATH}} is executable.
# systemd-rc-local-generator if {{SYSTEM_SYSVRCLOCAL_PATH}} is executable.
[Unit]
Description={{RC_LOCAL_PATH}} Compatibility
Description={{SYSTEM_SYSVRCLOCAL_PATH}} Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable={{RC_LOCAL_PATH}}
ConditionFileIsExecutable={{SYSTEM_SYSVRCLOCAL_PATH}}
After=network.target
[Service]
Type=forking
ExecStart={{RC_LOCAL_PATH}} start
ExecStart={{SYSTEM_SYSVRCLOCAL_PATH}} start
TimeoutSec=infinity
RemainAfterExit=yes
GuessMainPID=no