]> git.pld-linux.org Git - packages/chkconfig.git/blobdiff - chkconfig-noxinet.patch
up to 1.6 (fixes systemd<->sysv "ping-pong" issue)
[packages/chkconfig.git] / chkconfig-noxinet.patch
index e5007c084ca66e89bc2a8f03a39c7abde696b18d..b6a4fe07fd6e244ab6da6fb22c7abf6d67765f76 100644 (file)
@@ -1,40 +1,50 @@
---- chkconfig-1.3.37.org/chkconfig.c   2007-11-08 22:28:34.000000000 +0100
-+++ chkconfig-1.3.37/chkconfig.c       2008-04-24 09:30:17.709152778 +0200
-@@ -68,8 +68,6 @@
-       readServiceError(rc, name);
-       return 1;
-     }
--    if (s.type == TYPE_XINETD) return 0;
--
+--- chkconfig-1.3.63/chkconfig.8       2014-11-05 18:39:09.000000000 +0200
++++ chkconfig-1.3.63.no-xinetd/chkconfig.8     2014-11-30 14:54:29.771983174 +0200
+@@ -63,16 +63,6 @@
+ an already-started service, and will not re-stop a service that is
+ not running.
  
-     if (!findServiceEntries(name, level, &globres)) {
-           for (i = 0; i < globres.gl_pathc; i++)
-@@ -88,7 +86,6 @@
+-\fBchkconfig\fR also can manage xinetd scripts via the means
+-of xinetd.d configuration files. Note that only the
+-\fBon\fR, \fBoff\fR, and \fB-\-list\fR commands are supported
+-for xinetd.d services.
+-
+-\fBchkconfig\fR supports a \fB-\-type\fR argument to limit actions to only
+-a specific type of services, in the case where services of either type may
+-share a name. Possible values for \fItype\fR are \fIsysv\fR
+-and \fIxinetd\fR.
+-
+ .SH OPTIONS
+ .TP
+ \fB-\-level \fIlevels\fR
+--- chkconfig-1.4/chkconfig.c~ 2015-04-25 12:27:57.000000000 +0300
++++ chkconfig-1.4/chkconfig.c  2015-04-25 12:29:08.685346749 +0300
+@@ -102,7 +102,6 @@
        readServiceError(rc, name);
        return 1;
      }
 -    if (s.type == TYPE_XINETD) return 0;
  
