Signed-off-by: Chris Leech <[email protected]>
---
iscsiuio/src/unix/iscsid_ipc.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
index 4a89ec2..3e92d90 100644
--- a/iscsiuio/src/unix/iscsid_ipc.c
+++ b/iscsiuio/src/unix/iscsid_ipc.c
@@ -953,6 +953,30 @@ static void *iscsid_loop(void *arg)
pthread_exit(NULL);
}
+#define SD_SOCKET_FDS_START 3
+
+static int ipc_systemd(void)
+{
+ char *env;
+
+ env = getenv("LISTEN_PID");
+
+ if (!env || (strtoul(env, NULL, 10) != getpid()))
+ return -EINVAL;
+
+ env = getenv("LISTEN_FDS");
+
+ if (!env)
+ return -EINVAL;
+
+ if (strtoul(env, NULL, 10) != 1) {
+ LOG_ERR("Did not receive exactly one IPC socket from systemd");
+ return -EINVAL;
+ }
+
+ return SD_SOCKET_FDS_START;
+}
+
/******************************************************************************
* Initialize/Cleanup routines
******************************************************************************/
@@ -966,6 +990,10 @@ int iscsid_init()
int rc, addr_len;
struct sockaddr_un addr;
+ iscsid_opts.fd = ipc_systemd();
+ if (iscsid_opts.fd >= 0)
+ return 0;
+
iscsid_opts.fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (iscsid_opts.fd < 0) {
LOG_ERR(PFX "Can not create IPC socket");
--
2.1.0
--
You received this message because you are subscribed to the Google Groups
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.