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