[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 17/73] sepolgen: audit.py Dont crash if empty data is passed



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


   This patch looks good to me. acked.


If you pass output from a log file that does not include any avc's
audit2allow will crash.  This patch fixes this problem.

ausearch -m avc -ts recent | audit2allow

If there was no AVC's recently, we do not want the python to crash.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9x10EACgkQrlYvE4MpobNJqACgl9Iny1pmGGMKSypaCEJt320m
T5cAn3BwldGDPQ7Hpf9FWF/j1IbuIRkx
=NXL5
-----END PGP SIGNATURE-----
>From 12570d6797fe1c720e3c7069c7777816420ff1d8 Mon Sep 17 00:00:00 2001
From: Dan Walsh <dwalsh@xxxxxxxxxx>
Date: Wed, 18 Jan 2012 16:41:36 -0500
Subject: [PATCH 17/73] sepolgen: audit.py Dont crash if empty data is passed
 to sepolgen FIXME

Needs explaination of the crash.

NOT-Signed-off-by: Eric Paris <eparis@xxxxxxxxxx>
---
 sepolgen/src/sepolgen/audit.py |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sepolgen/src/sepolgen/audit.py b/sepolgen/src/sepolgen/audit.py
index 9fdfafa..9e2ccee 100644
--- a/sepolgen/src/sepolgen/audit.py
+++ b/sepolgen/src/sepolgen/audit.py
@@ -20,6 +20,7 @@
 import refpolicy
 import access
 import re
+import sys
 
 # Convenience functions
 
@@ -343,6 +344,7 @@ class AuditParser:
         self.policy_load_msgs = []
         self.path_msgs = []
         self.by_header = { }
+        self.check_input_file = False
                 
     # Low-level parsing function - tries to determine if this audit
     # message is an SELinux related message and then parses it into
@@ -378,6 +380,7 @@ class AuditParser:
                 found = True
                 
             if found:
+                self.check_input_file = True
                 try:
                     msg.from_split_string(rec)
                 except ValueError:
@@ -447,6 +450,9 @@ class AuditParser:
         while line:
             self.__parse(line)
             line = input.readline()
+        if not self.check_input_file:
+            sys.stderr.write("Nothing to do\n")
+            sys.exit(0)
         self.__post_process()
 
     def parse_string(self, input):
-- 
1.7.9.3


[Fedora Users]     [Fedora Legacy]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite News]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

Powered by Linux