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