From 74f25ea7a930c67aa7de4fa5c086dd4bbc5f6989 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Apr 2025 22:09:12 +0900 Subject: [PATCH 1/2] meson: disable rc-local-generator when an empty string is specified to rc-local= meson option In such case, the generator is meaningless. Let's kill it. --- man/rules/meson.build | 5 ++++- man/systemd-rc-local-generator.xml | 2 +- meson.build | 2 ++ meson_options.txt | 4 ++-- src/rc-local-generator/meson.build | 5 ++++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/man/rules/meson.build b/man/rules/meson.build index f98a55437c7..c33d9fee0e4 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -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'], diff --git a/man/systemd-rc-local-generator.xml b/man/systemd-rc-local-generator.xml index cc6068a91e1..882c5d6e7d1 100644 --- a/man/systemd-rc-local-generator.xml +++ b/man/systemd-rc-local-generator.xml @@ -6,7 +6,7 @@ ]> - + systemd-rc-local-generator systemd diff --git a/meson.build b/meson.build index 43858480a6b..3357df3d319 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/meson_options.txt b/meson_options.txt index 1e752eeb9ef..00963a6e4ad 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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, diff --git a/src/rc-local-generator/meson.build b/src/rc-local-generator/meson.build index e74225cd486..62daab28463 100644 --- a/src/rc-local-generator/meson.build +++ b/src/rc-local-generator/meson.build @@ -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', + ], }, ] From 011360eed3afcdd489c0b45cfaa9298e133bee0c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Apr 2025 22:10:29 +0900 Subject: [PATCH 2/2] meson: rename RC_LOCAL_PATH -> SYSTEM_SYSVRCLOCAL_PATH No functional change, but just for emphasizing that this is for SysV compatibility. --- man/custom-entities.ent.in | 2 +- man/systemd-rc-local-generator.xml | 8 ++++---- meson.build | 4 ++-- src/rc-local-generator/rc-local-generator.c | 2 +- units/rc-local.service.in | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/man/custom-entities.ent.in b/man/custom-entities.ent.in index b1f401bc900..3e39542bbc4 100644 --- a/man/custom-entities.ent.in +++ b/man/custom-entities.ent.in @@ -11,7 +11,7 @@ - + diff --git a/man/systemd-rc-local-generator.xml b/man/systemd-rc-local-generator.xml index 882c5d6e7d1..ff384d1b273 100644 --- a/man/systemd-rc-local-generator.xml +++ b/man/systemd-rc-local-generator.xml @@ -20,7 +20,7 @@ systemd-rc-local-generator rc-local.service - Compatibility generator and service to start &RC_LOCAL_PATH; during boot + Compatibility generator and service to start &SYSTEM_SYSVRCLOCAL_PATH; during boot @@ -32,7 +32,7 @@ Description systemd-rc-local-generator is a generator that checks whether - &RC_LOCAL_PATH; exists and is executable, and if it is, pulls the + &SYSTEM_SYSVRCLOCAL_PATH; exists and is executable, and if it is, pulls the rc-local.service unit into the boot process. This unit is responsible for running this script during late boot. The script is run after network.target, but in parallel with most other regular system services. @@ -53,7 +53,7 @@ Wants=network-online.target After=network-online.target - Support for &RC_LOCAL_PATH; is provided for compatibility with specific + Support for &SYSTEM_SYSVRCLOCAL_PATH; 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. @@ -66,7 +66,7 @@ After=network-online.target Notes On systems with SELinux, when creating the file, make sure to set the appropriate context, e.g. - with "sudo restorecon -v &RC_LOCAL_PATH;". + with "sudo restorecon -v &SYSTEM_SYSVRCLOCAL_PATH;". diff --git a/meson.build b/meson.build index 3357df3d319..f25ad1a27ef 100644 --- a/meson.build +++ b/meson.build @@ -262,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) @@ -303,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) @@ -2930,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, @@ -2946,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'), diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index 89cc5fadb6a..53ea23215ed 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -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"); diff --git a/units/rc-local.service.in b/units/rc-local.service.in index 6fb0838cdb4..b135f3894de 100644 --- a/units/rc-local.service.in +++ b/units/rc-local.service.in @@ -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