summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFabiano Fidencio <fidencio@profusion.mobi>2010-09-21 00:23:12 -0300
committerLennart Poettering <lennart@poettering.net>2010-09-27 03:25:05 +0200
commit07459bb6b92268beb2599f65cf195708d88c51cc (patch)
treef533168f2e656f3de37a53293b60b1a27b8580be /src
parent66d9b3b59551a33398b2201662af5c8c17a367c9 (diff)
sysv: optionally disable of SysV init/rcN.d support at compile time
This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to isolate code dealing with /etc/init.d and /etc/rcN.d for systems where it does not make sense (one that does not use sysv or one that is fully systemd native). The patch tries to be as little intrusive as possible, however in order to minimize the number of #ifdef'ed regions I've reordered some code in path-lookup.c:lookup_paths_init() where all code dealing with sysv is now isolated under running_as == MANAGER_SYSTEM as well. Moreover, In struct Service, some fields were rearranged to reduce the number of ifdefs. Lennart's suggestions were fixed and squashed with the original patch, that was sent by Gustavo Sverzut Barbieri (barbieri@profusion.mobi).
Diffstat (limited to 'src')
-rw-r--r--src/build.h8
-rw-r--r--src/dbus-manager.c49
-rw-r--r--src/dbus-service.c31
-rw-r--r--src/load-fragment.c25
-rw-r--r--src/main.c22
-rw-r--r--src/manager.h2
-rw-r--r--src/path-lookup.c102
-rw-r--r--src/path-lookup.h2
-rw-r--r--src/service.c22
-rw-r--r--src/service.h5
-rw-r--r--src/systemctl.c15
11 files changed, 218 insertions, 65 deletions
diff --git a/src/build.h b/src/build.h
index 5cb69bede4..04ac639c56 100644
--- a/src/build.h
+++ b/src/build.h
@@ -46,6 +46,12 @@
#define _SELINUX_FEATURE_ "-SELINUX"
#endif
-#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " _AUDIT_FEATURE_ " " _SELINUX_FEATURE_
+#ifdef HAVE_SYSV_COMPAT
+#define _SYSVINIT_FEATURE_ "+SYSVINIT"
+#else
+#define _SYSVINIT_FEATURE_ "-SYSVINIT"
+#endif
+
+#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " _AUDIT_FEATURE_ " " _SELINUX_FEATURE_ " " _SYSVINIT_FEATURE_
#endif
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index efff06a18e..3754a0ca8b 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -27,14 +27,16 @@
#include "strv.h"
#include "bus-errors.h"
-#define BUS_MANAGER_INTERFACE \
- " <interface name=\"org.freedesktop.systemd1.Manager\">\n" \
+#define BUS_MANAGER_INTERFACE_BEGIN \
+ " <interface name=\"org.freedesktop.systemd1.Manager\">\n"
+
+#define BUS_MANAGER_INTERFACE_METHODS \
" <method name=\"GetUnit\">\n" \
" <arg name=\"name\" type=\"s\" direction=\"in\"/>\n" \
" <arg name=\"unit\" type=\"o\" direction=\"out\"/>\n" \
" </method>\n" \
" <method name=\"GetUnitByPID\">\n" \
- " <arg name=\"pid\" type=\"u\" direction=\"in\"/>\n" \
+ " <arg name=\"pid\" type=\"u\" direction=\"in\"/>\n" \
" <arg name=\"unit\" type=\"o\" direction=\"out\"/>\n" \
" </method>\n" \
" <method name=\"LoadUnit\">\n" \
@@ -107,7 +109,9 @@
" </method>\n" \
" <method name=\"UnsetEnvironment\">\n" \
" <arg name=\"names\" type=\"as\" direction=\"in\"/>\n" \
- " </method>\n" \
+ " </method>\n"
+
+#define BUS_MANAGER_INTERFACE_SIGNALS \
" <signal name=\"UnitNew\">\n" \
" <arg name=\"id\" type=\"s\"/>\n" \
" <arg name=\"unit\" type=\"o\"/>\n" \
@@ -124,7 +128,10 @@
" <arg name=\"id\" type=\"u\"/>\n" \
" <arg name=\"job\" type=\"o\"/>\n" \
" <arg name=\"success\" type=\"b\"/>\n" \
- " </signal>" \
+ " </signal>"
+
+
+#define BUS_MANAGER_INTERFACE_PROPERTIES_GENERAL \
" <property name=\"Version\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"RunningAs\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"StartupTimestamp\" type=\"t\" access=\"read\"/>\n" \
@@ -138,16 +145,32 @@
" <property name=\"Environment\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"ConfirmSpawn\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"ShowStatus\" type=\"b\" access=\"read\"/>\n" \
- " <property name=\"SysVConsole\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"UnitPath\" type=\"as\" access=\"read\"/>\n" \
- " <property name=\"SysVInitPath\" type=\"as\" access=\"read\"/>\n" \
- " <property name=\"SysVRcndPath\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"NotifySocket\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"ControlGroupHierarchy\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"MountAuto\" type=\"b\" access=\"read\"/>\n" \
- " <property name=\"SwapAuto\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"SwapAuto\" type=\"b\" access=\"read\"/>\n"
+
+#ifdef HAVE_SYSV_COMPAT
+#define BUS_MANAGER_INTERFACE_PROPERTIES_SYSV \
+ " <property name=\"SysVConsole\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"SysVInitPath\" type=\"as\" access=\"read\"/>\n" \
+ " <property name=\"SysVRcndPath\" type=\"as\" access=\"read\"/>\n"
+#else
+#define BUS_MANAGER_INTERFACE_PROPERTIES_SYSV
+#endif
+
+#define BUS_MANAGER_INTERFACE_END \
" </interface>\n"
+#define BUS_MANAGER_INTERFACE \
+ BUS_MANAGER_INTERFACE_BEGIN \
+ BUS_MANAGER_INTERFACE_METHODS \
+ BUS_MANAGER_INTERFACE_SIGNALS \
+ BUS_MANAGER_INTERFACE_PROPERTIES_GENERAL \
+ BUS_MANAGER_INTERFACE_PROPERTIES_SYSV \
+ BUS_MANAGER_INTERFACE_END
+
#define INTROSPECTION_BEGIN \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
"<node>\n" \
@@ -273,14 +296,16 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "org.freedesktop.systemd1.Manager", "Environment", bus_property_append_strv, "as", m->environment },
{ "org.freedesktop.systemd1.Manager", "ConfirmSpawn", bus_property_append_bool, "b", &m->confirm_spawn },
{ "org.freedesktop.systemd1.Manager", "ShowStatus", bus_property_append_bool, "b", &m->show_status },
- { "org.freedesktop.systemd1.Manager", "SysVConsole", bus_property_append_bool, "b", &m->sysv_console },
{ "org.freedesktop.systemd1.Manager", "UnitPath", bus_property_append_strv, "as", m->lookup_paths.unit_path },
- { "org.freedesktop.systemd1.Manager", "SysVInitPath", bus_property_append_strv, "as", m->lookup_paths.sysvinit_path },
- { "org.freedesktop.systemd1.Manager", "SysVRcndPath", bus_property_append_strv, "as", m->lookup_paths.sysvrcnd_path },
{ "org.freedesktop.systemd1.Manager", "NotifySocket", bus_property_append_string, "s", m->notify_socket },
{ "org.freedesktop.systemd1.Manager", "ControlGroupHierarchy", bus_property_append_string, "s", m->cgroup_hierarchy },
{ "org.freedesktop.systemd1.Manager", "MountAuto", bus_property_append_bool, "b", &m->mount_auto },
{ "org.freedesktop.systemd1.Manager", "SwapAuto", bus_property_append_bool, "b", &m->swap_auto },
+#ifdef HAVE_SYSV_COMPAT
+ { "org.freedesktop.systemd1.Manager", "SysVConsole", bus_property_append_bool, "b", &m->sysv_console },
+ { "org.freedesktop.systemd1.Manager", "SysVInitPath", bus_property_append_strv, "as", m->lookup_paths.sysvinit_path },
+ { "org.freedesktop.systemd1.Manager", "SysVRcndPath", bus_property_append_strv, "as", m->lookup_paths.sysvrcnd_path },
+#endif
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-service.c b/src/dbus-service.c
index 86c18dddcf..ad3264c8c3 100644
--- a/src/dbus-service.c
+++ b/src/dbus-service.c
@@ -25,6 +25,7 @@
#include "dbus-execute.h"
#include "dbus-service.h"
+#ifdef HAVE_SYSV_COMPAT
#define BUS_SERVICE_INTERFACE \
" <interface name=\"org.freedesktop.systemd1.Service\">\n" \
" <property name=\"Type\" type=\"s\" access=\"read\"/>\n" \
@@ -52,6 +53,32 @@
" <property name=\"BusName\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"StatusText\" type=\"s\" access=\"read\"/>\n" \
" </interface>\n"
+#else
+#define BUS_SERVICE_INTERFACE \
+ " <interface name=\"org.freedesktop.systemd1.Service\">\n" \
+ " <property name=\"Type\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"Restart\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"PIDFile\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"NotifyAccess\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"RestartUSec\" type=\"t\" access=\"read\"/>\n" \
+ " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
+ BUS_EXEC_COMMAND_INTERFACE("ExecStartPre") \
+ BUS_EXEC_COMMAND_INTERFACE("ExecStart") \
+ BUS_EXEC_COMMAND_INTERFACE("ExecStartPost") \
+ BUS_EXEC_COMMAND_INTERFACE("ExecReload") \
+ BUS_EXEC_COMMAND_INTERFACE("ExecStop") \
+ BUS_EXEC_COMMAND_INTERFACE("ExecStopPost") \
+ BUS_EXEC_CONTEXT_INTERFACE \
+ " <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"RemainAfterExit\" type=\"b\" access=\"read\"/>\n" \
+ BUS_EXEC_STATUS_INTERFACE("ExecMain") \
+ " <property name=\"MainPID\" type=\"u\" access=\"read\"/>\n" \
+ " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
+ " <property name=\"BusName\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"StatusText\" type=\"s\" access=\"read\"/>\n" \
+ " </interface>\n"
+#endif
#define INTROSPECTION \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
@@ -104,11 +131,15 @@ DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connectio
BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", u->service.main_exec_status, "ExecMain"),
{ "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid, "u", &u->service.main_pid },
{ "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid, "u", &u->service.control_pid },
+#ifdef HAVE_SYSV_COMPAT
{ "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", u->service.sysv_path },
+#endif
{ "org.freedesktop.systemd1.Service", "BusName", bus_property_append_string, "s", u->service.bus_name },
{ "org.freedesktop.systemd1.Service", "StatusText", bus_property_append_string, "s", u->service.status_text },
+#ifdef HAVE_SYSV_COMPAT
{ "org.freedesktop.systemd1.Service", "SysVRunLevels", bus_property_append_string, "s", u->service.sysv_runlevels },
{ "org.freedesktop.systemd1.Service", "SysVStartPriority", bus_property_append_int, "i", &u->service.sysv_start_priority },
+#endif
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 1190ef4acc..74114c43b8 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -42,6 +42,21 @@
#include "unit-name.h"
#include "bus-errors.h"
+#ifndef HAVE_SYSV_COMPAT
+static int config_parse_warn_compat(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ log_debug("[%s:%u] Support for option %s= has been disabled at compile time and is ignored", filename, line, lvalue);
+ return 0;
+}
+#endif
+
static int config_parse_deps(
const char *filename,
unsigned line,
@@ -959,6 +974,7 @@ static int config_parse_cgroup(
return 0;
}
+#ifdef HAVE_SYSV_COMPAT
static int config_parse_sysv_priority(
const char *filename,
unsigned line,
@@ -984,6 +1000,7 @@ static int config_parse_sysv_priority(
*priority = (int) i;
return 0;
}
+#endif
static DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode");
@@ -1446,7 +1463,11 @@ static void dump_items(FILE *f, const ConfigItem *items) {
{ config_parse_exec, "PATH [ARGUMENT [...]]" },
{ config_parse_service_type, "SERVICETYPE" },
{ config_parse_service_restart, "SERVICERESTART" },
+#ifdef HAVE_SYSV_COMPAT
{ config_parse_sysv_priority, "SYSVPRIORITY" },
+#else
+ { config_parse_warn_compat, "NOTSUPPORTED" },
+#endif
{ config_parse_kill_mode, "KILLMODE" },
{ config_parse_kill_signal, "SIGNAL" },
{ config_parse_listen, "SOCKET [...]" },
@@ -1597,7 +1618,11 @@ static int load_from_path(Unit *u, const char *path) {
{ "PermissionsStartOnly", config_parse_bool, &u->service.permissions_start_only, "Service" },
{ "RootDirectoryStartOnly", config_parse_bool, &u->service.root_directory_start_only, "Service" },
{ "RemainAfterExit", config_parse_bool, &u->service.remain_after_exit, "Service" },
+#ifdef HAVE_SYSV_COMPAT
{ "SysVStartPriority", config_parse_sysv_priority, &u->service.sysv_start_priority, "Service" },
+#else
+ { "SysVStartPriority", config_parse_warn_compat, NULL, "Service" },
+#endif
{ "NonBlocking", config_parse_bool, &u->service.exec_context.non_blocking, "Service" },
{ "BusName", config_parse_string_printf, &u->service.bus_name, "Service" },
{ "NotifyAccess", config_parse_notify_access, &u->service.notify_access, "Service" },
diff --git a/src/main.c b/src/main.c
index fcb6e8f9db..ee12e1f3af 100644
--- a/src/main.c
+++ b/src/main.c
@@ -64,7 +64,9 @@ static bool arg_crash_shell = false;
static int arg_crash_chvt = -1;
static bool arg_confirm_spawn = false;
static bool arg_show_status = true;
+#ifdef HAVE_SYSV_COMPAT
static bool arg_sysv_console = true;
+#endif
static bool arg_mount_auto = true;
static bool arg_swap_auto = true;
static char *arg_console = NULL;
@@ -312,7 +314,7 @@ static int parse_proc_cmdline_word(const char *word) {
log_warning("Failed to parse show status switch %s, Ignoring.", word + 20);
else
arg_show_status = r;
-
+#ifdef HAVE_SYSV_COMPAT
} else if (startswith(word, "systemd.sysv_console=")) {
int r;
@@ -320,6 +322,7 @@ static int parse_proc_cmdline_word(const char *word) {
log_warning("Failed to parse SysV console switch %s, Ignoring.", word + 20);
else
arg_sysv_console = r;
+#endif
} else if (startswith(word, "systemd.")) {
@@ -332,7 +335,9 @@ static int parse_proc_cmdline_word(const char *word) {
"systemd.crash_chvt=N Change to VT #N on crash\n"
"systemd.confirm_spawn=0|1 Confirm every process spawn\n"
"systemd.show_status=0|1 Show status updates on the console during bootup\n"
+#ifdef HAVE_SYSV_COMPAT
"systemd.sysv_console=0|1 Connect output of SysV scripts to console\n"
+#endif
"systemd.log_target=console|kmsg|syslog|syslog-org-kmsg|null\n"
" Log target\n"
"systemd.log_level=LEVEL Log level\n"
@@ -361,7 +366,9 @@ static int parse_proc_cmdline_word(const char *word) {
} else if (streq(word, "quiet")) {
arg_show_status = false;
+#ifdef HAVE_SYSV_COMPAT
arg_sysv_console = false;
+#endif
} else {
unsigned i;
@@ -505,7 +512,9 @@ static int parse_config_file(void) {
{ "DumpCore", config_parse_bool, &arg_dump_core, "Manager" },
{ "CrashShell", config_parse_bool, &arg_crash_shell, "Manager" },
{ "ShowStatus", config_parse_bool, &arg_show_status, "Manager" },
+#ifdef HAVE_SYSV_COMPAT
{ "SysVConsole", config_parse_bool, &arg_sysv_console, "Manager" },
+#endif
{ "CrashChVT", config_parse_int, &arg_crash_chvt, "Manager" },
{ "CPUAffinity", config_parse_cpu_affinity, NULL, "Manager" },
{ "MountAuto", config_parse_bool, &arg_mount_auto, "Manager" },
@@ -610,7 +619,9 @@ static int parse_argv(int argc, char *argv[]) {
{ "crash-shell", no_argument, NULL, ARG_CRASH_SHELL },
{ "confirm-spawn", no_argument, NULL, ARG_CONFIRM_SPAWN },
{ "show-status", optional_argument, NULL, ARG_SHOW_STATUS },
+#ifdef HAVE_SYSV_COMPAT
{ "sysv-console", optional_argument, NULL, ARG_SYSV_CONSOLE },
+#endif
{ "deserialize", required_argument, NULL, ARG_DESERIALIZE },
{ "introspect", optional_argument, NULL, ARG_INTROSPECT },
{ NULL, 0, NULL, 0 }
@@ -714,7 +725,7 @@ static int parse_argv(int argc, char *argv[]) {
} else
arg_show_status = true;
break;
-
+#ifdef HAVE_SYSV_COMPAT
case ARG_SYSV_CONSOLE:
if (optarg) {
@@ -726,6 +737,7 @@ static int parse_argv(int argc, char *argv[]) {
} else
arg_sysv_console = true;
break;
+#endif
case ARG_DESERIALIZE: {
int fd;
@@ -813,7 +825,9 @@ static int help(void) {
" --crash-shell Run shell on crash\n"
" --confirm-spawn Ask for confirmation when spawning processes\n"
" --show-status[=0|1] Show status updates on the console during bootup\n"
+#ifdef HAVE_SYSV_COMPAT
" --sysv-console[=0|1] Connect output of SysV scripts to console\n"
+#endif
" --log-target=TARGET Set log target (console, syslog, kmsg, syslog-or-kmsg, null)\n"
" --log-level=LEVEL Set log level (debug, info, notice, warning, err, crit, alert, emerg)\n"
" --log-color[=0|1] Highlight important log messages\n"
@@ -1017,7 +1031,9 @@ int main(int argc, char *argv[]) {
m->confirm_spawn = arg_confirm_spawn;
m->show_status = arg_show_status;
+#ifdef HAVE_SYSV_COMPAT
m->sysv_console = arg_sysv_console;
+#endif
m->mount_auto = arg_mount_auto;
m->swap_auto = arg_swap_auto;
@@ -1162,10 +1178,12 @@ finish:
else
args[i++] = "--show-status=0";
+#ifdef HAVE_SYSV_COMPAT
if (arg_sysv_console)
args[i++] = "--sysv-console=1";
else
args[i++] = "--sysv-console=0";
+#endif
snprintf(sfd, sizeof(sfd), "%i", fileno(serialization));
char_array_0(sfd);
diff --git a/src/manager.h b/src/manager.h
index df87ed6b62..10ff24c798 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -203,7 +203,9 @@ struct Manager {
bool show_status;
bool confirm_spawn;
+#ifdef HAVE_SYSV_COMPAT
bool sysv_console;
+#endif
bool mount_auto;
bool swap_auto;
diff --git a/src/path-lookup.c b/src/path-lookup.c
index 28336ebf15..258252a564 100644
--- a/src/path-lookup.c
+++ b/src/path-lookup.c
@@ -191,7 +191,26 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
return -ENOMEM;
}
+ if (p->unit_path)
+ if (!strv_path_canonicalize(p->unit_path))
+ return -ENOMEM;
+
+ strv_uniq(p->unit_path);
+
+ if (!strv_isempty(p->unit_path)) {
+
+ if (!(t = strv_join(p->unit_path, "\n\t")))
+ return -ENOMEM;
+ log_debug("Looking for unit files in:\n\t%s", t);
+ free(t);
+ } else {
+ log_debug("Ignoring unit files.");
+ strv_free(p->unit_path);
+ p->unit_path = NULL;
+ }
+
if (running_as == MANAGER_SYSTEM) {
+#ifdef HAVE_SYSV_COMPAT
/* /etc/init.d/ compatibility does not matter to users */
if ((e = getenv("SYSTEMD_SYSVINIT_PATH")))
@@ -219,60 +238,46 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
NULL)))
return -ENOMEM;
}
- }
-
- if (p->unit_path)
- if (!strv_path_canonicalize(p->unit_path))
- return -ENOMEM;
-
- if (p->sysvinit_path)
- if (!strv_path_canonicalize(p->sysvinit_path))
- return -ENOMEM;
- if (p->sysvrcnd_path)
- if (!strv_path_canonicalize(p->sysvrcnd_path))
- return -ENOMEM;
-
- strv_uniq(p->unit_path);
- strv_uniq(p->sysvinit_path);
- strv_uniq(p->sysvrcnd_path);
+ if (p->sysvinit_path)
+ if (!strv_path_canonicalize(p->sysvinit_path))
+ return -ENOMEM;
- if (!strv_isempty(p->unit_path)) {
+ if (p->sysvrcnd_path)
+ if (!strv_path_canonicalize(p->sysvrcnd_path))
+ return -ENOMEM;
- if (!(t = strv_join(p->unit_path, "\n\t")))
- return -ENOMEM;
- log_debug("Looking for unit files in:\n\t%s", t);
- free(t);
- } else {
- log_debug("Ignoring unit files.");
- strv_free(p->unit_path);
- p->unit_path = NULL;
- }
+ strv_uniq(p->sysvinit_path);
+ strv_uniq(p->sysvrcnd_path);
- if (!strv_isempty(p->sysvinit_path)) {
+ if (!strv_isempty(p->sysvinit_path)) {
- if (!(t = strv_join(p->sysvinit_path, "\n\t")))
- return -ENOMEM;
+ if (!(t = strv_join(p->sysvinit_path, "\n\t")))
+ return -ENOMEM;
- log_debug("Looking for SysV init scripts in:\n\t%s", t);
- free(t);
- } else {
- log_debug("Ignoring SysV init scripts.");
- strv_free(p->sysvinit_path);
- p->sysvinit_path = NULL;
- }
+ log_debug("Looking for SysV init scripts in:\n\t%s", t);
+ free(t);
+ } else {
+ log_debug("Ignoring SysV init scripts.");
+ strv_free(p->sysvinit_path);
+ p->sysvinit_path = NULL;
+ }
- if (!strv_isempty(p->sysvrcnd_path)) {
+ if (!strv_isempty(p->sysvrcnd_path)) {
- if (!(t = strv_join(p->sysvrcnd_path, "\n\t")))
- return -ENOMEM;
+ if (!(t = strv_join(p->sysvrcnd_path, "\n\t")))
+ return -ENOMEM;
- log_debug("Looking for SysV rcN.d links in:\n\t%s", t);
- free(t);
- } else {
- log_debug("Ignoring SysV rcN.d links.");
- strv_free(p->sysvrcnd_path);
- p->sysvrcnd_path = NULL;
+ log_debug("Looking for SysV rcN.d links in:\n\t%s", t);
+ free(t);
+ } else {
+ log_debug("Ignoring SysV rcN.d links.");
+ strv_free(p->sysvrcnd_path);
+ p->sysvrcnd_path = NULL;
+ }
+#else
+ log_debug("Disabled SysV init scripts and rcN.d links support");
+#endif
}
return 0;
@@ -282,8 +287,11 @@ void lookup_paths_free(LookupPaths *p) {
assert(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->unit_path = p->sysvinit_path = p->sysvrcnd_path = NULL;
+ p->sysvinit_path = p->sysvrcnd_path = NULL;
+#endif
}
diff --git a/src/path-lookup.h b/src/path-lookup.h
index f53aa214a3..dca8b55e15 100644
--- a/src/path-lookup.h
+++ b/src/path-lookup.h
@@ -24,8 +24,10 @@
typedef struct LookupPaths {
char **unit_path;
+#ifdef HAVE_SYSV_COMPAT
char **sysvinit_path;
char **sysvrcnd_path;
+#endif
} LookupPaths;
#include "manager.h"
diff --git a/src/service.c b/src/service.c
index 51a7e6b20f..797f285774 100644
--- a/src/service.c
+++ b/src/service.c
@@ -38,6 +38,7 @@
#define COMMENTS "#;\n"
#define NEWLINES "\n\r"
+#ifdef HAVE_SYSV_COMPAT
typedef enum RunlevelType {
RUNLEVEL_UP,
RUNLEVEL_DOWN,
@@ -80,6 +81,7 @@ static const struct {
#define RUNLEVELS_UP "12345"
/* #define RUNLEVELS_DOWN "06" */
/* #define RUNLEVELS_BOOT "bBsS" */
+#endif
static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
[SERVICE_DEAD] = UNIT_INACTIVE,
@@ -108,7 +110,9 @@ static void service_init(Unit *u) {
s->timeout_usec = DEFAULT_TIMEOUT_USEC;
s->restart_usec = DEFAULT_RESTART_USEC;
s->timer_watch.type = WATCH_INVALID;
+#ifdef HAVE_SYSV_COMPAT
s->sysv_start_priority = -1;
+#endif
s->socket_fd = -1;
exec_context_init(&s->exec_context);
@@ -189,11 +193,13 @@ static void service_done(Unit *u) {
free(s->pid_file);
s->pid_file = NULL;
+#ifdef HAVE_SYSV_COMPAT
free(s->sysv_path);
s->sysv_path = NULL;
free(s->sysv_runlevels);
s->sysv_runlevels = NULL;
+#endif
free(s->status_text);
s->status_text = NULL;
@@ -219,6 +225,7 @@ static void service_done(Unit *u) {
unit_unwatch_timer(u, &s->timer_watch);
}
+#ifdef HAVE_SYSV_COMPAT
static char *sysv_translate_name(const char *name) {
char *r;
@@ -831,6 +838,7 @@ static int service_load_sysv(Service *s) {
return 0;
}
+#endif
static int service_verify(Service *s) {
assert(s);
@@ -896,10 +904,12 @@ static int service_load(Unit *u) {
if ((r = unit_load_fragment(u)) < 0)
return r;
+#ifdef HAVE_SYSV_COMPAT
/* Load a classic init script as a fallback, if we couldn't find anything */
if (u->meta.load_state == UNIT_STUB)
if ((r = service_load_sysv(s)) < 0)
return r;
+#endif
/* Still nothing found? Then let's give up */
if (u->meta.load_state == UNIT_STUB)
@@ -918,8 +928,10 @@ static int service_load(Unit *u) {
if ((r = unit_add_default_cgroup(u)) < 0)
return r;
+#ifdef HAVE_SYSV_COMPAT
if ((r = sysv_fix_order(s)) < 0)
return r;
+#endif
if (s->bus_name)
if ((r = unit_watch_bus_name(u, s->bus_name)) < 0)
@@ -1003,6 +1015,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
exec_command_dump_list(s->exec_command[c], f, prefix2);
}
+#ifdef HAVE_SYSV_COMPAT
if (s->sysv_path)
fprintf(f,
"%sSysV Init Script Path: %s\n"
@@ -1020,6 +1033,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
if (s->sysv_runlevels)
fprintf(f, "%sSysVRunLevels: %s\n",
prefix, s->sysv_runlevels);
+#endif
if (s->status_text)
fprintf(f, "%sStatus Text: %s\n",
@@ -2262,6 +2276,7 @@ static const char *service_sub_state_to_string(Unit *u) {
return service_state_to_string(SERVICE(u)->state);
}
+#ifdef HAVE_SYSV_COMPAT
static bool service_check_gc(Unit *u) {
Service *s = SERVICE(u);
@@ -2269,6 +2284,7 @@ static bool service_check_gc(Unit *u) {
return !!s->sysv_path;
}
+#endif
static bool service_check_snapshot(Unit *u) {
Service *s = SERVICE(u);
@@ -2654,6 +2670,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
unit_add_to_dbus_queue(u);
}
+#ifdef HAVE_SYSV_COMPAT
static int service_enumerate(Manager *m) {
char **p;
unsigned i;
@@ -2874,6 +2891,7 @@ finish:
return r;
}
+#endif
static void service_bus_name_owner_change(
Unit *u,
@@ -3057,7 +3075,9 @@ const UnitVTable service_vtable = {
.active_state = service_active_state,
.sub_state_to_string = service_sub_state_to_string,
+#ifdef HAVE_SYSV_COMPAT
.check_gc = service_check_gc,
+#endif
.check_snapshot = service_check_snapshot,
.sigchld_event = service_sigchld_event,
@@ -3075,5 +3095,7 @@ const UnitVTable service_vtable = {
.bus_message_handler = bus_service_message_handler,
.bus_invalidating_properties = bus_service_invalidating_properties,
+#ifdef HAVE_SYSV_COMPAT
.enumerate = service_enumerate
+#endif
};
diff --git a/src/service.h b/src/service.h
index f01906cad4..39bd1b3401 100644
--- a/src/service.h
+++ b/src/service.h
@@ -106,6 +106,7 @@ struct Service {
ExecCommand *control_command;
ServiceExecCommand control_command_id;
pid_t main_pid, control_pid;
+ int socket_fd;
bool permissions_start_only;
bool root_directory_start_only;
@@ -117,14 +118,14 @@ struct Service {
bool bus_name_good:1;
bool forbid_restart:1;
bool got_socket_fd:1;
+#ifdef HAVE_SYSV_COMPAT
bool sysv_has_lsb:1;
bool sysv_enabled:1;
-
- int socket_fd;
int sysv_start_priority;
char *sysv_path;
char *sysv_runlevels;
+#endif
char *bus_name;
diff --git a/src/systemctl.c b/src/systemctl.c
index 2525967bcc..1f2b43be03 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -1581,7 +1581,9 @@ typedef struct UnitStatusInfo {
pid_t control_pid;
const char *status_text;
bool running:1;
+#ifdef HAVE_SYSV_COMPAT
bool is_sysv:1;
+#endif
usec_t start_timestamp;
usec_t exit_timestamp;
@@ -1701,7 +1703,11 @@ static void print_status_info(UnitStatusInfo *i) {
printf("status=%i", p->status);
+#ifdef HAVE_SYSV_COMPAT
if ((c = exit_status_to_string(p->status, i->is_sysv ? EXIT_STATUS_LSB : EXIT_STATUS_SYSTEMD)))
+#else
+ if ((c = exit_status_to_string(p->status, EXIT_STATUS_SYSTEMD)))
+#endif
printf("/%s", c);
} else
@@ -1739,7 +1745,11 @@ static void print_status_info(UnitStatusInfo *i) {
printf("status=%i", i->exit_status);
+#ifdef HAVE_SYSV_COMPAT
if ((c = exit_status_to_string(i->exit_status, i->is_sysv ? EXIT_STATUS_LSB : EXIT_STATUS_SYSTEMD)))
+#else
+ if ((c = exit_status_to_string(i->exit_status, EXIT_STATUS_SYSTEMD)))
+#endif
printf("/%s", c);
} else
@@ -1811,10 +1821,13 @@ static int status_property(const char *name, DBusMessageIter *iter, UnitStatusIn
i->description = s;
else if (streq(name, "FragmentPath"))
i->path = s;
+#ifdef HAVE_SYSV_COMPAT
else if (streq(name, "SysVPath")) {
i->is_sysv = true;
i->path = s;
- } else if (streq(name, "DefaultControlGroup"))
+ }
+#endif
+ else if (streq(name, "DefaultControlGroup"))
i->default_control_group = s;
else if (streq(name, "StatusText"))
i->status_text = s;