Blame SOURCES/bz1683438-fix-vrrp_script-execution.patch

4b4efe
From 4e60fead497c9e99953dd6106c6a5869182533cc Mon Sep 17 00:00:00 2001
4b4efe
From: Quentin Armitage <quentin@armitage.org.uk>
4b4efe
Date: Thu, 9 May 2019 19:23:46 +0100
4b4efe
Subject: [PATCH] Don't enclose /dev/tcp/127.0.0.1/22 in ' chars when running
4b4efe
 as script
4b4efe
4b4efe
RedHat identified a problem with scripts like:
4b4efe
    vrrp_script {
4b4efe
        script "
4b4efe
    }
4b4efe
where returning an exit code of 127 (script not found).
4b4efe
4b4efe
This was identified to be due to the "script" being enclosed in '
4b4efe
characters, so the resulting system call was
4b4efe
system("'
4b4efe
and trailing ' characters when the first character of the script is '<'
4b4efe
or '>' resolves the problem.
4b4efe
4b4efe
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
4b4efe
---
4b4efe
 lib/notify.c | 12 ++++++++++--
4b4efe
 1 file changed, 10 insertions(+), 2 deletions(-)
4b4efe
4b4efe
diff --git a/lib/notify.c b/lib/notify.c
4b4efe
index 2f60e24c..1984bde3 100644
4b4efe
--- a/lib/notify.c
4b4efe
+++ b/lib/notify.c
4b4efe
@@ -130,10 +130,18 @@ cmd_str_r(const notify_script_t *script, char *buf, size_t len)
4b4efe
 
4b4efe
 		if (i)
4b4efe
 			*str_p++ = ' ';
4b4efe
-		*str_p++ = '\'';
4b4efe
+
4b4efe
+		/* Allow special case of bash script which is redirection only to
4b4efe
+		 * test for file existence. */
4b4efe
+		if (i || (script->args[i][0] != '<' && script->args[i][0] != '>'))
4b4efe
+			*str_p++ = '\'';
4b4efe
+
4b4efe
 		strcpy(str_p, script->args[i]);
4b4efe
 		str_p += str_len;
4b4efe
-		*str_p++ = '\'';
4b4efe
+
4b4efe
+		/* Close opening ' if we added one */
4b4efe
+		if (i || (script->args[i][0] != '<' && script->args[i][0] != '>'))
4b4efe
+			*str_p++ = '\'';
4b4efe
 	}
4b4efe
 	*str_p = '\0';
4b4efe
 
4b4efe
-- 
4b4efe
2.24.1
4b4efe