From f3b2e56d173cde3cdd158a8233c717cf21f4ef77 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 12 Oct 2017 14:42:59 +1100 Subject: [PATCH] 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/config/events.d/README | 4 +++- ctdb/server/ctdb_eventd.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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. diff --git a/ctdb/server/ctdb_eventd.c b/ctdb/server/ctdb_eventd.c index 232711ce4e2..c9a9bf6fa0e 100644 --- a/ctdb/server/ctdb_eventd.c +++ b/ctdb/server/ctdb_eventd.c @@ -425,6 +425,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; } -- 2.13.6