File open-iscsi-synchronize-startup-settings of Package open-iscsi

From e7e8d62b02361c05e857cd87a68855725c3a72c7 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 17 Jul 2009 16:00:39 +0200
Subject: [PATCH] Synchronize startup settings

The iscsi node settings contain two 'startup' settings, one for
the node and one for the connection. However, as MC/S is not
supported both settings have the same effect.
And if both of them are set differently the --loginall and
--logoutall code will match against _both_, leading to
erratic behaviour.

So we should make sure that both of them are always in synch
to avoid these errors.

References: bnc#514273

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 usr/iscsiadm.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 3fa4964..5311b2c 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1899,8 +1899,31 @@ static int exec_node_op(int op, int do_login, int do_logout,
 		set_param.name = name;
 		set_param.value = value;
 
-		if (for_each_rec(rec, &set_param, idbm_node_set_param))	
+		if (for_each_rec(rec, &set_param, idbm_node_set_param))
 			rc = -1;
+
+		/*
+		 * Compat hack:
+		 * node.startup and node.conn[0].startup must be kept
+		 * in sync so as not to confuse --loginall and --logoutall
+		 */
+		if (!strcmp(name, "node.startup")) {
+			log_debug(1, "synch node.conn[0].startup mode");
+			set_param.name = "node.conn[0].startup";
+			set_param.value = value;
+			if (for_each_rec(rec, &set_param,
+					 idbm_node_set_param))
+				rc = -1;
+		}
+		if (!strcmp(name, "node.conn[0].startup")) {
+			log_debug(1, "synch node.startup modes");
+			set_param.name = "node.startup";
+			set_param.value = value;
+			if (for_each_rec(rec, &set_param,
+					 idbm_node_set_param))
+				rc = -1;
+		}
+
 		goto out;
 	} else if (op == OP_DELETE) {
 		if (for_each_rec(rec, NULL, delete_node))
-- 
1.6.0.2