From 4f76c143d2f2036af02677469c542f563a10158d Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 23 Aug 2012 12:38:45 -0400 Subject: Use Dogtag 10 only when it is available Put the changes from Ade's dogtag 10 patch into namespaced constants in dogtag.py, which are then referenced in the code. Make ipaserver.install.CAInstance use the service name specified in the configuration. Uninstallation, where config is removed before CA uninstall, also uses the (previously) configured value. This and Ade's patch address https://fedorahosted.org/freeipa/ticket/2846 --- ipapython/ipautil.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'ipapython/ipautil.py') diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index a3fd83e4..d6e97b89 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -293,19 +293,12 @@ def run(args, stdin=None, raiseonerr=True, raise # The command and its output may include passwords that we don't want - # to log. Run through the nolog items. + # to log. Replace those. args = ' '.join(args) - for value in nolog: - if not isinstance(value, basestring): - continue - - quoted = urllib2.quote(value) - shquoted = shell_quote(value) - for nolog_value in (shquoted, value, quoted): - if capture_output: - stdout = stdout.replace(nolog_value, 'XXXXXXXX') - stderr = stderr.replace(nolog_value, 'XXXXXXXX') - args = args.replace(nolog_value, 'XXXXXXXX') + if capture_output: + stdout = nolog_replace(stdout, nolog) + stderr = nolog_replace(stderr, nolog) + args = nolog_replace(args, nolog) root_logger.debug('args=%s' % args) if capture_output: @@ -317,6 +310,20 @@ def run(args, stdin=None, raiseonerr=True, return (stdout, stderr, p.returncode) + +def nolog_replace(string, nolog): + """Replace occurences of strings given in `nolog` with XXXXXXXX""" + for value in nolog: + if not isinstance(value, basestring): + continue + + quoted = urllib2.quote(value) + shquoted = shell_quote(value) + for nolog_value in (shquoted, value, quoted): + string = string.replace(nolog_value, 'XXXXXXXX') + return string + + def file_exists(filename): try: mode = os.stat(filename)[stat.ST_MODE] -- cgit