diff --git a/lib/backend.py b/lib/backend.py index f4e308e651ad505818c89543ee98c202863ba5e1..44e45f63ad164c56164804f9ed8e8025263f3b94 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2499,8 +2499,6 @@ class HooksRunner(object): on the master side. """ - RE_MASK = re.compile("^[a-zA-Z0-9_-]+$") - def __init__(self, hooks_base_dir=None): """Constructor for hooks runner. @@ -2607,7 +2605,7 @@ class HooksRunner(object): for relname in dir_contents: fname = os.path.join(dir_name, relname) if not (os.path.isfile(fname) and os.access(fname, os.X_OK) and - self.RE_MASK.match(relname) is not None): + constants.EXT_PLUGIN_MASK.match(relname) is not None): rrval = constants.HKR_SKIP output = "" else: diff --git a/lib/constants.py b/lib/constants.py index e5dafb174fa2f3a1b2141d8412f9de510a745c74..02cb385ca5f31ea4f34331c4ff223141086589ad 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -21,6 +21,8 @@ """Module holding different constants.""" +import re + from ganeti import _autoconf # various versions @@ -144,6 +146,9 @@ VALUE_NONE = "none" VALUE_TRUE = "true" VALUE_FALSE = "false" +# External script validation mask +EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$") + # hooks-related constants HOOKS_BASE_DIR = _autoconf.SYSCONFDIR + "/ganeti/hooks" HOOKS_PHASE_PRE = "pre"