Blame SOURCES/0026-iscsiuio-Change-socket-bind-to-use-the-same-struct-s.patch

6c64be
From fef4db2784fac34fa99468de09c386114b228b36 Mon Sep 17 00:00:00 2001
6c64be
From: Jan Vesely <jvesely@redhat.com>
6c64be
Date: Wed, 26 Jun 2013 15:55:12 +0200
6c64be
Subject: iscsiuio: Change socket bind to use the same struct size as iscsid
6c64be
6c64be
Without this patch connections to iscsiuio fail, and strace prints:
6c64be
6c64be
connect(8, {sa_family=AF_FILE, path=@"ISCSID_UIP_ABSTRACT_NAMESPACE"}, 32) = -1 ECONNREFUSED (Connection refused)
6c64be
6c64be
Note that updating mgmt_ipc_listen and ipc_connect to use sizeof(addr) instead
6c64be
of the precomputed values also fixes the issue.
6c64be
Looks like "(Null bytes in the name have no special significance.)" [man 7 unix] is the culprit here.
6c64be
6c64be
Signed-off-by: Jan Vesely <jvesely@redhat.com>
6c64be
---
6c64be
 iscsiuio/src/unix/iscsid_ipc.c | 6 ++++--
6c64be
 1 file changed, 4 insertions(+), 2 deletions(-)
6c64be
6c64be
diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
6c64be
index 5c097e6..e22de0d 100644
6c64be
--- a/iscsiuio/src/unix/iscsid_ipc.c
6c64be
+++ b/iscsiuio/src/unix/iscsid_ipc.c
6c64be
@@ -958,7 +958,7 @@ static void *iscsid_loop(void *arg)
6c64be
  */
6c64be
 int iscsid_init()
6c64be
 {
6c64be
-	int rc;
6c64be
+	int rc, addr_len;
6c64be
 	struct sockaddr_un addr;
6c64be
 
6c64be
 	iscsid_opts.fd = socket(AF_LOCAL, SOCK_STREAM, 0);
6c64be
@@ -967,12 +967,14 @@ int iscsid_init()
6c64be
 		return iscsid_opts.fd;
6c64be
 	}
6c64be
 
6c64be
+	addr_len = offsetof(struct sockaddr_un, sun_path) + strlen(ISCSID_UIP_NAMESPACE) + 1;
6c64be
+
6c64be
 	memset(&addr, 0, sizeof(addr));
6c64be
 	addr.sun_family = AF_LOCAL;
6c64be
 	memcpy((char *)&addr.sun_path + 1, ISCSID_UIP_NAMESPACE,
6c64be
 	       strlen(ISCSID_UIP_NAMESPACE));
6c64be
 
6c64be
-	rc = bind(iscsid_opts.fd, (struct sockaddr *)&addr, sizeof(addr));
6c64be
+	rc = bind(iscsid_opts.fd, (struct sockaddr *)&addr, addr_len);
6c64be
 	if (rc < 0) {
6c64be
 		LOG_ERR(PFX "Can not bind IPC socket: %s", strerror(errno));
6c64be
 		goto error;
6c64be
-- 
6c64be
1.8.1.4
6c64be