Skip to contentSkip to conversation

Eric hit a bug with sepolgen handing a newer kernel version then the policy handled.

PATCH Daniel J Walsh 1 participant 1 message Nov 11, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

This patch will look for all policyfiles installed on a machine. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkzb9zIACgkQrlYvE4MpobPVcACgwGszP4lstRB6KXsu9grIo3Bj fU8An38O1uTy+84I+yqBkzJ+Jy2Dt/EU
=FbXs
-----END PGP SIGNATURE-----

usr/bin/sepolgen-ifgen renamed from usr/bin/sepolgen-ifgen~ +12 -2
@@ -61,8 +61,18 @@
     return options
 
 def get_attrs():
+    vers = selinux.security_policyvers()
+    while vers > 0:
+        policy_path = selinux.selinux_binary_policy_path() + "." + str(vers)
+        if os.path.exists(policy_path):
+            break
+        vers -= 1
+
+    if vers == 0:
+        sys.stderr.write("could not open policy file %s.*\n" % selinux.selinux_binary_policy_path())
+        return None
+
     try:
-        policy_path = selinux.selinux_binary_policy_path() + "." + str(selinux.security_policyvers())
         outfile = tempfile.NamedTemporaryFile()
     except IOError, e:
         sys.stderr.write("could not open attribute output file\n")
@@ -75,7 +85,7 @@
     ret = subprocess.Popen([ATTR_HELPER, policy_path, outfile.name], stdout=fd).wait()
     fd.close()
     if ret != 0:
-        sys.stderr.write("could not run attribute helper")
+        sys.stderr.write("could not run attribute helper\n")
         return None
 
     attrs = interfaces.AttributeSet()