1 diff -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
5 an already-started service, and will not re-stop a service that is
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.
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
20 \fB-\-level \fIlevels\fR
21 diff -urNpa chkconfig-1.15.orig/chkconfig.c chkconfig-1.15/chkconfig.c
22 --- chkconfig-1.15.orig/chkconfig.c 2021-05-03 16:44:13.175185842 +0200
23 +++ chkconfig-1.15/chkconfig.c 2021-05-03 17:27:19.517139905 +0200
24 @@ -117,8 +117,6 @@ static int delService(char *name, int ty
25 readServiceError(rc, name);
28 - if (s.type == TYPE_XINETD)
33 @@ -333,8 +331,6 @@ static int addService(char *name, int ty
37 - if (s.type == TYPE_XINETD)
42 @@ -373,9 +369,6 @@ static int overrideService(char *name, i
46 - if (s.type == TYPE_XINETD)
51 if ((s.levels == o.levels) && (s.kPriority == o.kPriority) &&
52 @@ -452,10 +445,6 @@ static int showServiceInfo(struct servic
55 printf("%-15s", s.name);
56 - if (s.type == TYPE_XINETD) {
57 - printf("\t%s\n", s.levels ? _("on") : _("off"));
61 for (i = 0; i < 7; i++) {
62 printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
63 @@ -469,8 +458,7 @@ static int showServiceInfoByName(char *n
67 - if (systemdActive() && isOverriddenBySystemd(name) &&
68 - !(type & TYPE_XINETD)) {
69 + if (systemdActive() && isOverriddenBySystemd(name)) {
70 return forgiving ? 0 : 1;
73 @@ -485,31 +473,10 @@ static int showServiceInfoByName(char *n
74 return showServiceInfo(s, forgiving);
77 -static int isXinetdEnabled() {
80 - if (isOverriddenBySystemd("xinetd") && isEnabledInSystemd("xinetd"))
83 - if (readServiceInfo("xinetd", TYPE_INIT_D, &s, 0)) {
86 - if (s.currentLevels)
91 static int serviceNameCmp(const void *a, const void *b) {
92 return strcmp(*(char **)a, *(char **)b);
95 -static int xinetdNameCmp(const void *a, const void *b) {
96 - const struct service *first = a;
97 - const struct service *second = b;
99 - return strcmp(first->name, second->name);
102 static int listService(char *item, int type) {
105 @@ -539,55 +506,6 @@ static int listService(char *item, int t
109 - if (isXinetdEnabled() && type & TYPE_XINETD) {
110 - struct service *s, *t;
113 - printf(_("xinetd based services:\n"));
114 - if (!(dir = opendir(XINETDDIR))) {
115 - fprintf(stderr, _("failed to open directory %s: %s\n"), XINETDDIR,
120 - numServicesAlloced = 10;
121 - s = malloc(sizeof(*s) * numServicesAlloced);
123 - while ((ent = readdir(dir))) {
126 - /* Skip any file starting with a . */
127 - if (ent->d_name[0] == '.')
130 - /* Skip files with known bad extensions */
131 - if ((dn = strrchr(ent->d_name, '.')) != NULL &&
132 - (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") ||
133 - !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
136 - dn = ent->d_name + strlen(ent->d_name) - 1;
137 - if (*dn == '~' || *dn == ',')
140 - if (numServices == numServicesAlloced) {
141 - numServicesAlloced += 10;
142 - s = realloc(s, numServicesAlloced * sizeof(*s));
144 - if (readXinetdServiceInfo(ent->d_name, s + numServices) != -1)
148 - qsort(s, numServices, sizeof(*s), xinetdNameCmp);
150 - for (i = 0; i < numServices; i++, s++) {
151 - char *tmp = malloc(strlen(s->name) + 5);
152 - sprintf(tmp, "%s:", s->name);
153 - printf("\t%-15s\t%s\n", tmp, s->levels ? _("on") : _("off"));
161 @@ -650,11 +568,6 @@ int setService(char *name, int type, int
165 - } else if (s.type == TYPE_XINETD) {
166 - if (setXinetdService(s, state)) {
169 - system("/sbin/service xinetd reload >/dev/null 2>&1");
173 @@ -662,8 +575,6 @@ int setService(char *name, int type, int
175 void forwardSystemd(const char *name, int type, const char *verb) {
177 - if (type == TYPE_XINETD)
180 if (!systemdIsInit())
182 @@ -747,12 +658,10 @@ int main(int argc, const char **argv) {
186 - if (!strcmp(typeString, "xinetd"))
187 - type = TYPE_XINETD;
188 - else if (!strcmp(typeString, "sysv"))
189 + if (!strcmp(typeString, "sysv"))
192 - fprintf(stderr, _("--type must be 'sysv' or 'xinetd'\n"));
193 + fprintf(stderr, _("--type must be 'sysv'\n"));
197 @@ -877,16 +786,9 @@ int main(int argc, const char **argv) {
198 rc = readServiceInfo(name, type, &s, 0);
201 - if (s.type == TYPE_XINETD) {
202 - if (isXinetdEnabled())
208 level = currentRunlevel();
209 return s.currentLevels & (1 << level) ? 0 : 1;
211 } else if (!strcmp(state, "on")) {
212 if (!noRedirectItem) {
213 forwardSystemd(name, type, "enable");
214 diff -urNpa chkconfig-1.15.orig/leveldb.c chkconfig-1.15/leveldb.c
215 --- chkconfig-1.15.orig/leveldb.c 2021-05-03 16:40:14.588185842 +0200
216 +++ chkconfig-1.15/leveldb.c 2021-05-03 17:50:29.728139905 +0200
217 @@ -204,114 +204,6 @@ int readDescription(char *start, char *b
221 -int readXinetdServiceInfo(char *name, struct service *service) {
224 - struct service serv = {
232 - softStartDeps : NULL,
233 - softStopDeps : NULL,
235 - type : TYPE_XINETD,
240 - char *buf = NULL, *ptr;
241 - char *eng_desc = NULL, *start;
243 - asprintf(&filename, XINETDDIR "/%s", name);
245 - if ((fd = open(filename, O_RDONLY)) < 0)
248 - if (!S_ISREG(sb.st_mode))
250 - buf = malloc(sb.st_size + 1);
251 - if (read(fd, buf, sb.st_size) != sb.st_size)
254 - serv.name = strdup(name);
255 - buf[sb.st_size] = '\0';
258 - ptr = strchr(buf, '\n');
261 - while (isspace(*buf) && buf < ptr)
263 - if (!strncmp(buf, "default:", 9)) {
265 - while (isspace(*buf))
267 - if (!strncmp(buf + 9, "on", 2)) {
272 - } else if (!strncmp(buf, "description:", 12)) {
274 - if (readDescription(buf, start + sb.st_size, &serv.desc,
281 - serv.desc = eng_desc;
283 - serv.desc = strdup(name);
284 - } else if (eng_desc)
294 - while (isspace(*buf) && buf < ptr)
296 - if (!strncmp(buf, "disable", 7)) {
297 - buf = strstr(buf, "=");
301 - } while (isspace(*buf));
303 - if (buf && strncmp(buf, "yes", 3)) {
304 - serv.levels = parseLevels("0123456", 0);
305 - if (serv.enabled == -1)
309 - if (serv.enabled == -1)
329 int readServices(struct service **services) {
332 @@ -365,12 +257,12 @@ int readServiceInfo(char *name, int type
335 if (!(type & TYPE_INIT_D))
339 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
341 if ((fd = open(filename, O_RDONLY)) < 0)
346 parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
347 @@ -410,12 +302,6 @@ int readServiceInfo(char *name, int type
354 - if (!(type & TYPE_XINETD))
356 - return readXinetdServiceInfo(name, service);
359 int readServiceDifferences(char *name, int type, struct service *service,
360 @@ -426,12 +312,12 @@ int readServiceDifferences(char *name, i
363 if (!(type & TYPE_INIT_D))
367 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
369 if ((fd = open(filename, O_RDONLY)) < 0) {
375 @@ -455,12 +341,6 @@ int readServiceDifferences(char *name, i
377 *service_overrides = serv_overrides;
382 - if (!(type & TYPE_XINETD))
384 - return readXinetdServiceInfo(name, service);
387 static struct dep *parseDeps(char *pos, char *end) {
388 @@ -863,68 +743,6 @@ int whatLevels(char *name) {
392 -int setXinetdService(struct service s, int on) {
394 - char oldfname[100], newfname[100];
396 - char *buf, *ptr, *tmp;
402 - on = s.enabled ? 1 : 0;
404 - snprintf(oldfname, 100, "%s/%s", XINETDDIR, s.name);
405 - if ((oldfd = open(oldfname, O_RDONLY)) == -1) {
409 - buf = malloc(sb.st_size + 1);
410 - if (read(oldfd, buf, sb.st_size) != sb.st_size) {
416 - buf[sb.st_size] = '\0';
417 - snprintf(newfname, 100, "%s/%s.XXXXXX", XINETDDIR, s.name);
418 - mode = umask(S_IRWXG | S_IRWXO);
419 - newfd = mkstemp(newfname);
427 - ptr = strchr(buf, '\n');
432 - while (isspace(*buf))
434 - if (strncmp(buf, "disable", 7) && strlen(buf)) {
435 - write(newfd, tmp, strlen(tmp));
436 - write(newfd, "\n", 1);
437 - if (buf[0] == '{') {
438 - snprintf(tmpstr, 50, "\tdisable\t= %s", on ? "no" : "yes");
439 - write(newfd, tmpstr, strlen(tmpstr));
440 - write(newfd, "\n", 1);
447 - r = rename(newfname, oldfname);
448 - if (selinux_restore(oldfname) != 0)
449 - fprintf(stderr, _("Unable to set SELinux context for %s: %s\n"),
450 - oldfname, strerror(errno));
454 int doSetService(struct service s, int level, int on) {
455 int priority = on ? s.sPriority : s.kPriority;
457 diff -urNpa chkconfig-1.15.orig/leveldb.h chkconfig-1.15/leveldb.h
458 --- chkconfig-1.15.orig/leveldb.h 2021-01-21 09:19:06.000000000 +0100
459 +++ chkconfig-1.15/leveldb.h 2021-05-03 17:47:25.388139905 +0200
463 #define RUNLEVELS "/etc"
464 -#define XINETDDIR "/etc/xinetd.d"
468 #define TYPE_INIT_D 0x1
469 -#define TYPE_XINETD 0x2
470 #define TYPE_SYSTEMD 0x4
471 -#define TYPE_ANY (TYPE_INIT_D | TYPE_XINETD | TYPE_SYSTEMD)
472 +#define TYPE_ANY (TYPE_INIT_D | TYPE_SYSTEMD)
474 #ifndef SYSTEMD_SERVICE_PATH
475 #define SYSTEMD_SERVICE_PATH "/lib/systemd/system"
476 @@ -71,8 +69,6 @@ int isConfigured(char *name, int level,
477 int whatLevels(char *name);
478 int doSetService(struct service s, int level, int on);
479 int findServiceEntries(char *name, int level, glob_t *globresptr);
480 -int readXinetdServiceInfo(char *name, struct service *service);
481 -int setXinetdService(struct service s, int on);
484 int isOverriddenBySystemd(const char *service);
485 diff -urNpa chkconfig-1.15.orig/ntsysv.c chkconfig-1.15/ntsysv.c
486 --- chkconfig-1.15.orig/ntsysv.c 2021-01-21 09:19:06.000000000 +0100
487 +++ chkconfig-1.15/ntsysv.c 2021-05-03 17:45:56.483139905 +0200
488 @@ -69,19 +69,13 @@ static int servicesWindow(struct service
489 newtCompactButton(-1, count,
490 services[i].type == TYPE_INIT_D
492 - : services[i].type == TYPE_XINETD
493 - ? "xinetd services"
494 : services[i].type == TYPE_SYSTEMD
498 last = services[i].type;
500 - if (services[i].type == TYPE_XINETD) {
502 - newtCheckbox(-1, count, services[i].name,
503 - services[i].levels ? '*' : ' ', NULL, states + i);
504 - } else if (services[i].type == TYPE_SYSTEMD) {
505 + if (services[i].type == TYPE_SYSTEMD) {
507 newtCheckbox(-1, count, services[i].name,
508 services[i].enabled ? '*' : ' ', NULL, states + i);
509 @@ -150,11 +144,7 @@ static int servicesWindow(struct service
512 for (i = 0; i < numServices; i++) {
513 - if (services[i].type == TYPE_XINETD) {
514 - if ((services[i].enabled && states[i] != '*') ||
515 - (!services[i].enabled && states[i] == '*'))
516 - setXinetdService(services[i], states[i] == '*');
517 - } else if (services[i].type == TYPE_SYSTEMD) {
518 + if (services[i].type == TYPE_SYSTEMD) {
521 if (services[i].enabled && states[i] != '*')
522 @@ -368,50 +358,6 @@ static int getServices(struct service **
526 - if (!stat("/usr/sbin/xinetd", &sb)) {
527 - if (!(dir = opendir(XINETDDIR))) {
528 - fprintf(stderr, "failed to open " XINETDDIR ": %s\n",
533 - while ((ent = readdir(dir))) {
534 - if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
535 - strchr(ent->d_name, '.'))
538 - sprintf(fn, "%s/%s", XINETDDIR, ent->d_name);
539 - if (stat(fn, &sb)) {
543 - if (!S_ISREG(sb.st_mode))
546 - if (numServices == numServicesAlloced) {
547 - numServicesAlloced += 10;
549 - realloc(services, numServicesAlloced * sizeof(*services));
552 - rc = readXinetdServiceInfo(ent->d_name, services + numServices);
555 - fprintf(stderr, _("error reading info for service %s: %s\n"),
556 - ent->d_name, strerror(errno));
564 - fprintf(stderr, _("error reading from directory %s: %s\n"),
565 - XINETDDIR, strerror(err));
570 getSystemdServices(&services, &numServices);
572 qsort(services, numServices, sizeof(*services), serviceNameCmp);