Commit 72531478 authored by Martin Pitt's avatar Martin Pitt

sysv-generator: add support for /etc/insserv/overrides

Closes: #759001
parent dd56a6cd
...@@ -12,10 +12,12 @@ systemd (215-13) UNRELEASED; urgency=medium ...@@ -12,10 +12,12 @@ systemd (215-13) UNRELEASED; urgency=medium
* tmpfiles-setup-dev: Call tmpfiles with --boot to allow unsafe device * tmpfiles-setup-dev: Call tmpfiles with --boot to allow unsafe device
creation. Fixes creation of static device nodes with kmod 20. creation. Fixes creation of static device nodes with kmod 20.
(Closes: #780263) (Closes: #780263)
[ Christian Seiler ]
* core: Don't migrate PIDs for units that may contain subcgroups. * core: Don't migrate PIDs for units that may contain subcgroups.
This stops messing up lxc/libvirt/other custom cgroup layouts after This stops messing up lxc/libvirt/other custom cgroup layouts after
daemon-reload. Thanks to Christian Seiler for the backport! daemon-reload. (Closes: #777164)
(Closes: #777164) * sysv-generator: add support for /etc/insserv/overrides. (Closes: #759001)
[ Michael Biebl ] [ Michael Biebl ]
* debian/udev.init: Recognize '!' flag with static device lists, to work * debian/udev.init: Recognize '!' flag with static device lists, to work
......
...@@ -193,3 +193,4 @@ Only-start-logind-if-dbus-is-installed.patch ...@@ -193,3 +193,4 @@ Only-start-logind-if-dbus-is-installed.patch
cgroup-don-t-trim-cgroup-trees-created-by-someone-el.patch cgroup-don-t-trim-cgroup-trees-created-by-someone-el.patch
core-don-t-fail-to-run-services-in-user-instances-if.patch core-don-t-fail-to-run-services-in-user-instances-if.patch
PrivateTmp-shouldn-t-require-tmpfs.patch PrivateTmp-shouldn-t-require-tmpfs.patch
sysv-generator-add-support-for-etc-insserv-overrides.patch
From: Christian Seiler <christian@iwakd.de>
Date: Tue, 17 Feb 2015 00:27:21 +0100
Subject: sysv-generator: add support for /etc/insserv/overrides
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759001
---
src/sysv-generator/sysv-generator.c | 57 ++++++++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 628d579..3b5e874 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -41,6 +41,8 @@
#include "fileio.h"
#include "hashmap.h"
+#define SYSV_OVERRIDE_PATH "/etc/insserv/overrides/"
+
typedef enum RunlevelType {
RUNLEVEL_SYSINIT,
RUNLEVEL_UP,
@@ -76,6 +78,7 @@ static const struct {
typedef struct SysvStub {
char *name;
char *path;
+ char *override_path;
char *description;
bool sysinit;
int sysv_start_priority;
@@ -207,6 +210,12 @@ static int generate_unit_file(SysvStub *s) {
if (!isempty(conflicts))
fprintf(f, "Conflicts=%s\n", conflicts);
+ /* make systemctl status show the information that the headers
+ * were overridden; not the most elegant way, but SourcePath=
+ * only accepts a single entry */
+ if (s->override_path)
+ fprintf(f, "Documentation=file://%s\n", s->override_path);
+
fprintf(f,
"\n[Service]\n"
"Type=forking\n"
@@ -351,7 +360,7 @@ finish:
return 1;
}
-static int load_sysv(SysvStub *s) {
+static int load_sysv(SysvStub *s, const char *fpath, bool check_for_usage_only) {
_cleanup_fclose_ FILE *f;
unsigned line = 0;
int r;
@@ -368,7 +377,7 @@ static int load_sysv(SysvStub *s) {
assert(s);
- f = fopen(s->path, "re");
+ f = fopen(fpath, "re");
if (!f)
return errno == ENOENT ? 0 : -errno;
@@ -381,7 +390,7 @@ static int load_sysv(SysvStub *s) {
log_error_unit(s->name,
"Failed to read configuration file '%s': %m",
- s->path);
+ fpath);
return -errno;
}
@@ -406,6 +415,11 @@ static int load_sysv(SysvStub *s) {
continue;
}
+ /* If this is just the run to determine whether the init
+ * script supports reload. */
+ if (check_for_usage_only)
+ continue;
+
if (state == NORMAL && streq(t, "### BEGIN INIT INFO")) {
state = LSB;
s->has_lsb = true;
@@ -456,7 +470,7 @@ static int load_sysv(SysvStub *s) {
if (!path_is_absolute(fn)) {
log_error_unit(s->name,
"[%s:%u] PID file not absolute. Ignoring.",
- s->path, line);
+ fpath, line);
continue;
}
@@ -547,7 +561,7 @@ static int load_sysv(SysvStub *s) {
if (r < 0)
log_error_unit(s->name,
"[%s:%u] Failed to add LSB Provides name %s, ignoring: %s",
- s->path, line, m, strerror(-r));
+ fpath, line, m, strerror(-r));
}
} else if (startswith_no_case(t, "Required-Start:") ||
@@ -571,7 +585,7 @@ static int load_sysv(SysvStub *s) {
if (r < 0) {
log_error_unit(s->name,
"[%s:%u] Failed to translate LSB dependency %s, ignoring: %s",
- s->path, line, n, strerror(-r));
+ fpath, line, n, strerror(-r));
continue;
}
@@ -605,7 +619,7 @@ static int load_sysv(SysvStub *s) {
if (r < 0)
log_error_unit(s->name,
"[%s:%u] Failed to add dependency on %s, ignoring: %s",
- s->path, line, m, strerror(-r));
+ fpath, line, m, strerror(-r));
}
} else if (startswith_no_case(t, "Description:")) {
@@ -761,6 +775,7 @@ static int native_unit_exists(LookupPaths lp, char *name) {
static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
char **path;
+ int had_override = 0;
STRV_FOREACH(path, lp.sysvinit_path) {
_cleanup_closedir_ DIR *d = NULL;
@@ -776,7 +791,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
while ((de = readdir(d))) {
SysvStub *service;
struct stat st;
- _cleanup_free_ char *fpath = NULL, *name = NULL;
+ _cleanup_free_ char *fpath = NULL, *name = NULL, *override_fpath = NULL;
int r;
if (ignore_file(de->d_name))
@@ -792,6 +807,19 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
if (!(st.st_mode & S_IXUSR))
continue;
+ override_fpath = strjoin(SYSV_OVERRIDE_PATH, de->d_name, NULL);
+ if (!override_fpath)
+ return log_oom();
+
+ if (stat(override_fpath, &st) < 0) {
+ free(override_fpath);
+ override_fpath = NULL;
+ } else if (!had_override) {
+ /* Only display this message once. */
+ had_override = 1;
+ log_info("Using overrides in %s. This is only supported in Jessie as a transitional measure.", SYSV_OVERRIDE_PATH);
+ }
+
name = sysv_translate_name(de->d_name);
if (!name)
return log_oom();
@@ -812,8 +840,17 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
service->sysv_start_priority = -1;
service->name = name;
service->path = fpath;
+ service->override_path = override_fpath;
+
+ if (override_fpath) {
+ r = load_sysv(service, override_fpath, false);
+ if (r < 0)
+ continue;
+ }
- r = load_sysv(service);
+ /* always read in the init script to determine whether
+ * it supports reload action */
+ r = load_sysv(service, fpath, (bool) override_fpath);
if (r < 0)
continue;
@@ -821,7 +858,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
if (r < 0)
return log_oom();
- name = fpath = NULL;
+ name = fpath = override_fpath = NULL;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment