From 1f7fda212bee2c22bb51d0256a1435af3ed4183d Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 18 May 2016 11:10:02 -0500 Subject: [PATCH] Disambiguate non-exact matches when checking if sysv service is enabled (#33324) Fixes #33323 --- salt/modules/systemd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/salt/modules/systemd.py b/salt/modules/systemd.py index 52091c15d6c5..cf3bf80990c7 100644 --- a/salt/modules/systemd.py +++ b/salt/modules/systemd.py @@ -273,7 +273,11 @@ def _sysv_enabled(name): (starts with "S") to its script is found in /etc/init.d in the current runlevel. ''' - return bool(glob.glob('/etc/rc%s.d/S*%s' % (_runlevel(), name))) + # Find exact match (disambiguate matches like "S01anacron" for cron) + for match in glob.glob('/etc/rc%s.d/S*%s' % (_runlevel(), name)): + if re.match(r'S\d{,2}%s' % name, os.path.basename(match)): + return True + return False def _untracked_custom_unit_found(name):