keepalived/SOURCES/bz1683438-fix-vrrp_script-execution.patch
2021-09-09 19:40:45 +00:00

52 lines
1.5 KiB
Diff

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