Control: tags -1 + patch (remove CC systemd-devel, add CC corresponding Debian bug)
Am 16.02.2015 um 19:12 schrieb Michael Biebl:
That said, as one of the Debian systemd maintainers, I could probably be convinced to add the insserv override support as a downstream patch for jessie.
I've attached a minimal patch for Debian Jessie for this. I tested it briefly, i.e. if no /etc/insserv/overrides/$NAME exists, nothing changes, but if it exists, it properly overrides the current LSB script. Please review. Only minor issue is that SourcePath= is a single-valued entry in systemd, so I can't just add the override if it exists, and FragmentPath= is only ever dynamically filled by systemd when parsing, so I can't set that either. It's mostly cosmetic, but systemctl status for example won't show that the file was overwritten. (Alternatively, one could ONLY use /etc/insserv/overrides/$NAME as SourcePath=, of course, I don't have a strong opinion on either one of these solutions.)
We are pretty late into the freeze though, so this would require an ack from our release managers.
Do you want me to ask for pre-approval? Christian
From: Christian Seiler <[email protected]> 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 | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 628d579..c4888e2 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; @@ -351,7 +354,7 @@ finish: return 1; } -static int load_sysv(SysvStub *s) { +static int load_sysv(SysvStub *s, const char *lsb_header_path) { _cleanup_fclose_ FILE *f; unsigned line = 0; int r; @@ -368,7 +371,7 @@ static int load_sysv(SysvStub *s) { assert(s); - f = fopen(s->path, "re"); + f = fopen(lsb_header_path, "re"); if (!f) return errno == ENOENT ? 0 : -errno; @@ -381,7 +384,7 @@ static int load_sysv(SysvStub *s) { log_error_unit(s->name, "Failed to read configuration file '%s': %m", - s->path); + lsb_header_path); return -errno; } @@ -456,7 +459,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); + lsb_header_path, line); continue; } @@ -547,7 +550,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)); + lsb_header_path, line, m, strerror(-r)); } } else if (startswith_no_case(t, "Required-Start:") || @@ -571,7 +574,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)); + lsb_header_path, line, n, strerror(-r)); continue; } @@ -605,7 +608,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)); + lsb_header_path, line, m, strerror(-r)); } } else if (startswith_no_case(t, "Description:")) { @@ -776,7 +779,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 +795,15 @@ 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; + } + name = sysv_translate_name(de->d_name); if (!name) return log_oom(); @@ -812,8 +824,9 @@ 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; - r = load_sysv(service); + r = load_sysv(service, override_fpath ? override_fpath : fpath); if (r < 0) continue; @@ -821,7 +834,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) { if (r < 0) return log_oom(); - name = fpath = NULL; + name = fpath = override_fpath = NULL; } }

