On 04/26/2013 04:03 PM, Petr Viktorin wrote:
> On 04/26/2013 03:03 PM, Ana Krivokapic wrote:
>> Ensure that 'ipactl stop' stops the dirsrv instance, even when no other
>> services are running.
>>
>> https://fedorahosted.org/freeipa/ticket/3574
>
> Thanks for the patch. It solves the problem, but when I look at the
> `if len(svc_list) == 0:` block, I see it only protects the os.unlink
> at the bottom against the case where there file doesn't exist.
> I think the code would be more straightforward if you removed the `if`
> block entirely, and wrapped a try/except around the unlink call.
>

Agreed, updated patch attached.

-- 
Regards,

Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.

From f2882303d8856ce3e18ccad5869c4f941db235ea Mon Sep 17 00:00:00 2001
From: Ana Krivokapic <akriv...@redhat.com>
Date: Fri, 26 Apr 2013 14:46:17 +0200
Subject: [PATCH] Always stop dirsrv in 'ipactl stop'

Ensure that 'ipactl stop' stops the dirsrv instance, even when no other
services are running.

https://fedorahosted.org/freeipa/ticket/3574
---
 install/tools/ipactl | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/install/tools/ipactl b/install/tools/ipactl
index 6500c274c446155987a8aefde7265d4d5f7a732a..2d699880ccf818cc33802994aa10bbd10e4c8851 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -252,7 +252,6 @@ def ipa_start(options):
 
 def ipa_stop(options):
     dirsrv = ipaservices.knownservices.dirsrv
-    svc_list = []
     try:
         svc_list = get_config_from_file()
     except Exception, e:
@@ -270,9 +269,11 @@ def ipa_stop(options):
             finally:
                 raise IpactlError()
 
-    if len(svc_list) == 0:
-        # no service to stop
-        return
+    try:
+        print "Stopping Directory Service"
+        dirsrv.stop(capture_output=False)
+    except:
+        raise IpactlError("Failed to stop Directory Service")
 
     for svc in reversed(svc_list):
         svchandle = ipaservices.service(svc)
@@ -282,14 +283,11 @@ def ipa_stop(options):
         except:
             emit_err("Failed to stop %s Service" % svc)
 
-    try:
-        print "Stopping Directory Service"
-        dirsrv.stop(capture_output=False)
-    except:
-        raise IpactlError("Failed to stop Directory Service")
-
     # remove file with list of started services
-    os.unlink(ipaservices.SVC_LIST_FILE)
+    try:
+        os.unlink(ipaservices.SVC_LIST_FILE)
+    except OSError:
+        pass
 
 
 def ipa_restart(options):
-- 
1.8.1.4

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

Reply via email to