Blame SOURCES/0004-multipathd-set-return-code-for-multipathd-commands.patch

5c2e41
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5c2e41
From: Benjamin Marzinski <bmarzins@redhat.com>
5c2e41
Date: Mon, 8 Oct 2018 14:49:30 -0500
5c2e41
Subject: [PATCH] multipathd: set return code for multipathd commands
5c2e41
5c2e41
Failed multipathd commands should set the return code to 1.
5c2e41
5c2e41
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
5c2e41
---
5c2e41
 multipathd/main.c   |  8 ++++----
5c2e41
 multipathd/uxclnt.c | 13 ++++++++-----
5c2e41
 2 files changed, 12 insertions(+), 9 deletions(-)
5c2e41
5c2e41
diff --git a/multipathd/main.c b/multipathd/main.c
5c2e41
index d3f7719..2d45d98 100644
5c2e41
--- a/multipathd/main.c
5c2e41
+++ b/multipathd/main.c
5c2e41
@@ -2966,9 +2966,9 @@ main (int argc, char *argv[])
5c2e41
 			if (verbosity)
5c2e41
 				conf->verbosity = verbosity;
5c2e41
 			uxsock_timeout = conf->uxsock_timeout;
5c2e41
-			uxclnt(optarg, uxsock_timeout + 100);
5c2e41
+			err = uxclnt(optarg, uxsock_timeout + 100);
5c2e41
 			free_config(conf);
5c2e41
-			exit(0);
5c2e41
+			return err;
5c2e41
 		case 'B':
5c2e41
 			bindings_read_only = 1;
5c2e41
 			break;
5c2e41
@@ -3005,9 +3005,9 @@ main (int argc, char *argv[])
5c2e41
 			optind++;
5c2e41
 		}
5c2e41
 		c += snprintf(c, s + CMDSIZE - c, "\n");
5c2e41
-		uxclnt(s, uxsock_timeout + 100);
5c2e41
+		err = uxclnt(s, uxsock_timeout + 100);
5c2e41
 		free_config(conf);
5c2e41
-		exit(0);
5c2e41
+		return err;
5c2e41
 	}
5c2e41
 
5c2e41
 	if (foreground) {
5c2e41
diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c
5c2e41
index 08db0e8..a76f8e2 100644
5c2e41
--- a/multipathd/uxclnt.c
5c2e41
+++ b/multipathd/uxclnt.c
5c2e41
@@ -103,14 +103,14 @@ static void process(int fd, unsigned int timeout)
5c2e41
 	}
5c2e41
 }
5c2e41
 
5c2e41
-static void process_req(int fd, char * inbuf, unsigned int timeout)
5c2e41
+static int process_req(int fd, char * inbuf, unsigned int timeout)
5c2e41
 {
5c2e41
 	char *reply;
5c2e41
 	int ret;
5c2e41
 
5c2e41
 	if (send_packet(fd, inbuf) != 0) {
5c2e41
 		printf("cannot send packet\n");
5c2e41
-		return;
5c2e41
+		return 1;
5c2e41
 	}
5c2e41
 	ret = recv_packet(fd, &reply, timeout);
5c2e41
 	if (ret < 0) {
5c2e41
@@ -118,9 +118,12 @@ static void process_req(int fd, char * inbuf, unsigned int timeout)
5c2e41
 			printf("timeout receiving packet\n");
5c2e41
 		else
5c2e41
 			printf("error %d receiving packet\n", ret);
5c2e41
+		return 1;
5c2e41
 	} else {
5c2e41
 		printf("%s", reply);
5c2e41
+		ret = (strcmp(reply, "fail\n") == 0);
5c2e41
 		FREE(reply);
5c2e41
+		return ret;
5c2e41
 	}
5c2e41
 }
5c2e41
 
5c2e41
@@ -129,16 +132,16 @@ static void process_req(int fd, char * inbuf, unsigned int timeout)
5c2e41
  */
5c2e41
 int uxclnt(char * inbuf, unsigned int timeout)
5c2e41
 {
5c2e41
-	int fd;
5c2e41
+	int fd, ret = 0;
5c2e41
 
5c2e41
 	fd = mpath_connect();
5c2e41
 	if (fd == -1)
5c2e41
 		exit(1);
5c2e41
 
5c2e41
 	if (inbuf)
5c2e41
-		process_req(fd, inbuf, timeout);
5c2e41
+		ret = process_req(fd, inbuf, timeout);
5c2e41
 	else
5c2e41
 		process(fd, timeout);
5c2e41
 	mpath_disconnect(fd);
5c2e41
-	return 0;
5c2e41
+	return ret;
5c2e41
 }
5c2e41
-- 
5c2e41
2.7.4
5c2e41