mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipautil: remove the timeout argument of run()
The argument depends on the platform-specific timeout binary and is used only in ipaclient.ntpconf. Call the timeout binary explicitly in ipaclient.ntpconf and remove the argument. https://fedorahosted.org/freeipa/ticket/6474 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
parent
7b966e8577
commit
d911f49348
@ -150,19 +150,22 @@ def synconce_ntp(server_fqdn, debug=False):
|
||||
if not os.path.exists(ntpd):
|
||||
return False
|
||||
|
||||
# The ntpd command will never exit if it is unable to reach the
|
||||
# server, so timeout after 15 seconds.
|
||||
timeout = 15
|
||||
|
||||
tmp_ntp_conf = ipautil.write_tmp_file('server %s' % server_fqdn)
|
||||
args = [ntpd, '-qgc', tmp_ntp_conf.name]
|
||||
args = [paths.BIN_TIMEOUT, str(timeout), ntpd, '-qgc', tmp_ntp_conf.name]
|
||||
if debug:
|
||||
args.append('-d')
|
||||
try:
|
||||
# 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(args, timeout=timeout)
|
||||
ipautil.run(args)
|
||||
return True
|
||||
except ipautil.CalledProcessError:
|
||||
except ipautil.CalledProcessError as e:
|
||||
if e.returncode == 124:
|
||||
root_logger.debug('Process did not complete before timeout')
|
||||
return False
|
||||
|
||||
|
||||
|
@ -307,7 +307,7 @@ class _RunResult(collections.namedtuple('_RunResult',
|
||||
|
||||
def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
|
||||
capture_output=False, skip_output=False, cwd=None,
|
||||
runas=None, timeout=None, suplementary_groups=[],
|
||||
runas=None, suplementary_groups=[],
|
||||
capture_error=False, encoding=None, redirect_output=False):
|
||||
"""
|
||||
Execute an external command.
|
||||
@ -336,8 +336,6 @@ def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
|
||||
:param cwd: Current working directory
|
||||
:param runas: Name of a user that the command should be run as. The spawned
|
||||
process will have both real and effective UID and GID set.
|
||||
:param timeout: Timeout if the command hasn't returned within the specified
|
||||
number of seconds.
|
||||
:param suplementary_groups: List of group names that will be used as
|
||||
suplementary groups for subporcess.
|
||||
The option runas must be specified together with this option.
|
||||
@ -413,11 +411,6 @@ def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
|
||||
if six.PY3 and isinstance(stdin, str):
|
||||
stdin = stdin.encode(encoding)
|
||||
|
||||
if timeout:
|
||||
# If a timeout was provided, use the timeout command
|
||||
# to execute the requested command.
|
||||
args[0:0] = [paths.BIN_TIMEOUT, str(timeout)]
|
||||
|
||||
arg_string = nolog_replace(' '.join(_log_arg(a) for a in args), nolog)
|
||||
root_logger.debug('Starting external process')
|
||||
root_logger.debug('args=%s' % arg_string)
|
||||
@ -458,9 +451,6 @@ def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
|
||||
if skip_output:
|
||||
p_out.close() # pylint: disable=E1103
|
||||
|
||||
if timeout and p.returncode == 124:
|
||||
root_logger.debug('Process did not complete before timeout')
|
||||
|
||||
root_logger.debug('Process finished, return code=%s', p.returncode)
|
||||
|
||||
# The command and its output may include passwords that we don't want
|
||||
|
Loading…
Reference in New Issue
Block a user