summaryrefslogtreecommitdiffstats
path: root/ipapython/ipautil.py
diff options
context:
space:
mode:
authorAlexander Bokovoy <abokovoy@redhat.com>2011-07-01 12:41:45 +0300
committerAlexander Bokovoy <abokovoy@redhat.com>2011-07-29 12:58:10 +0300
commit4c4b8a8189b5390628890717c01f2b6cb3e06c6a (patch)
treeb7cc9626955c363a0a8cf39c3316b2f7a9c7c84d /ipapython/ipautil.py
parent1ebe3c1d12e8694baa00c713a60122a40a0c51a3 (diff)
downloadfreeipa-4c4b8a8189b5390628890717c01f2b6cb3e06c6a.tar.gz
freeipa-4c4b8a8189b5390628890717c01f2b6cb3e06c6a.tar.xz
freeipa-4c4b8a8189b5390628890717c01f2b6cb3e06c6a.zip
Make error reporting more 'local' for various configurations of nss_ldap packages
https://fedorahosted.org/freeipa/ticket/1369 When nss_ldap-based configuration does not work, report proper package name instead of always assuming nss_ldap. At least, in RHEL6 and Fedora appropriate package is called nss-pam-ldapd while in older releases and other distributions it might be called differently. The change makes less confusing error reporting. It also introduces common utility function package_installed_name() which provides an interface to query package manager for existence of mutually exclusive packages which is helpful to distinguish between different configuration paths.
Diffstat (limited to 'ipapython/ipautil.py')
-rw-r--r--ipapython/ipautil.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index da6e94c85..6bfebcaeb 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -1171,3 +1171,21 @@ def bind_port_responder(port, socket_stream=True, socket_timeout=None, responder
s.sendto(responder_data, addr)
finally:
s.close()
+
+def package_installed_name(packages):
+ """
+ Find out which of mutually exclusive packages is installed
+
+ packages is a list of package names to check
+
+ Returns package name or None
+ """
+
+ args = ["/bin/rpm","-q","--queryformat","%{NAME}"]
+ for package in packages:
+ try:
+ (package_name, error, retcode) = run(args+[package])
+ return package_name
+ except CalledProcessError:
+ continue
+ return None