Am 17.02.2015 um 13:04 schrieb Christian Seiler:
Thinking about it, perhaps we could use Documentation=? Just add a
Documentation=file:///etc/insserv/overrides/$NAME? Then at least
systemctl status will show the information. Not perfect, but
probably better than nothing...

Somehow I think we should make clear though, that this is a
transitional
measure and parsing of insserv overrides is not going to be supported
forever.

Then perhaps write out a INFO priority log message (the lowest one
that's still higher than DEBUG), saying that the override was used
but is deprecated? And add a logcheck-ignore rule for this message,
since this is something the administrator should see when looking
at the logs, but not be reminded of every time systemctl
daemon-reload is executed.

Thoughts?

I've implemented both of these and attached a modified version of
the patch. Do you have any objections? If not, I'll ask for pre-
approval by the release team.

Christian

From: Christian Seiler <christ...@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 | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

--- 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 *
         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 *lsb_header_path) {
         _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(lsb_header_path, "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);
+                                       lsb_header_path);
                         return -errno;
                 }
 
@@ -456,7 +465,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 +556,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 +580,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 +614,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:")) {
@@ -761,6 +770,7 @@ static int native_unit_exists(LookupPath
 
 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 +786,7 @@ static int enumerate_sysv(LookupPaths lp
                 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 +802,19 @@ static int enumerate_sysv(LookupPaths lp
                         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 +835,9 @@ static int enumerate_sysv(LookupPaths lp
                         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 +845,7 @@ static int enumerate_sysv(LookupPaths lp
                         if (r < 0)
                                 return log_oom();
 
-                        name = fpath = NULL;
+                        name = fpath = override_fpath = NULL;
                 }
         }
 
_______________________________________________
Pkg-systemd-maintainers mailing list
Pkg-systemd-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-systemd-maintainers

Reply via email to