From a3b23257872fe2f8cf99aa2da008f55ada583bb3 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 8 Apr 2015 08:45:34 +0200 Subject: [PATCH] Remove SysV compat --- Makefile-man.am | 26 -------- Makefile.am | 64 ------------------- configure.ac | 31 ---------- src/core/load-fragment.c | 37 ----------- src/core/main.c | 12 ---- src/fsck/fsck.c | 23 ------- src/quotacheck/quotacheck.c | 14 ----- src/shared/build.h | 6 -- src/shared/path-lookup.c | 76 ----------------------- src/shared/path-lookup.h | 4 -- src/systemctl/systemctl.c | 120 ------------------------------------ 11 files changed, 413 deletions(-) diff --git a/Makefile-man.am b/Makefile-man.am index 2f3e5f227..9f9ba7715 100644 --- a/Makefile-man.am +++ b/Makefile-man.am @@ -1625,32 +1625,6 @@ MANPAGES_ALIAS += \ endif -if HAVE_SYSV_COMPAT -MANPAGES += \ - man/systemd-sysv-generator.8 -MANPAGES_ALIAS += \ - # - - -endif - -if HAVE_UTMP -MANPAGES += \ - man/runlevel.8 \ - man/systemd-update-utmp.service.8 -MANPAGES_ALIAS += \ - man/systemd-update-utmp-runlevel.service.8 \ - man/systemd-update-utmp.8 -man/systemd-update-utmp-runlevel.service.8: man/systemd-update-utmp.service.8 -man/systemd-update-utmp.8: man/systemd-update-utmp.service.8 -man/systemd-update-utmp-runlevel.service.html: man/systemd-update-utmp.service.html - $(html-alias) - -man/systemd-update-utmp.html: man/systemd-update-utmp.service.html - $(html-alias) - -endif - # Really, do not edit this file. EXTRA_DIST += \ diff --git a/Makefile.am b/Makefile.am index 11a8d3c33..135e7b35c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -605,16 +605,6 @@ EXTRA_DIST += \ units/systemd-nspawn@.service.in \ units/systemd-update-done.service.in -if HAVE_SYSV_COMPAT -nodist_systemunit_DATA += \ - units/rc-local.service \ - units/halt-local.service - -systemgenerator_PROGRAMS += \ - systemd-sysv-generator \ - systemd-rc-local-generator -endif - EXTRA_DIST += \ units/rc-local.service.in \ units/halt-local.service.in @@ -2187,11 +2177,6 @@ dist_tmpfiles_DATA = \ tmpfiles.d/x11.conf \ tmpfiles.d/var.conf -if HAVE_SYSV_COMPAT -dist_tmpfiles_DATA += \ - tmpfiles.d/legacy.conf -endif - SYSINIT_TARGET_WANTS += \ systemd-tmpfiles-setup-dev.service \ systemd-tmpfiles-setup.service @@ -3865,11 +3850,6 @@ TESTS += \ test/rule-syntax-check.py \ $(NULL) -if HAVE_SYSV_COMPAT -TESTS += \ - test/sysv-generator-test.py \ - $(NULL) -endif endif manual_tests += \ @@ -6527,24 +6507,6 @@ EXTRA_DIST += \ man/custom-man.xsl # ------------------------------------------------------------------------------ -if HAVE_SYSV_COMPAT -sysvinit_DATA = \ - docs/sysvinit/README - -varlog_DATA = \ - docs/var-log/README - -docs/sysvinit/README: docs/sysvinit/README.in - $(SED_PROCESS) - -docs/var-log/README: docs/var-log/README.in - $(SED_PROCESS) - -CLEANFILES += \ - docs/sysvinit/README \ - docs/var-log/README -endif - EXTRA_DIST += \ docs/sysvinit/README.in \ docs/var-log/README.in @@ -6574,17 +6536,6 @@ SYSINIT_TARGET_WANTS += \ systemd-sysctl.service \ systemd-ask-password-console.path -if HAVE_SYSV_COMPAT -SYSTEM_UNIT_ALIASES += \ - poweroff.target runlevel0.target \ - rescue.target runlevel1.target \ - multi-user.target runlevel2.target \ - multi-user.target runlevel3.target \ - multi-user.target runlevel4.target \ - graphical.target runlevel5.target \ - reboot.target runlevel6.target -endif - SYSTEM_UNIT_ALIASES += \ graphical.target default.target \ reboot.target ctrl-alt-del.target \ @@ -6611,15 +6562,6 @@ GENERAL_ALIASES += \ $(pkgsysconfdir)/user $(sysconfdir)/xdg/systemd/user \ $(dbussystemservicedir)/org.freedesktop.systemd1.service $(dbussessionservicedir)/org.freedesktop.systemd1.service -if HAVE_SYSV_COMPAT -INSTALL_DIRS += \ - $(systemunitdir)/runlevel1.target.wants \ - $(systemunitdir)/runlevel2.target.wants \ - $(systemunitdir)/runlevel3.target.wants \ - $(systemunitdir)/runlevel4.target.wants \ - $(systemunitdir)/runlevel5.target.wants -endif - INSTALL_DIRS += \ $(prefix)/lib/modules-load.d \ $(sysconfdir)/modules-load.d \ @@ -6668,15 +6610,9 @@ DISTCHECK_CONFIGURE_FLAGS = \ --enable-kdbus \ --enable-compat-libs -if HAVE_SYSV_COMPAT -DISTCHECK_CONFIGURE_FLAGS += \ - --with-sysvinit-path=$$dc_install_base/$(sysvinitdir) \ - --with-sysvrcnd-path=$$dc_install_base/$(sysvrcnddir) -else DISTCHECK_CONFIGURE_FLAGS += \ --with-sysvinit-path= \ --with-sysvrcnd-path= -endif if HAVE_PYTHON DISTCHECK_CONFIGURE_FLAGS += \ diff --git a/configure.ac b/configure.ac index 204b3e00c..8144bdb34 100644 --- a/configure.ac +++ b/configure.ac @@ -1325,39 +1325,8 @@ AC_ARG_ENABLE(ldconfig, enable_ldconfig=$enableval, enable_ldconfig=yes) AM_CONDITIONAL(ENABLE_LDCONFIG, [test x$enable_ldconfig = xyes]) -# ------------------------------------------------------------------------------ -# Location of the init scripts as mandated by LSB -SYSTEM_SYSVINIT_PATH=/etc/init.d -SYSTEM_SYSVRCND_PATH=/etc/rc.d - -AC_ARG_WITH([sysvinit-path], - [AS_HELP_STRING([--with-sysvinit-path=PATH], - [Specify the path to where the SysV init scripts are located])], - [SYSTEM_SYSVINIT_PATH="$withval"], - []) - -AC_ARG_WITH([sysvrcnd-path], - [AS_HELP_STRING([--with-sysvrcnd-path=PATH], - [Specify the path to the base directory for the SysV rcN.d directories])], - [SYSTEM_SYSVRCND_PATH="$withval"], - []) - -if test "x${SYSTEM_SYSVINIT_PATH}" != "x" -a "x${SYSTEM_SYSVRCND_PATH}" != "x"; then - AC_DEFINE(HAVE_SYSV_COMPAT, [], [SysV init scripts and rcN.d links are supported.]) - SYSTEM_SYSV_COMPAT="yes" - M4_DEFINES="$M4_DEFINES -DHAVE_SYSV_COMPAT" -elif test "x${SYSTEM_SYSVINIT_PATH}" != "x" -o "x${SYSTEM_SYSVRCND_PATH}" != "x"; then - AC_MSG_ERROR([*** You need both --with-sysvinit-path=PATH and --with-sysvrcnd-path=PATH to enable SysV compatibility support, or both empty to disable it.]) -else - SYSTEM_SYSV_COMPAT="no" -fi - -AC_SUBST(SYSTEM_SYSVINIT_PATH) -AC_SUBST(SYSTEM_SYSVRCND_PATH) AC_SUBST(M4_DEFINES) -AM_CONDITIONAL(HAVE_SYSV_COMPAT, test "$SYSTEM_SYSV_COMPAT" = "yes") - AC_ARG_WITH([tty-gid], [AS_HELP_STRING([--with-tty-gid=GID], [Specify the numeric GID of the 'tty' group])], diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 07384d366..1553f8cda 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -1107,38 +1107,6 @@ int config_parse_limit(const char *unit, return 0; } -#ifdef HAVE_SYSV_COMPAT -int config_parse_sysv_priority(const char *unit, - const char *filename, - unsigned line, - const char *section, - unsigned section_line, - const char *lvalue, - int ltype, - const char *rvalue, - void *data, - void *userdata) { - - int *priority = data; - int i, r; - - assert(filename); - assert(lvalue); - assert(rvalue); - assert(data); - - r = safe_atoi(rvalue, &i); - if (r < 0 || i < 0) { - log_syntax(unit, LOG_ERR, filename, line, -r, - "Failed to parse SysV start priority, ignoring: %s", rvalue); - return 0; - } - - *priority = (int) i; - return 0; -} -#endif - DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode"); int config_parse_kill_signal(const char *unit, @@ -3684,9 +3652,7 @@ void unit_dump_config_items(FILE *f) { const ConfigParserCallback callback; const char *rvalue; } table[] = { -#if !defined(HAVE_SYSV_COMPAT) || !defined(HAVE_SECCOMP) || !defined(HAVE_PAM) || !defined(HAVE_SELINUX) || !defined(HAVE_SMACK) || !defined(HAVE_APPARMOR) { config_parse_warn_compat, "NOTSUPPORTED" }, -#endif { config_parse_int, "INTEGER" }, { config_parse_unsigned, "UNSIGNED" }, { config_parse_iec_size, "SIZE" }, @@ -3718,9 +3684,6 @@ void unit_dump_config_items(FILE *f) { { config_parse_exec, "PATH [ARGUMENT [...]]" }, { config_parse_service_type, "SERVICETYPE" }, { config_parse_service_restart, "SERVICERESTART" }, -#ifdef HAVE_SYSV_COMPAT - { config_parse_sysv_priority, "SYSVPRIORITY" }, -#endif { config_parse_kill_mode, "KILLMODE" }, { config_parse_kill_signal, "SIGNAL" }, { config_parse_socket_listen, "SOCKET [...]" }, diff --git a/src/core/main.c b/src/core/main.c index dd8b65083..4fe0b7380 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1226,18 +1226,6 @@ int main(int argc, char *argv[]) { struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0); const char *error_message = NULL; -#ifdef HAVE_SYSV_COMPAT - if (getpid() != 1 && strstr(program_invocation_short_name, "init")) { - /* This is compatibility support for SysV, where - * calling init as a user is identical to telinit. */ - - errno = -ENOENT; - execv(SYSTEMCTL_BINARY_PATH, argv); - log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m"); - return 1; - } -#endif - dual_timestamp_from_monotonic(&kernel_timestamp, 0); dual_timestamp_get(&userspace_timestamp); diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 7eaf902e7..d0316b3af 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -100,34 +100,11 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { log_warning("Invalid fsck.repair= parameter '%s'. Ignoring.", value); } -#ifdef HAVE_SYSV_COMPAT - else if (streq(key, "fastboot") && !value) { - log_warning("Please pass 'fsck.mode=skip' rather than 'fastboot' on the kernel command line."); - arg_skip = true; - - } else if (streq(key, "forcefsck") && !value) { - log_warning("Please pass 'fsck.mode=force' rather than 'forcefsck' on the kernel command line."); - arg_force = true; - } -#endif - return 0; } static void test_files(void) { -#ifdef HAVE_SYSV_COMPAT - if (access("/fastboot", F_OK) >= 0) { - log_error("Please pass 'fsck.mode=skip' on the kernel command line rather than creating /fastboot on the root file system."); - arg_skip = true; - } - - if (access("/forcefsck", F_OK) >= 0) { - log_error("Please pass 'fsck.mode=force' on the kernel command line rather than creating /forcefsck on the root file system."); - arg_force = true; - } -#endif - } static int process_progress(int fd, pid_t fsck_pid, dev_t device_num) { diff --git a/src/quotacheck/quotacheck.c b/src/quotacheck/quotacheck.c index 819706a72..a7e47dd32 100644 --- a/src/quotacheck/quotacheck.c +++ b/src/quotacheck/quotacheck.c @@ -43,24 +43,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { log_warning("Invalid quotacheck.mode= parameter '%s'. Ignoring.", value); } -#ifdef HAVE_SYSV_COMPAT - else if (streq(key, "forcequotacheck") && !value) { - log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line."); - arg_force = true; - } -#endif - return 0; } static void test_files(void) { - -#ifdef HAVE_SYSV_COMPAT - if (access("/forcequotacheck", F_OK) >= 0) { - log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system."); - arg_force = true; - } -#endif } int main(int argc, char *argv[]) { diff --git a/src/shared/build.h b/src/shared/build.h index 8b82ede29..b0a5a7246 100644 --- a/src/shared/build.h +++ b/src/shared/build.h @@ -57,12 +57,6 @@ #define _SMACK_FEATURE_ "-SMACK" #endif -#ifdef HAVE_SYSV_COMPAT -#define _SYSVINIT_FEATURE_ "+SYSVINIT" -#else -#define _SYSVINIT_FEATURE_ "-SYSVINIT" -#endif - #ifdef HAVE_LIBCRYPTSETUP #define _LIBCRYPTSETUP_FEATURE_ "+LIBCRYPTSETUP" #else diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index fb2c2c233..83abf53fa 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -338,77 +338,7 @@ int lookup_paths_init( } if (running_as == SYSTEMD_SYSTEM) { -#ifdef HAVE_SYSV_COMPAT - /* /etc/init.d/ compatibility does not matter to users */ - - e = getenv("SYSTEMD_SYSVINIT_PATH"); - if (e) { - p->sysvinit_path = path_split_and_make_absolute(e); - if (!p->sysvinit_path) - return -ENOMEM; - } else - p->sysvinit_path = NULL; - - if (strv_isempty(p->sysvinit_path)) { - strv_free(p->sysvinit_path); - - p->sysvinit_path = strv_new( - SYSTEM_SYSVINIT_PATH, /* /etc/init.d/ */ - NULL); - if (!p->sysvinit_path) - return -ENOMEM; - } - - e = getenv("SYSTEMD_SYSVRCND_PATH"); - if (e) { - p->sysvrcnd_path = path_split_and_make_absolute(e); - if (!p->sysvrcnd_path) - return -ENOMEM; - } else - p->sysvrcnd_path = NULL; - - if (strv_isempty(p->sysvrcnd_path)) { - strv_free(p->sysvrcnd_path); - - p->sysvrcnd_path = strv_new( - SYSTEM_SYSVRCND_PATH, /* /etc/rcN.d/ */ - NULL); - if (!p->sysvrcnd_path) - return -ENOMEM; - } - - if (!path_strv_resolve_uniq(p->sysvinit_path, root_dir)) - return -ENOMEM; - - if (!path_strv_resolve_uniq(p->sysvrcnd_path, root_dir)) - return -ENOMEM; - - if (!strv_isempty(p->sysvinit_path)) { - _cleanup_free_ char *t = strv_join(p->sysvinit_path, "\n\t"); - if (!t) - return -ENOMEM; - log_debug("Looking for SysV init scripts in:\n\t%s", t); - } else { - log_debug("Ignoring SysV init scripts."); - strv_free(p->sysvinit_path); - p->sysvinit_path = NULL; - } - - if (!strv_isempty(p->sysvrcnd_path)) { - _cleanup_free_ char *t = - strv_join(p->sysvrcnd_path, "\n\t"); - if (!t) - return -ENOMEM; - - log_debug("Looking for SysV rcN.d links in:\n\t%s", t); - } else { - log_debug("Ignoring SysV rcN.d links."); - strv_free(p->sysvrcnd_path); - p->sysvrcnd_path = NULL; - } -#else log_debug("SysV init scripts and rcN.d links support disabled"); -#endif } return 0; @@ -419,12 +349,6 @@ void lookup_paths_free(LookupPaths *p) { strv_free(p->unit_path); p->unit_path = NULL; - -#ifdef HAVE_SYSV_COMPAT - strv_free(p->sysvinit_path); - strv_free(p->sysvrcnd_path); - p->sysvinit_path = p->sysvrcnd_path = NULL; -#endif } int lookup_paths_init_from_scope(LookupPaths *paths, diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h index f1925eef6..2e0d3f7bd 100644 --- a/src/shared/path-lookup.h +++ b/src/shared/path-lookup.h @@ -27,10 +27,6 @@ typedef enum UnitFileScope UnitFileScope; typedef struct LookupPaths { char **unit_path; -#ifdef HAVE_SYSV_COMPAT - char **sysvinit_path; - char **sysvrcnd_path; -#endif } LookupPaths; typedef enum SystemdRunningAs { diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 3158a3800..30dffecd3 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -5038,126 +5038,6 @@ static int import_environment(sd_bus *bus, char **args) { static int enable_sysv_units(const char *verb, char **args) { int r = 0; -#if defined(HAVE_SYSV_COMPAT) && defined(HAVE_CHKCONFIG) - unsigned f = 0; - _cleanup_lookup_paths_free_ LookupPaths paths = {}; - - if (arg_scope != UNIT_FILE_SYSTEM) - return 0; - - if (!streq(verb, "enable") && - !streq(verb, "disable") && - !streq(verb, "is-enabled")) - return 0; - - /* Processes all SysV units, and reshuffles the array so that - * afterwards only the native units remain */ - - r = lookup_paths_init(&paths, SYSTEMD_SYSTEM, false, arg_root, NULL, NULL, NULL); - if (r < 0) - return r; - - r = 0; - while (args[f]) { - const char *name; - _cleanup_free_ char *p = NULL, *q = NULL, *l = NULL; - bool found_native = false, found_sysv; - unsigned c = 1; - const char *argv[6] = { "/sbin/chkconfig", NULL, NULL, NULL, NULL }; - char **k; - int j; - pid_t pid; - siginfo_t status; - - name = args[f++]; - - if (!endswith(name, ".service")) - continue; - - if (path_is_absolute(name)) - continue; - - STRV_FOREACH(k, paths.unit_path) { - _cleanup_free_ char *path = NULL; - - path = path_join(arg_root, *k, name); - if (!path) - return log_oom(); - - found_native = access(path, F_OK) >= 0; - if (found_native) - break; - } - - if (found_native) - continue; - - p = path_join(arg_root, SYSTEM_SYSVINIT_PATH, name); - if (!p) - return log_oom(); - - p[strlen(p) - strlen(".service")] = 0; - found_sysv = access(p, F_OK) >= 0; - if (!found_sysv) - continue; - - log_info("%s is not a native service, redirecting to /sbin/chkconfig.", name); - - if (!isempty(arg_root)) - argv[c++] = q = strappend("--root=", arg_root); - - argv[c++] = basename(p); - argv[c++] = - streq(verb, "enable") ? "on" : - streq(verb, "disable") ? "off" : "--level=5"; - argv[c] = NULL; - - l = strv_join((char**)argv, " "); - if (!l) - return log_oom(); - - log_info("Executing %s", l); - - pid = fork(); - if (pid < 0) - return log_error_errno(errno, "Failed to fork: %m"); - else if (pid == 0) { - /* Child */ - - execv(argv[0], (char**) argv); - _exit(EXIT_FAILURE); - } - - j = wait_for_terminate(pid, &status); - if (j < 0) { - log_error_errno(r, "Failed to wait for child: %m"); - return j; - } - - if (status.si_code == CLD_EXITED) { - if (streq(verb, "is-enabled")) { - if (status.si_status == 0) { - if (!arg_quiet) - puts("enabled"); - r = 1; - } else { - if (!arg_quiet) - puts("disabled"); - } - - } else if (status.si_status != 0) - return -EINVAL; - } else - return -EPROTO; - - /* Remove this entry, so that we don't try enabling it as native unit */ - assert(f > 0); - f--; - assert(args[f] == name); - strv_remove(args, name); - } - -#endif return r; } -- 2.30.2