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
4 an already-started service, and will not re-stop a service that is
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.
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
19 \fB-\-level \fIlevels\fR
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
23 readServiceError(rc, name);
26 - if (s.type == TYPE_XINETD) return 0;
34 - if (s.type == TYPE_XINETD) return 0;
42 - if (s.type == TYPE_XINETD) return 0;
46 if ((s.levels == o.levels) &&
50 printf("%-15s", s.name);
51 - if (s.type == TYPE_XINETD) {
52 - printf("\t%s\n", s.levels ? _("on") : _("off"));
56 for (i = 0; i < 7; i++) {
57 printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
62 - if (systemdActive() && isOverriddenBySystemd(name) && !(type & TYPE_XINETD)) {
63 + if (systemdActive() && isOverriddenBySystemd(name)) {
64 return forgiving ? 0 : 1;
68 return showServiceInfo(s, forgiving);
72 -static int isXinetdEnabled() {
75 - if (isOverriddenBySystemd("xinetd") && isEnabledInSystemd("xinetd"))
78 - if (readServiceInfo("xinetd", TYPE_INIT_D, &s, 0)) {
81 - if (s.currentLevels)
86 static int serviceNameCmp(const void * a, const void * b) {
87 return strcmp(* (char **)a, * (char **)b);
90 -static int xinetdNameCmp(const void * a, const void * b) {
91 - const struct service * first = a;
92 - const struct service * second = b;
94 - return strcmp(first->name, second->name);
98 static int listService(char * item, int type) {
106 - if (isXinetdEnabled() && type & TYPE_XINETD) {
107 - struct service *s, *t;
110 - printf(_("xinetd based services:\n"));
111 - if (!(dir = opendir(XINETDDIR))) {
112 - fprintf(stderr, _("failed to open directory %s: %s\n"),
113 - XINETDDIR, strerror(err));
117 - numServicesAlloced = 10;
118 - s = malloc(sizeof (*s) * numServicesAlloced);
120 - while ((ent = readdir(dir))) {
123 - /* Skip any file starting with a . */
124 - if (ent->d_name[0] == '.') continue;
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")))
131 - dn = ent->d_name + strlen(ent->d_name) - 1;
132 - if (*dn == '~' || *dn == ',')
135 - if (numServices == numServicesAlloced) {
136 - numServicesAlloced += 10;
137 - s = realloc(s, numServicesAlloced * sizeof (*s));
139 - if (readXinetdServiceInfo(ent->d_name, s + numServices) != -1)
143 - qsort(s, numServices, sizeof(*s), xinetdNameCmp);
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"));
160 - } else if (s.type == TYPE_XINETD) {
161 - if (setXinetdService(s, state)) {
164 - system("/sbin/service xinetd reload >/dev/null 2>&1");
170 void forwardSystemd(const char *name, int type, const char *verb) {
172 - if (type == TYPE_XINETD)
175 if (!systemdIsInit())
177 @@ -704,12 +618,10 @@
178 if (help) usage(progname);
181 - if (!strcmp(typeString, "xinetd"))
182 - type = TYPE_XINETD;
183 - else if (!strcmp(typeString, "sysv"))
184 + if (!strcmp(typeString, "sysv"))
187 - fprintf(stderr, _("--type must be 'sysv' or 'xinetd'\n"));
188 + fprintf(stderr, _("--type must be 'sysv'\n"));
193 rc = readServiceInfo(name, type, &s, 0);
196 - if (s.type == TYPE_XINETD) {
197 - if (isOn("xinetd",level))
203 level = currentRunlevel();
204 return s.currentLevels & (1 << level) ? 0 : 1;
206 } else if (!strcmp(state, "on")) {
207 if (!noRedirectItem) {
208 forwardSystemd(name, type, "enable");
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
211 @@ -154,107 +154,6 @@
215 -int readXinetdServiceInfo(char *name, struct service * service) {
218 - struct service serv = {
226 - softStartDeps: NULL,
227 - softStopDeps: NULL,
234 - char * buf = NULL, *ptr;
235 - char * eng_desc = NULL, *start;
237 - asprintf(&filename, XINETDDIR "/%s", name);
239 - if ((fd = open(filename, O_RDONLY)) < 0) goto out_err;
241 - if (! S_ISREG(sb.st_mode)) goto out_err;
242 - buf = malloc(sb.st_size+1);
243 - if (read(fd,buf,sb.st_size)!=sb.st_size) goto out_err;
245 - serv.name = strdup(name);
246 - buf[sb.st_size] = '\0';
249 - ptr = strchr(buf,'\n');
252 - while (isspace(*buf) && buf < ptr) buf++;
253 - if (!strncmp(buf,"default:", 9)) {
255 - while(isspace(*buf)) buf++;
256 - if (!strncmp(buf+9,"on",2)) {
261 - } else if (!strncmp(buf,"description:",12)) {
263 - if (readDescription(buf,start+sb.st_size,
264 - &serv.desc,&eng_desc)) {
265 - if (serv.desc) free(serv.desc);
269 - serv.desc = eng_desc;
271 - serv.desc = strdup(name);
272 - } else if (eng_desc)
282 - while (isspace(*buf) && buf < ptr) buf++;
283 - if (!strncmp(buf,"disable", 7)) {
284 - buf = strstr(buf,"=");
288 - } while(isspace(*buf));
290 - if (buf && strncmp(buf,"yes",3)) {
291 - serv.levels = parseLevels("0123456",0);
292 - if (serv.enabled == -1)
296 - if (serv.enabled == -1)
316 int readServices(struct service **services) {
319 @@ -304,12 +203,14 @@
322 if (!(type & TYPE_INIT_D))
326 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
328 - if ((fd = open(filename, O_RDONLY)) < 0)
330 + if ((fd = open(filename, O_RDONLY)) < 0) {
336 parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
344 - if (!(type & TYPE_XINETD))
346 - return readXinetdServiceInfo(name,service);
349 int readServiceDifferences(char * name, int type, struct service * service, struct service * service_overrides, int honorHide) {
350 @@ -353,12 +248,13 @@
353 if (!(type & TYPE_INIT_D))
357 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
359 if ((fd = open(filename, O_RDONLY)) < 0) {
368 *service_overrides = serv_overrides;
373 - if (!(type & TYPE_XINETD))
375 - return readXinetdServiceInfo(name,service);
378 static struct dep *parseDeps(char *pos, char *end) {
383 -int setXinetdService(struct service s, int on) {
385 - char oldfname[100], newfname[100];
387 - char *buf, *ptr, *tmp;
393 - on = s.enabled ? 1 : 0;
395 - snprintf(oldfname,100,"%s/%s",XINETDDIR,s.name);
396 - if ( (oldfd = open(oldfname,O_RDONLY)) == -1 ) {
400 - buf = malloc(sb.st_size+1);
401 - if (read(oldfd,buf,sb.st_size)!=sb.st_size) {
407 - buf[sb.st_size] = '\0';
408 - snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name);
409 - mode = umask(S_IRWXG | S_IRWXO);
410 - newfd = mkstemp(newfname);
418 - ptr = strchr(buf,'\n');
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);
437 - r = rename(newfname,oldfname);
438 - if (selinux_restore(oldfname) != 0)
439 - fprintf(stderr, _("Unable to set selinux context for %s: %s\n"), oldfname,
444 int doSetService(struct service s, int level, int on) {
445 int priority = on ? s.sPriority : s.kPriority;
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
452 #define RUNLEVELS "/etc"
453 -#define XINETDDIR "/etc/xinetd.d"
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)
463 #ifndef SYSTEMD_SERVICE_PATH
464 #define SYSTEMD_SERVICE_PATH "/lib/systemd/system"
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);
473 int isOverriddenBySystemd(const char *service);
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
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":
484 last = services[i].type;
486 - if (services[i].type == TYPE_XINETD) {
487 - checkboxes[i] = newtCheckbox(-1, count, services[i].name,
488 - services[i].levels ? '*' : ' ', NULL,
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,
496 if (!update) return 1;
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] == '*');
503 - } else if (services[i].type == TYPE_SYSTEMD) {
504 + if (services[i].type == TYPE_SYSTEMD) {
507 if (services[i].enabled && states[i] != '*')
512 - if (!stat("/usr/sbin/xinetd",&sb)) {
513 - if (!(dir = opendir(XINETDDIR))) {
514 - fprintf(stderr, "failed to open " XINETDDIR ": %s\n",
519 - while ((ent = readdir(dir))) {
520 - if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
521 - strchr(ent->d_name, '.')) continue;
523 - sprintf(fn, "%s/%s", XINETDDIR, ent->d_name);
529 - if (!S_ISREG(sb.st_mode)) continue;
531 - if (numServices == numServicesAlloced) {
532 - numServicesAlloced += 10;
533 - services = realloc(services,
534 - numServicesAlloced * sizeof(*services));
537 - rc = readXinetdServiceInfo(ent->d_name, services + numServices);
540 - fprintf(stderr, _("error reading info for service %s: %s\n"),
541 - ent->d_name, strerror(errno));
549 - fprintf(stderr, _("error reading from directory %s: %s\n"),
550 - XINETDDIR, strerror(err));
555 getSystemdServices(&services, &numServices);
557 qsort(services, numServices, sizeof(*services), serviceNameCmp);