1 Patch from upstream to detect and reject loops in virtual
2 facilities (#541613) and warn about indirect dependencies to $all.
4 Index: insserv/insserv.c
5 ===================================================================
6 --- insserv.orig/insserv.c 2009-09-26 22:35:39.000000000 +0200
7 +++ insserv/insserv.c 2009-09-26 22:35:39.000000000 +0200
14 #define getrepl(arg) list_entry((arg), struct repl, r_list)
17 if (posix_memalign((void*)&subst, sizeof(void*), alignof(repl_t)) != 0)
18 error("%s", strerror(errno));
19 insert(&subst->r_list, r_list->prev);
22 if (posix_memalign((void*)&r->ref, sizeof(void*), alignof(typeof(r->ref))+strsize(token)) != 0)
23 error("%s", strerror(errno));
25 error("%s", strerror(errno));
26 insert(&subst->r_list, r_list->prev);
29 if (posix_memalign((void*)&r->ref, sizeof(void*), alignof(typeof(r->ref))+strsize(token)) != 0)
30 error("%s", strerror(errno));
32 @@ -2127,13 +2130,19 @@
34 list_for_each_safe(tmp, safe, ptr) {
35 repl_t * rnxt = getrepl(tmp);
36 + if (rnxt->flags & 0x0001) {
37 + error("Loop detected during expanding system facilities in the insserv.conf file(s): %s\n",
40 if (*rnxt->r[0].name == '$') {
42 warn("The nested level of the system facilities in the insserv.conf file(s) is to large\n");
46 + rnxt->flags |= 0x0001;
47 expand_faci(tmp, head, deep);
48 + rnxt->flags &= ~0x0001;
50 } else if (*deep > 0) {
51 repl_t *restrict subst;
52 @@ -2154,9 +2163,12 @@
53 list_for_each(ptr, sysfaci_start) {
54 list_t * rlist, * safe, * head = &getfaci(ptr)->replace;
55 list_for_each_safe(rlist, safe, head) {
56 - if (*getrepl(rlist)->r[0].name == '$') {
57 + repl_t * tmp = getrepl(rlist);
58 + if (*tmp->r[0].name == '$') {
60 + tmp->flags |= 0x0001;
61 expand_faci(rlist, rlist, &deep);
62 + tmp->flags &= ~0x0001;
66 Index: insserv/listing.c
67 ===================================================================
68 --- insserv.orig/listing.c 2009-09-26 22:35:24.000000000 +0200
69 +++ insserv/listing.c 2009-09-26 22:35:39.000000000 +0200
71 break; /* Loop detected, stop recursion */
74 + if ((mode == 'S') && (attof(tmp)->flags & SERV_ALL)) {
75 + warn("%s depends on %s and therefore on system facility `$all' which can not be true!\n",
76 + target->script ? target->script : target->name, tmp->script ? tmp->script : tmp->name);
80 if (ptrg->deep >= deep) /* Nothing new */
82 /* The inner recursion */