summaryrefslogtreecommitdiffstats
path: root/ipa-client
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2015-02-25 15:19:47 -0800
committerMartin Kosek <mkosek@redhat.com>2015-03-16 15:55:26 +0100
commita58b77ca9cd3620201306258dd6bd05ea1c73c73 (patch)
tree5de232c8838d8b4884e6c3da9a59834597eb2d1b /ipa-client
parentfbf192f0e255c5f48e93f8838fc530b26f357deb (diff)
downloadfreeipa-a58b77ca9cd3620201306258dd6bd05ea1c73c73.tar.gz
freeipa-a58b77ca9cd3620201306258dd6bd05ea1c73c73.tar.xz
freeipa-a58b77ca9cd3620201306258dd6bd05ea1c73c73.zip
Timeout when performing time sync during client install
We use ntpd now to sync time before fetching a TGT during client install. Unfortuantely, ntpd will hang forever if it is unable to reach the NTP server. This patch adds the ability for commands run via ipautil.run() to have an optional timeout. This capability is used by the NTP sync code that is run during ipa-client-install. Ticket: https://fedorahosted.org/freeipa/ticket/4842 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipa-client')
-rw-r--r--ipa-client/ipaclient/ntpconf.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/ipa-client/ipaclient/ntpconf.py b/ipa-client/ipaclient/ntpconf.py
index e1ac55a1d..7d5c82a89 100644
--- a/ipa-client/ipaclient/ntpconf.py
+++ b/ipa-client/ipaclient/ntpconf.py
@@ -18,6 +18,7 @@
#
from ipapython import ipautil
+from ipapython.ipa_log_manager import root_logger
import shutil
import os
from ipaplatform.tasks import tasks
@@ -149,7 +150,12 @@ def synconce_ntp(server_fqdn):
tmp_ntp_conf = ipautil.write_tmp_file('server %s' % server_fqdn)
try:
- ipautil.run([ntpd, '-qgc', tmp_ntp_conf.name])
+ # The ntpd command will never exit if it is unable to reach the
+ # server, so timeout after 15 seconds.
+ timeout = 15
+ root_logger.info('Attempting to sync time using ntpd. '
+ 'Will timeout after %d seconds' % timeout)
+ ipautil.run([ntpd, '-qgc', tmp_ntp_conf.name], timeout=timeout)
return True
except ipautil.CalledProcessError:
return False