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

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