Skip to content

Commit

Permalink
Better error message when 'date' fails
Browse files Browse the repository at this point in the history
The traceback is human-unfriendly and provides no additional
information.  The stderr output and the command are all that is needed.
  • Loading branch information
DemiMarie committed Jul 10, 2022
1 parent 9604a2b commit 2ef9f3e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qubes-rpc/qubes-sync-clock
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ def main():
sys.stderr.write('Received a date older than this program, aborting!\n')
sys.exit(1)
date_out = untrusted_date_out
subprocess.check_call([b'date', b'-u', b'-I' + precision, b'-s',
date_out[:-1]],
stdout=subprocess.DEVNULL)
try:
subprocess.check_call([b'date', b'-u', b'-I' + precision, b'-s',
date_out[:-1]],
stdout=subprocess.DEVNULL)
except subprocess.CalledProcessError as e:
# input is trusted here, so it can be safely printed
sys.stderr.write('Unable to set the date: process {!r} failed.\n'.format(e.cmd))
sys.exit(e.returncode)

if __name__ == '__main__':
main()
Expand Down

0 comments on commit 2ef9f3e

Please sign in to comment.