clock sync: drop untrusted_ prefix after validation, fix error msg

This commit is contained in:
Marek Marczykowski-Górecki 2017-07-12 12:52:43 +02:00
parent ab88cd9644
commit dce0b28cf4
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -35,9 +35,10 @@ def main():
untrusted_date_out = untrusted_date_out.strip() untrusted_date_out = untrusted_date_out.strip()
if not re.match(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+00:?00$', untrusted_date_out): if not re.match(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+00:?00$', untrusted_date_out):
sys.stderr.write('Invalid date received, aborting!') sys.stderr.write('Invalid date received, aborting!\n')
sys.exit(1) sys.exit(1)
subprocess.check_call(['date', '-u', '-Iseconds', '-s', untrusted_date_out], date_out = untrusted_date_out
subprocess.check_call(['date', '-u', '-Iseconds', '-s', date_out],
stdout=subprocess.DEVNULL) stdout=subprocess.DEVNULL)
subprocess.check_call(['hwclock', '--systohc'], subprocess.check_call(['hwclock', '--systohc'],
stdout=subprocess.DEVNULL) stdout=subprocess.DEVNULL)