1 diff -ur chkconfig-1.3.58/chkconfig.8 chkconfig-1.3.58-noxinet/chkconfig.8
2 --- chkconfig-1.3.58/chkconfig.8 2012-02-10 20:37:38.000000000 +0100
3 +++ chkconfig-1.3.58-noxinet/chkconfig.8 2012-12-17 15:22:31.472800234 +0100
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 -ur chkconfig-1.3.58/chkconfig.c chkconfig-1.3.58-noxinet/chkconfig.c
22 --- chkconfig-1.3.58/chkconfig.c 2012-12-17 15:22:52.589660844 +0100
23 +++ chkconfig-1.3.58-noxinet/chkconfig.c 2012-12-17 15:17:47.586865799 +0100
25 readServiceError(rc, name);
28 - if (s.type == TYPE_XINETD) return 0;
36 - if (s.type == TYPE_XINETD) return 0;
44 - if (s.type == TYPE_XINETD) return 0;
48 if ((s.levels == o.levels) &&
52 printf("%-15s", s.name);
53 - if (s.type == TYPE_XINETD) {
54 - printf("\t%s\n", s.levels ? _("on") : _("off"));
58 for (i = 0; i < 7; i++) {
59 printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
64 -static int isXinetdEnabled() {
67 - if (readServiceInfo("xinetd", TYPE_INIT_D, &s, 0)) {
70 - if (s.currentLevels)
75 static int serviceNameCmp(const void * a, const void * b) {
76 return strcmp(* (char **)a, * (char **)b);
79 -static int xinetdNameCmp(const void * a, const void * b) {
80 - const struct service * first = a;
81 - const struct service * second = b;
83 - return strcmp(first->name, second->name);
87 static int listService(char * item, int type) {
95 - if (isXinetdEnabled() && type & TYPE_XINETD) {
96 - struct service *s, *t;
99 - printf(_("xinetd based services:\n"));
100 - if (!(dir = opendir(XINETDDIR))) {
101 - fprintf(stderr, _("failed to open directory %s: %s\n"),
102 - XINETDDIR, strerror(err));
106 - numServicesAlloced = 10;
107 - s = malloc(sizeof (*s) * numServicesAlloced);
109 - while ((ent = readdir(dir))) {
112 - /* Skip any file starting with a . */
113 - if (ent->d_name[0] == '.') continue;
115 - /* Skip files with known bad extensions */
116 - if ((dn = strrchr(ent->d_name, '.')) != NULL &&
117 - (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") || !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
120 - dn = ent->d_name + strlen(ent->d_name) - 1;
121 - if (*dn == '~' || *dn == ',')
124 - if (numServices == numServicesAlloced) {
125 - numServicesAlloced += 10;
126 - s = realloc(s, numServicesAlloced * sizeof (*s));
128 - if (readXinetdServiceInfo(ent->d_name, s + numServices) != -1)
132 - qsort(s, numServices, sizeof(*s), xinetdNameCmp);
134 - for (i = 0; i < numServices; i++, s++) {
135 - char *tmp = malloc(strlen(s->name) + 5);
136 - sprintf(tmp,"%s:",s->name);
137 - printf("\t%-15s\t%s\n", tmp, s->levels ? _("on") : _("off"));
149 - } else if (s.type == TYPE_XINETD) {
150 - if (setXinetdService(s, state)) {
153 - system("/etc/init.d/xinetd reload >/dev/null 2>&1");
159 void forwardSystemd(const char *name, int type, const char *verb) {
161 - if (type == TYPE_XINETD)
164 if (!systemdIsInit())
167 @@ -683,12 +600,10 @@
171 - if (!strcmp(typeString, "xinetd"))
172 - type = TYPE_XINETD;
173 - else if (!strcmp(typeString, "sysv"))
174 + if (!strcmp(typeString, "sysv"))
177 - fprintf(stderr, _("--type must be 'sysv' or 'xinetd'\n"));
178 + fprintf(stderr, _("--type must be 'sysv'\n"));
183 rc = readServiceInfo(name, type, &s, 0);
186 - if (s.type == TYPE_XINETD) {
187 - if (isOn("xinetd",level))
193 level = currentRunlevel();
194 return s.currentLevels & (1 << level) ? 0 : 1;
196 } else if (!strcmp(state, "on")) {
197 if (!noRedirectItem) {
198 forwardSystemd(name, type, "enable");
199 diff -ur chkconfig-1.3.58/leveldb.c chkconfig-1.3.58-noxinet/leveldb.c
200 --- chkconfig-1.3.58/leveldb.c 2012-12-17 15:22:52.589660844 +0100
201 +++ chkconfig-1.3.58-noxinet/leveldb.c 2012-12-17 15:20:13.621535628 +0100
202 @@ -154,107 +154,6 @@
206 -int readXinetdServiceInfo(char *name, struct service * service) {
209 - struct service serv = {
217 - softStartDeps: NULL,
218 - softStopDeps: NULL,
225 - char * buf = NULL, *ptr;
226 - char * eng_desc = NULL, *start;
228 - asprintf(&filename, XINETDDIR "/%s", name);
230 - if ((fd = open(filename, O_RDONLY)) < 0) goto out_err;
232 - if (! S_ISREG(sb.st_mode)) goto out_err;
233 - buf = malloc(sb.st_size+1);
234 - if (read(fd,buf,sb.st_size)!=sb.st_size) goto out_err;
236 - serv.name = strdup(name);
237 - buf[sb.st_size] = '\0';
240 - ptr = strchr(buf,'\n');
243 - while (isspace(*buf) && buf < ptr) buf++;
244 - if (!strncmp(buf,"default:", 9)) {
246 - while(isspace(*buf)) buf++;
247 - if (!strncmp(buf+9,"on",2)) {
252 - } else if (!strncmp(buf,"description:",12)) {
254 - if (readDescription(buf,start+sb.st_size,
255 - &serv.desc,&eng_desc)) {
256 - if (serv.desc) free(serv.desc);
260 - serv.desc = eng_desc;
262 - serv.desc = strdup(name);
263 - } else if (eng_desc)
273 - while (isspace(*buf) && buf < ptr) buf++;
274 - if (!strncmp(buf,"disable", 7)) {
275 - buf = strstr(buf,"=");
279 - } while(isspace(*buf));
281 - if (buf && strncmp(buf,"yes",3)) {
282 - serv.levels = parseLevels("0123456",0);
283 - if (serv.enabled == -1)
287 - if (serv.enabled == -1)
307 int readServices(struct service **services) {
310 @@ -304,12 +203,14 @@
313 if (!(type & TYPE_INIT_D))
317 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
319 - if ((fd = open(filename, O_RDONLY)) < 0)
321 + if ((fd = open(filename, O_RDONLY)) < 0) {
327 parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
335 - if (!(type & TYPE_XINETD))
337 - return readXinetdServiceInfo(name,service);
340 int readServiceDifferences(char * name, int type, struct service * service, struct service * service_overrides, int honorHide) {
341 @@ -353,12 +248,13 @@
344 if (!(type & TYPE_INIT_D))
348 asprintf(&filename, RUNLEVELS "/init.d/%s", name);
350 if ((fd = open(filename, O_RDONLY)) < 0) {
359 *service_overrides = serv_overrides;
364 - if (!(type & TYPE_XINETD))
366 - return readXinetdServiceInfo(name,service);
369 static struct dep *parseDeps(char *pos, char *end) {
374 -int setXinetdService(struct service s, int on) {
376 - char oldfname[100], newfname[100];
378 - char *buf, *ptr, *tmp;
382 - on = s.enabled ? 1 : 0;
384 - snprintf(oldfname,100,"%s/%s",XINETDDIR,s.name);
385 - if ( (oldfd = open(oldfname,O_RDONLY)) == -1 ) {
389 - buf = malloc(sb.st_size+1);
390 - if (read(oldfd,buf,sb.st_size)!=sb.st_size) {
396 - buf[sb.st_size] = '\0';
397 - snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name);
398 - newfd = mkstemp(newfname);
405 - ptr = strchr(buf,'\n');
410 - while (isspace(*buf)) buf++;
411 - if (strncmp(buf,"disable", 7) && strlen(buf)) {
412 - write(newfd,tmp,strlen(tmp));
413 - write(newfd,"\n",1);
414 - if (buf[0] == '{') {
415 - snprintf(tmpstr,50,"\tdisable\t= %s", on ? "no" : "yes");
416 - write(newfd,tmpstr,strlen(tmpstr));
417 - write(newfd,"\n",1);
423 - chmod(newfname,0644);
425 - return(rename(newfname,oldfname));
428 int doSetService(struct service s, int level, int on) {
429 int priority = on ? s.sPriority : s.kPriority;
431 diff -ur chkconfig-1.3.58/leveldb.h chkconfig-1.3.58-noxinet/leveldb.h
432 --- chkconfig-1.3.58/leveldb.h 2012-12-17 15:22:52.592994208 +0100
433 +++ chkconfig-1.3.58-noxinet/leveldb.h 2012-12-17 15:20:38.435096400 +0100
437 #define RUNLEVELS "/etc"
438 -#define XINETDDIR "/etc/xinetd.d"
442 #define TYPE_INIT_D 0x1
443 -#define TYPE_XINETD 0x2
444 -#define TYPE_ANY (TYPE_INIT_D | TYPE_XINETD)
445 +#define TYPE_ANY (TYPE_INIT_D)
447 #ifndef SYSTEMD_SERVICE_PATH
448 #define SYSTEMD_SERVICE_PATH "/lib/systemd/system"
450 int whatLevels(char * name);
451 int doSetService(struct service s, int level, int on);
452 int findServiceEntries(char * name, int level, glob_t * globresptr);
453 -int readXinetdServiceInfo(char *name, struct service *service);
454 -int setXinetdService(struct service s, int on);
457 int isOverriddenBySystemd(const char *service);
458 diff -ur chkconfig-1.3.58/ntsysv.c chkconfig-1.3.58-noxinet/ntsysv.c
459 --- chkconfig-1.3.58/ntsysv.c 2012-02-10 20:37:38.000000000 +0100
460 +++ chkconfig-1.3.58-noxinet/ntsysv.c 2012-12-17 15:21:53.479118101 +0100
462 states = alloca(sizeof(*states) * numServices);
464 for (i = 0; i < numServices; i++) {
465 - if (services[i].type == TYPE_XINETD) {
466 - checkboxes[i] = newtCheckbox(-1, i, services[i].name,
467 - services[i].levels ? '*' : ' ', NULL,
470 checkboxes[i] = newtCheckbox(-1, i, services[i].name,
471 (services[i].currentLevels & levels) ? '*' : ' ', NULL,
474 newtFormAddComponent(subform, checkboxes[i]);
478 if (!update) return 1;
480 for (i = 0; i < numServices; i++) {
481 - if (services[i].type == TYPE_XINETD) {
482 - if ((services[i].enabled && states[i] != '*') ||
483 - (!services[i].enabled && states[i] == '*'))
484 - setXinetdService(services[i], states[i] == '*');
486 for (j = 0; j < 7; j++) {
487 if (levels & (1 << j))
488 doSetService(services[i], j, states[i] == '*');
498 - if (!stat("/usr/sbin/xinetd",&sb)) {
499 - if (!(dir = opendir(XINETDDIR))) {
500 - fprintf(stderr, "failed to open " XINETDDIR ": %s\n",
505 - while ((ent = readdir(dir))) {
506 - if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
507 - strchr(ent->d_name, '.')) continue;
509 - sprintf(fn, "%s/%s", XINETDDIR, ent->d_name);
515 - if (!S_ISREG(sb.st_mode)) continue;
517 - if (numServices == numServicesAlloced) {
518 - numServicesAlloced += 10;
519 - services = realloc(services,
520 - numServicesAlloced * sizeof(*services));
523 - rc = readXinetdServiceInfo(ent->d_name, services + numServices);
526 - fprintf(stderr, _("error reading info for service %s: %s\n"),
527 - ent->d_name, strerror(errno));
535 - fprintf(stderr, _("error reading from directory %s: %s\n"),
536 - XINETDDIR, strerror(err));
541 qsort(services, numServices, sizeof(*services), serviceNameCmp);