Skip to content

Commit

Permalink
Merge pull request #62943 from nicholasmhughes/fix-systemd-service-path
Browse files Browse the repository at this point in the history
Fix systemd_service.* functions hard code relative command name
  • Loading branch information
garethgreenaway authored Oct 24, 2022
2 parents 089277b + ace2284 commit c20115c
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 222 deletions.
1 change: 1 addition & 0 deletions changelog/62942.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix systemd_service.* functions hard code relative command name
10 changes: 6 additions & 4 deletions salt/modules/systemd_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ def _runlevel():
contextkey = "systemd._runlevel"
if contextkey in __context__:
return __context__[contextkey]
out = __salt__["cmd.run"]("runlevel", python_shell=False, ignore_retcode=True)
out = __salt__["cmd.run"](
salt.utils.path.which("runlevel"), python_shell=False, ignore_retcode=True
)
try:
ret = out.split()[1]
except IndexError:
Expand Down Expand Up @@ -338,8 +340,8 @@ def _systemctl_cmd(action, name=None, systemd_scope=False, no_block=False, root=
and salt.utils.systemd.has_scope(__context__)
and __salt__["config.get"]("systemd.scope", True)
):
ret.extend(["systemd-run", "--scope"])
ret.append("systemctl")
ret.extend([salt.utils.path.which("systemd-run"), "--scope"])
ret.append(salt.utils.path.which("systemctl"))
if no_block:
ret.append("--no-block")
if root:
Expand Down Expand Up @@ -1440,7 +1442,7 @@ def firstboot(
salt '*' service.firstboot keymap=jp locale=en_US.UTF-8
"""
cmd = ["systemd-firstboot"]
cmd = [salt.utils.path.which("systemd-firstboot")]
parameters = [
("locale", locale),
("locale-message", locale_message),
Expand Down
Loading

0 comments on commit c20115c

Please sign in to comment.