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