@@ -169,14 +169,14 @@ class SystemdService(SysvService):
169169
170170 def _has_systemd_suffix (self ):
171171 """
172- Check if service name has a known systemd unit suffix
172+ Check if the service name has a known systemd unit suffix
173173 """
174174 unit_suffix = self .name .split ("." )[- 1 ]
175175 return unit_suffix in self .suffix_list
176176
177177 @property
178178 def exists (self ):
179- cmd = self .run_test ('systemctl list-unit-files | grep -q "^%s"' , self .name )
179+ cmd = self .run_test ('systemctl list-unit-files | grep -q -- "^%s"' , self .name )
180180 return cmd .rc == 0
181181
182182 @property
@@ -186,15 +186,15 @@ def is_running(self):
186186 # 1: program is dead and pid file exists
187187 # 3: not running and pid file does not exists
188188 # 4: Unable to determine status (no such unit)
189- out = self .run_expect ([0 , 1 , 3 , 4 ], "systemctl is-active %s" , self .name )
189+ out = self .run_expect ([0 , 1 , 3 , 4 ], "systemctl is-active -- %s" , self .name )
190190 if out .rc == 1 :
191191 # Failed to connect to bus: No such file or directory
192192 return super ().is_running
193193 return out .rc == 0
194194
195195 @property
196196 def is_enabled (self ):
197- cmd = self .run_test ("systemctl is-enabled %s" , self .name )
197+ cmd = self .run_test ("systemctl is-enabled -- %s" , self .name )
198198 if cmd .rc == 0 :
199199 return True
200200 if cmd .stdout .strip () == "disabled" :
@@ -211,7 +211,7 @@ def is_enabled(self):
211211 def is_valid (self ):
212212 # systemd-analyze requires a full unit name.
213213 name = self .name if self ._has_systemd_suffix () else f"{ self .name } .service"
214- cmd = self .run ("systemd-analyze verify %s" , name )
214+ cmd = self .run ("systemd-analyze verify -- %s" , name )
215215 # A bad unit file still returns a rc of 0, so check the
216216 # stdout for anything. Nothing means no warns/errors.
217217 # Docs at https://www.freedesktop.org/software/systemd/man/systemd
@@ -234,12 +234,12 @@ def is_valid(self):
234234
235235 @property
236236 def is_masked (self ):
237- cmd = self .run_test ("systemctl is-enabled %s" , self .name )
237+ cmd = self .run_test ("systemctl is-enabled -- %s" , self .name )
238238 return cmd .stdout .strip () == "masked"
239239
240240 @functools .cached_property
241241 def systemd_properties (self ):
242- out = self .check_output ("systemctl show %s" , self .name )
242+ out = self .check_output ("systemctl show -- %s" , self .name )
243243 out_d = {}
244244 if out :
245245 # maxsplit is required because values can contain `=`
0 commit comments