-     for (level = 0; level < 7; level++) {
-           if (!findServiceEntries(name, level, &globres)) {
-@@ -238,7 +235,6 @@
+     checkRoot();
+@@ -298,7 +297,6 @@
        return 1;
      }
-       
 -    if (s.type == TYPE_XINETD) return 0;
-     if (s.isLSB)
-               frobDependencies(&s);
-     else
-@@ -269,8 +265,6 @@
-     if ((rc = readServiceDifferences(name, &s, &o, 0))) {
+     checkRoot();
+     if (s.isLSB) {
+@@ -337,8 +335,6 @@
        return 0;
      }
--      
 -    if (s.type == TYPE_XINETD) return 0;
+-
+     checkRoot();
  
      if ((s.levels == o.levels) &&
-         (s.kPriority == o.kPriority) &&
-@@ -351,10 +345,6 @@
+@@ -416,10 +412,6 @@
      }
  
      printf("%-15s", s.name);
  
      for (i = 0; i < 7; i++) {
        printf("\t%d:%s", i, isOn(s.name, i) ? _("on") : _("off"));
-@@ -364,32 +354,10 @@
-     return 0;
+@@ -425,7 +425,7 @@
+     int rc;
+     struct service s;
+-    if (systemdActive() && isOverriddenBySystemd(name) && !(type & TYPE_XINETD)) {
++    if (systemdActive() && isOverriddenBySystemd(name)) {
+         return forgiving ? 0 : 1;
+     }
+@@ -448,33 +440,10 @@
+     return showServiceInfo(s, forgiving);
  }
  
+-
 -static int isXinetdEnabled() {
--      int i;
 -      struct service s;
--      
--      if (readServiceInfo("xinetd", &s, 0)) {
+-
+-        if (isOverriddenBySystemd("xinetd") && isEnabledInSystemd("xinetd"))
+-                return 1;
+-
+-      if (readServiceInfo("xinetd", TYPE_INIT_D, &s, 0)) {
 -              return 0;
 -      }
--      for (i = 0; i < 7; i++) {
--              if (isOn("xinetd", i))
--                return 1;
--      }
+-      if (s.currentLevels)
+-              return 1;
 -      return 0;
 -}
 -
 -}
 -
 -
- static int listService(char * item) {
+ static int listService(char * item, int type) {
      DIR * dir;
-@@ -459,53 +427,6 @@
-       
-     closedir(dir);
-       
--    if (isXinetdEnabled()) {
+     struct dirent * ent;
+@@ -502,54 +471,6 @@
+           }
+         }
+     }
+-
+-    if (isXinetdEnabled() && type & TYPE_XINETD) {
 -          struct service *s, *t;
--        
+-
 -          printf("\n");
 -          printf(_("xinetd based services:\n"));
 -          if (!(dir = opendir(XINETDDIR))) {
 -          numServices = 0;
 -          numServicesAlloced = 10;
 -          s = malloc(sizeof (*s) * numServicesAlloced);
--          
+-
 -          while ((ent = readdir(dir))) {
 -                  const char *dn;
 -
 -                  dn = ent->d_name + strlen(ent->d_name) - 1;
 -                  if (*dn == '~' || *dn == ',')
 -                    continue;
--          
+-
 -                  if (numServices == numServicesAlloced) {
 -                          numServicesAlloced += 10;
 -                          s = realloc(s, numServicesAlloced * sizeof (*s));
 -                  }
--                  if (readXinetdServiceInfo(ent->d_name, s + numServices, 0) != -1)
+-                  if (readXinetdServiceInfo(ent->d_name, s + numServices) != -1)
 -                          numServices ++;
 -          }
--          
+-
 -          qsort(s, numServices, sizeof(*s), xinetdNameCmp);
 -          t = s;
 -          for (i = 0; i < numServices; i++, s++) {
      return 0;
  }
  
-@@ -547,11 +468,6 @@
-                   rc |= doSetService(s, i, what);
-           }
-           return rc;
+@@ -610,11 +531,6 @@
+             reloadSystemd();
+             return rc;
 -    } else if (s.type == TYPE_XINETD) {
 -          if (setXinetdService(s, state)) {
 -                  return 1;
 -          }
--          system("/etc/init.d/xinetd reload >/dev/null 2>&1");
+-          system("/sbin/service xinetd reload >/dev/null 2>&1");
      }
  
      return 0;
-@@ -682,13 +598,7 @@
-           rc = readServiceInfo(name, &s, 0);
+@@ -622,8 +538,6 @@
+ void forwardSystemd(const char *name, int type, const char *verb) {
+     int socket = 0;
+-    if (type == TYPE_XINETD)
+-        return;
+     if (!systemdIsInit())
+       return;
+@@ -704,12 +618,10 @@
+     if (help) usage(progname);
+     if (typeString) {
+-      if (!strcmp(typeString, "xinetd"))
+-          type = TYPE_XINETD;
+-      else if (!strcmp(typeString, "sysv"))
++      if (!strcmp(typeString, "sysv"))
+           type = TYPE_INIT_D;
+       else {
+-          fprintf(stderr, _("--type must be 'sysv' or 'xinetd'\n"));
++          fprintf(stderr, _("--type must be 'sysv'\n"));
+           exit(1);
+       }
+     }
+@@ -809,16 +721,9 @@
+           rc = readServiceInfo(name, type, &s, 0);
            if (rc)
               return 1;
 -          if (s.type == TYPE_XINETD) {
 -                     return !s.levels;
 -             else
 -                     return 1;
--          } else      
--             return isOn(name, level) ? 0 : 1;
-+          return isOn(name, level) ? 0 : 1;
-       } else if (!strcmp(state, "on"))
-           return setService(name, where, 1);
-       else if (!strcmp(state, "off"))
-diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
---- chkconfig-1.3.37.org/leveldb.c     2007-08-03 19:57:56.000000000 +0200
-+++ chkconfig-1.3.37/leveldb.c 2008-04-24 09:34:20.447423719 +0200
-@@ -149,101 +149,6 @@
+-          } else {
+                if (level == -1)
+                    level = currentRunlevel();
+              return s.currentLevels & (1 << level) ? 0 : 1;
+-          }
+       } else if (!strcmp(state, "on")) {
+           if (!noRedirectItem) {
+               forwardSystemd(name, type, "enable");
+--- chkconfig-1.4/leveldb.c~   2015-04-25 12:20:58.000000000 +0300
++++ chkconfig-1.4/leveldb.c    2015-04-25 12:21:39.535385553 +0300
+@@ -154,107 +154,6 @@
        return 0;
  }
  
--int readXinetdServiceInfo(char *name, struct service * service, int honorHide) {
--      char * filename = alloca(strlen(name) + strlen(XINETDDIR) + 50);
+-int readXinetdServiceInfo(char *name, struct service * service) {
+-      char * filename;
 -      int fd;
--      struct service serv = { 
+-      struct service serv = {
 -                      name: NULL,
 -                      levels: -1,
--                      kPriority: -1,
--                      sPriority: -1, 
--                      desc: NULL, 
--                      startDeps: NULL, 
+-                      kPriority: 100,
+-                      sPriority: -1,
+-                      desc: NULL,
+-                      startDeps: NULL,
 -                      stopDeps: NULL,
+-                      softStartDeps: NULL,
+-                      softStopDeps: NULL,
 -                      provides: NULL,
--                      type: TYPE_XINETD, 
--                      isLSB: 0, 
+-                      type: TYPE_XINETD,
+-                      isLSB: 0,
 -                      enabled: -1
 -      };
 -      struct stat sb;
--      char * buf, *ptr;
+-      char * buf = NULL, *ptr;
 -      char * eng_desc = NULL, *start;
--      
--      snprintf(filename, strlen(name)+strlen(XINETDDIR)+50, XINETDDIR "/%s", name);
--      
--      if ((fd = open(filename, O_RDONLY)) < 0) return -1;
+-
+-      asprintf(&filename, XINETDDIR "/%s", name);
+-
+-      if ((fd = open(filename, O_RDONLY)) < 0) goto out_err;
 -      fstat(fd,&sb);
--      if (! S_ISREG(sb.st_mode)) return -1;
+-      if (! S_ISREG(sb.st_mode)) goto out_err;
 -      buf = malloc(sb.st_size+1);
--      if (read(fd,buf,sb.st_size)!=sb.st_size) {
--              close(fd);
--              free(buf);
--              return -1;
--      }
+-      if (read(fd,buf,sb.st_size)!=sb.st_size) goto out_err;
 -      close(fd);
 -        serv.name = strdup(name);
 -      buf[sb.st_size] = '\0';
@@ -223,20 +267,22 @@ diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
 -                              if (!serv.desc) {
 -                                      if (eng_desc)
 -                                        serv.desc = eng_desc;
+-                                        else
+-                                          serv.desc = strdup(name);
 -                              } else if (eng_desc)
 -                                        free (eng_desc);
 -                      }
 -                      if (ptr) {
 -                              *ptr = '\0';
 -                              ptr++;
--                      } 
+-                      }
 -                      buf = ptr;
 -                      continue;
 -              }
 -              while (isspace(*buf) && buf < ptr) buf++;
 -              if (!strncmp(buf,"disable", 7)) {
 -                      buf = strstr(buf,"=");
--                      if (buf) 
+-                      if (buf)
 -                        do {
 -                                buf++;
 -                        } while(isspace(*buf));
@@ -254,36 +300,84 @@ diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
 -              if (ptr) {
 -                      *ptr = '\0';
 -                      ptr++;
--              } 
+-              }
 -              buf = ptr;
 -      }
 -      *service = serv;
 -      return 0;
+-out_err:
+-        if (fd >= 0)
+-            close(fd);
+-        free(buf);
+-        free(filename);
+-        return -1;
 -}
 -
