All of lore.kernel.org
 help / color / mirror / Atom feed
* Fixes for chcat to work better in Large category environment.
@ 2007-01-24 20:14 Daniel J Walsh
  0 siblings, 0 replies; only message in thread
From: Daniel J Walsh @ 2007-01-24 20:14 UTC (permalink / raw)
  To: Stephen Smalley, SE Linux

[-- Attachment #1: Type: text/plain, Size: 104 bytes --]

Also fixes problem with creating wrong context, by execing semanage 
rather then using python bindings.

[-- Attachment #2: policycoreutils-chcat.patch --]
[-- Type: text/x-patch, Size: 2456 bytes --]

--- nsapolicycoreutils/scripts/chcat	2006-11-16 17:14:27.000000000 -0500
+++ policycoreutils-1.34.1/scripts/chcat	2007-01-24 14:42:19.000000000 -0500
@@ -62,12 +62,20 @@
         for i in newcat[1:]:
             if i not in cats:
                 cats.append(i)
+
         new_serange = "%s-%s:%s" % (serange[0], top[0], string.join(cats, ","))
-        
+        if new_serange[-1:] == ":":
+            new_serange = new_serange[:-1]
+            
         if add_ind:
-            logins.add(u, user[0], new_serange)
+            cmd = "semanage login -a -r %s -s %s %s" % (new_serange, user[0], u)
         else:
-            logins.modify(u, user[0], new_serange)
+            cmd = "semanage login -m -r %s -s %s %s" % (new_serange, user[0], u)
+        rc = commands.getstatusoutput(cmd)
+        if rc[0] != 0:
+            print rc[1]
+            errors += 1
+
     return errors
         
 def chcat_add(orig, newcat, objects,login_ind):
@@ -133,11 +141,17 @@
                 cats.remove(i)
 
         new_serange = "%s-%s:%s" % (serange[0], top[0], string.join(cats, ","))
+        if new_serange[-1:] == ":":
+            new_serange = new_serange[:-1]
         
         if add_ind:
-            logins.add(u, user[0], new_serange)
+            cmd = "semanage login -a -r %s -s %s %s" % (new_serange, user[0], u)
         else:
-            logins.modify(u, user[0], new_serange)
+            cmd = "semanage login -m -r %s -s %s %s" % (new_serange, user[0], u)
+        rc = commands.getstatusoutput(cmd)
+        if rc[0] != 0:
+            print rc[1]
+            errors += 1
     return errors
         
 def chcat_remove(orig, newcat, objects, login_ind):
@@ -198,11 +212,17 @@
             user = seusers["__default__"]
         serange = user[1].split("-")
         new_serange = "%s-%s:%s" % (serange[0],newcat[0], string.join(newcat[1:], ","))
-        
+        if new_serange[-1:] == ":":
+            new_serange = new_serange[:-1]
+
         if add_ind:
-            logins.add(u, user[0], new_serange)
+            cmd = "semanage login -a -r %s -s %s %s" % (new_serange, user[0], u)
         else:
-            logins.modify(u, user[0], new_serange)
+            cmd = "semanage login -m -r %s -s %s %s" % (new_serange, user[0], u)
+        rc = commands.getstatusoutput(cmd)
+        if rc[0] != 0:
+            print rc[1]
+            errors += 1
     return errors
     
 def chcat_replace(newcat, objects, login_ind):

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-01-24 20:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-24 20:14 Fixes for chcat to work better in Large category environment Daniel J Walsh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.