Blame SOURCES/0001-partly-support-socket-activated-services.patch

e2083d
From 7b2f13a52e3629f81052faa49e8be973bb9aa3a2 Mon Sep 17 00:00:00 2001
e2083d
From: Lukas Nykryn <lnykryn@redhat.com>
e2083d
Date: Thu, 15 Aug 2013 09:54:31 +0200
e2083d
Subject: [PATCH] partly support socket activated services
e2083d
e2083d
---
e2083d
 chkconfig.c      |  9 ++++++---
e2083d
 leveldb.c        | 26 ++++++++++++++++++++++++++
e2083d
 leveldb.h        |  1 +
e2083d
 po/chkconfig.pot | 24 ++++++++++++------------
e2083d
 4 files changed, 45 insertions(+), 15 deletions(-)
e2083d
e2083d
diff --git a/chkconfig.c b/chkconfig.c
e2083d
index ccdb225..6a1fc61 100644
e2083d
--- a/chkconfig.c
e2083d
+++ b/chkconfig.c
e2083d
@@ -622,17 +622,20 @@ int setService(char * name, int type, int where, int state) {
e2083d
 }
e2083d
 
e2083d
 void forwardSystemd(const char *name, int type, const char *verb) {
e2083d
-
e2083d
+    int socket = 0;
e2083d
     if (type == TYPE_XINETD)
e2083d
         return;
e2083d
 
e2083d
     if (!systemdIsInit())
e2083d
 	return;
e2083d
 
e2083d
-    if (isOverriddenBySystemd(name)) {
e2083d
+    if (isOverriddenBySystemd(name) || (socket = isSocketActivatedBySystemd(name))) {
e2083d
         char *p;
e2083d
 
e2083d
-        asprintf(&p, "%s.service", name);
e2083d
+        if(!socket)
e2083d
+                asprintf(&p, "%s.service", name);
e2083d
+        else
e2083d
+                asprintf(&p, "%s.socket", name);
e2083d
 
e2083d
         fprintf(stderr, _("Note: Forwarding request to 'systemctl %s %s'.\n"),
e2083d
                 verb, p);
e2083d
diff --git a/leveldb.c b/leveldb.c
e2083d
index 77a1396..352076c 100644
e2083d
--- a/leveldb.c
e2083d
+++ b/leveldb.c
e2083d
@@ -869,6 +869,32 @@ out:
e2083d
     return rc;
e2083d
 }
e2083d
 
e2083d
+int isSocketActivatedBySystemd(const char *service) {
e2083d
+    char *p;
e2083d
+    char *s;
e2083d
+    int rc = 0;
e2083d
+
e2083d
+    asprintf(&p, SYSTEMD_SERVICE_PATH "/%s@.service", service);
e2083d
+    asprintf(&s, SYSTEMD_SERVICE_PATH "/%s.socket", service);
e2083d
+
e2083d
+    if (access(p, F_OK) >= 0 && access(s, F_OK) >= 0) {
e2083d
+        rc = 1;
e2083d
+        goto out;
e2083d
+    }
e2083d
+    free(p);
e2083d
+    free(s);
e2083d
+
e2083d
+    asprintf(&p, SYSTEMD_LOCAL_SERVICE_PATH "/%s@.service", service);
e2083d
+    asprintf(&s, SYSTEMD_LOCAL_SERVICE_PATH "/%s.socket", service);
e2083d
+    if (access(p, F_OK) >= 0 && access(s, F_OK) >= 0) {
e2083d
+        rc = 1;
e2083d
+    }
e2083d
+out:
e2083d
+    free(p);
e2083d
+    free(s);
e2083d
+    return rc;
e2083d
+}
e2083d
+
e2083d
 int isEnabledInSystemd(const char *service) {
e2083d
         char *c = NULL;
e2083d
         int r;
e2083d
diff --git a/leveldb.h b/leveldb.h
e2083d
index bfa281a..63ab99e 100644
e2083d
--- a/leveldb.h
e2083d
+++ b/leveldb.h
e2083d
@@ -73,6 +73,7 @@ int systemdIsInit();
e2083d
 int systemdActive();
e2083d
 int isOverriddenBySystemd(const char *service);
e2083d
 int isEnabledInSystemd(const char *service);
e2083d
+int isSocketActivatedBySystemd(const char *service);
e2083d
 
e2083d
 void checkSystemdDependencies(struct service *s);
e2083d
 #endif
e2083d
diff --git a/po/chkconfig.pot b/po/chkconfig.pot
e2083d
index 7acfe8d..d174fdd 100644
e2083d
--- a/po/chkconfig.pot
e2083d
+++ b/po/chkconfig.pot
e2083d
@@ -8,7 +8,7 @@ msgid ""
e2083d
 msgstr ""
e2083d
 "Project-Id-Version: PACKAGE VERSION\n"
e2083d
 "Report-Msgid-Bugs-To: \n"
e2083d
-"POT-Creation-Date: 2013-07-31 17:00+0200\n"
e2083d
+"POT-Creation-Date: 2013-08-08 17:07+0200\n"
e2083d
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
e2083d
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
e2083d
 "Language-Team: LANGUAGE <LL@li.org>\n"
e2083d
@@ -100,50 +100,50 @@ msgstr ""
e2083d
 msgid "You do not have enough privileges to perform this operation.\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:422 ../chkconfig.c:427 ../chkconfig.c:550
e2083d
+#: ../chkconfig.c:421 ../chkconfig.c:426 ../chkconfig.c:549
e2083d
 msgid "on"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:422 ../chkconfig.c:427 ../chkconfig.c:550
e2083d
+#: ../chkconfig.c:421 ../chkconfig.c:426 ../chkconfig.c:549
e2083d
 msgid "off"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:512
e2083d
+#: ../chkconfig.c:511
e2083d
 #, c-format
e2083d
 msgid "xinetd based services:\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:514
e2083d
+#: ../chkconfig.c:513
e2083d
 #, c-format
e2083d
 msgid "failed to open directory %s: %s\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:638
e2083d
+#: ../chkconfig.c:640
e2083d
 #, c-format
e2083d
 msgid "Note: Forwarding request to 'systemctl %s %s'.\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:643
e2083d
+#: ../chkconfig.c:645
e2083d
 #, c-format
e2083d
 msgid "Failed to forward service request to systemctl: %m\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:699
e2083d
+#: ../chkconfig.c:701
e2083d
 #, c-format
e2083d
 msgid "%s version %s\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:711
e2083d
+#: ../chkconfig.c:713
e2083d
 #, c-format
e2083d
 msgid "--type must be 'sysv' or 'xinetd'\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:718
e2083d
+#: ../chkconfig.c:720
e2083d
 #, c-format
e2083d
 msgid "only one of --list, --add, --del, or --override may be specified\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../chkconfig.c:803
e2083d
+#: ../chkconfig.c:805
e2083d
 #, c-format
e2083d
 msgid "only one runlevel may be specified for a chkconfig query\n"
e2083d
 msgstr ""
e2083d
@@ -212,7 +212,7 @@ msgstr ""
e2083d
 msgid "cannot determine current run level\n"
e2083d
 msgstr ""
e2083d
 
e2083d
-#: ../leveldb.c:813
e2083d
+#: ../leveldb.c:815
e2083d
 #, c-format
e2083d
 msgid "failed to make symlink %s: %s\n"
e2083d
 msgstr ""
e2083d
-- 
e2083d
1.8.3.1
e2083d