]> git.pld-linux.org Git - packages/open-iscsi.git/blob - 0047-iscsiuio-systemd-socket-activation-support.patch
896eba922694a514797da2147722fe44658cd1bc
[packages/open-iscsi.git] / 0047-iscsiuio-systemd-socket-activation-support.patch
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
5
6 ---
7  iscsiuio/src/unix/iscsid_ipc.c | 28 ++++++++++++++++++++++++++++
8  1 file changed, 28 insertions(+)
9
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)
15         pthread_exit(NULL);
16  }
17  
18 +#define SD_SOCKET_FDS_START 3
19 +
20 +static int ipc_systemd(void)
21 +{
22 +       char *env;
23 +
24 +       env = getenv("LISTEN_PID");
25 +
26 +       if (!env || (strtoul(env, NULL, 10) != getpid()))
27 +               return -EINVAL;
28 +
29 +       env = getenv("LISTEN_FDS");
30 +
31 +       if (!env)
32 +               return -EINVAL;
33 +
34 +       if (strtoul(env, NULL, 10) != 1) {
35 +               LOG_ERR("Did not receive exactly one IPC socket from systemd");
36 +               return -EINVAL;
37 +       }
38 +
39 +       return SD_SOCKET_FDS_START;
40 +}
41 +
42  /******************************************************************************
43   *  Initialize/Cleanup routines
44   ******************************************************************************/
45 @@ -961,6 +985,10 @@ int iscsid_init()
46         int rc, addr_len;
47         struct sockaddr_un addr;
48  
49 +       iscsid_opts.fd = ipc_systemd();
50 +       if (iscsid_opts.fd >= 0)
51 +               return 0;
52 +
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");
56 -- 
57 1.8.3.1
58
This page took 0.055438 seconds and 2 git commands to generate.