Re: [Freeipa-devel] [PATCH] 868 better handling of ipa-pki-proxy.conf

2011-09-13 Thread Martin Kosek
On Fri, 2011-09-09 at 17:41 -0400, Rob Crittenden wrote:
 - Remove ipa-pki-proxy.conf when IPA is uninstalled
 - Move file removal to httpinstance.py and use remove_file()
 - Add a version stanza
 - Create the file if it doesn't exist on upgraded installs
 
 https://fedorahosted.org/freeipa/ticket/1771
 
 rob

Both upgrade and new install worked fine. I only find the following
try..except clause redundant since all exceptions are captured and
logged in installutils.remove_file:

+# Remove the configuration files we create
+try:
+installutils.remove_file(/etc/httpd/conf.d/ipa-rewrite.conf)
+installutils.remove_file(/etc/httpd/conf.d/ipa.conf)
+installutils.remove_file(/etc/httpd/conf.d/ipa-pki-proxy.conf)
+except:
+pass

Martin

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


Re: [Freeipa-devel] [PATCH] 868 better handling of ipa-pki-proxy.conf

2011-09-13 Thread Rob Crittenden

Martin Kosek wrote:

On Fri, 2011-09-09 at 17:41 -0400, Rob Crittenden wrote:

- Remove ipa-pki-proxy.conf when IPA is uninstalled
- Move file removal to httpinstance.py and use remove_file()
- Add a version stanza
- Create the file if it doesn't exist on upgraded installs

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

rob


Both upgrade and new install worked fine. I only find the following
try..except clause redundant since all exceptions are captured and
logged in installutils.remove_file:

+# Remove the configuration files we create
+try:
+installutils.remove_file(/etc/httpd/conf.d/ipa-rewrite.conf)
+installutils.remove_file(/etc/httpd/conf.d/ipa.conf)
+installutils.remove_file(/etc/httpd/conf.d/ipa-pki-proxy.conf)
+except:
+pass

Martin



Updated patch attached

rob
From b68d09e3c79560adf5d3fecae0ec8b0d5f23e614 Mon Sep 17 00:00:00 2001
From: Rob Crittenden rcrit...@redhat.com
Date: Fri, 9 Sep 2011 17:07:09 -0400
Subject: [PATCH] Improved handling for ipa-pki-proxy.conf

- Remove ipa-pki-proxy.conf when IPA is uninstalled
- Move file removal to httpinstance.py and use remove_file()
- Add a version stanza
- Create the file if it doesn't exist on upgraded installs

https://fedorahosted.org/freeipa/ticket/1771
---
 install/conf/ipa-pki-proxy.conf   |2 ++
 install/tools/ipa-server-install  |6 +-
 install/tools/ipa-upgradeconfig   |   21 +
 ipaserver/install/httpinstance.py |5 +
 4 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/install/conf/ipa-pki-proxy.conf b/install/conf/ipa-pki-proxy.conf
index 275f326..91a99aa 100644
--- a/install/conf/ipa-pki-proxy.conf
+++ b/install/conf/ipa-pki-proxy.conf
@@ -1,3 +1,5 @@
+# VERSION 1 - DO NOT REMOVE THIS LINE
+
 ProxyRequests Off
 
 # matches for ee port
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index 0572d4f..03cb2e0 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -490,12 +490,8 @@ def uninstall():
 os.remove(ANSWER_CACHE)
 except Exception:
 pass
+
 # ipa-client-install removes /etc/ipa/default.conf
-try:
-os.remove(/etc/httpd/conf.d/ipa-rewrite.conf)
-os.remove(/etc/httpd/conf.d/ipa.conf)
-except:
-pass
 
 sstore._load()
 group_exists = sstore.restore_state(install, group_exists)
diff --git a/install/tools/ipa-upgradeconfig b/install/tools/ipa-upgradeconfig
index 4ac3092..1b08382 100644
--- a/install/tools/ipa-upgradeconfig
+++ b/install/tools/ipa-upgradeconfig
@@ -52,7 +52,13 @@ def backup_file(filename, ext):
 while os.path.exists(backupfile):
 backupfile = backupfile + . + str(ext)
 
-shutil.copy2(filename, backupfile)
+try:
+shutil.copy2(filename, backupfile)
+except IOError, e:
+if e.errno == 2: # No such file or directory
+pass
+else:
+raise e
 
 def update_conf(sub_dict, filename, template_filename):
 template = ipautil.template_file(template_filename, sub_dict)
@@ -93,18 +99,24 @@ def find_version(filename):
 else:
 return -1
 
-def upgrade(sub_dict, filename, template):
+def upgrade(sub_dict, filename, template, add=False):
+
+Get the version from the current and template files and update the
+installed configuration file if there is a new template.
+
+If add is True then create a new configuration file.
+
 old = int(find_version(filename))
 new = int(find_version(template))
 
-if old  0:
+if old  0 and not add:
 print %s not found. % filename
 sys.exit(1)
 
 if new  0:
 print %s not found. % template
 
-if old  new:
+if old  new or add:
 backup_file(filename, new)
 update_conf(sub_dict, filename, template)
 print Upgraded %s to version %d % (filename, new)
@@ -149,6 +161,7 @@ def main():
 
 upgrade(sub_dict, /etc/httpd/conf.d/ipa.conf, ipautil.SHARE_DIR + ipa.conf)
 upgrade(sub_dict, /etc/httpd/conf.d/ipa-rewrite.conf, ipautil.SHARE_DIR + ipa-rewrite.conf)
+upgrade(sub_dict, /etc/httpd/conf.d/ipa-pki-proxy.conf, ipautil.SHARE_DIR + ipa-pki-proxy.conf, add=True)
 
 try:
 if __name__ == __main__:
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index 4294bee..723654d 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -281,6 +281,11 @@ class HTTPInstance(service.Service):
 logging.debug(error)
 pass
 
+# Remove the configuration files we create
+installutils.remove_file(/etc/httpd/conf.d/ipa-rewrite.conf)
+installutils.remove_file(/etc/httpd/conf.d/ipa.conf)
+installutils.remove_file(/etc/httpd/conf.d/ipa-pki-proxy.conf)
+
 sebool_state = self.restore_state(httpd_can_network_connect)
 if not sebool_state is None:
 try:
-- 
1.7.6


Re: [Freeipa-devel] [PATCH] 868 better handling of ipa-pki-proxy.conf

2011-09-13 Thread Martin Kosek
On Tue, 2011-09-13 at 09:58 -0400, Rob Crittenden wrote:
 Martin Kosek wrote:
  On Fri, 2011-09-09 at 17:41 -0400, Rob Crittenden wrote:
  - Remove ipa-pki-proxy.conf when IPA is uninstalled
  - Move file removal to httpinstance.py and use remove_file()
  - Add a version stanza
  - Create the file if it doesn't exist on upgraded installs
 
  https://fedorahosted.org/freeipa/ticket/1771
 
  rob
 
  Both upgrade and new install worked fine. I only find the following
  try..except clause redundant since all exceptions are captured and
  logged in installutils.remove_file:
 
  +# Remove the configuration files we create
  +try:
  +installutils.remove_file(/etc/httpd/conf.d/ipa-rewrite.conf)
  +installutils.remove_file(/etc/httpd/conf.d/ipa.conf)
  +
  installutils.remove_file(/etc/httpd/conf.d/ipa-pki-proxy.conf)
  +except:
  +pass
 
  Martin
 
 
 Updated patch attached
 
 rob

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

I didn't close the ticket as I saw that this patch is not a complete
solution.

Martin

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