[Freeipa-devel] [PATCH 0040] Make sure uninstall script prompts for reboot as last

2013-03-13 Thread Tomas Babej

Hi,

Parts of client uninstall logic could be skipped in attended
uninstallation if user agreed to reboot the machine. Particulary,
the uninstall script would not try to remove /etc/ipa/default.conf
and therefore subsequent installation would fail, client being
detected as already configured.

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

Tomas
From 465e5c01a760fb99c43658a0aa97abdec169882c Mon Sep 17 00:00:00 2001
From: Tomas Babej tba...@redhat.com
Date: Wed, 13 Mar 2013 12:53:24 +0100
Subject: [PATCH] Make sure uninstall script prompts for reboot as last

Parts of client uninstall logic could be skipped in attended
uninstallation if user agreed to reboot the machine. Particulary,
the uninstall script would not try to remove /etc/ipa/default.conf
and therefore subsequent installation would fail, client being
detected as already configured.

https://fedorahosted.org/freeipa/ticket/3462
---
 ipa-client/ipa-install/ipa-client-install | 54 ---
 1 file changed, 35 insertions(+), 19 deletions(-)

diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index 4433fc7175a7d565538fa7f3a681a36c0f91dc09..97332d1a02e4e78c648d02501c6055c0618ae1c7 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -611,41 +611,57 @@ def uninstall(options, env):
 if was_sshd_configured and ipaservices.knownservices.sshd.is_running():
 ipaservices.knownservices.sshd.restart()
 
-if not options.unattended:
-root_logger.info(
-The original nsswitch.conf configuration has been restored.)
-root_logger.info(
-You may need to restart services or reboot the machine.)
-if not options.on_master:
-if user_input(Do you want to reboot the machine?, False):
-try:
-run([/sbin/reboot])
-except Exception, e:
-root_logger.error(
-Reboot command failed to exceute: %s, str(e))
-return CLIENT_UNINSTALL_ERROR
-
 rv = 0
 
 if fstore.has_files():
-root_logger.error('Some files have not been restored, see /var/lib/ipa-client/sysrestore/sysrestore.index')
+root_logger.error('Some files have not been restored, see '
+  '/var/lib/ipa-client/sysrestore/sysrestore.index')
 has_state = False
 for module in statestore.modules.keys():
-root_logger.error('Some installation state for %s has not been restored, see /var/lib/ipa/sysrestore/sysrestore.state' % module)
+root_logger.error('Some installation state for %s has not been '
+'restored, see /var/lib/ipa/sysrestore/sysrestore.state',
+module)
 has_state = True
 rv = 1
 
 if has_state:
-root_logger.warning('Some installation state has not been restored.\nThis may cause re-installation to fail.\nIt should be safe to remove /var/lib/ipa-client/sysrestore.state but it may\nmean your system hasn\'t be restored to its pre-installation state.')
+root_logger.warning(
+'Some installation state has not been restored.\n'
+'This may cause re-installation to fail.\n'
+'It should be safe to remove /var/lib/ipa-client/sysrestore.state '
+'but it may\n mean your system hasn\'t been restored '
+'to its pre-installation state.')
 
 # Remove the IPA configuration file
 try:
 os.remove(/etc/ipa/default.conf)
-except Exception:
-pass
+except OSError, e:
+root_logger.warning('/etc/ipa/default.conf could not be removed: %s',
+str(e))
+root_logger.warning('Please remove /etc/ipa/default.conf manually, '
+'as it can cause subsequent installation to fail.')
 
 root_logger.info(Client uninstall complete.)
 
+# The next block of code prompts for reboot, therefore all uninstall
+# logic has to be done before
+
+if not options.unattended:
+root_logger.info(
+The original nsswitch.conf configuration has been restored.)
+root_logger.info(
+You may need to restart services or reboot the machine.)
+if not options.on_master:
+if user_input(Do you want to reboot the machine?, False):
+try:
+run([/sbin/reboot])
+except Exception, e:
+root_logger.error(
+Reboot command failed to exceute: %s, str(e))
+return CLIENT_UNINSTALL_ERROR
+
+# IMPORTANT: Do not put any client uninstall logic after the block above
+
 return rv
 
 def configure_ipa_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server):
-- 
1.7.11.7

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com

Re: [Freeipa-devel] [PATCH 0040] Make sure uninstall script prompts for reboot as last

2013-03-13 Thread Martin Kosek
On 03/13/2013 02:34 PM, Tomas Babej wrote:
 Hi,
 
 Parts of client uninstall logic could be skipped in attended
 uninstallation if user agreed to reboot the machine. Particulary,
 the uninstall script would not try to remove /etc/ipa/default.conf
 and therefore subsequent installation would fail, client being
 detected as already configured.
 
 https://fedorahosted.org/freeipa/ticket/3462
 
 Tomas
 

ACK. Pushed to master, ipa-3-1.

Martin

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