Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > eb284da017ca08c3a9a32c8fd2ca634c > files > 9

chkconfig-1.11-2.mga7.src.rpm

From 3eab8167f04ed47f871b34c3898cfa10c6a17fe3 Mon Sep 17 00:00:00 2001
From: Andrey Borzenkov <arvidjaar@gmail.com>
Date: Wed, 24 Jun 2015 09:54:38 +0100
Subject: [PATCH 905/907] chkconfig: Skip any init script with a dot, comma or
 tilde anywhere in it's name

---
 chkconfig.c | 12 ++----------
 leveldb.c   | 12 ++----------
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/chkconfig.c b/chkconfig.c
index f70db48..0a75789 100644
--- a/chkconfig.c
+++ b/chkconfig.c
@@ -532,19 +532,9 @@ static int listService(char * item, int type) {
         while ((ent = readdir(dir))) {
             const char *dn;
 
-            /* Skip any file starting with a . */
-            if (ent->d_name[0] == '.')
-                continue;
-
             /* Skip files with known bad extensions */
-            if ((dn = strrchr(ent->d_name, '.')) != NULL &&
-                (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") ||
-                 !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
-                continue;
-
-            dn = ent->d_name + strlen(ent->d_name) - 1;
-            if (*dn == '~' || *dn == ',')
-                continue;
+            if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
+                 strchr(ent->d_name, '.')) continue;
 
             if (numServices == numServicesAlloced) {
                 numServicesAlloced += 10;
diff --git a/leveldb.c b/leveldb.c
index 352076c..d3ad763 100644
--- a/leveldb.c
+++ b/leveldb.c
@@ -268,18 +268,8 @@ int readServices(struct service **services) {
     while ((ent = readdir(dir))) {
         const char *dn;
 
-        /* Skip any file starting with a . */
-        if (ent->d_name[0] == '.')
-            continue;
-
-        /* Skip files with known bad extensions */
-        if ((dn = strrchr(ent->d_name, '.')) != NULL &&
-            (!strcmp(dn, ".rpmsave") || !strcmp(dn, ".rpmnew") ||
-             !strcmp(dn, ".rpmorig") || !strcmp(dn, ".swp")))
-            continue;
-
-        dn = ent->d_name + strlen(ent->d_name) - 1;
-        if (*dn == '~' || *dn == ',')
+        if (strchr(ent->d_name, '~') || strchr(ent->d_name, ',') ||
+            strchr(ent->d_name, '.'))
             continue;
 
         sprintf(fn, RUNLEVELS "/init.d/%s", ent->d_name);
-- 
2.3.2