- int readServiceInfo(char * name, struct service * service, int honorHide) {
-     char * filename = alloca(strlen(name) + strlen(RUNLEVELS) + 50);
-     int fd;
-@@ -253,7 +158,7 @@
-     sprintf(filename, RUNLEVELS "/init.d/%s", name);
+ int readServices(struct service **services) {
+       DIR * dir;
+       struct dirent * ent;
+@@ -304,12 +203,14 @@
+     int parseret;
  
-     if ((fd = open(filename, O_RDONLY)) < 0) {
--          return readXinetdServiceInfo(name,service,honorHide);
-+          return -1;
-     }
+     if (!(type & TYPE_INIT_D))
+-      goto try_xinetd;
++      return -1;
+     asprintf(&filename, RUNLEVELS "/init.d/%s", name);
  
+-    if ((fd = open(filename, O_RDONLY)) < 0)
+-      goto try_xinetd;
++    if ((fd = open(filename, O_RDONLY)) < 0) {
++      free(filename);
++      return -1;
++    }
+     free(filename);
      parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
-@@ -290,7 +195,7 @@
-     sprintf(filename, RUNLEVELS "/init.d/%s", name);
+@@ -338,12 +239,6 @@
+     free(filename);
+     *service = serv;
+     return 0;
+-
+-try_xinetd:
+-    free(filename);
+-    if (!(type & TYPE_XINETD))
+-      return -1;
+-    return readXinetdServiceInfo(name,service);
+ }
+ int readServiceDifferences(char * name, int type, struct service * service, struct service * service_overrides, int honorHide) {
+@@ -353,12 +248,13 @@
+     int parseret;
+     if (!(type & TYPE_INIT_D))
+-      goto try_xinetd;
++      return -1;
+     asprintf(&filename, RUNLEVELS "/init.d/%s", name);
  
      if ((fd = open(filename, O_RDONLY)) < 0) {
--          return readXinetdServiceInfo(name,service,honorHide);
-+          return -1;
+-      goto try_xinetd;
++        free(filename);
++      return -1;
      }
  
-     parseret = parseServiceInfo(fd, name, &serv, honorHide, 0);
-@@ -656,60 +561,6 @@
-     return 1;
+     free(filename);
+@@ -382,12 +278,6 @@
+     *service = serv;
+     *service_overrides = serv_overrides;
+     return 0;
+-
+-try_xinetd:
+-    free(filename);
+-    if (!(type & TYPE_XINETD))
+-      return -1;
+-    return readXinetdServiceInfo(name,service);
+ }
+ static struct dep *parseDeps(char *pos, char *end) {
+@@ -682,67 +682,6 @@
+     return ret;
  }
  
 -int setXinetdService(struct service s, int on) {
@@ -292,7 +386,9 @@ diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
 -      char tmpstr[50];
 -      char *buf, *ptr, *tmp;
 -      struct stat sb;
--      
+-        mode_t mode;
+-        int r;
+-
 -      if (on == -1) {
 -              on = s.enabled ? 1 : 0;
 -      }
@@ -310,7 +406,9 @@ diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
 -      close(oldfd);
 -      buf[sb.st_size] = '\0';
 -      snprintf(newfname,100,"%s/%s.XXXXXX",XINETDDIR,s.name);
+-        mode = umask(S_IRWXG | S_IRWXO);
 -      newfd = mkstemp(newfname);
+-        umask(mode);
 -      if (newfd == -1) {
 -              free(buf);
 -              return -1;
@@ -321,7 +419,7 @@ diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
 -              if (ptr) {
 -                      *ptr = '\0';
 -                      ptr++;
--              } 
+-              }
 -              while (isspace(*buf)) buf++;
 -              if (strncmp(buf,"disable", 7) && strlen(buf)) {
 -                      write(newfd,tmp,strlen(tmp));
@@ -335,18 +433,66 @@ diff -urN chkconfig-1.3.37.org/leveldb.c chkconfig-1.3.37/leveldb.c
 -              buf = ptr;
 -      }
 -      close(newfd);
--      chmod(newfname,0644);
 -      unlink(oldfname);
--      return(rename(newfname,oldfname));
+-        r = rename(newfname,oldfname);
+-        if (selinux_restore(oldfname) != 0)
+-                fprintf(stderr, _("Unable to set selinux context for %s: %s\n"), oldfname,
+-              strerror(errno));
+-      return(r);
 -}
 -
  int doSetService(struct service s, int level, int on) {
      int priority = on ? s.sPriority : s.kPriority;
      char linkname[200];
-diff -urN chkconfig-1.3.37.org/ntsysv.c chkconfig-1.3.37/ntsysv.c
---- chkconfig-1.3.37.org/ntsysv.c      2007-08-03 19:57:56.000000000 +0200
-+++ chkconfig-1.3.37/ntsysv.c  2008-04-24 09:34:50.485526379 +0200
-@@ -131,16 +131,10 @@
+--- chkconfig-1.4/leveldb.h~   2015-04-25 12:20:58.000000000 +0300
++++ chkconfig-1.4/leveldb.h    2015-04-25 12:22:49.345672830 +0300
+@@ -17,14 +17,12 @@
+ #define H_LEVELDB
+ #define RUNLEVELS "/etc"
+-#define XINETDDIR "/etc/xinetd.d"
+ #include <glob.h>
+ #define TYPE_INIT_D   0x1
+-#define TYPE_XINETD   0x2
+ #define TYPE_SYSTEMD  0x4
+-#define TYPE_ANY      (TYPE_INIT_D | TYPE_XINETD | TYPE_SYSTEMD)
++#define TYPE_ANY      (TYPE_INIT_D | TYPE_SYSTEMD)
+ #ifndef SYSTEMD_SERVICE_PATH
+ #define SYSTEMD_SERVICE_PATH "/lib/systemd/system"
+@@ -67,8 +65,6 @@
+ int whatLevels(char * name);
+ int doSetService(struct service s, int level, int on);
+ int findServiceEntries(char * name, int level, glob_t * globresptr);
+-int readXinetdServiceInfo(char *name, struct service *service);
+-int setXinetdService(struct service s, int on);
+ int systemdIsInit();
+ int systemdActive();
+ int isOverriddenBySystemd(const char *service);
+--- chkconfig-1.4/ntsysv.c~    2015-03-26 15:14:53.000000000 +0200
++++ chkconfig-1.4/ntsysv.c     2015-04-25 12:25:27.840559610 +0300
+@@ -67,17 +67,12 @@
+         if (last != services[i].type) {
+               newtFormAddComponent(subform, newtCompactButton(-1, count,
+                                         services[i].type == TYPE_INIT_D ? "SysV initscripts":
+-                                        services[i].type == TYPE_XINETD ? "xinetd services":
+                                         services[i].type == TYPE_SYSTEMD ? "systemd services":
+                                         "Unknown"));
+                 count++;
+                 last = services[i].type;
+         }
+-      if (services[i].type == TYPE_XINETD) {
+-              checkboxes[i] = newtCheckbox(-1, count, services[i].name,
+-                                   services[i].levels ? '*' : ' ', NULL,
+-                                   states + i);
+-      } else if (services[i].type == TYPE_SYSTEMD) {
++      if (services[i].type == TYPE_SYSTEMD) {
+               checkboxes[i] = newtCheckbox(-1, count, services[i].name,
+                                    services[i].enabled ? '*' : ' ', NULL,
+                                    states + i);
+@@ -142,11 +137,7 @@
      if (!update) return 1;
  
      for (i = 0; i < numServices; i++) {
@@ -354,16 +500,12 @@ diff -urN chkconfig-1.3.37.org/ntsysv.c chkconfig-1.3.37/ntsysv.c
 -        if ((services[i].enabled && states[i] != '*') ||
 -          (!services[i].enabled && states[i] == '*'))
 -            setXinetdService(services[i], states[i] == '*');
--      } else {
-             for (j = 0; j < 7; j++) {
-                     if (levels & (1 << j))
-                       doSetService(services[i], j, states[i] == '*');
-             }
--      }
-     }
-     return 0;
-@@ -217,49 +211,6 @@
+-      } else if (services[i].type == TYPE_SYSTEMD) {
++        if (services[i].type == TYPE_SYSTEMD) {
+               char *cmd = NULL;
+               int en = 0;
+               if (services[i].enabled && states[i] != '*')
+@@ -347,49 +338,6 @@
  
      closedir(dir);
  
@@ -388,12 +530,12 @@ diff -urN chkconfig-1.3.37.org/ntsysv.c chkconfig-1.3.37/ntsysv.c
 -
 -      if (numServices == numServicesAlloced) {
 -          numServicesAlloced += 10;
--          services = realloc(services, 
+-          services = realloc(services,
 -                              numServicesAlloced * sizeof(*services));
 -      }
 -
--      rc = readXinetdServiceInfo(ent->d_name, services + numServices, honorHide);
--      
+-      rc = readXinetdServiceInfo(ent->d_name, services + numServices);
+-
 -      if (rc == -1) {
 -          fprintf(stderr, _("error reading info for service %s: %s\n"),
 -                      ent->d_name, strerror(errno));
@@ -410,20 +552,6 @@ diff -urN chkconfig-1.3.37.org/ntsysv.c chkconfig-1.3.37/ntsysv.c
 -    }
 -    }
 -
-     qsort(services, numServices, sizeof(*services), serviceNameCmp);
-     *servicesPtr = services;
---- chkconfig-1.3.37/chkconfig.8~      2007-11-08 23:28:34.000000000 +0200
-+++ chkconfig-1.3.37/chkconfig.8       2008-04-24 10:48:07.171320486 +0300
-@@ -63,11 +63,6 @@
- an already-started service, and will not re-stop a service that is
- not running.
+     getSystemdServices(&services, &numServices);
  
--\fBchkconfig\fR also can manage xinetd scripts via the means
--of xinetd.d configuration files. Note that only the
--\fBon\fR, \fBoff\fR, and \fB-\-list\fR commands are supported
--for xinetd.d services.
--
- .SH OPTIONS
- .TP
- \fB-\-level \fIlevels\fR
+     qsort(services, numServices, sizeof(*services), serviceNameCmp);
This page took 0.055596 seconds and 4 git commands to generate.