Re: [Freeipa-devel] Fix removal of ipa-kdc-proxy.conf symlink

2015-06-29 Thread Christian Heimes
On 2015-06-29 17:28, Petr Vobornik wrote:
> On 06/29/2015 03:22 PM, Fraser Tweedale wrote:
>> On Mon, Jun 29, 2015 at 10:54:50AM +0200, Christian Heimes wrote:
>>> Hello,
>>>
>>> the attached patch fixes the first bug, that was reported by Fraser
>>> today. installutils.remove_file() uses os.path.exists() to check if the
>>> file still exists, which in turn uses stat(2). I have modified the
>>> function to use os.path.lexists() instead. It doesn't follow symlinks.
>>>
>>> Because httpinstance first removes the target file
>>> /etc/ipa/kdcproxy/ipa-kdc-proxy.conf before it tries to remove the
>>> symlink /etc/httpd/conf.d/ipa-kdc-proxy.conf, the
>>> installutils.remove_file() ignores the dangling symlink.
>>>
>>> Christian
>>
>> ACK
>>
> 
> Pushed to master: 2842a83568301c85d340801daae42078333ce63d
> 
> Christian, could please provide [PATCH] in subject for new threads with
> patch? It is an established practice on freeipa-devel and it helps with
> mail filtering.

I'm sorry that I forgot to include [PATCH] and my patch number. It's
Monday...

Christian



signature.asc
Description: OpenPGP digital signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] Fix removal of ipa-kdc-proxy.conf symlink

2015-06-29 Thread Petr Vobornik

On 06/29/2015 03:22 PM, Fraser Tweedale wrote:

On Mon, Jun 29, 2015 at 10:54:50AM +0200, Christian Heimes wrote:

Hello,

the attached patch fixes the first bug, that was reported by Fraser
today. installutils.remove_file() uses os.path.exists() to check if the
file still exists, which in turn uses stat(2). I have modified the
function to use os.path.lexists() instead. It doesn't follow symlinks.

Because httpinstance first removes the target file
/etc/ipa/kdcproxy/ipa-kdc-proxy.conf before it tries to remove the
symlink /etc/httpd/conf.d/ipa-kdc-proxy.conf, the
installutils.remove_file() ignores the dangling symlink.

Christian


ACK



Pushed to master: 2842a83568301c85d340801daae42078333ce63d

Christian, could please provide [PATCH] in subject for new threads with 
patch? It is an established practice on freeipa-devel and it helps with 
mail filtering.

--
Petr Vobornik

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] Fix removal of ipa-kdc-proxy.conf symlink

2015-06-29 Thread Fraser Tweedale
On Mon, Jun 29, 2015 at 10:54:50AM +0200, Christian Heimes wrote:
> Hello,
> 
> the attached patch fixes the first bug, that was reported by Fraser
> today. installutils.remove_file() uses os.path.exists() to check if the
> file still exists, which in turn uses stat(2). I have modified the
> function to use os.path.lexists() instead. It doesn't follow symlinks.
> 
> Because httpinstance first removes the target file
> /etc/ipa/kdcproxy/ipa-kdc-proxy.conf before it tries to remove the
> symlink /etc/httpd/conf.d/ipa-kdc-proxy.conf, the
> installutils.remove_file() ignores the dangling symlink.
> 
> Christian

ACK

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


[Freeipa-devel] Fix removal of ipa-kdc-proxy.conf symlink

2015-06-29 Thread Christian Heimes
Hello,

the attached patch fixes the first bug, that was reported by Fraser
today. installutils.remove_file() uses os.path.exists() to check if the
file still exists, which in turn uses stat(2). I have modified the
function to use os.path.lexists() instead. It doesn't follow symlinks.

Because httpinstance first removes the target file
/etc/ipa/kdcproxy/ipa-kdc-proxy.conf before it tries to remove the
symlink /etc/httpd/conf.d/ipa-kdc-proxy.conf, the
installutils.remove_file() ignores the dangling symlink.

Christian
From 322ee58bd07aa3df270c185fd319578042b5854e Mon Sep 17 00:00:00 2001
From: Christian Heimes 
Date: Mon, 29 Jun 2015 10:45:15 +0200
Subject: [PATCH] Fix removal of ipa-kdc-proxy.conf symlink

installutils.remove_file() ignored broken symlinks. Now it uses
os.path.lexists() to detect and also remove dangling symlinks.
---
 ipaserver/install/httpinstance.py | 2 +-
 ipaserver/install/installutils.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index 107c20d7f116b0dc02f2066188c664b7014e316d..f5f2a86fca3a1ff3e9123d08052a7e57b50a94fe 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -481,8 +481,8 @@ class HTTPInstance(service.Service):
 installutils.remove_file(paths.HTTPD_IPA_REWRITE_CONF)
 installutils.remove_file(paths.HTTPD_IPA_CONF)
 installutils.remove_file(paths.HTTPD_IPA_PKI_PROXY_CONF)
-installutils.remove_file(paths.HTTPD_IPA_KDCPROXY_CONF)
 installutils.remove_file(paths.HTTPD_IPA_KDCPROXY_CONF_SYMLINK)
+installutils.remove_file(paths.HTTPD_IPA_KDCPROXY_CONF)
 
 # Restore SELinux boolean states
 boolean_states = {name: self.restore_state(name)
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 42df2b7119c0e74a2b85b1a6f835f9d2c707b6f4..f6d037230a0d4332434ba1e88717a93e6b41b2f2 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -657,7 +657,7 @@ def remove_file(filename):
 Remove a file and log any exceptions raised.
 """
 try:
-if os.path.exists(filename):
+if os.path.lexists(filename):
 os.unlink(filename)
 except Exception, e:
 root_logger.error('Error removing %s: %s' % (filename, str(e)))
-- 
2.4.3



signature.asc
Description: OpenPGP digital signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code