Blame SOURCES/bz1667292-fix-vrrp_script-misc_script.patch

9cfb40
From 83d10ba08b8cd550196ae14f4f40fdbb72078057 Mon Sep 17 00:00:00 2001
9cfb40
From: Quentin Armitage <quentin@armitage.org.uk>
9cfb40
Date: Thu, 22 Mar 2018 16:54:54 +0000
9cfb40
Subject: [PATCH] Fix vrrp_script and check_misc scripts of type
9cfb40
 
9cfb40
9cfb40
Issue #817 identified that these types of "scripts" no longer worked.
9cfb40
9cfb40
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
9cfb40
---
9cfb40
 keepalived/check/check_misc.c | 8 ++++++++
9cfb40
 keepalived/vrrp/vrrp.c        | 7 +++++++
9cfb40
 2 files changed, 15 insertions(+)
9cfb40
9cfb40
diff --git a/keepalived/check/check_misc.c b/keepalived/check/check_misc.c
9cfb40
index ccb9b63b..7d7e740b 100644
9cfb40
--- a/keepalived/check/check_misc.c
9cfb40
+++ b/keepalived/check/check_misc.c
9cfb40
@@ -149,6 +149,14 @@ check_misc_script_security(void)
9cfb40
 			continue;
9cfb40
 
9cfb40
 		misc_script = CHECKER_ARG(checker);
9cfb40
+
9cfb40
+		/* If the misc check script starts "</" (possibly with white space between
9cfb40
+		 * the '<' and '/'), it is checking for a file being openable,
9cfb40
+		 * so it won't be executed */
9cfb40
+		if (misc_script->path[0] == '<' &&
9cfb40
+		    misc_script->path[strspn(misc_script->path + 1, " \t") + 1] == '/')
9cfb40
+			return 0;
9cfb40
+
9cfb40
 		script.name = misc_script->path;
9cfb40
 		script.uid = misc_script->uid;
9cfb40
 		script.gid = misc_script->gid;
9cfb40
diff --git a/keepalived/vrrp/vrrp.c b/keepalived/vrrp/vrrp.c
9cfb40
index 3d2bfe41..c18a8d17 100644
9cfb40
--- a/keepalived/vrrp/vrrp.c
9cfb40
+++ b/keepalived/vrrp/vrrp.c
9cfb40
@@ -149,6 +149,13 @@ check_track_script_secure(tracked_sc_t *script)
9cfb40
 	if (script->scr->insecure)
9cfb40
 		return 0;
9cfb40
 
9cfb40
+	/* If the track script starts "</" (possibly with white space between
9cfb40
+	 * the '<' and '/'), it is checking for a file being openable,
9cfb40
+	 * so it won't be executed */
9cfb40
+	if (script->scr->script[0] == '<' &&
9cfb40
+	    script->scr->script[strspn(script->scr->script + 1, " \t") + 1] == '/')
9cfb40
+		return 0;
9cfb40
+
9cfb40
 	ns.name = script->scr->script;
9cfb40
 	ns.uid = script->scr->uid;
9cfb40
 	ns.gid = script->scr->gid;
9cfb40
-- 
9cfb40
2.21.0
9cfb40