diff options
author | Ana Krivokapic <akrivoka@redhat.com> | 2013-09-02 16:40:55 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-09-09 13:37:32 +0200 |
commit | 28144e358c38e1c27eeb332b02d8470f18913af6 (patch) | |
tree | 7164f39a2565443f730e52c6512842c082947543 /ipa-client/ipaclient | |
parent | a9225be0fa7bb834cd78609603300d81dcc4d3c9 (diff) | |
download | freeipa-28144e358c38e1c27eeb332b02d8470f18913af6.tar.gz freeipa-28144e358c38e1c27eeb332b02d8470f18913af6.tar.xz freeipa-28144e358c38e1c27eeb332b02d8470f18913af6.zip |
Replace ntpdate calls with ntpd
Due to the upcoming deprecation of the ntpdate program (targeted for Fedora 20),
replace ntpdate calls with ntpd.
https://fedorahosted.org/freeipa/ticket/3797
Diffstat (limited to 'ipa-client/ipaclient')
-rw-r--r-- | ipa-client/ipaclient/ntpconf.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/ipa-client/ipaclient/ntpconf.py b/ipa-client/ipaclient/ntpconf.py index eb9afdeee..714d4fb86 100644 --- a/ipa-client/ipaclient/ntpconf.py +++ b/ipa-client/ipaclient/ntpconf.py @@ -21,7 +21,6 @@ from ipapython import ipautil from ipapython import services as ipaservices import shutil import os -import sys ntp_conf = """# Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. @@ -137,24 +136,23 @@ def config_ntp(server_fqdn, fstore = None, sysstore = None): def synconce_ntp(server_fqdn): """ - Syncs time with specified server using ntpdate. + Syncs time with specified server using ntpd. Primarily designed to be used before Kerberos setup to get time following the KDC time Returns True if sync was successful """ - ntpdate="/usr/sbin/ntpdate" - if os.path.exists(ntpdate): - # retry several times -- logic follows /etc/init.d/ntpdate - # implementation - cmd = [ntpdate, "-U", "ntp", "-s", "-b", "-v", server_fqdn] - for retry in range(0, 3): - try: - ipautil.run(cmd) - return True - except: - pass - return False + ntpd = '/usr/sbin/ntpd' + if not os.path.exists(ntpd): + return False + + tmp_ntp_conf = ipautil.write_tmp_file('server %s' % server_fqdn) + try: + ipautil.run([ntpd, '-qgc', tmp_ntp_conf.name]) + return True + except ipautil.CalledProcessError: + return False + class NTPConfigurationError(Exception): pass |