1 --- chkconfig-1.3.37.org/chkconfig.c 2007-11-08 22:28:34.000000000 +0100
2 +++ chkconfig-1.3.37/chkconfig.c 2008-04-24 09:30:17.709152778 +0200
4 readServiceError(rc, name);
7 - if (s.type == TYPE_XINETD) return 0;
10 if (!findServiceEntries(name, level, &globres)) {
11 for (i = 0; i < globres.gl_pathc; i++)
13 readServiceError(rc, name);
16 - if (s.type == TYPE_XINETD) return 0;
18 for (level = 0; level < 7; level++) {
19 if (!findServiceEntries(name, level, &globres)) {
24 - if (s.type == TYPE_XINETD) return 0;
29 if ((rc = readServiceDifferences(name, &s, &o, 0))) {
33 - if (s.type == TYPE_XINETD) return 0;
35 if ((s.levels == o.levels) &&
36 (s.kPriority == o.kPriority) &&
40 printf("%-15s", s.name);
41 - if (s.type == TYPE_XINETD) {
42 - printf("\t%s\n", s.levels ? _("on") : _("off"));
46 for (i = 0; i < 7; i++) {
47 printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
52 -static int isXinetdEnabled() {
56 - if (readServiceInfo("xinetd", &s, 0)) {
59 - for (i = 0; i < 7; i++) {
60 - if (isOn("xinetd", i))
66 static int serviceNameCmp(const void * a, const void * b) {
67 return strcmp(* (char **)a, * (char **)b);
70 -static int xinetdNameCmp(const void * a, const void * b) {
71 - const struct service * first = a;
72 - const struct service * second = b;
74 - return strcmp(first->name, second->name);
79 static int listService(char * item) {
85 - if (isXinetdEnabled()) {
86 - struct service *s, *t;
89 - printf(_("xinetd based services:\n"));
90 - if (!(dir = opendir(XINETDDIR))) {
91 - fprintf(stderr, _("failed to open directory %s: %s\n"),
92 - XINETDDIR, strerror(err));
96 - numServicesAlloced = 10;
97 - s = malloc(sizeof (*s) * numServicesAlloced);
99 - while ((ent = readdir(dir))) {
102 - /* Skip any file starting with a . */
103 - if (ent->d_name[0] == '.') continue;
105 - /* Skip files with known bad extensions */
106 - if ((dn = strrchr(ent->d_name, '.')) != NULL &&
107 - (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") || !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
110 - dn = ent->d_name + strlen(ent->d_name) - 1;
111 - if (*dn == '~' || *dn == ',')
114 - if (numServices == numServicesAlloced) {
115 - numServicesAlloced += 10;
116 - s = realloc(s, numServicesAlloced * sizeof (*s));
118 - if (readXinetdServiceInfo(ent->d_name, s + numServices, 0) != -1)
122 - qsort(s, numServices, sizeof(*s), xinetdNameCmp);
124 - for (i = 0; i < numServices; i++, s++) {
125 - char *tmp = malloc(strlen(s->name) + 5);
126 - sprintf(tmp,"%s:",s->name);
127 - printf("\t%-15s\t%s\n", tmp, s->levels ? _("on") : _("off"));
136 rc |= doSetService(s, i, what);
139 - } else if (s.type == TYPE_XINETD) {
140 - if (setXinetdService(s, state)) {
143 - system("/etc/init.d/xinetd reload >/dev/null 2>&1");
148 rc = readServiceInfo(name, &s, 0);
151 - if (s.type == TYPE_XINETD) {
152 - if (isOn("xinetd",level))
157 - return isOn(name, level) ? 0 : 1;
158 + return isOn(name, level) ? 0 : 1;
159 } else if (!strcmp(state, "on"))
160 return setService(name, where, 1);
161 else if (!strcmp(state, "off"))
162 diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
163 --- chkconfig-1.3.37.org/leveldb.c 2007-08-03 19:57:56.000000000 +0200
164 +++ chkconfig-1.3.37/leveldb.c 2008-04-24 09:34:20.447423719 +0200
165 @@ -149,101 +149,6 @@
169 -int readXinetdServiceInfo(char *name, struct service * service, int honorHide) {
170 - char * filename = alloca(strlen(name) + strlen(XINETDDIR) + 50);
172 - struct service serv = {
187 - char * eng_desc = NULL, *start;
189 - snprintf(filename, strlen(name)+strlen(XINETDDIR)+50, XINETDDIR "/%s", name);
191 - if ((fd = open(filename, O_RDONLY)) < 0) return -1;
193 - if (! S_ISREG(sb.st_mode)) return -1;
194 - buf = malloc(sb.st_size+1);
195 - if (read(fd,buf,sb.st_size)!=sb.st_size) {
201 - serv.name = strdup(name);
202 - buf[sb.st_size] = '\0';
205 - ptr = strchr(buf,'\n');
208 - while (isspace(*buf) && buf < ptr) buf++;
209 - if (!strncmp(buf,"default:", 9)) {
211 - while(isspace(*buf)) buf++;
212 - if (!strncmp(buf+9,"on",2)) {
217 - } else if (!strncmp(buf,"description:",12)) {
219 - if (readDescription(buf,start+sb.st_size,
220 - &serv.desc,&eng_desc)) {
221 - if (serv.desc) free(serv.desc);
225 - serv.desc = eng_desc;
226 - } else if (eng_desc)
236 - while (isspace(*buf) && buf < ptr) buf++;
237 - if (!strncmp(buf,"disable", 7)) {
238 - buf = strstr(buf,"=");
242 - } while(isspace(*buf));
244 - if (buf && strncmp(buf,"yes",3)) {
245 - serv.levels = parseLevels("0123456",0);
246 - if (serv.enabled == -1)
250 - if (serv.enabled == -1)
264 int readServiceInfo(char * name, struct service * service, int honorHide) {
265 char * filename = alloca(strlen(name) + strlen(RUNLEVELS) + 50);
268 sprintf(filename, RUNLEVELS "/init.d/%s", name);
270 if ((fd = open(filename, O_RDONLY)) < 0) {
271 - return readXinetdServiceInfo(name,service,honorHide);
275 parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
277 sprintf(filename, RUNLEVELS "/init.d/%s", name);
279 if ((fd = open(filename, O_RDONLY)) < 0) {
280 - return readXinetdServiceInfo(name,service,honorHide);
284 parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
289 -int setXinetdService(struct service s, int on) {
291 - char oldfname[100], newfname[100];
293 - char *buf, *ptr, *tmp;
297 - on = s.enabled ? 1 : 0;
299 - snprintf(oldfname,100,"%s/%s",XINETDDIR,s.name);
300 - if ( (oldfd = open(oldfname,O_RDONLY)) == -1 ) {
304 - buf = malloc(sb.st_size+1);
305 - if (read(oldfd,buf,sb.st_size)!=sb.st_size) {
311 - buf[sb.st_size] = '\0';
312 - snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name);
313 - newfd = mkstemp(newfname);
320 - ptr = strchr(buf,'\n');
325 - while (isspace(*buf)) buf++;
326 - if (strncmp(buf,"disable", 7) && strlen(buf)) {
327 - write(newfd,tmp,strlen(tmp));
328 - write(newfd,"\n",1);
329 - if (buf[0] == '{') {
330 - snprintf(tmpstr,50,"\tdisable\t= %s", on ? "no" : "yes");
331 - write(newfd,tmpstr,strlen(tmpstr));
332 - write(newfd,"\n",1);
338 - chmod(newfname,0644);
340 - return(rename(newfname,oldfname));
343 int doSetService(struct service s, int level, int on) {
344 int priority = on ? s.sPriority : s.kPriority;
346 diff -urN chkconfig-1.3.37.org/ntsysv.c chkconfig-1.3.37/ntsysv.c
347 --- chkconfig-1.3.37.org/ntsysv.c 2007-08-03 19:57:56.000000000 +0200
348 +++ chkconfig-1.3.37/ntsysv.c 2008-04-24 09:34:50.485526379 +0200
349 @@ -131,16 +131,10 @@
350 if (!update) return 1;
352 for (i = 0; i < numServices; i++) {
353 - if (services[i].type == TYPE_XINETD) {
354 - if ((services[i].enabled && states[i] != '*') ||
355 - (!services[i].enabled && states[i] == '*'))
356 - setXinetdService(services[i], states[i] == '*');
358 for (j = 0; j < 7; j++) {
359 if (levels & (1 << j))
360 doSetService(services[i], j, states[i] == '*');
370 - if (!stat("/usr/sbin/xinetd",&sb)) {
371 - if (!(dir = opendir(XINETDDIR))) {
372 - fprintf(stderr, "failed to open " XINETDDIR ": %s\n",
377 - while ((ent = readdir(dir))) {
378 - if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
379 - strchr(ent->d_name, '.')) continue;
381 - sprintf(fn, "%s/%s", XINETDDIR, ent->d_name);
387 - if (!S_ISREG(sb.st_mode)) continue;
389 - if (numServices == numServicesAlloced) {
390 - numServicesAlloced += 10;
391 - services = realloc(services,
392 - numServicesAlloced * sizeof(*services));
395 - rc = readXinetdServiceInfo(ent->d_name, services + numServices, honorHide);
398 - fprintf(stderr, _("error reading info for service %s: %s\n"),
399 - ent->d_name, strerror(errno));
407 - fprintf(stderr, _("error reading from directory %s: %s\n"),
408 - XINETDDIR, strerror(err));
413 qsort(services, numServices, sizeof(*services), serviceNameCmp);
415 *servicesPtr = services;
416 --- chkconfig-1.3.37/chkconfig.8~ 2007-11-08 23:28:34.000000000 +0200
417 +++ chkconfig-1.3.37/chkconfig.8 2008-04-24 10:48:07.171320486 +0300
419 an already-started service, and will not re-stop a service that is
422 -\fBchkconfig\fR also can manage xinetd scripts via the means
423 -of xinetd.d configuration files. Note that only the
424 -\fBon\fR, \fBoff\fR, and \fB-\-list\fR commands are supported
425 -for xinetd.d services.
429 \fB-\-level \fIlevels\fR