On 02/21/2013 12:47 PM, Martin Kosek wrote:
On 02/20/2013 10:31 AM, Tomas Babej wrote:
Hi,

When installing / uninstalling IPA client, the checks that
determine whether IPA client is installed now take the existence
of /etc/ipa/default.conf into consideration.

The client will not uninstall unless either something is backed
up or /etc/ipa/default.conf file does exist.

The client will not install if something is backed up or
default.conf file does exist (unless it's installation on master).

https://fedorahosted.org/freeipa/ticket/3331

Tomas


Can we create a function testing if ipa client is installed to avoid
duplication of the decision logic? Something like is_ipa_configured present in
ipaserver/install/installutils.py.

Keep in mind that we cannot use ipaserver package as it may not be present on
client.

Martin
Moved to is_ipa_client_installed function to ipautils.py

Updated patch attached.

Tomas


>From 73c9f2e43c54640ed49e3fc6ce79ecfefae1a385 Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Tue, 19 Feb 2013 17:59:50 +0100
Subject: [PATCH] Use default.conf as flag of IPA client being installed

When installing / uninstalling IPA client, the checks that
determine whether IPA client is installed now take the existence
of /etc/ipa/default.conf into consideration.

The client will not uninstall unless either something is backed
up or /etc/ipa/default.conf file does exist.

The client will not install if something is backed up or
default.conf file does exist (unless it's installation on master).

https://fedorahosted.org/freeipa/ticket/3331
---
 ipa-client/ipa-install/ipa-client-install |  8 +++++---
 ipapython/ipautil.py                      | 16 ++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index 2d32e28ece72c1058152787058c83ae5b06df64c..aa38b2d603e728baa9777e36f7e5e9f597a476de 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -36,7 +36,9 @@ try:
     from ipaclient.ipadiscovery import CACERT
     import ipaclient.ipachangeconf
     import ipaclient.ntpconf
-    from ipapython.ipautil import run, user_input, CalledProcessError, file_exists, realm_to_suffix, convert_ldap_error
+    from ipapython.ipautil import run, user_input, CalledProcessError,\
+                                  file_exists, realm_to_suffix,\
+                                  convert_ldap_error, is_ipa_client_installed
     import ipapython.services as ipaservices
     from ipapython import ipautil
     from ipapython import sysrestore
@@ -283,7 +285,7 @@ def delete_ipa_domain():
 
 def uninstall(options, env):
 
-    if not fstore.has_files():
+    if not is_ipa_client_installed():
         root_logger.error("IPA client is not configured on this system.")
         return CLIENT_NOT_CONFIGURED
 
@@ -2326,7 +2328,7 @@ def main():
     if options.uninstall:
         return uninstall(options, env)
 
-    if fstore.has_files():
+    if is_ipa_client_installed(on_master=options.on_master):
         root_logger.error("IPA client is already configured on this system.")
         root_logger.info(
             "If you want to reinstall the IPA client, uninstall it first " +
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index c0ac3a1f76397e79672f1b99c2d46463d8e0af3e..9e6ecb1519a4413041a4727dabdb52b49dae29c5 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -49,6 +49,7 @@ from dns.exception import DNSException
 from ipapython.ipa_log_manager import *
 from ipapython import ipavalidate
 from ipapython import config
+from ipapython import sysrestore
 from ipapython.dn import DN
 
 try:
@@ -1210,3 +1211,18 @@ def convert_ldap_error(exc):
             return name
     else:
         return str(exc)
+
+def is_ipa_client_installed(on_master=False):
+    """
+    Consider IPA client not installed if nothing is backed up
+    and default.conf file does not exist. If on_master is set to True,
+    the existence of default.conf file is not taken into consideration,
+    since it has been already created by ipa-server-install.
+    """
+
+    fstore = sysrestore.FileStore('/var/lib/ipa-client/sysrestore')
+
+    installed = fstore.has_files() or \
+       (not on_master and os.path.exists('/etc/ipa/default.conf'))
+
+    return installed
-- 
1.7.11.7

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

Reply via email to