Hello,

This patch addresses ticket https://fedorahosted.org/freeipa/ticket/3797.

-- 
Regards,

Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.

From cfbf21ce24c677712d8f74a29ff5896cb2ad9396 Mon Sep 17 00:00:00 2001
From: Ana Krivokapic <akriv...@redhat.com>
Date: Mon, 2 Sep 2013 16:40:55 +0200
Subject: [PATCH] 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
---
 ipa-client/ipaclient/ntpconf.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/ipa-client/ipaclient/ntpconf.py b/ipa-client/ipaclient/ntpconf.py
index eb9afdeeefb24d994701b0f3e6859f69653be39d..f7d76764abe4f13fa57de362d9e2701ac9cc861b 100644
--- a/ipa-client/ipaclient/ntpconf.py
+++ b/ipa-client/ipaclient/ntpconf.py
@@ -21,7 +21,6 @@
 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,25 +136,26 @@ 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]
+    ntpd = '/usr/sbin/ntpd'
+    if os.path.exists(ntpd):
+        tmp_ntp_conf = ipautil.write_tmp_file('server %s' % server_fqdn)
+
+        # retry several times
         for retry in range(0, 3):
             try:
-                ipautil.run(cmd)
+                ipautil.run([ntpd, '-qgc', tmp_ntp_conf.name])
                 return True
-            except:
+            except ipautil.CalledProcessError:
                 pass
     return False
 
+
 class NTPConfigurationError(Exception):
     pass
 
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to