@@ -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
@@ -230,16 +230,17 @@ def is_valid(self):
230230 ]
231231
232232 stderr = "" .join (stderr_lines )
233- return (cmd .stdout , stderr ) == ("" , "" )
233+ return (cmd .stdout , stderr )
234+ # return (cmd.stdout, stderr) == ("", "")
234235
235236 @property
236237 def is_masked (self ):
237- cmd = self .run_test ("systemctl is-enabled %s" , self .name )
238+ cmd = self .run_test ("systemctl is-enabled -- %s" , self .name )
238239 return cmd .stdout .strip () == "masked"
239240
240241 @functools .cached_property
241242 def systemd_properties (self ):
242- out = self .check_output ("systemctl show %s" , self .name )
243+ out = self .check_output ("systemctl show -- %s" , self .name )
243244 out_d = {}
244245 if out :
245246 # maxsplit is required because values can contain `=`
0 commit comments