]>
Commit | Line | Data |
---|---|---|
bcda1112 ER |
1 | --- chkconfig-1.3.63/chkconfig.8 2014-11-05 18:39:09.000000000 +0200 |
2 | +++ chkconfig-1.3.63.no-xinetd/chkconfig.8 2014-11-30 14:54:29.771983174 +0200 | |
f20fb8bf JR |
3 | @@ -63,16 +63,6 @@ |
4 | an already-started service, and will not re-stop a service that is | |
5 | not running. | |
82df657c | 6 | |
f20fb8bf JR |
7 | -\fBchkconfig\fR also can manage xinetd scripts via the means |
8 | -of xinetd.d configuration files. Note that only the | |
9 | -\fBon\fR, \fBoff\fR, and \fB-\-list\fR commands are supported | |
10 | -for xinetd.d services. | |
11 | - | |
12 | -\fBchkconfig\fR supports a \fB-\-type\fR argument to limit actions to only | |
13 | -a specific type of services, in the case where services of either type may | |
14 | -share a name. Possible values for \fItype\fR are \fIsysv\fR | |
15 | -and \fIxinetd\fR. | |
16 | - | |
17 | .SH OPTIONS | |
18 | .TP | |
19 | \fB-\-level \fIlevels\fR | |
bcda1112 ER |
20 | --- chkconfig-1.3.63/chkconfig.c 2014-11-30 14:57:06.299908151 +0200 |
21 | +++ chkconfig-1.3.63.no-xinetd/chkconfig.c 2014-11-30 14:55:40.542232924 +0200 | |
22 | @@ -102,7 +102,6 @@ | |
82df657c ER |
23 | readServiceError(rc, name); |
24 | return 1; | |
25 | } | |
09a63b21 AM |
26 | - if (s.type == TYPE_XINETD) return 0; |
27 | ||
f20fb8bf JR |
28 | checkRoot(); |
29 | ||
bcda1112 | 30 | @@ -298,7 +297,6 @@ |
09a63b21 AM |
31 | return 1; |
32 | } | |
f20fb8bf | 33 | |
09a63b21 | 34 | - if (s.type == TYPE_XINETD) return 0; |
f20fb8bf JR |
35 | checkRoot(); |
36 | ||
37 | if (s.isLSB) { | |
bcda1112 | 38 | @@ -337,8 +335,6 @@ |
09a63b21 AM |
39 | return 0; |
40 | } | |
f20fb8bf | 41 | |
82df657c | 42 | - if (s.type == TYPE_XINETD) return 0; |
f20fb8bf JR |
43 | - |
44 | checkRoot(); | |
09a63b21 AM |
45 | |
46 | if ((s.levels == o.levels) && | |
bcda1112 | 47 | @@ -416,10 +412,6 @@ |
82df657c ER |
48 | } |
49 | ||
50 | printf("%-15s", s.name); | |
51 | - if (s.type == TYPE_XINETD) { | |
52 | - printf("\t%s\n", s.levels ? _("on") : _("off")); | |
53 | - return 0; | |
54 | - } | |
55 | ||
09a63b21 | 56 | for (i = 0; i < 7; i++) { |
82df657c | 57 | printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off")); |
bcda1112 ER |
58 | @@ -448,33 +440,10 @@ |
59 | return showServiceInfo(s, forgiving); | |
82df657c ER |
60 | } |
61 | ||
bcda1112 | 62 | - |
82df657c | 63 | -static int isXinetdEnabled() { |
09a63b21 | 64 | - struct service s; |
f20fb8bf | 65 | - |
bcda1112 ER |
66 | - if (isOverriddenBySystemd("xinetd") && isEnabledInSystemd("xinetd")) |
67 | - return 1; | |
68 | - | |
f20fb8bf | 69 | - if (readServiceInfo("xinetd", TYPE_INIT_D, &s, 0)) { |
09a63b21 AM |
70 | - return 0; |
71 | - } | |
f20fb8bf JR |
72 | - if (s.currentLevels) |
73 | - return 1; | |
09a63b21 AM |
74 | - return 0; |
75 | -} | |
82df657c | 76 | - |
09a63b21 AM |
77 | static int serviceNameCmp(const void * a, const void * b) { |
78 | return strcmp(* (char **)a, * (char **)b); | |
79 | } | |
80 | ||
81 | -static int xinetdNameCmp(const void * a, const void * b) { | |
82 | - const struct service * first = a; | |
83 | - const struct service * second = b; | |
84 | - | |
85 | - return strcmp(first->name, second->name); | |
82df657c | 86 | -} |
82df657c | 87 | - |
09a63b21 | 88 | - |
f20fb8bf | 89 | static int listService(char * item, int type) { |
82df657c | 90 | DIR * dir; |
f20fb8bf | 91 | struct dirent * ent; |
bcda1112 | 92 | @@ -502,54 +471,6 @@ |
f20fb8bf JR |
93 | } |
94 | } | |
95 | } | |
96 | - | |
97 | - if (isXinetdEnabled() && type & TYPE_XINETD) { | |
09a63b21 | 98 | - struct service *s, *t; |
f20fb8bf | 99 | - |
09a63b21 | 100 | - printf("\n"); |
82df657c | 101 | - printf(_("xinetd based services:\n")); |
09a63b21 AM |
102 | - if (!(dir = opendir(XINETDDIR))) { |
103 | - fprintf(stderr, _("failed to open directory %s: %s\n"), | |
104 | - XINETDDIR, strerror(err)); | |
82df657c ER |
105 | - return 1; |
106 | - } | |
09a63b21 AM |
107 | - numServices = 0; |
108 | - numServicesAlloced = 10; | |
109 | - s = malloc(sizeof (*s) * numServicesAlloced); | |
f20fb8bf | 110 | - |
82df657c ER |
111 | - while ((ent = readdir(dir))) { |
112 | - const char *dn; | |
82df657c ER |
113 | - |
114 | - /* Skip any file starting with a . */ | |
115 | - if (ent->d_name[0] == '.') continue; | |
116 | - | |
117 | - /* Skip files with known bad extensions */ | |
118 | - if ((dn = strrchr(ent->d_name, '.')) != NULL && | |
119 | - (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") || !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp"))) | |
120 | - continue; | |
121 | - | |
122 | - dn = ent->d_name + strlen(ent->d_name) - 1; | |
123 | - if (*dn == '~' || *dn == ',') | |
124 | - continue; | |
f20fb8bf | 125 | - |
09a63b21 AM |
126 | - if (numServices == numServicesAlloced) { |
127 | - numServicesAlloced += 10; | |
128 | - s = realloc(s, numServicesAlloced * sizeof (*s)); | |
129 | - } | |
f20fb8bf | 130 | - if (readXinetdServiceInfo(ent->d_name, s + numServices) != -1) |
09a63b21 AM |
131 | - numServices ++; |
132 | - } | |
f20fb8bf | 133 | - |
09a63b21 AM |
134 | - qsort(s, numServices, sizeof(*s), xinetdNameCmp); |
135 | - t = s; | |
136 | - for (i = 0; i < numServices; i++, s++) { | |
137 | - char *tmp = malloc(strlen(s->name) + 5); | |
138 | - sprintf(tmp,"%s:",s->name); | |
139 | - printf("\t%-15s\t%s\n", tmp, s->levels ? _("on") : _("off")); | |
82df657c ER |
140 | - } |
141 | - closedir(dir); | |
09a63b21 | 142 | - free(t); |
82df657c ER |
143 | - } |
144 | return 0; | |
145 | } | |
146 | ||
bcda1112 | 147 | @@ -610,11 +531,6 @@ |
f20fb8bf JR |
148 | reloadSystemd(); |
149 | ||
150 | return rc; | |
82df657c | 151 | - } else if (s.type == TYPE_XINETD) { |
09a63b21 AM |
152 | - if (setXinetdService(s, state)) { |
153 | - return 1; | |
154 | - } | |
bcda1112 | 155 | - system("/sbin/service xinetd reload >/dev/null 2>&1"); |
09a63b21 | 156 | } |
82df657c ER |
157 | |
158 | return 0; | |
bcda1112 | 159 | @@ -622,8 +538,6 @@ |
f20fb8bf JR |
160 | |
161 | void forwardSystemd(const char *name, int type, const char *verb) { | |
bcda1112 | 162 | int socket = 0; |
f20fb8bf JR |
163 | - if (type == TYPE_XINETD) |
164 | - return; | |
bcda1112 | 165 | |
f20fb8bf JR |
166 | if (!systemdIsInit()) |
167 | return; | |
bcda1112 ER |
168 | @@ -704,12 +618,10 @@ |
169 | if (help) usage(progname); | |
f20fb8bf JR |
170 | |
171 | if (typeString) { | |
172 | - if (!strcmp(typeString, "xinetd")) | |
173 | - type = TYPE_XINETD; | |
174 | - else if (!strcmp(typeString, "sysv")) | |
175 | + if (!strcmp(typeString, "sysv")) | |
176 | type = TYPE_INIT_D; | |
177 | else { | |
178 | - fprintf(stderr, _("--type must be 'sysv' or 'xinetd'\n")); | |
179 | + fprintf(stderr, _("--type must be 'sysv'\n")); | |
180 | exit(1); | |
181 | } | |
182 | } | |
bcda1112 | 183 | @@ -809,16 +721,9 @@ |
f20fb8bf | 184 | rc = readServiceInfo(name, type, &s, 0); |
09a63b21 AM |
185 | if (rc) |
186 | return 1; | |
187 | - if (s.type == TYPE_XINETD) { | |
188 | - if (isOn("xinetd",level)) | |
189 | - return !s.levels; | |
190 | - else | |
191 | - return 1; | |
f20fb8bf JR |
192 | - } else { |
193 | if (level == -1) | |
194 | level = currentRunlevel(); | |
195 | return s.currentLevels & (1 << level) ? 0 : 1; | |
196 | - } | |
197 | } else if (!strcmp(state, "on")) { | |
198 | if (!noRedirectItem) { | |
199 | forwardSystemd(name, type, "enable"); | |
bcda1112 ER |
200 | --- chkconfig-1.3.63/leveldb.c 2014-11-30 14:57:06.299908151 +0200 |
201 | +++ chkconfig-1.3.63.no-xinetd/leveldb.c 2014-11-30 14:56:00.846594263 +0200 | |
f20fb8bf | 202 | @@ -154,107 +154,6 @@ |
82df657c ER |
203 | return 0; |
204 | } | |
205 | ||
f20fb8bf JR |
206 | -int readXinetdServiceInfo(char *name, struct service * service) { |
207 | - char * filename; | |
82df657c | 208 | - int fd; |
f20fb8bf | 209 | - struct service serv = { |
09a63b21 AM |
210 | - name: NULL, |
211 | - levels: -1, | |
f20fb8bf JR |
212 | - kPriority: 100, |
213 | - sPriority: -1, | |
214 | - desc: NULL, | |
215 | - startDeps: NULL, | |
09a63b21 | 216 | - stopDeps: NULL, |
f20fb8bf JR |
217 | - softStartDeps: NULL, |
218 | - softStopDeps: NULL, | |
09a63b21 | 219 | - provides: NULL, |
f20fb8bf JR |
220 | - type: TYPE_XINETD, |
221 | - isLSB: 0, | |
09a63b21 AM |
222 | - enabled: -1 |
223 | - }; | |
82df657c | 224 | - struct stat sb; |
f20fb8bf | 225 | - char * buf = NULL, *ptr; |
82df657c | 226 | - char * eng_desc = NULL, *start; |
f20fb8bf JR |
227 | - |
228 | - asprintf(&filename, XINETDDIR "/%s", name); | |
229 | - | |
230 | - if ((fd = open(filename, O_RDONLY)) < 0) goto out_err; | |
82df657c | 231 | - fstat(fd,&sb); |
f20fb8bf | 232 | - if (! S_ISREG(sb.st_mode)) goto out_err; |
82df657c | 233 | - buf = malloc(sb.st_size+1); |
f20fb8bf | 234 | - if (read(fd,buf,sb.st_size)!=sb.st_size) goto out_err; |
82df657c ER |
235 | - close(fd); |
236 | - serv.name = strdup(name); | |
237 | - buf[sb.st_size] = '\0'; | |
238 | - start = buf; | |
239 | - while (buf) { | |
240 | - ptr = strchr(buf,'\n'); | |
241 | - if (*buf == '#') { | |
242 | - buf++; | |
243 | - while (isspace(*buf) && buf < ptr) buf++; | |
244 | - if (!strncmp(buf,"default:", 9)) { | |
245 | - buf+=8; | |
246 | - while(isspace(*buf)) buf++; | |
247 | - if (!strncmp(buf+9,"on",2)) { | |
248 | - serv.enabled = 1; | |
249 | - } else { | |
250 | - serv.enabled = 0; | |
251 | - } | |
252 | - } else if (!strncmp(buf,"description:",12)) { | |
253 | - buf+=11; | |
254 | - if (readDescription(buf,start+sb.st_size, | |
255 | - &serv.desc,&eng_desc)) { | |
256 | - if (serv.desc) free(serv.desc); | |
257 | - } | |
258 | - if (!serv.desc) { | |
259 | - if (eng_desc) | |
260 | - serv.desc = eng_desc; | |
f20fb8bf JR |
261 | - else |
262 | - serv.desc = strdup(name); | |
82df657c ER |
263 | - } else if (eng_desc) |
264 | - free (eng_desc); | |
265 | - } | |
266 | - if (ptr) { | |
267 | - *ptr = '\0'; | |
268 | - ptr++; | |
f20fb8bf | 269 | - } |
82df657c ER |
270 | - buf = ptr; |
271 | - continue; | |
272 | - } | |
273 | - while (isspace(*buf) && buf < ptr) buf++; | |
274 | - if (!strncmp(buf,"disable", 7)) { | |
275 | - buf = strstr(buf,"="); | |
f20fb8bf | 276 | - if (buf) |
82df657c ER |
277 | - do { |
278 | - buf++; | |
279 | - } while(isspace(*buf)); | |
280 | - | |
281 | - if (buf && strncmp(buf,"yes",3)) { | |
282 | - serv.levels = parseLevels("0123456",0); | |
283 | - if (serv.enabled == -1) | |
284 | - serv.enabled = 1; | |
285 | - } else { | |
286 | - serv.levels = 0; | |
287 | - if (serv.enabled == -1) | |
288 | - serv.enabled = 0; | |
289 | - } | |
290 | - } | |
291 | - if (ptr) { | |
292 | - *ptr = '\0'; | |
293 | - ptr++; | |
f20fb8bf | 294 | - } |
82df657c ER |
295 | - buf = ptr; |
296 | - } | |
297 | - *service = serv; | |
298 | - return 0; | |
f20fb8bf JR |
299 | -out_err: |
300 | - if (fd >= 0) | |
301 | - close(fd); | |
302 | - free(buf); | |
303 | - free(filename); | |
304 | - return -1; | |
82df657c ER |
305 | -} |
306 | - | |
f20fb8bf JR |
307 | int readServices(struct service **services) { |
308 | DIR * dir; | |
309 | struct dirent * ent; | |
310 | @@ -304,12 +203,14 @@ | |
311 | int parseret; | |
27ddd8a0 | 312 | |
f20fb8bf JR |
313 | if (!(type & TYPE_INIT_D)) |
314 | - goto try_xinetd; | |
315 | + return -1; | |
316 | ||
317 | asprintf(&filename, RUNLEVELS "/init.d/%s", name); | |
27ddd8a0 | 318 | |
f20fb8bf JR |
319 | - if ((fd = open(filename, O_RDONLY)) < 0) |
320 | - goto try_xinetd; | |
321 | + if ((fd = open(filename, O_RDONLY)) < 0) { | |
322 | + free(filename); | |
323 | + return -1; | |
324 | + } | |
325 | ||
326 | free(filename); | |
27ddd8a0 | 327 | parseret = parseServiceInfo(fd, name, &serv, honorHide, 0); |
f20fb8bf JR |
328 | @@ -338,12 +239,6 @@ |
329 | free(filename); | |
330 | *service = serv; | |
331 | return 0; | |
332 | - | |
333 | -try_xinetd: | |
334 | - free(filename); | |
335 | - if (!(type & TYPE_XINETD)) | |
336 | - return -1; | |
337 | - return readXinetdServiceInfo(name,service); | |
338 | } | |
339 | ||
340 | int readServiceDifferences(char * name, int type, struct service * service, struct service * service_overrides, int honorHide) { | |
341 | @@ -353,12 +248,13 @@ | |
342 | int parseret; | |
343 | ||
344 | if (!(type & TYPE_INIT_D)) | |
345 | - goto try_xinetd; | |
346 | + return -1; | |
347 | ||
348 | asprintf(&filename, RUNLEVELS "/init.d/%s", name); | |
27ddd8a0 AM |
349 | |
350 | if ((fd = open(filename, O_RDONLY)) < 0) { | |
f20fb8bf JR |
351 | - goto try_xinetd; |
352 | + free(filename); | |
353 | + return -1; | |
27ddd8a0 AM |
354 | } |
355 | ||
f20fb8bf JR |
356 | free(filename); |
357 | @@ -382,12 +278,6 @@ | |
358 | *service = serv; | |
359 | *service_overrides = serv_overrides; | |
360 | return 0; | |
361 | - | |
362 | -try_xinetd: | |
363 | - free(filename); | |
364 | - if (!(type & TYPE_XINETD)) | |
365 | - return -1; | |
366 | - return readXinetdServiceInfo(name,service); | |
367 | } | |
368 | ||
369 | static struct dep *parseDeps(char *pos, char *end) { | |
bcda1112 | 370 | @@ -760,62 +650,6 @@ |
f20fb8bf | 371 | return ret; |
82df657c ER |
372 | } |
373 | ||
374 | -int setXinetdService(struct service s, int on) { | |
375 | - int oldfd, newfd; | |
376 | - char oldfname[100], newfname[100]; | |
377 | - char tmpstr[50]; | |
378 | - char *buf, *ptr, *tmp; | |
379 | - struct stat sb; | |
bcda1112 | 380 | - mode_t mode; |
f20fb8bf | 381 | - |
82df657c ER |
382 | - if (on == -1) { |
383 | - on = s.enabled ? 1 : 0; | |
384 | - } | |
385 | - snprintf(oldfname,100,"%s/%s",XINETDDIR,s.name); | |
386 | - if ( (oldfd = open(oldfname,O_RDONLY)) == -1 ) { | |
387 | - return -1; | |
388 | - } | |
389 | - fstat(oldfd,&sb); | |
390 | - buf = malloc(sb.st_size+1); | |
391 | - if (read(oldfd,buf,sb.st_size)!=sb.st_size) { | |
392 | - close(oldfd); | |
393 | - free(buf); | |
394 | - return -1; | |
395 | - } | |
396 | - close(oldfd); | |
397 | - buf[sb.st_size] = '\0'; | |
398 | - snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name); | |
bcda1112 | 399 | - mode = umask(S_IRWXG | S_IRWXO); |
82df657c | 400 | - newfd = mkstemp(newfname); |
bcda1112 | 401 | - umask(mode); |
82df657c ER |
402 | - if (newfd == -1) { |
403 | - free(buf); | |
404 | - return -1; | |
405 | - } | |
406 | - while (buf) { | |
407 | - tmp = buf; | |
408 | - ptr = strchr(buf,'\n'); | |
409 | - if (ptr) { | |
410 | - *ptr = '\0'; | |
411 | - ptr++; | |
f20fb8bf | 412 | - } |
82df657c ER |
413 | - while (isspace(*buf)) buf++; |
414 | - if (strncmp(buf,"disable", 7) && strlen(buf)) { | |
415 | - write(newfd,tmp,strlen(tmp)); | |
416 | - write(newfd,"\n",1); | |
417 | - if (buf[0] == '{') { | |
418 | - snprintf(tmpstr,50,"\tdisable\t= %s", on ? "no" : "yes"); | |
419 | - write(newfd,tmpstr,strlen(tmpstr)); | |
420 | - write(newfd,"\n",1); | |
421 | - } | |
422 | - } | |
423 | - buf = ptr; | |
424 | - } | |
425 | - close(newfd); | |
82df657c ER |
426 | - unlink(oldfname); |
427 | - return(rename(newfname,oldfname)); | |
428 | -} | |
429 | - | |
430 | int doSetService(struct service s, int level, int on) { | |
431 | int priority = on ? s.sPriority : s.kPriority; | |
432 | char linkname[200]; | |
bcda1112 ER |
433 | --- chkconfig-1.3.63/leveldb.h 2014-11-05 18:39:09.000000000 +0200 |
434 | +++ chkconfig-1.3.63.no-xinetd/leveldb.h 2014-11-30 14:54:29.775316676 +0200 | |
f20fb8bf JR |
435 | @@ -17,13 +17,11 @@ |
436 | #define H_LEVELDB | |
437 | ||
438 | #define RUNLEVELS "/etc" | |
439 | -#define XINETDDIR "/etc/xinetd.d" | |
440 | ||
441 | #include <glob.h> | |
442 | ||
443 | #define TYPE_INIT_D 0x1 | |
444 | -#define TYPE_XINETD 0x2 | |
445 | -#define TYPE_ANY (TYPE_INIT_D | TYPE_XINETD) | |
446 | +#define TYPE_ANY (TYPE_INIT_D) | |
447 | ||
448 | #ifndef SYSTEMD_SERVICE_PATH | |
449 | #define SYSTEMD_SERVICE_PATH "/lib/systemd/system" | |
bcda1112 | 450 | @@ -67,8 +65,6 @@ |
f20fb8bf JR |
451 | int whatLevels(char * name); |
452 | int doSetService(struct service s, int level, int on); | |
453 | int findServiceEntries(char * name, int level, glob_t * globresptr); | |
454 | -int readXinetdServiceInfo(char *name, struct service *service); | |
455 | -int setXinetdService(struct service s, int on); | |
456 | int systemdIsInit(); | |
457 | int systemdActive(); | |
458 | int isOverriddenBySystemd(const char *service); | |
bcda1112 ER |
459 | --- chkconfig-1.3.63/ntsysv.c 2014-11-05 18:39:09.000000000 +0200 |
460 | +++ chkconfig-1.3.63.no-xinetd/ntsysv.c 2014-11-30 14:54:29.775316676 +0200 | |
f20fb8bf JR |
461 | @@ -61,15 +61,9 @@ |
462 | states = alloca(sizeof(*states) * numServices); | |
463 | ||
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, | |
468 | - states + i); | |
469 | - } else { | |
470 | checkboxes[i] = newtCheckbox(-1, i, services[i].name, | |
471 | (services[i].currentLevels & levels) ? '*' : ' ', NULL, | |
472 | states + i); | |
473 | - } | |
474 | newtFormAddComponent(subform, checkboxes[i]); | |
475 | } | |
476 | ||
bcda1112 | 477 | @@ -126,16 +120,10 @@ |
27ddd8a0 AM |
478 | if (!update) return 1; |
479 | ||
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] == '*'); | |
485 | - } else { | |
486 | for (j = 0; j < 7; j++) { | |
487 | if (levels & (1 << j)) | |
488 | doSetService(services[i], j, states[i] == '*'); | |
489 | } | |
490 | - } | |
491 | } | |
492 | ||
bcda1112 ER |
493 | return 0; |
494 | @@ -214,49 +202,6 @@ | |
27ddd8a0 AM |
495 | |
496 | closedir(dir); | |
bcda1112 | 497 | |
27ddd8a0 AM |
498 | - if (!stat("/usr/sbin/xinetd",&sb)) { |
499 | - if (!(dir = opendir(XINETDDIR))) { | |
500 | - fprintf(stderr, "failed to open " XINETDDIR ": %s\n", | |
501 | - strerror(errno)); | |
502 | - return 2; | |
503 | - } | |
504 | - | |
505 | - while ((ent = readdir(dir))) { | |
506 | - if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') || | |
507 | - strchr(ent->d_name, '.')) continue; | |
508 | - | |
509 | - sprintf(fn, "%s/%s", XINETDDIR, ent->d_name); | |
510 | - if (stat(fn, &sb)) | |
511 | - { | |
512 | - err = errno; | |
513 | - continue; | |
514 | - } | |
515 | - if (!S_ISREG(sb.st_mode)) continue; | |
516 | - | |
517 | - if (numServices == numServicesAlloced) { | |
518 | - numServicesAlloced += 10; | |
f20fb8bf | 519 | - services = realloc(services, |
27ddd8a0 AM |
520 | - numServicesAlloced * sizeof(*services)); |
521 | - } | |
522 | - | |
f20fb8bf JR |
523 | - rc = readXinetdServiceInfo(ent->d_name, services + numServices); |
524 | - | |
27ddd8a0 AM |
525 | - if (rc == -1) { |
526 | - fprintf(stderr, _("error reading info for service %s: %s\n"), | |
527 | - ent->d_name, strerror(errno)); | |
528 | - closedir(dir); | |
529 | - return 2; | |
530 | - } else if (!rc) | |
531 | - numServices++; | |
532 | - } | |
533 | - | |
534 | - if (err) { | |
535 | - fprintf(stderr, _("error reading from directory %s: %s\n"), | |
536 | - XINETDDIR, strerror(err)); | |
537 | - return 1; | |
538 | - } | |
539 | - } | |
bcda1112 | 540 | - |
f20fb8bf | 541 | qsort(services, numServices, sizeof(*services), serviceNameCmp); |
564d2f1f | 542 | |
bcda1112 | 543 | *servicesPtr = services; |