Hi Frederic, On 24.10.2012 17:51, Frederic Crozat wrote: > > First, make sure you have this patch > (https://build.opensuse.org/package/view_file?file=0001-service-Fix-dependencies-added-when-parsing-insserv..patch&package=systemd&project=Base%3ASystem&rev=df941bd8d87aadf2194e1eb4ada5c1d9 > ) in your tree.
[..] > Without this patch, the dependencies between target were incorrectly > set, as you figured (you'll note now UNIT_BEFORE is set with an > by_name_inverse call). I've merged the bits you had in that patch, but that didn't quite work, since the rpcbind.target was not activated. I had a look how NetworkManager-wait-online.service does it. It has a [Unit] Wants/Before=network.target and a [Install] WantedBy=network.target After changing your patch to not only add a BEFORE dependency but also a WANTS dependency, everything seems to work as expected: # cat /etc/insserv.conf.d/rpcbind $portmap rpcbind # systemctl status rpcbind.service rpcbind.target nfs-common.service rpcbind.service - LSB: RPC portmapper replacement Loaded: loaded (/etc/init.d/rpcbind) Active: active (running) since Sat, 27 Oct 2012 20:44:59 +0200; 6min ago Process: 1062 ExecStart=/etc/init.d/rpcbind start (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/rpcbind.service └ 1071 /sbin/rpcbind -w rpcbind.target - RPC Port Mapper Loaded: loaded (/lib/systemd/system/rpcbind.target; static) Active: active since Sat, 27 Oct 2012 20:44:59 +0200; 6min ago nfs-common.service - LSB: NFS support files common to client and server Loaded: loaded (/etc/init.d/nfs-common) Active: active (running) since Sat, 27 Oct 2012 20:44:59 +0200; 6min ago Process: 1075 ExecStart=/etc/init.d/nfs-common start (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/nfs-common.service ├ 1082 /sbin/rpc.statd └ 1096 /usr/sbin/rpc.idmapd # systemctl show rpcbind.target rpcbind.service nfs-common.service Id=rpcbind.target Names=rpcbind.target Requires=rpcbind.service WantedBy=rpcbind.service Conflicts=shutdown.target Before=nfs-common.service After=rpcbind.service ... Id=rpcbind.service Names=rpcbind.service Requires=systemd-journald.socket Wants=rpcbind.target RequiredBy=rpcbind.target WantedBy=multi-user.target sysinit.target Conflicts=shutdown.target Before=multi-user.target sysinit.target shutdown.target rpcbind.target After=network.target local-fs.target systemd-journald.socket ... Id=nfs-common.service Names=nfs-common.service Requires=systemd-journald.socket WantedBy=multi-user.target sysinit.target Conflicts=shutdown.target Before=multi-user.target sysinit.target shutdown.target After=rpcbind.target time-sync.target systemd-journald.socket I've attached the current version of the patch. Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?
diff --git a/src/service.c b/src/service.c index 808a1b8..fffe037 100644 --- a/src/service.c +++ b/src/service.c @@ -3269,12 +3269,13 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { #ifdef HAVE_SYSV_COMPAT -#ifdef TARGET_SUSE -static void sysv_facility_in_insserv_conf(Manager *mgr) { - FILE *f=NULL; +#if defined(TARGET_SUSE) || defined(TARGET_DEBIAN) +static void sysv_parse_insserv_conf(Manager *mgr, const char* filename) { + FILE *f = NULL; int r; - if (!(f = fopen("/etc/insserv.conf", "re"))) { + if (!(f = fopen(filename, "re"))) { + log_error("Failed to open file %s", filename); r = errno == ENOENT ? 0 : -errno; goto finish; } @@ -3288,7 +3289,7 @@ static void sysv_facility_in_insserv_conf(Manager *mgr) { break; r = -errno; - log_error("Failed to read configuration file '/etc/insserv.conf': %s", strerror(-r)); + log_error("Failed to read configuration file '%s': %s", filename, strerror(-r)); goto finish; } @@ -3304,22 +3305,19 @@ static void sysv_facility_in_insserv_conf(Manager *mgr) { if (sysv_translate_facility(parsed[0], NULL, &facility) < 0) continue; if ((u = manager_get_unit(mgr, facility)) && (u->type == UNIT_TARGET)) { - UnitDependency e; char *dep = NULL, *name, **j; STRV_FOREACH (j, parsed+1) { - if (*j[0]=='+') { - e = UNIT_WANTS; + if (*j[0] == '+') name = *j+1; - } - else { - e = UNIT_REQUIRES; + else name = *j; - } if (sysv_translate_facility(name, NULL, &dep) < 0) continue; - r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, e, dep, NULL, true); + 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); } } @@ -3332,6 +3330,35 @@ finish: 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"); +} + #endif static int service_enumerate(Manager *m) { @@ -3482,7 +3509,7 @@ static int service_enumerate(Manager *m) { r = 0; -#ifdef TARGET_SUSE +#if defined(TARGET_SUSE) || defined(TARGET_DEBIAN) sysv_facility_in_insserv_conf (m); #endif
signature.asc
Description: OpenPGP digital signature