commit ef9272eada5c2d7b468e711a0e0e4499ad1bb6d1
Author: KOVACS Krisztian <hidden@balabit.hu>
Date:   Tue Jan 25 15:20:28 2011 +0100

    pylib: don't try to use KZorp if detection was unsuccessful
    
    There's no point in trying to use KZorp if we know that the initial
    Netlink communication failed.

diff --git a/pylib/Zorp/Zorp.py b/pylib/Zorp/Zorp.py
index d413231..b12dd6c 100644
--- a/pylib/Zorp/Zorp.py
+++ b/pylib/Zorp/Zorp.py
@@ -358,6 +358,22 @@ def init(names):
 		except IOError:
 			log(None, CORE_ERROR, 1, "Error reading audit encryption certificate; file='%s'", (config.audit.encrypt_certificate_file))
 
+        Globals.kzorp_responds_to_ping = False
+        if config.options.kzorp_enabled:
+                # ping kzorp to see if it's there
+                try:
+                        h = KZorp.openHandle()
+                        m = h.create_message(kznf.nfnetlink.NFNL_SUBSYS_KZORP, kznf.kznfnetlink.KZNL_MSG_GET_ZONE,
+                                             kznf.nfnetlink.NLM_F_REQUEST | kznf.nfnetlink.NLM_F_DUMP)
+                        m.set_nfmessage(kznf.kznfnetlink.create_get_zone_msg(None))
+                        result = h.talk(m, (0, 0), KZorp.netlinkmsg_handler)
+                        if result < 0:
+                                log(None, CORE_ERROR, 0, "Error pinging KZorp, it is probably unavailable; result='%d'" % (result))
+                        else:
+                                Globals.kzorp_responds_to_ping = True
+                except:
+                        log(None, CORE_ERROR, 0, "Error pinging KZorp, it is probably unavailable; exc_value='%s'" % (sys.exc_value))
+
         Globals.instance_name = names[0]
         for i in names:
                 try:
@@ -371,22 +387,7 @@ def init(names):
                         return FALSE
                 func()
 
-        # ping kzorp to see if it's there
-        kzorp_responds_to_ping = True
-        try:
-                h = KZorp.openHandle()
-                m = h.create_message(kznf.nfnetlink.NFNL_SUBSYS_KZORP, kznf.kznfnetlink.KZNL_MSG_GET_ZONE,
-                                     kznf.nfnetlink.NLM_F_REQUEST | kznf.nfnetlink.NLM_F_DUMP)
-                m.set_nfmessage(kznf.kznfnetlink.create_get_zone_msg(None))
-                result = h.talk(m, (0, 0), KZorp.netlinkmsg_handler)
-                if result == -errno.EINVAL:               # -22 was found empirically, this seems to be what it is
-                        log(None, CORE_ERROR, 0, "Error pinging KZorp, it is probably unavailable; result='%d'" % (result))
-                        kzorp_responds_to_ping = False
-        except:
-                log(None, CORE_ERROR, 0, "Error pinging KZorp, it is probably unavailable; exc_value='%s'" % (sys.exc_value))
-                kzorp_responds_to_ping = False
-
-        if config.options.kzorp_enabled:
+        if Globals.kzorp_responds_to_ping:
                 try:
                         KZorp.downloadKZorpConfig(names[0])
                 except:
@@ -401,12 +402,10 @@ def init(names):
                                                 log(None, CORE_ERROR, 0, "Traceback: %s" % (l))
 
                         # if kzorp did respond to the ping, the configuration is erroneous -- we die here so the user finds out
-                        if kzorp_responds_to_ping:
-                                return FALSE
+                        return FALSE
 
         return TRUE
 
-
 def deinit(name):
 	"""
         <function internal="yes">
