1 diff -Nru chkconfig-1.2.24h.orig/chkconfig.c chkconfig-1.2.24h/chkconfig.c
2 --- chkconfig-1.2.24h.orig/chkconfig.c Wed Jul 17 20:10:55 2002
3 +++ chkconfig-1.2.24h/chkconfig.c Wed Jan 22 12:43:07 2003
5 readServiceError(rc, name);
8 - if (s.type == TYPE_XINETD) return 0;
10 for (level = 0; level <= conf.maxlevel; level++) {
11 if (!findServiceEntries(name, level, &globres)) {
13 readServiceError(rc, name);
17 - if (s.type == TYPE_XINETD) return 0;
19 for (i = 0; i <= conf.maxlevel; i++) {
20 if (!isConfigured(name, i)) {
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 <= conf.maxlevel; 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 <= conf.maxlevel; 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(conf.xinetddir))) {
61 - fprintf(stderr, _("failed to open directory %s: %s"),
62 - conf.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, ".rpmnew") || !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 <= conf.maxlevel; i++) {
95 if (!((1 << i) & where)) continue;
99 doSetService(s, i, what);
101 - } else if (s.type == TYPE_XINETD) {
104 - setXinetdService(s, state);
105 - snprintf(xinetd, sizeof(xinetd),
106 - "%s/xinetd reload >/dev/null 2>&1", conf.initdir);
112 diff -Nru chkconfig-1.2.24h.orig/leveldb.c chkconfig-1.2.24h/leveldb.c
113 --- chkconfig-1.2.24h.orig/leveldb.c Fri Apr 19 03:15:55 2002
114 +++ chkconfig-1.2.24h/leveldb.c Wed Jan 22 12:46:28 2003
119 -int readXinetdServiceInfo(char *name, struct service * service, int honorHide) {
120 - char * filename = alloca(strlen(name) + strlen(XINETDDIR) + 50);
122 - struct service serv = { NULL, -1, -1, -1, NULL, 1, -1 };
125 - char * eng_desc = NULL, *start;
127 - snprintf(filename, strlen(name)+strlen(XINETDDIR)+50, XINETDDIR "/%s", name);
129 - if ((fd = open(filename, O_RDONLY)) < 0) return -1;
131 - buf = malloc(sb.st_size+1);
132 - if (read(fd,buf,sb.st_size)!=sb.st_size) {
138 - serv.name = strdup(name);
139 - buf[sb.st_size] = '\0';
142 - ptr = strchr(buf,'\n');
145 - while (isspace(*buf) && buf < ptr) buf++;
146 - if (!strncmp(buf,"default:", 9)) {
148 - while(isspace(*buf)) buf++;
149 - if (!strncmp(buf+9,"on",2)) {
154 - } else if (!strncmp(buf,"description:",12)) {
156 - if (readDescription(buf,start+sb.st_size,
157 - &serv.desc,&eng_desc)) {
158 - if (serv.desc) free(serv.desc);
162 - serv.desc = eng_desc;
163 - } else if (eng_desc)
173 - while (isspace(*buf) && buf < ptr) buf++;
174 - if (!strncmp(buf,"disable", 7)) {
175 - buf = strstr(buf,"=");
179 - } while(isspace(*buf));
181 - if (buf && strncmp(buf,"yes",3)) {
182 - serv.levels = parseLevels("0123456",0);
183 - if (serv.enabled == -1)
187 - if (serv.enabled == -1)
201 int readServiceInfo(char * name, struct service * service, int honorHide) {
202 char * filename = alloca(strlen(name) + strlen(conf.initdir) + 50);
205 sprintf(filename, "%s/%s", conf.initdir, name);
207 if ((fd = open(filename, O_RDONLY)) < 0) {
208 - return readXinetdServiceInfo(name,service,honorHide);
217 -int setXinetdService(struct service s, int on) {
219 - char oldfname[100], newfname[100];
221 - char *buf, *ptr, *tmp;
225 - on = s.enabled ? 1 : 0;
227 - snprintf(oldfname,100,"%s/%s",XINETDDIR,s.name);
228 - if ( (oldfd = open(oldfname,O_RDONLY)) == -1 ) {
232 - buf = malloc(sb.st_size+1);
233 - if (read(oldfd,buf,sb.st_size)!=sb.st_size) {
239 - buf[sb.st_size] = '\0';
240 - snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name);
241 - newfd = mkstemp(newfname);
248 - ptr = strchr(buf,'\n');
253 - while (isspace(*buf)) buf++;
254 - if (strncmp(buf,"disable", 7) && strlen(buf)) {
255 - write(newfd,tmp,strlen(tmp));
256 - write(newfd,"\n",1);
257 - if (buf[0] == '{') {
258 - snprintf(tmpstr,50,"\tdisable\t= %s", on ? "no" : "yes");
259 - write(newfd,tmpstr,strlen(tmpstr));
260 - write(newfd,"\n",1);
266 - chmod(newfname,0644);
268 - return(rename(newfname,oldfname));
271 int doSetService(struct service s, int level, int on) {
272 int priority = on ? s.sPriority : s.kPriority;
274 diff -Nru chkconfig-1.2.24h.orig/ntsysv.c chkconfig-1.2.24h/ntsysv.c
275 --- chkconfig-1.2.24h.orig/ntsysv.c Sun Jul 28 10:50:04 2002
276 +++ chkconfig-1.2.24h/ntsysv.c Wed Jan 22 12:50:38 2003
278 states = alloca(sizeof(*states) * numServices);
280 for (i = 0; i < numServices; i++) {
281 - if (services[i].type == TYPE_XINETD) {
282 - checkboxes[i] = newtCheckbox(-1, i, services[i].name,
283 - services[i].levels ? '*' : ' ', NULL,
286 for (j = 0; j <= conf.maxlevel; j++) {
287 if (levels & (1 << j)) {
288 if (isOn(services[i].name, j)) break;
290 (j != (conf.maxlevel+1)) ?
294 newtFormAddComponent(subform, checkboxes[i]);
298 if (!update) return 1;
300 for (i = 0; i < numServices; i++) {
301 - if (services[i].type == TYPE_XINETD)
302 - setXinetdService(services[i], states[i] == '*');
304 for (j = 0; j <= conf.maxlevel; j++) {
305 if (levels & (1 << j))
306 doSetService(services[i], j, states[i] == '*');
315 - if (!stat("/usr/sbin/xinetd",&sb)) {
316 - if (!(dir = opendir(conf.xinetddir))) {
317 - fprintf(stderr, "failed to open %s: %s\n", conf.xinetddir,
322 - while ((ent = readdir(dir))) {
323 - if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
324 - strchr(ent->d_name, '.')) continue;
326 - sprintf(fn, "%s/%s", conf.xinetddir, ent->d_name);
332 - if (!S_ISREG(sb.st_mode)) continue;
334 - if (numServices == numServicesAlloced) {
335 - numServicesAlloced += 10;
336 - services = realloc(services,
337 - numServicesAlloced * sizeof(*services));
340 - rc = readXinetdServiceInfo(ent->d_name, services + numServices, honorHide);
343 - fprintf(stderr, _("error reading info for service %s: %s\n"),
344 - ent->d_name, strerror(errno));
352 - fprintf(stderr, _("error reading from directory %s: %s\n"),
353 - conf.xinetddir, strerror(err));
358 qsort(services, numServices, sizeof(*services), serviceNameCmp);
360 *servicesPtr = services;