systemd/parse-etc-insserv.conf-and-adds-dependencies-accordingly.patch
Marcus Meissner e118bb4a4a - Update to release 204:
+ systemd-nspawn creates etc/resolv.conf in container if needed.
  + systemd-nspawn will store metadata about container in container
    cgroup including its root directory.
  + cgroup hierarchy has been reworked, all objects are now suffxed
    (with .session for user sessions, .user for users, .nspawn for
     containers). All cgroup names are now escaped to preven
     collision of object names.
  + systemctl list-dependencies gained --plain, --reverse, --after
    and --before switches.
  + systemd-inhibit shows processes name taking inhibitor lock.
  + nss-myhostname will now resolve "localhost" implicitly.
  + .include is not allowed recursively anymore and only in unit
    files. Drop-in files should be favored in most cases.
  + systemd-analyze gained "critical-chain" command, to get slowest
    chain of units run during boot-up.
  + systemd-nspawn@.service has been added to easily run nspawn
    container for system services. Just start
    "systemd-nspawn@foobar.service" and container from
    /var/lib/container/foobar" will be booted.
  + systemd-cgls has new --machine parameter to list processes from
    one container.
  + ConditionSecurity= can now check for apparmor and SMACK.
  + /etc/systemd/sleep.conf has been introduced to configure which
    kernel operation will be execute when "suspend", "hibernate" or
    "hybrid-sleep" is requrested. It allow new kernel "freeze"
    state to be used too. (This setting won't have any effect if
    pm-utils is installed).
  + ENV{SYSTEMD_WANTS} in udev rules will now implicitly escape
    passed argument if applicable.

OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=388
2013-05-29 15:26:40 +00:00

132 lines
4.9 KiB
Diff

From: Frederic Crozat <fcrozat@suse.com>
Date: Fri, 30 Sep 2011 13:55:31 +0000
Subject: parse /etc/insserv.conf and adds dependencies accordingly
(bnc#721428)
---
src/core/service.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 104 insertions(+)
diff --git a/src/core/service.c b/src/core/service.c
index 3617c24..3c66cdb 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3443,6 +3443,108 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
}
#ifdef HAVE_SYSV_COMPAT
+static void sysv_parse_insserv_conf(Manager *mgr, const char* filename) {
+ FILE *f = NULL;
+ int r;
+
+ if (!(f = fopen(filename, "re"))) {
+ log_debug("Failed to open file %s", filename);
+ r = errno == ENOENT ? 0 : -errno;
+ goto finish;
+ }
+
+ while (!feof(f)) {
+ char l[LINE_MAX], *t;
+ char **parsed = NULL;
+
+ if (!fgets(l, sizeof(l), f)) {
+ if (feof(f))
+ break;
+
+ r = -errno;
+ log_error("Failed to read configuration file '%s': %s", filename, strerror(-r));
+ goto finish;
+ }
+
+ t = strstrip(l);
+ if (*t != '$' && *t != '<')
+ continue;
+
+ parsed = strv_split(t,WHITESPACE);
+ /* we ignore <interactive>, not used, equivalent to X-Interactive */
+ if (parsed && !startswith_no_case (parsed[0], "<interactive>")) {
+ char *facility;
+ Unit *u;
+ if (sysv_translate_facility(parsed[0], NULL, &facility) < 0)
+ continue;
+ if (streq(facility, SPECIAL_REMOTE_FS_TARGET)) {
+ /* insert also a Wants dependency from remote-fs-pre on remote-fs */
+ u = manager_get_unit(mgr, SPECIAL_REMOTE_FS_TARGET);
+ if (u) {
+ unit_add_dependency_by_name(u, UNIT_WANTS, SPECIAL_REMOTE_FS_PRE_TARGET, NULL, true);
+ free (facility);
+ facility=strdup(SPECIAL_REMOTE_FS_PRE_TARGET);
+ }
+ }
+ u = manager_get_unit(mgr, facility);
+ if (u && (u->type == UNIT_TARGET)) {
+ char *dep = NULL, *name, **j;
+
+ STRV_FOREACH (j, parsed+1) {
+ if (*j[0] == '+')
+ name = *j+1;
+ else
+ name = *j;
+ if (streq(name, "boot.localfs") ||
+ streq(name, "boot.crypto"))
+ continue;
+ if ((sysv_translate_facility(name, NULL, &dep) < 0) || !dep)
+ continue;
+
+ r = unit_add_two_dependencies_by_name_inverse(u, UNIT_WANTS, UNIT_BEFORE, dep, NULL, true);
+ if (*j[0] != '+')
+ r = unit_add_dependency_by_name(u, UNIT_REQUIRES, dep, NULL, true);
+ free(dep);
+ }
+ }
+ free(facility);
+ }
+ strv_free(parsed);
+ }
+finish:
+ if (f)
+ fclose(f);
+
+}
+
+static void sysv_facility_in_insserv_conf(Manager *mgr) {
+ DIR *d =NULL;
+ struct dirent *de;
+
+#ifdef TARGET_DEBIAN
+ if (!(d = opendir("/etc/insserv.conf.d/")))
+ if (errno != ENOENT) {
+ log_warning("opendir() failed on /etc/insserv.conf.d/ %s", strerror(errno));
+ goto finish;
+ }
+
+ while ((de = readdir(d))) {
+ char *path = NULL;
+ if (ignore_file(de->d_name))
+ continue;
+
+ path = join("/etc/insserv.conf.d/", de->d_name, NULL);
+ sysv_parse_insserv_conf(mgr, path);
+ free(path);
+ }
+finish:
+ if (d)
+ closedir(d);
+#endif
+
+ sysv_parse_insserv_conf(mgr, "/etc/insserv.conf");
+}
+
static int service_enumerate(Manager *m) {
char **p;
@@ -3603,6 +3705,8 @@ static int service_enumerate(Manager *m) {
r = 0;
+ sysv_facility_in_insserv_conf (m);
+
finish:
for (i = 0; i < ELEMENTSOF(rcnd_table); i++)