Hello community, here is the log from the commit of package systemd for openSUSE:Factory checked in at 2013-07-03 16:53:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/systemd (Old) and /work/SRC/openSUSE:Factory/.systemd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "systemd" Changes: -------- --- /work/SRC/openSUSE:Factory/systemd/systemd-mini.changes 2013-07-02 14:30:29.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.systemd.new/systemd-mini.changes 2013-07-03 16:53:51.000000000 +0200 @@ -1,0 +2,9 @@ +Mon Jul 1 13:43:31 UTC 2013 - [email protected] + +- Replace + parse-etc-insserv.conf-and-adds-dependencies-accordingly.patch + patch with insserv-generator.patch: no longer patch systemd main + binary but generate systemd drop-in files using a generator, for + insserv.conf compatibility. + +------------------------------------------------------------------- --- /work/SRC/openSUSE:Factory/systemd/systemd.changes 2013-07-02 14:30:29.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.systemd.new/systemd.changes 2013-07-03 16:53:51.000000000 +0200 @@ -1,0 +2,9 @@ +Mon Jul 1 13:43:31 UTC 2013 - [email protected] + +- Replace + parse-etc-insserv.conf-and-adds-dependencies-accordingly.patch + patch with insserv-generator.patch: no longer patch systemd main + binary but generate systemd drop-in files using a generator, for + insserv.conf compatibility. + +------------------------------------------------------------------- Old: ---- parse-etc-insserv.conf-and-adds-dependencies-accordingly.patch New: ---- insserv-generator.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ systemd-mini.spec ++++++ --- /var/tmp/diff_new_pack.PpjxuD/_old 2013-07-03 16:53:52.000000000 +0200 +++ /var/tmp/diff_new_pack.PpjxuD/_new 2013-07-03 16:53:52.000000000 +0200 @@ -106,7 +106,6 @@ Source2: localfs.service Source3: systemd-sysv-convert Source4: macros.systemd -Source5: systemd-insserv_conf Source6: baselibs.conf Source7: libgcrypt.m4 Source8: systemd-journald.init @@ -124,7 +123,7 @@ # handle SUSE specific kbd settings Patch3: handle-disable_caplock-and-compose_table-and-kbd_rate.patch Patch4: handle-numlock-value-in-etc-sysconfig-keyboard.patch -Patch6: parse-etc-insserv.conf-and-adds-dependencies-accordingly.patch +Patch6: insserv-generator.patch Patch7: service-flags-sysv-service-with-detected-pid-as-RemainAfte.patch Patch8: module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch Patch9: remain_after_exit-initscript-heuristic-and-add-new-LSB-hea.patch @@ -507,8 +506,6 @@ mkdir -p %{buildroot}/{sbin,var/lib/systemd/sysv-convert,var/lib/systemd/migrated} %{buildroot}/usr/lib/systemd/{system-generators,user-generators,system-preset,user-preset,system/halt.target.wants,system/kexec.target.wants,system/poweroff.target.wants,system/reboot.target.wants} install -m755 %{S:3} -D %{buildroot}%{_sbindir}/systemd-sysv-convert -# do not install, code has been fixed, might be useful in the future -#install -m755 %{S:5} %{buildroot}/usr/lib/systemd/system-generators ln -s ../usr/lib/systemd/systemd %{buildroot}/bin/systemd ln -s ../usr/lib/systemd/systemd %{buildroot}/sbin/init ln -s ../usr/bin/systemctl %{buildroot}/sbin/reboot @@ -849,6 +846,7 @@ %{_prefix}/lib/systemd/system-generators/systemd-rc-local-generator %{_prefix}/lib/systemd/system-generators/systemd-fstab-generator %{_prefix}/lib/systemd/system-generators/systemd-system-update-generator +%{_prefix}/lib/systemd/system-generators/systemd-insserv-generator /%{_lib}/security/pam_systemd.so %dir %{_libexecdir}/modules-load.d ++++++ systemd.spec ++++++ --- /var/tmp/diff_new_pack.PpjxuD/_old 2013-07-03 16:53:52.000000000 +0200 +++ /var/tmp/diff_new_pack.PpjxuD/_new 2013-07-03 16:53:52.000000000 +0200 @@ -101,7 +101,6 @@ Source2: localfs.service Source3: systemd-sysv-convert Source4: macros.systemd -Source5: systemd-insserv_conf Source6: baselibs.conf Source7: libgcrypt.m4 Source8: systemd-journald.init @@ -119,7 +118,7 @@ # handle SUSE specific kbd settings Patch3: handle-disable_caplock-and-compose_table-and-kbd_rate.patch Patch4: handle-numlock-value-in-etc-sysconfig-keyboard.patch -Patch6: parse-etc-insserv.conf-and-adds-dependencies-accordingly.patch +Patch6: insserv-generator.patch Patch7: service-flags-sysv-service-with-detected-pid-as-RemainAfte.patch Patch8: module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch Patch9: remain_after_exit-initscript-heuristic-and-add-new-LSB-hea.patch @@ -502,8 +501,6 @@ mkdir -p %{buildroot}/{sbin,var/lib/systemd/sysv-convert,var/lib/systemd/migrated} %{buildroot}/usr/lib/systemd/{system-generators,user-generators,system-preset,user-preset,system/halt.target.wants,system/kexec.target.wants,system/poweroff.target.wants,system/reboot.target.wants} install -m755 %{S:3} -D %{buildroot}%{_sbindir}/systemd-sysv-convert -# do not install, code has been fixed, might be useful in the future -#install -m755 %{S:5} %{buildroot}/usr/lib/systemd/system-generators ln -s ../usr/lib/systemd/systemd %{buildroot}/bin/systemd ln -s ../usr/lib/systemd/systemd %{buildroot}/sbin/init ln -s ../usr/bin/systemctl %{buildroot}/sbin/reboot @@ -844,6 +841,7 @@ %{_prefix}/lib/systemd/system-generators/systemd-rc-local-generator %{_prefix}/lib/systemd/system-generators/systemd-fstab-generator %{_prefix}/lib/systemd/system-generators/systemd-system-update-generator +%{_prefix}/lib/systemd/system-generators/systemd-insserv-generator /%{_lib}/security/pam_systemd.so %dir %{_libexecdir}/modules-load.d ++++++ insserv-generator.patch ++++++ >From a8cbe79c77836cc2466e3534157864abc98ef3ef Mon Sep 17 00:00:00 2001 From: Frederic Crozat <[email protected]> Date: Fri, 28 Jun 2013 17:54:41 +0200 Subject: [PATCH] insserv.conf generator parse /etc/insserv.conf.dd content and /etc/insserv.conf and generate systemd unit drop-in files to add dependencies --- Makefile.am | 9 + src/insserv-generator/Makefile | 28 +++ src/insserv-generator/insserv-generator.c | 309 ++++++++++++++++++++++++++++++ 3 files changed, 346 insertions(+) create mode 100644 src/insserv-generator/Makefile create mode 100644 src/insserv-generator/insserv-generator.c diff --git a/Makefile.am b/Makefile.am index 016d7da..9f8319d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -315,6 +315,7 @@ rootlibexec_PROGRAMS = \ systemd-sleep systemgenerator_PROGRAMS = \ + systemd-insserv-generator \ systemd-getty-generator \ systemd-fstab-generator \ systemd-system-update-generator @@ -1549,6 +1550,14 @@ systemd_delta_LDADD = \ libsystemd-shared.la # ------------------------------------------------------------------------------ +systemd_insserv_generator_SOURCES = \ + src/insserv-generator/insserv-generator.c + +systemd_insserv_generator_LDADD = \ + libsystemd-label.la \ + libsystemd-shared.la + +# ------------------------------------------------------------------------------ systemd_getty_generator_SOURCES = \ src/getty-generator/getty-generator.c diff --git a/src/insserv-generator/Makefile b/src/insserv-generator/Makefile new file mode 100644 index 0000000..9d07505 --- /dev/null +++ b/src/insserv-generator/Makefile @@ -0,0 +1,28 @@ +# This file is part of systemd. +# +# Copyright 2010 Lennart Poettering +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with systemd; If not, see <http://www.gnu.org/licenses/>. + +# This file is a dirty trick to simplify compilation from within +# emacs. This file is not intended to be distributed. So, don't touch +# it, even better ignore it! + +all: + $(MAKE) -C .. + +clean: + $(MAKE) -C .. clean + +.PHONY: all clean diff --git a/src/insserv-generator/insserv-generator.c b/src/insserv-generator/insserv-generator.c new file mode 100644 index 0000000..067ee2f --- /dev/null +++ b/src/insserv-generator/insserv-generator.c @@ -0,0 +1,309 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2012 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. + ***/ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <sys/stat.h> + +#include "mkdir.h" +#include "log.h" +#include "fileio.h" +#include "unit-name.h" +#include "special.h" +#include "path-util.h" +#include "util.h" +#include "strv.h" + +static const char *arg_dest = "/tmp"; + +static char *sysv_translate_name(const char *name) { + char *r; + + r = new(char, strlen(name) + sizeof(".service")); + if (!r) + return NULL; + + if (endswith(name, ".sh")) + /* Drop .sh suffix */ + strcpy(stpcpy(r, name) - 3, ".service"); + else + /* Normal init script name */ + strcpy(stpcpy(r, name), ".service"); + + return r; +} + +static int sysv_translate_facility(const char *name, const char *filename, char **_r) { + + /* We silently ignore the $ prefix here. According to the LSB + * spec it simply indicates whether something is a + * standardized name or a distribution-specific one. Since we + * just follow what already exists and do not introduce new + * uses or names we don't care who introduced a new name. */ + + static const char * const table[] = { + /* LSB defined facilities */ + "local_fs", NULL, + "network", SPECIAL_NETWORK_TARGET, + "named", SPECIAL_NSS_LOOKUP_TARGET, + "portmap", SPECIAL_RPCBIND_TARGET, + "remote_fs", SPECIAL_REMOTE_FS_TARGET, + "syslog", NULL, + "time", SPECIAL_TIME_SYNC_TARGET, + }; + + unsigned i; + char *r; + const char *n; + + assert(name); + assert(_r); + + n = *name == '$' ? name + 1 : name; + + for (i = 0; i < ELEMENTSOF(table); i += 2) { + + if (!streq(table[i], n)) + continue; + + if (!table[i+1]) + return 0; + + r = strdup(table[i+1]); + if (!r) + return log_oom(); + + goto finish; + } + + /* If we don't know this name, fallback heuristics to figure + * out whether something is a target or a service alias. */ + + if (*name == '$') { + if (!unit_prefix_is_valid(n)) + return -EINVAL; + + /* Facilities starting with $ are most likely targets */ + r = unit_name_build(n, NULL, ".target"); + } else if (filename && streq(name, filename)) + /* Names equaling the file name of the services are redundant */ + return 0; + else + /* Everything else we assume to be normal service names */ + r = sysv_translate_name(n); + + if (!r) + return -ENOMEM; + +finish: + *_r = r; + + return 1; +} + + + +static int parse_insserv_conf(const char* filename) { + _cleanup_fclose_ FILE *f = NULL; + int r; + + if (!(f = fopen(filename, "re"))) { + log_debug("Failed to open file %s", filename); + r = errno == ENOENT ? 0 : -errno; + return r; + } + + while (!feof(f)) { + char l[LINE_MAX], *t; + _cleanup_strv_free_ 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)); + return -r; + } + + 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>")) { + _cleanup_free_ char *facility = NULL; + if (sysv_translate_facility(parsed[0], NULL, &facility) < 0) + continue; + if (streq(facility, SPECIAL_REMOTE_FS_TARGET)) { + _cleanup_free_ char *unit = NULL; + /* insert also a Wants dependency from remote-fs-pre on remote-fs */ + unit = strjoin(arg_dest, "/remote-fs.target.d/50-",path_get_file_name(filename),".conf", NULL); + if (!unit) + return log_oom(); + + mkdir_parents_label(unit, 0755); + + r = write_string_file(unit, + "# Automatically generated by systemd-insserv-generator\n\n" + "[Unit]\n" + "Wants=remote-fs-pre.target\n"); + if (r) + return r; + free (facility); + facility=strdup(SPECIAL_REMOTE_FS_PRE_TARGET); + } + if (facility && endswith(facility, ".target")) { + char *name, **j; + FILE *file = NULL; + + STRV_FOREACH (j, parsed+1) { + _cleanup_free_ char *unit = NULL; + _cleanup_free_ char *dep = NULL; + + 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; + + unit = strjoin(arg_dest, "/", dep, ".d/50-",path_get_file_name(filename),"-",parsed[0],".conf", NULL); + if (!unit) + return log_oom(); + + mkdir_parents_label(unit, 0755); + + file = fopen(unit, "wxe"); + if (!file) { + if (errno == EEXIST) + log_error("Failed to create drop-in file %s", unit); + else + log_error("Failed to create drop-in file %s: %m", unit); + return -errno; + } + + fprintf(file, + "# Automatically generated by systemd-insserv-generator\n\n" + "[Unit]\n" + "Wants=%s\n" + "Before=%s\n", + facility, facility); + + fflush(file); + if (ferror(file)) { + log_error("Failed to write unit file %s: %m", unit); + return -errno; + } + fclose(file); + + if (*j[0] != '+') { + free (unit); + unit = strjoin(arg_dest, "/", facility, ".d/50-hard-dependency-",path_get_file_name(filename),"-",parsed[0],".conf", NULL); + if (!unit) + return log_oom(); + + mkdir_parents_label(unit, 0755); + + file = fopen(unit, "wxe"); + if (!file) { + if (errno == EEXIST) + log_error("Failed to create drop-in file %s, as it already exists", unit); + else + log_error("Failed to create drop-in file %s: %m", unit); + return -errno; + } + + + fprintf(file, + "# Automatically generated by systemd-insserv-generator\n\n" + "[Unit]\n" + "SourcePath=%s\n" + "Requires=%s\n", + filename, dep); + fflush(file); + if (ferror(file)) { + log_error("Failed to write unit file %s: %m", unit); + return -errno; + } + fclose(file); + } + } + } + } + } + return r; +} + +static int parse_insserv(void) { + DIR *d = NULL; + struct dirent *de; + int r = 0; + + if (!(d = opendir("/etc/insserv.conf.d/"))) { + if (errno != ENOENT) { + log_debug("opendir() failed on /etc/insserv.conf.d/ %s", strerror(errno)); + } + } else { + + while ((de = readdir(d))) { + char *path = NULL; + if (ignore_file(de->d_name)) + continue; + + path = strjoin("/etc/insserv.conf.d/", de->d_name, NULL); + parse_insserv_conf(path); + free(path); + } + closedir (d); + } + + r = parse_insserv_conf("/etc/insserv.conf"); + + return r; +} + +int main(int argc, char *argv[]) { + int r = 0; + + if (argc > 1 && argc != 4) { + log_error("This program takes three or no arguments."); + return EXIT_FAILURE; + } + + if (argc > 1) + arg_dest = argv[1]; + + log_set_target(LOG_TARGET_SAFE); + log_parse_environment(); + log_open(); + + umask(0022); + + r = parse_insserv(); + + return (r < 0) ? EXIT_FAILURE : EXIT_SUCCESS; +} -- 1.8.1.4 -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
