From eea5a234bb01ef71743faa26efcd99795305555e Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 12 Oct 2017 14:42:59 +1100 Subject: [PATCH 1/2] ctdb-common: Ignore event scripts with multiple '.'s BUG: https://bugzilla.samba.org/show_bug.cgi?id=13070 This avoids running event script copies left by a package manager. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 7720ca0729b127a93d78401aaf1341d79f9603a4) --- ctdb/common/run_event.c | 6 ++++++ ctdb/config/events.d/README | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ctdb/common/run_event.c b/ctdb/common/run_event.c index e5d562c96b3..0961d657a74 100644 --- a/ctdb/common/run_event.c +++ b/ctdb/common/run_event.c @@ -60,6 +60,12 @@ static int script_filter(const struct dirent *de) return 0; } + /* Ignore filenames with multiple '.'s */ + ptr = index(&de->d_name[3], '.'); + if (ptr != NULL) { + return 0; + } + return 1; } diff --git a/ctdb/config/events.d/README b/ctdb/config/events.d/README index 11da7028be9..69f5904c3c2 100644 --- a/ctdb/config/events.d/README +++ b/ctdb/config/events.d/README @@ -11,7 +11,9 @@ alphanumeric sort order. As a special case, any eventscript that ends with a '~' character will be ignored since this is a common postfix that some editors will append to -older versions of a file. +older versions of a file. Similarly, any eventscript with multiple '.'s +will be ignored as package managers can create copies with additional +suffix starting with '.' (e.g. .rpmnew, .dpkg-dist). Only executable event scripts are run by CTDB. Any event script that does not have execute permission is ignored. -- 2.13.6 From 187daec05587dc9dcd624c8dfc1bfde17ab3210c Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 12 Oct 2017 14:44:03 +1100 Subject: [PATCH 2/2] ctdb-tests: Add tests for event scripts with multiple '.'s BUG: https://bugzilla.samba.org/show_bug.cgi?id=13070 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Wed Oct 18 10:19:48 CEST 2017 on sn-devel-144 (cherry picked from commit 3bc8880ea0532abed1db002710d3dd6a91f750dc) --- ctdb/tests/cunit/run_event_001.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ctdb/tests/cunit/run_event_001.sh b/ctdb/tests/cunit/run_event_001.sh index f0ffe4ff0c6..35c256b6fcd 100755 --- a/ctdb/tests/cunit/run_event_001.sh +++ b/ctdb/tests/cunit/run_event_001.sh @@ -37,6 +37,27 @@ required_result 1 < "$scriptdir/10.test.rpmnew" < "$scriptdir/11.foo" <