Skip to content

Commit

Permalink
Disambiguate non-exact matches when checking if sysv service is enabl…
Browse files Browse the repository at this point in the history
…ed (#33324)

Fixes #33323
  • Loading branch information
Erik Johnson authored and Mike Place committed May 18, 2016
1 parent 8c1f19a commit 1f7fda2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion salt/modules/systemd.py
Expand Up @@ -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):
Expand Down

0 comments on commit 1f7fda2

Please sign in to comment.