@@ -169,14 +169,14 @@ 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
176
176
177
177
@property
178
178
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 )
180
180
return cmd .rc == 0
181
181
182
182
@property
@@ -186,15 +186,15 @@ def is_running(self):
186
186
# 1: program is dead and pid file exists
187
187
# 3: not running and pid file does not exists
188
188
# 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 )
190
190
if out .rc == 1 :
191
191
# Failed to connect to bus: No such file or directory
192
192
return super ().is_running
193
193
return out .rc == 0
194
194
195
195
@property
196
196
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 )
198
198
if cmd .rc == 0 :
199
199
return True
200
200
if cmd .stdout .strip () == "disabled" :
@@ -211,7 +211,7 @@ def is_enabled(self):
211
211
def is_valid (self ):
212
212
# systemd-analyze requires a full unit name.
213
213
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 )
215
215
# A bad unit file still returns a rc of 0, so check the
216
216
# stdout for anything. Nothing means no warns/errors.
217
217
# Docs at https://www.freedesktop.org/software/systemd/man/systemd
@@ -230,16 +230,17 @@ def is_valid(self):
230
230
]
231
231
232
232
stderr = "" .join (stderr_lines )
233
- return (cmd .stdout , stderr ) == ("" , "" )
233
+ return (cmd .stdout , stderr )
234
+ # return (cmd.stdout, stderr) == ("", "")
234
235
235
236
@property
236
237
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 )
238
239
return cmd .stdout .strip () == "masked"
239
240
240
241
@functools .cached_property
241
242
def systemd_properties (self ):
242
- out = self .check_output ("systemctl show %s" , self .name )
243
+ out = self .check_output ("systemctl show -- %s" , self .name )
243
244
out_d = {}
244
245
if out :
245
246
# maxsplit is required because values can contain `=`
0 commit comments