@@ -169,7 +169,7 @@ class SystemdService(SysvService):
169
169
170
170
def _has_systemd_suffix (self ):
171
171
"""
172
- Check if service name has a known systemd unit suffix
172
+ Check if the service name has a known systemd unit suffix
173
173
"""
174
174
unit_suffix = self .name .split ("." )[- 1 ]
175
175
return unit_suffix in self .suffix_list
@@ -182,7 +182,7 @@ def exists(self):
182
182
# 2: unused
183
183
# 3: unit is not active
184
184
# 4: no such unit
185
- cmd = self .run_expect ([0 , 1 , 3 , 4 ], "systemctl status %s" , self .name )
185
+ cmd = self .run_expect ([0 , 1 , 3 , 4 ], "systemctl status -- %s" , self .name )
186
186
return cmd .rc < 4
187
187
188
188
@property
@@ -192,15 +192,15 @@ def is_running(self):
192
192
# 1: program is dead and pid file exists
193
193
# 3: not running and pid file does not exists
194
194
# 4: Unable to determine status (no such unit)
195
- out = self .run_expect ([0 , 1 , 3 , 4 ], "systemctl is-active %s" , self .name )
195
+ out = self .run_expect ([0 , 1 , 3 , 4 ], "systemctl is-active -- %s" , self .name )
196
196
if out .rc == 1 :
197
197
# Failed to connect to bus: No such file or directory
198
198
return super ().is_running
199
199
return out .rc == 0
200
200
201
201
@property
202
202
def is_enabled (self ):
203
- cmd = self .run_test ("systemctl is-enabled %s" , self .name )
203
+ cmd = self .run_test ("systemctl is-enabled -- %s" , self .name )
204
204
if cmd .rc == 0 :
205
205
return True
206
206
if cmd .stdout .strip () == "disabled" :
@@ -217,7 +217,7 @@ def is_enabled(self):
217
217
def is_valid (self ):
218
218
# systemd-analyze requires a full unit name.
219
219
name = self .name if self ._has_systemd_suffix () else f"{ self .name } .service"
220
- cmd = self .run ("systemd-analyze verify %s" , name )
220
+ cmd = self .run ("systemd-analyze verify -- %s" , name )
221
221
# A bad unit file still returns a rc of 0, so check the
222
222
# stdout for anything. Nothing means no warns/errors.
223
223
# Docs at https://www.freedesktop.org/software/systemd/man/systemd
@@ -244,12 +244,12 @@ def is_valid(self):
244
244
245
245
@property
246
246
def is_masked (self ):
247
- cmd = self .run_test ("systemctl is-enabled %s" , self .name )
247
+ cmd = self .run_test ("systemctl is-enabled -- %s" , self .name )
248
248
return cmd .stdout .strip () == "masked"
249
249
250
250
@functools .cached_property
251
251
def systemd_properties (self ):
252
- out = self .check_output ("systemctl show %s" , self .name )
252
+ out = self .check_output ("systemctl show -- %s" , self .name )
253
253
out_d = {}
254
254
if out :
255
255
# maxsplit is required because values can contain `=`
0 commit comments