]> git.pld-linux.org Git - packages/chkconfig.git/blame - chkconfig-noxinet.patch
- added Epoch: 1 (for allow upgrade from current RH version).
[packages/chkconfig.git] / chkconfig-noxinet.patch
CommitLineData
bda1ec50 1diff -Nru chkconfig-1.2.22/chkconfig.c chkconfig-1.2.22.new/chkconfig.c
2--- chkconfig-1.2.22/chkconfig.c Sun Mar 25 03:29:32 2001
3+++ chkconfig-1.2.22.new/chkconfig.c Sun Mar 25 03:31:17 2001
4@@ -51,7 +51,6 @@
46170f11
JB
5 readServiceError(rc, name);
6 return 1;
7 }
8- if (s.type == TYPE_XINETD) return 0;
9
10 for (level = 0; level < 7; level++) {
11 if (!findServiceEntries(name, level, &globres)) {
bda1ec50 12@@ -72,8 +71,6 @@
46170f11
JB
13 return 1;
14 }
15
16- if (s.type == TYPE_XINETD) return 0;
17-
18 for (i = 0; i < 7; i++) {
19 if ((1 << i) & s.levels)
20 doSetService(s, i, 1);
bda1ec50 21@@ -96,10 +93,6 @@
46170f11
JB
22 }
23
24 printf("%-15s", s.name);
25- if (s.type == TYPE_XINETD) {
26- printf("\t%s\n", s.levels ? _("on") : _("off"));
27- return 0;
28- }
29
30 for (i = 0; i < 7; i++) {
31 printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
bda1ec50 32@@ -109,21 +102,6 @@
46170f11
JB
33 return 0;
34 }
35
36-static int isXinetdEnabled() {
37- int i;
38- struct service s;
39-
40- if (readServiceInfo("xinetd", &s, 0)) {
41- return 0;
42- }
43- for (i = 0; i < 7; i++) {
44- if (isOn("xinetd", i))
45- return 1;
46- }
47- return 0;
48-}
49-
50-
51 static int listService(char * item) {
52 DIR * dir;
53 struct dirent * ent;
bda1ec50 54@@ -174,35 +152,6 @@
55 }
46170f11
JB
56
57 closedir(dir);
bda1ec50 58-
46170f11
JB
59- if (isXinetdEnabled()) {
60- printf(_("xinetd based services:\n"));
61- if (!(dir = opendir(XINETDDIR))) {
62- fprintf(stderr, _("failed to open directory %s: %s"),
63- XINETDDIR, strerror(err));
64- return 1;
65- }
66- while ((ent = readdir(dir))) {
67- const char *dn;
68- struct service s;
69-
70- /* Skip any file starting with a . */
71- if (ent->d_name[0] == '.') continue;
72-
73- /* Skip files with known bad extensions */
74- if ((dn = strrchr(ent->d_name, '.')) != NULL &&
bda1ec50 75- (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") || !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
46170f11
JB
76- continue;
77-
78- dn = ent->d_name + strlen(ent->d_name) - 1;
79- if (*dn == '~' || *dn == ',')
80- continue;
81-
82- readXinetdServiceInfo(ent->d_name, &s, 0);
83- printf("\t%s:\t%s\n", s.name, s.levels ? _("on") : _("off"));
84- }
85- closedir(dir);
86- }
87 return 0;
88 }
89
bda1ec50 90@@ -224,21 +173,16 @@
46170f11
JB
91 return 1;
92 }
93
94- if (s.type == TYPE_INIT_D) {
95- for (i = 0; i < 7; i++) {
96- if (!((1 << i) & where)) continue;
97-
98- if (state == 1 || state == 0)
99- what = state;
100- else if (s.levels & (1 << i))
101- what = 1;
102- else
103- what = 0;
104- doSetService(s, i, what);
105- }
106- } else if (s.type == TYPE_XINETD) {
107- setXinetdService(s, state);
108- system("/etc/init.d/xinetd reload >/dev/null 2>&1");
109+ for (i = 0; i < 7; i++) {
110+ if (!((1 << i) & where)) continue;
111+
112+ if (state == 1 || state == 0)
113+ what = state;
114+ else if (s.levels & (1 << i))
115+ what = 1;
116+ else
117+ what = 0;
118+ doSetService(s, i, what);
119 }
120
121 return 0;
bda1ec50 122diff -Nru chkconfig-1.2.22/leveldb.c chkconfig-1.2.22.new/leveldb.c
123--- chkconfig-1.2.22/leveldb.c Sun Mar 25 03:29:32 2001
124+++ chkconfig-1.2.22.new/leveldb.c Sun Mar 25 03:31:47 2001
46170f11
JB
125@@ -138,88 +138,6 @@
126 return 0;
127 }
128
129-int readXinetdServiceInfo(char *name, struct service * service, int honorHide) {
130- char * filename = alloca(strlen(name) + strlen(XINETDDIR) + 50);
131- int fd;
132- struct service serv = { NULL, -1, -1, -1, NULL, 1, -1 };
133- struct stat sb;
134- char * buf, *ptr;
135- char * eng_desc = NULL, *start;
136-
137- snprintf(filename, strlen(name)+strlen(XINETDDIR)+50, XINETDDIR "/%s", name);
138-
139- if ((fd = open(filename, O_RDONLY)) < 0) return -1;
140- fstat(fd,&sb);
141- buf = malloc(sb.st_size+1);
142- if (read(fd,buf,sb.st_size)!=sb.st_size) {
143- close(fd);
144- free(buf);
145- return -1;
146- }
147- close(fd);
148- serv.name = strdup(name);
149- buf[sb.st_size] = '\0';
150- start = buf;
151- while (buf) {
152- ptr = strchr(buf,'\n');
153- if (*buf == '#') {
154- buf++;
155- while (isspace(*buf) && buf < ptr) buf++;
156- if (!strncmp(buf,"default:", 9)) {
157- buf+=8;
158- while(isspace(*buf)) buf++;
159- if (!strncmp(buf+9,"on",2)) {
160- serv.enabled = 1;
161- } else {
162- serv.enabled = 0;
163- }
164- } else if (!strncmp(buf,"description:",12)) {
165- buf+=11;
166- if (readDescription(buf,start+sb.st_size,
167- &serv.desc,&eng_desc)) {
168- if (serv.desc) free(serv.desc);
169- }
170- if (!serv.desc) {
171- if (eng_desc)
172- serv.desc = eng_desc;
173- } else if (eng_desc)
174- free (eng_desc);
175- }
176- if (ptr) {
177- *ptr = '\0';
178- ptr++;
179- }
180- buf = ptr;
181- continue;
182- }
183- while (isspace(*buf) && buf < ptr) buf++;
184- if (!strncmp(buf,"disable", 7)) {
185- buf = strstr(buf,"=");
186- if (buf)
187- do {
188- buf++;
189- } while(isspace(*buf));
190-
191- if (buf && strncmp(buf,"yes",3)) {
192- serv.levels = parseLevels("0123456",0);
193- if (serv.enabled == -1)
194- serv.enabled = 1;
195- } else {
196- serv.levels = 0;
197- if (serv.enabled == -1)
198- serv.enabled = 0;
199- }
200- }
201- if (ptr) {
202- *ptr = '\0';
203- ptr++;
204- }
205- buf = ptr;
206- }
207- *service = serv;
208- return 0;
209-}
210-
211 int readServiceInfo(char * name, struct service * service, int honorHide) {
212 char * filename = alloca(strlen(name) + strlen(RUNLEVELS) + 50);
213 int fd;
214@@ -236,7 +154,7 @@
215 sprintf(filename, RUNLEVELS "/init.d/%s", name);
216
217 if ((fd = open(filename, O_RDONLY)) < 0) {
218- return readXinetdServiceInfo(name,service,honorHide);
219+ return -1;
220 }
221 fstat(fd, &sb);
222
223@@ -418,60 +336,6 @@
224
225 globfree(&globres);
226 return 1;
227-}
228-
229-int setXinetdService(struct service s, int on) {
230- int oldfd, newfd;
231- char oldfname[100], newfname[100];
232- char tmpstr[50];
233- char *buf, *ptr, *tmp;
234- struct stat sb;
235-
236- if (on == -1) {
237- on = s.enabled ? 1 : 0;
238- }
239- snprintf(oldfname,100,"%s/%s",XINETDDIR,s.name);
240- if ( (oldfd = open(oldfname,O_RDONLY)) == -1 ) {
241- return -1;
242- }
243- fstat(oldfd,&sb);
244- buf = malloc(sb.st_size+1);
245- if (read(oldfd,buf,sb.st_size)!=sb.st_size) {
246- close(oldfd);
247- free(buf);
248- return -1;
249- }
250- close(oldfd);
251- buf[sb.st_size] = '\0';
252- snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name);
253- newfd = mkstemp(newfname);
254- if (newfd == -1) {
255- free(buf);
256- return -1;
257- }
258- while (buf) {
259- tmp = buf;
260- ptr = strchr(buf,'\n');
261- if (ptr) {
262- *ptr = '\0';
263- ptr++;
264- }
265- while (isspace(*buf)) buf++;
bda1ec50 266- if (strncmp(buf,"disable", 7) && strlen(buf)) {
46170f11
JB
267- write(newfd,tmp,strlen(tmp));
268- write(newfd,"\n",1);
269- if (buf[0] == '{') {
270- snprintf(tmpstr,50,"\tdisable\t= %s", on ? "no" : "yes");
271- write(newfd,tmpstr,strlen(tmpstr));
272- write(newfd,"\n",1);
273- }
274- }
275- buf = ptr;
276- }
277- close(newfd);
278- chmod(newfname,0644);
279- unlink(oldfname);
280- return(rename(newfname,oldfname));
281 }
282
283 int doSetService(struct service s, int level, int on) {
bda1ec50 284diff -Nru chkconfig-1.2.22/ntsysv.c chkconfig-1.2.22.new/ntsysv.c
285--- chkconfig-1.2.22/ntsysv.c Mon Mar 5 06:51:54 2001
286+++ chkconfig-1.2.22.new/ntsysv.c Sun Mar 25 03:33:04 2001
46170f11
JB
287@@ -40,20 +40,14 @@
288 states = alloca(sizeof(*states) * numServices);
289
290 for (i = 0; i < numServices; i++) {
291- if (services[i].type == TYPE_XINETD) {
292- checkboxes[i] = newtCheckbox(-1, i, services[i].name,
293- services[i].levels ? '*' : ' ', NULL,
294- states + i);
295- } else {
296- for (j = 0; j < 7; j++) {
297- if (levels & (1 << j)) {
298- if (isOn(services[i].name, j)) break;
299- }
300+ for (j = 0; j < 7; j++) {
301+ if (levels & (1 << j)) {
302+ if (isOn(services[i].name, j)) break;
303 }
304- checkboxes[i] = newtCheckbox(-1, i, services[i].name,
305- (j != 7) ? '*' : ' ', NULL,
306- states + i);
307 }
308+ checkboxes[i] = newtCheckbox(-1, i, services[i].name,
309+ (j != 7) ? '*' : ' ', NULL,
310+ states + i);
311 newtFormAddComponent(subform, checkboxes[i]);
312 }
313
314@@ -110,13 +104,9 @@
315 if (!update) return 1;
316
317 for (i = 0; i < numServices; i++) {
318- if (services[i].type == TYPE_XINETD)
319- setXinetdService(services[i], states[i] == '*');
320- else {
321- for (j = 0; j < 7; j++) {
322- if (levels & (1 << j))
323- doSetService(services[i], j, states[i] == '*');
324- }
325+ for (j = 0; j < 7; j++) {
326+ if (levels & (1 << j))
327+ doSetService(services[i], j, states[i] == '*');
328 }
329 }
330
bda1ec50 331@@ -186,50 +176,6 @@
46170f11
JB
332 }
333
334 closedir(dir);
335-
bda1ec50 336- if (!stat("/usr/sbin/xinetd",&sb)) {
46170f11
JB
337- if (!(dir = opendir(XINETDDIR))) {
338- fprintf(stderr, "failed to open " XINETDDIR ": %s\n",
339- strerror(errno));
340- return 2;
341- }
342-
343- while ((ent = readdir(dir))) {
344- if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
345- strchr(ent->d_name, '.')) continue;
346-
347- sprintf(fn, "%s/%s", XINETDDIR, ent->d_name);
348- if (stat(fn, &sb))
349- {
350- err = errno;
351- continue;
352- }
353- if (!S_ISREG(sb.st_mode)) continue;
354-
355- if (numServices == numServicesAlloced) {
356- numServicesAlloced += 10;
357- services = realloc(services,
358- numServicesAlloced * sizeof(*services));
359- }
360-
361- rc = readXinetdServiceInfo(ent->d_name, services + numServices, honorHide);
362-
363- if (rc == -1) {
364- fprintf(stderr, _("error reading info for service %s: %s\n"),
365- ent->d_name, strerror(errno));
366- closedir(dir);
367- return 2;
368- } else if (!rc)
369- numServices++;
370- }
371-
372- if (err) {
373- fprintf(stderr, _("error reading from directory %s: %s\n"),
374- XINETDDIR, strerror(err));
375- return 1;
376- }
bda1ec50 377- }
378-
46170f11
JB
379 qsort(services, numServices, sizeof(*services), serviceNameCmp);
380
bda1ec50 381 *servicesPtr = services;
This page took 0.116864 seconds and 4 git commands to generate.