]> git.pld-linux.org Git - packages/chkconfig.git/blame - chkconfig-noxinet.patch
unbreak systemd-sysv-install symlink; rel 2
[packages/chkconfig.git] / chkconfig-noxinet.patch
CommitLineData
6a99f366
MK
1diff -urNpa chkconfig-1.15.orig/chkconfig.8 chkconfig-1.15/chkconfig.8
2--- chkconfig-1.15.orig/chkconfig.8 2021-01-21 09:19:06.000000000 +0100
3+++ chkconfig-1.15/chkconfig.8 2021-05-03 16:45:40.506185842 +0200
4@@ -63,16 +63,6 @@ or a stop script. When switching runlev
f20fb8bf
JR
5 an already-started service, and will not re-stop a service that is
6 not running.
82df657c 7
f20fb8bf
JR
8-\fBchkconfig\fR also can manage xinetd scripts via the means
9-of xinetd.d configuration files. Note that only the
10-\fBon\fR, \fBoff\fR, and \fB-\-list\fR commands are supported
11-for xinetd.d services.
12-
13-\fBchkconfig\fR supports a \fB-\-type\fR argument to limit actions to only
14-a specific type of services, in the case where services of either type may
15-share a name. Possible values for \fItype\fR are \fIsysv\fR
16-and \fIxinetd\fR.
17-
18 .SH OPTIONS
19 .TP
20 \fB-\-level \fIlevels\fR
176c6fd2
JB
21--- chkconfig-1.25/chkconfig.c.orig 2023-10-07 20:29:44.542142680 +0200
22+++ chkconfig-1.25/chkconfig.c 2023-10-07 20:30:56.375086861 +0200
6a99f366
MK
23@@ -117,8 +117,6 @@ static int delService(char *name, int ty
24 readServiceError(rc, name);
25 return 1;
82df657c 26 }
6a99f366
MK
27- if (s.type == TYPE_XINETD)
28- return 0;
09a63b21 29
f20fb8bf
JR
30 checkRoot();
31
6a99f366
MK
32@@ -333,8 +331,6 @@ static int addService(char *name, int ty
33 return 1;
09a63b21 34 }
f20fb8bf 35
6a99f366
MK
36- if (s.type == TYPE_XINETD)
37- return 0;
f20fb8bf
JR
38 checkRoot();
39
40 if (s.isLSB) {
6a99f366
MK
41@@ -373,9 +369,6 @@ static int overrideService(char *name, i
42 return 0;
09a63b21 43 }
f20fb8bf 44
6a99f366
MK
45- if (s.type == TYPE_XINETD)
46- return 0;
f20fb8bf
JR
47-
48 checkRoot();
09a63b21 49
6a99f366
MK
50 if ((s.levels == o.levels) && (s.kPriority == o.kPriority) &&
51@@ -452,10 +445,6 @@ static int showServiceInfo(struct servic
82df657c
ER
52 }
53
54 printf("%-15s", s.name);
55- if (s.type == TYPE_XINETD) {
6a99f366
MK
56- printf("\t%s\n", s.levels ? _("on") : _("off"));
57- return 0;
82df657c
ER
58- }
59
09a63b21 60 for (i = 0; i < 7; i++) {
6a99f366
MK
61 printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
62@@ -469,8 +458,7 @@ static int showServiceInfoByName(char *n
5edaa756
ER
63 int rc;
64 struct service s;
65
6a99f366
MK
66- if (systemdActive() && isOverriddenBySystemd(name) &&
67- !(type & TYPE_XINETD)) {
5edaa756
ER
68+ if (systemdActive() && isOverriddenBySystemd(name)) {
69 return forgiving ? 0 : 1;
70 }
71
176c6fd2 72@@ -485,20 +473,6 @@ static int showServiceInfoByName(char *n
bcda1112 73 return showServiceInfo(s, forgiving);
82df657c
ER
74 }
75
76-static int isXinetdEnabled() {
6a99f366 77- struct service s;
f20fb8bf 78-
6a99f366
MK
79- if (isOverriddenBySystemd("xinetd") && isEnabledInSystemd("xinetd"))
80- return 1;
bcda1112 81-
6a99f366
MK
82- if (readServiceInfo("xinetd", TYPE_INIT_D, &s, 0)) {
83- return 0;
84- }
85- if (s.currentLevels)
86- return 1;
87- return 0;
09a63b21 88-}
82df657c 89-
6a99f366 90 static int serviceNameCmp(const void *a, const void *b) {
176c6fd2
JB
91 const struct service *first = a;
92 const struct service *second = b;
93@@ -534,56 +508,6 @@ static int listService(char *item, int t
94 }
f20fb8bf
JR
95 }
96 }
176c6fd2 97-
f20fb8bf 98- if (isXinetdEnabled() && type & TYPE_XINETD) {
6a99f366
MK
99- struct service *s, *t;
100-
101- printf("\n");
102- printf(_("xinetd based services:\n"));
103- if (!(dir = opendir(XINETDDIR))) {
104- fprintf(stderr, _("failed to open directory %s: %s\n"), XINETDDIR,
105- strerror(err));
106- return 1;
107- }
108- numServices = 0;
109- numServicesAlloced = 10;
110- s = malloc(sizeof(*s) * numServicesAlloced);
111-
112- while ((ent = readdir(dir))) {
113- const char *dn;
114-
115- /* Skip any file starting with a . */
116- if (ent->d_name[0] == '.')
117- continue;
118-
119- /* Skip files with known bad extensions */
120- if ((dn = strrchr(ent->d_name, '.')) != NULL &&
121- (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") ||
122- !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
123- continue;
124-
125- dn = ent->d_name + strlen(ent->d_name) - 1;
126- if (*dn == '~' || *dn == ',')
127- continue;
128-
129- if (numServices == numServicesAlloced) {
130- numServicesAlloced += 10;
131- s = realloc(s, numServicesAlloced * sizeof(*s));
132- }
133- if (readXinetdServiceInfo(ent->d_name, s + numServices) != -1)
134- numServices++;
135- }
136-
176c6fd2 137- qsort(s, numServices, sizeof(*s), serviceNameCmp);
6a99f366
MK
138- t = s;
139- for (i = 0; i < numServices; i++, s++) {
140- char *tmp = malloc(strlen(s->name) + 5);
141- sprintf(tmp, "%s:", s->name);
142- printf("\t%-15s\t%s\n", tmp, s->levels ? _("on") : _("off"));
143- }
144- closedir(dir);
145- free(t);
82df657c
ER
146- }
147 return 0;
148 }
149
176c6fd2 150@@ -646,11 +570,6 @@ int setService(char *name, int type, int
6a99f366 151 reloadSystemd();
f20fb8bf 152
6a99f366 153 return rc;
82df657c 154- } else if (s.type == TYPE_XINETD) {
6a99f366
MK
155- if (setXinetdService(s, state)) {
156- return 1;
157- }
158- system("/sbin/service xinetd reload >/dev/null 2>&1");
09a63b21 159 }
82df657c
ER
160
161 return 0;
176c6fd2 162@@ -658,8 +577,6 @@ int setService(char *name, int type, int
f20fb8bf
JR
163
164 void forwardSystemd(const char *name, int type, const char *verb) {
bcda1112 165 int socket = 0;
f20fb8bf
JR
166- if (type == TYPE_XINETD)
167- return;
bcda1112 168
f20fb8bf 169 if (!systemdIsInit())
6a99f366 170 return;
176c6fd2 171@@ -743,12 +660,10 @@ int main(int argc, const char **argv) {
6a99f366 172 usage(progname);
f20fb8bf
JR
173
174 if (typeString) {
6a99f366
MK
175- if (!strcmp(typeString, "xinetd"))
176- type = TYPE_XINETD;
177- else if (!strcmp(typeString, "sysv"))
178+ if (!strcmp(typeString, "sysv"))
179 type = TYPE_INIT_D;
180 else {
181- fprintf(stderr, _("--type must be 'sysv' or 'xinetd'\n"));
182+ fprintf(stderr, _("--type must be 'sysv'\n"));
183 exit(1);
184 }
f20fb8bf 185 }
176c6fd2 186@@ -873,16 +788,9 @@ int main(int argc, const char **argv) {
6a99f366
MK
187 rc = readServiceInfo(name, type, &s, 0);
188 if (rc)
189 return 1;
190- if (s.type == TYPE_XINETD) {
191- if (isXinetdEnabled())
192- return !s.levels;
193- else
194- return 1;
195- } else {
196 if (level == -1)
197 level = currentRunlevel();
198 return s.currentLevels & (1 << level) ? 0 : 1;
199- }
200 } else if (!strcmp(state, "on")) {
201 if (!noRedirectItem) {
202 forwardSystemd(name, type, "enable");
203diff -urNpa chkconfig-1.15.orig/leveldb.c chkconfig-1.15/leveldb.c
204--- chkconfig-1.15.orig/leveldb.c 2021-05-03 16:40:14.588185842 +0200
205+++ chkconfig-1.15/leveldb.c 2021-05-03 17:50:29.728139905 +0200
206@@ -204,114 +204,6 @@ int readDescription(char *start, char *b
207 return 0;
82df657c
ER
208 }
209
6a99f366
MK
210-int readXinetdServiceInfo(char *name, struct service *service) {
211- char *filename;
212- int fd;
213- struct service serv = {
214- name : NULL,
215- levels : -1,
216- kPriority : 100,
217- sPriority : -1,
218- desc : NULL,
219- startDeps : NULL,
220- stopDeps : NULL,
221- softStartDeps : NULL,
222- softStopDeps : NULL,
223- provides : NULL,
224- type : TYPE_XINETD,
225- isLSB : 0,
226- enabled : -1
227- };
228- struct stat sb;
229- char *buf = NULL, *ptr;
230- char *eng_desc = NULL, *start;
231-
232- asprintf(&filename, XINETDDIR "/%s", name);
82df657c 233-
6a99f366
MK
234- if ((fd = open(filename, O_RDONLY)) < 0)
235- goto out_err;
236- fstat(fd, &sb);
237- if (!S_ISREG(sb.st_mode))
238- goto out_err;
239- buf = malloc(sb.st_size + 1);
240- if (read(fd, buf, sb.st_size) != sb.st_size)
241- goto out_err;
242- close(fd);
243- serv.name = strdup(name);
244- buf[sb.st_size] = '\0';
245- start = buf;
246- while (buf) {
247- ptr = strchr(buf, '\n');
248- if (*buf == '#') {
249- buf++;
250- while (isspace(*buf) && buf < ptr)
251- buf++;
252- if (!strncmp(buf, "default:", 9)) {
253- buf += 8;
254- while (isspace(*buf))
255- buf++;
256- if (!strncmp(buf + 9, "on", 2)) {
257- serv.enabled = 1;
258- } else {
259- serv.enabled = 0;
260- }
261- } else if (!strncmp(buf, "description:", 12)) {
262- buf += 11;
263- if (readDescription(buf, start + sb.st_size, &serv.desc,
264- &eng_desc)) {
265- if (serv.desc)
266- free(serv.desc);
267- }
268- if (!serv.desc) {
269- if (eng_desc)
270- serv.desc = eng_desc;
271- else
272- serv.desc = strdup(name);
273- } else if (eng_desc)
274- free(eng_desc);
275- }
276- if (ptr) {
277- *ptr = '\0';
278- ptr++;
279- }
280- buf = ptr;
281- continue;
282- }
283- while (isspace(*buf) && buf < ptr)
284- buf++;
285- if (!strncmp(buf, "disable", 7)) {
286- buf = strstr(buf, "=");
287- if (buf)
288- do {
289- buf++;
290- } while (isspace(*buf));
291-
292- if (buf && strncmp(buf, "yes", 3)) {
293- serv.levels = parseLevels("0123456", 0);
294- if (serv.enabled == -1)
295- serv.enabled = 1;
296- } else {
297- serv.levels = 0;
298- if (serv.enabled == -1)
299- serv.enabled = 0;
300- }
301- }
302- if (ptr) {
303- *ptr = '\0';
304- ptr++;
305- }
306- buf = ptr;
307- }
308- *service = serv;
309- return 0;
f20fb8bf 310-out_err:
6a99f366
MK
311- if (fd >= 0)
312- close(fd);
313- free(buf);
314- free(filename);
315- return -1;
82df657c
ER
316-}
317-
f20fb8bf 318 int readServices(struct service **services) {
6a99f366
MK
319 DIR *dir;
320 struct dirent *ent;
321@@ -365,12 +257,12 @@ int readServiceInfo(char *name, int type
f20fb8bf 322 int parseret;
27ddd8a0 323
f20fb8bf 324 if (!(type & TYPE_INIT_D))
6a99f366
MK
325- goto try_xinetd;
326+ return -1;
f20fb8bf
JR
327
328 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
27ddd8a0 329
6a99f366
MK
330 if ((fd = open(filename, O_RDONLY)) < 0)
331- goto try_xinetd;
332+ return -1;
f20fb8bf
JR
333
334 free(filename);
27ddd8a0 335 parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
6a99f366 336@@ -410,12 +302,6 @@ int readServiceInfo(char *name, int type
f20fb8bf
JR
337 free(filename);
338 *service = serv;
339 return 0;
340-
341-try_xinetd:
342- free(filename);
343- if (!(type & TYPE_XINETD))
6a99f366
MK
344- return -1;
345- return readXinetdServiceInfo(name, service);
f20fb8bf
JR
346 }
347
6a99f366
MK
348 int readServiceDifferences(char *name, int type, struct service *service,
349@@ -426,12 +312,12 @@ int readServiceDifferences(char *name, i
f20fb8bf
JR
350 int parseret;
351
352 if (!(type & TYPE_INIT_D))
6a99f366
MK
353- goto try_xinetd;
354+ return -1;
f20fb8bf
JR
355
356 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
27ddd8a0
AM
357
358 if ((fd = open(filename, O_RDONLY)) < 0) {
6a99f366
MK
359- goto try_xinetd;
360+ return -1;
27ddd8a0
AM
361 }
362
f20fb8bf 363 free(filename);
6a99f366 364@@ -455,12 +341,6 @@ int readServiceDifferences(char *name, i
f20fb8bf
JR
365 *service = serv;
366 *service_overrides = serv_overrides;
367 return 0;
368-
369-try_xinetd:
370- free(filename);
371- if (!(type & TYPE_XINETD))
6a99f366
MK
372- return -1;
373- return readXinetdServiceInfo(name, service);
f20fb8bf
JR
374 }
375
376 static struct dep *parseDeps(char *pos, char *end) {
6a99f366 377@@ -863,68 +743,6 @@ int whatLevels(char *name) {
f20fb8bf 378 return ret;
82df657c
ER
379 }
380
381-int setXinetdService(struct service s, int on) {
6a99f366
MK
382- int oldfd, newfd;
383- char oldfname[100], newfname[100];
384- char tmpstr[50];
385- char *buf, *ptr, *tmp;
386- struct stat sb;
387- mode_t mode;
388- int r;
389-
390- if (on == -1) {
391- on = s.enabled ? 1 : 0;
392- }
393- snprintf(oldfname, 100, "%s/%s", XINETDDIR, s.name);
394- if ((oldfd = open(oldfname, O_RDONLY)) == -1) {
395- return -1;
396- }
397- fstat(oldfd, &sb);
398- buf = malloc(sb.st_size + 1);
399- if (read(oldfd, buf, sb.st_size) != sb.st_size) {
400- close(oldfd);
401- free(buf);
402- return -1;
403- }
404- close(oldfd);
405- buf[sb.st_size] = '\0';
406- snprintf(newfname, 100, "%s/%s.XXXXXX", XINETDDIR, s.name);
407- mode = umask(S_IRWXG | S_IRWXO);
408- newfd = mkstemp(newfname);
409- umask(mode);
410- if (newfd == -1) {
411- free(buf);
412- return -1;
413- }
414- while (buf) {
415- tmp = buf;
416- ptr = strchr(buf, '\n');
417- if (ptr) {
418- *ptr = '\0';
419- ptr++;
420- }
421- while (isspace(*buf))
422- buf++;
423- if (strncmp(buf, "disable", 7) && strlen(buf)) {
424- write(newfd, tmp, strlen(tmp));
425- write(newfd, "\n", 1);
426- if (buf[0] == '{') {
427- snprintf(tmpstr, 50, "\tdisable\t= %s", on ? "no" : "yes");
428- write(newfd, tmpstr, strlen(tmpstr));
429- write(newfd, "\n", 1);
430- }
431- }
432- buf = ptr;
433- }
434- close(newfd);
435- unlink(oldfname);
436- r = rename(newfname, oldfname);
437- if (selinux_restore(oldfname) != 0)
438- fprintf(stderr, _("Unable to set SELinux context for %s: %s\n"),
439- oldfname, strerror(errno));
440- return (r);
82df657c
ER
441-}
442-
443 int doSetService(struct service s, int level, int on) {
444 int priority = on ? s.sPriority : s.kPriority;
445 char linkname[200];
6a99f366
MK
446diff -urNpa chkconfig-1.15.orig/leveldb.h chkconfig-1.15/leveldb.h
447--- chkconfig-1.15.orig/leveldb.h 2021-01-21 09:19:06.000000000 +0100
448+++ chkconfig-1.15/leveldb.h 2021-05-03 17:47:25.388139905 +0200
5edaa756 449@@ -17,14 +17,12 @@
f20fb8bf
JR
450 #define H_LEVELDB
451
452 #define RUNLEVELS "/etc"
453-#define XINETDDIR "/etc/xinetd.d"
454
455 #include <glob.h>
456
6a99f366
MK
457 #define TYPE_INIT_D 0x1
458-#define TYPE_XINETD 0x2
459 #define TYPE_SYSTEMD 0x4
460-#define TYPE_ANY (TYPE_INIT_D | TYPE_XINETD | TYPE_SYSTEMD)
461+#define TYPE_ANY (TYPE_INIT_D | TYPE_SYSTEMD)
f20fb8bf
JR
462
463 #ifndef SYSTEMD_SERVICE_PATH
464 #define SYSTEMD_SERVICE_PATH "/lib/systemd/system"
6a99f366
MK
465@@ -71,8 +69,6 @@ int isConfigured(char *name, int level,
466 int whatLevels(char *name);
f20fb8bf 467 int doSetService(struct service s, int level, int on);
6a99f366 468 int findServiceEntries(char *name, int level, glob_t *globresptr);
f20fb8bf
JR
469-int readXinetdServiceInfo(char *name, struct service *service);
470-int setXinetdService(struct service s, int on);
471 int systemdIsInit();
472 int systemdActive();
473 int isOverriddenBySystemd(const char *service);
6a99f366
MK
474diff -urNpa chkconfig-1.15.orig/ntsysv.c chkconfig-1.15/ntsysv.c
475--- chkconfig-1.15.orig/ntsysv.c 2021-01-21 09:19:06.000000000 +0100
476+++ chkconfig-1.15/ntsysv.c 2021-05-03 17:45:56.483139905 +0200
477@@ -69,19 +69,13 @@ static int servicesWindow(struct service
478 newtCompactButton(-1, count,
479 services[i].type == TYPE_INIT_D
480 ? "SysV initscripts"
481- : services[i].type == TYPE_XINETD
482- ? "xinetd services"
483 : services[i].type == TYPE_SYSTEMD
484 ? "systemd services"
485 : "Unknown"));
486 count++;
487 last = services[i].type;
5edaa756 488 }
6a99f366
MK
489- if (services[i].type == TYPE_XINETD) {
490- checkboxes[i] =
491- newtCheckbox(-1, count, services[i].name,
492- services[i].levels ? '*' : ' ', NULL, states + i);
493- } else if (services[i].type == TYPE_SYSTEMD) {
494+ if (services[i].type == TYPE_SYSTEMD) {
495 checkboxes[i] =
496 newtCheckbox(-1, count, services[i].name,
497 services[i].enabled ? '*' : ' ', NULL, states + i);
498@@ -150,11 +144,7 @@ static int servicesWindow(struct service
499 return 1;
27ddd8a0
AM
500
501 for (i = 0; i < numServices; i++) {
6a99f366
MK
502- if (services[i].type == TYPE_XINETD) {
503- if ((services[i].enabled && states[i] != '*') ||
504- (!services[i].enabled && states[i] == '*'))
505- setXinetdService(services[i], states[i] == '*');
506- } else if (services[i].type == TYPE_SYSTEMD) {
507+ if (services[i].type == TYPE_SYSTEMD) {
508 char *cmd = NULL;
509 int en = 0;
510 if (services[i].enabled && states[i] != '*')
511@@ -368,50 +358,6 @@ static int getServices(struct service **
27ddd8a0
AM
512
513 closedir(dir);
bcda1112 514
6a99f366
MK
515- if (!stat("/usr/sbin/xinetd", &sb)) {
516- if (!(dir = opendir(XINETDDIR))) {
517- fprintf(stderr, "failed to open " XINETDDIR ": %s\n",
518- strerror(errno));
519- return 2;
520- }
521-
522- while ((ent = readdir(dir))) {
523- if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
524- strchr(ent->d_name, '.'))
525- continue;
526-
527- sprintf(fn, "%s/%s", XINETDDIR, ent->d_name);
528- if (stat(fn, &sb)) {
529- err = errno;
530- continue;
531- }
532- if (!S_ISREG(sb.st_mode))
533- continue;
534-
535- if (numServices == numServicesAlloced) {
536- numServicesAlloced += 10;
537- services =
538- realloc(services, numServicesAlloced * sizeof(*services));
539- }
540-
541- rc = readXinetdServiceInfo(ent->d_name, services + numServices);
542-
543- if (rc == -1) {
544- fprintf(stderr, _("error reading info for service %s: %s\n"),
545- ent->d_name, strerror(errno));
546- closedir(dir);
547- return 2;
548- } else if (!rc)
549- numServices++;
550- }
551-
552- if (err) {
553- fprintf(stderr, _("error reading from directory %s: %s\n"),
554- XINETDDIR, strerror(err));
555- return 1;
556- }
27ddd8a0 557- }
bcda1112 558-
5edaa756 559 getSystemdServices(&services, &numServices);
564d2f1f 560
5edaa756 561 qsort(services, numServices, sizeof(*services), serviceNameCmp);
This page took 0.179074 seconds and 4 git commands to generate.