Rather than print an ugly error message from
Popen, display a warning to the user if visudo
is missing.
Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): David Mulder <dmulder@samba.org>
Autobuild-Date(master): Fri Feb 10 20:31:37 UTC 2023 on atb-devel-224
with NamedTemporaryFile() as f:
with open(f.name, 'w') as w:
w.write(contents)
+ if visudo is None:
+ raise FileNotFoundError('visudo not found, please install it')
sudo_validation = \
Popen([visudo, '-c', '-f', f.name],
stdout=PIPE, stderr=PIPE).wait()