1 From 8003178db245b43d04b27b559d5541ced24ec13f Mon Sep 17 00:00:00 2001
2 From: Chris Leech <cleech@redhat.com>
3 Date: Wed, 19 Dec 2012 21:39:06 -0800
4 Subject: [PATCH] iscsiuio systemd socket activation support
7 iscsiuio/src/unix/iscsid_ipc.c | 28 ++++++++++++++++++++++++++++
8 1 file changed, 28 insertions(+)
10 diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
11 index e22de0d..4908cb7 100644
12 --- a/iscsiuio/src/unix/iscsid_ipc.c
13 +++ b/iscsiuio/src/unix/iscsid_ipc.c
14 @@ -948,6 +948,30 @@ static void *iscsid_loop(void *arg)
18 +#define SD_SOCKET_FDS_START 3
20 +static int ipc_systemd(void)
24 + env = getenv("LISTEN_PID");
26 + if (!env || (strtoul(env, NULL, 10) != getpid()))
29 + env = getenv("LISTEN_FDS");
34 + if (strtoul(env, NULL, 10) != 1) {
35 + LOG_ERR("Did not receive exactly one IPC socket from systemd");
39 + return SD_SOCKET_FDS_START;
42 /******************************************************************************
43 * Initialize/Cleanup routines
44 ******************************************************************************/
45 @@ -961,6 +985,10 @@ int iscsid_init()
47 struct sockaddr_un addr;
49 + iscsid_opts.fd = ipc_systemd();
50 + if (iscsid_opts.fd >= 0)
53 iscsid_opts.fd = socket(AF_LOCAL, SOCK_STREAM, 0);
54 if (iscsid_opts.fd < 0) {
55 LOG_ERR(PFX "Can not create IPC socket");