1 diff -Nur chkconfig-1.2.16.orig/chkconfig.c chkconfig-1.2.16/chkconfig.c
2 --- chkconfig-1.2.16.orig/chkconfig.c Sat Mar 24 14:51:20 2001
3 +++ chkconfig-1.2.16/chkconfig.c Sat Mar 24 15:15:33 2001
5 readServiceError(rc, name);
8 - if (s.type == TYPE_XINETD) return 0;
10 for (level = 0; level < 7; level++) {
11 if (!findServiceEntries(name, level, &globres)) {
16 - if (s.type == TYPE_XINETD) return 0;
18 for (i = 0; i < 7; i++) {
19 if ((1 << i) & s.levels)
20 doSetService(s, i, 1);
24 printf("%-15s", s.name);
25 - if (s.type == TYPE_XINETD) {
26 - printf("\t%s\n", s.levels ? _("on") : _("off"));
30 for (i = 0; i < 7; i++) {
31 printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
36 -static int isXinetdEnabled() {
40 - if (readServiceInfo("xinetd", &s, 0)) {
43 - for (i = 0; i < 7; i++) {
44 - if (isOn("xinetd", i))
51 static int listService(char * item) {
58 - if (isXinetdEnabled()) {
59 - printf(_("xinetd based services:\n"));
60 - if (!(dir = opendir(XINETDDIR))) {
61 - fprintf(stderr, _("failed to open directory %s: %s"),
62 - XINETDDIR, strerror(err));
65 - while ((ent = readdir(dir))) {
69 - /* Skip any file starting with a . */
70 - if (ent->d_name[0] == '.') continue;
72 - /* Skip files with known bad extensions */
73 - if ((dn = strrchr(ent->d_name, '.')) != NULL &&
74 - (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
77 - dn = ent->d_name + strlen(ent->d_name) - 1;
78 - if (*dn == '~' || *dn == ',')
81 - readXinetdServiceInfo(ent->d_name, &s, 0);
82 - printf("\t%s:\t%s\n", s.name, s.levels ? _("on") : _("off"));
93 - if (s.type == TYPE_INIT_D) {
94 - for (i = 0; i < 7; i++) {
95 - if (!((1 << i) & where)) continue;
97 - if (state == 1 || state == 0)
99 - else if (s.levels & (1 << i))
103 - doSetService(s, i, what);
105 - } else if (s.type == TYPE_XINETD) {
106 - setXinetdService(s, state);
107 - system("/etc/init.d/xinetd reload >/dev/null 2>&1");
108 + for (i = 0; i < 7; i++) {
109 + if (!((1 << i) & where)) continue;
111 + if (state == 1 || state == 0)
113 + else if (s.levels & (1 << i))
117 + doSetService(s, i, what);
121 diff -Nur chkconfig-1.2.16.orig/leveldb.c chkconfig-1.2.16/leveldb.c
122 --- chkconfig-1.2.16.orig/leveldb.c Sat Mar 24 14:51:20 2001
123 +++ chkconfig-1.2.16/leveldb.c Sat Mar 24 15:17:14 2001
128 -int readXinetdServiceInfo(char *name, struct service * service, int honorHide) {
129 - char * filename = alloca(strlen(name) + strlen(XINETDDIR) + 50);
131 - struct service serv = { NULL, -1, -1, -1, NULL, 1, -1 };
134 - char * eng_desc = NULL, *start;
136 - snprintf(filename, strlen(name)+strlen(XINETDDIR)+50, XINETDDIR "/%s", name);
138 - if ((fd = open(filename, O_RDONLY)) < 0) return -1;
140 - buf = malloc(sb.st_size+1);
141 - if (read(fd,buf,sb.st_size)!=sb.st_size) {
147 - serv.name = strdup(name);
148 - buf[sb.st_size] = '\0';
151 - ptr = strchr(buf,'\n');
154 - while (isspace(*buf) && buf < ptr) buf++;
155 - if (!strncmp(buf,"default:", 9)) {
157 - while(isspace(*buf)) buf++;
158 - if (!strncmp(buf+9,"on",2)) {
163 - } else if (!strncmp(buf,"description:",12)) {
165 - if (readDescription(buf,start+sb.st_size,
166 - &serv.desc,&eng_desc)) {
167 - if (serv.desc) free(serv.desc);
171 - serv.desc = eng_desc;
172 - } else if (eng_desc)
182 - while (isspace(*buf) && buf < ptr) buf++;
183 - if (!strncmp(buf,"disable", 7)) {
184 - buf = strstr(buf,"=");
188 - } while(isspace(*buf));
190 - if (buf && strncmp(buf,"yes",3)) {
191 - serv.levels = parseLevels("0123456",0);
192 - if (serv.enabled == -1)
196 - if (serv.enabled == -1)
210 int readServiceInfo(char * name, struct service * service, int honorHide) {
211 char * filename = alloca(strlen(name) + strlen(RUNLEVELS) + 50);
214 sprintf(filename, RUNLEVELS "/init.d/%s", name);
216 if ((fd = open(filename, O_RDONLY)) < 0) {
217 - return readXinetdServiceInfo(name,service,honorHide);
228 -int setXinetdService(struct service s, int on) {
230 - char oldfname[100], newfname[100];
232 - char *buf, *ptr, *tmp;
236 - on = s.enabled ? 1 : 0;
238 - snprintf(oldfname,100,"%s/%s",XINETDDIR,s.name);
239 - if ( (oldfd = open(oldfname,O_RDONLY)) == -1 ) {
243 - buf = malloc(sb.st_size+1);
244 - if (read(oldfd,buf,sb.st_size)!=sb.st_size) {
250 - buf[sb.st_size] = '\0';
251 - snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name);
252 - newfd = mkstemp(newfname);
259 - ptr = strchr(buf,'\n');
264 - while (isspace(*buf)) buf++;
265 - if (strncmp(buf,"disable", 7)) {
266 - write(newfd,tmp,strlen(tmp));
267 - write(newfd,"\n",1);
268 - if (buf[0] == '{') {
269 - snprintf(tmpstr,50,"\tdisable\t= %s", on ? "no" : "yes");
270 - write(newfd,tmpstr,strlen(tmpstr));
271 - write(newfd,"\n",1);
277 - chmod(newfname,0644);
279 - return(rename(newfname,oldfname));
282 int doSetService(struct service s, int level, int on) {
283 diff -Nur chkconfig-1.2.16.orig/leveldb.h chkconfig-1.2.16/leveldb.h
284 --- chkconfig-1.2.16.orig/leveldb.h Sat Mar 24 14:51:20 2001
285 +++ chkconfig-1.2.16/leveldb.h Sat Mar 24 15:14:46 2001
289 #define RUNLEVELS "/etc/rc.d"
290 -#define XINETDDIR "/etc/xinetd.d"
294 #define TYPE_INIT_D 0
295 -#define TYPE_XINETD 1
300 int isConfigured(char * name, int level);
301 int doSetService(struct service s, int level, int on);
302 int findServiceEntries(char * name, int level, glob_t * globresptr);
303 -int readXinetdServiceInfo(char *name, struct service *service, int honorHide);
304 -int setXinetdService(struct service s, int on);
307 diff -Nur chkconfig-1.2.16.orig/ntsysv.c chkconfig-1.2.16/ntsysv.c
308 --- chkconfig-1.2.16.orig/ntsysv.c Wed Aug 16 22:04:28 2000
309 +++ chkconfig-1.2.16/ntsysv.c Sat Mar 24 15:14:46 2001
311 states = alloca(sizeof(*states) * numServices);
313 for (i = 0; i < numServices; i++) {
314 - if (services[i].type == TYPE_XINETD) {
315 - checkboxes[i] = newtCheckbox(-1, i, services[i].name,
316 - services[i].levels ? '*' : ' ', NULL,
319 - for (j = 0; j < 7; j++) {
320 - if (levels & (1 << j)) {
321 - if (isOn(services[i].name, j)) break;
323 + for (j = 0; j < 7; j++) {
324 + if (levels & (1 << j)) {
325 + if (isOn(services[i].name, j)) break;
327 - checkboxes[i] = newtCheckbox(-1, i, services[i].name,
328 - (j != 7) ? '*' : ' ', NULL,
331 + checkboxes[i] = newtCheckbox(-1, i, services[i].name,
332 + (j != 7) ? '*' : ' ', NULL,
334 newtFormAddComponent(subform, checkboxes[i]);
338 if (!update) return 1;
340 for (i = 0; i < numServices; i++) {
341 - if (services[i].type == TYPE_XINETD)
342 - setXinetdService(services[i], states[i] == '*');
344 - for (j = 0; j < 7; j++) {
345 - if (levels & (1 << j))
346 - doSetService(services[i], j, states[i] == '*');
348 + for (j = 0; j < 7; j++) {
349 + if (levels & (1 << j))
350 + doSetService(services[i], j, states[i] == '*');
359 - if (!(dir = opendir(XINETDDIR))) {
360 - fprintf(stderr, "failed to open " XINETDDIR ": %s\n",
365 - while ((ent = readdir(dir))) {
366 - if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
367 - strchr(ent->d_name, '.')) continue;
369 - sprintf(fn, "%s/%s", XINETDDIR, ent->d_name);
375 - if (!S_ISREG(sb.st_mode)) continue;
377 - if (numServices == numServicesAlloced) {
378 - numServicesAlloced += 10;
379 - services = realloc(services,
380 - numServicesAlloced * sizeof(*services));
383 - rc = readXinetdServiceInfo(ent->d_name, services + numServices, honorHide);
386 - fprintf(stderr, _("error reading info for service %s: %s\n"),
387 - ent->d_name, strerror(errno));
395 - fprintf(stderr, _("error reading from directory %s: %s\n"),
396 - XINETDDIR, strerror(err));
400 qsort(services, numServices, sizeof(*services), serviceNameCmp);