Skip to contentSkip to conversation

patch to policycoreutils

PATCH Daniel J Walsh 3 participants 5 messages Apr 1, 2009 – May 18, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

Multiple patches to policycoreutils.

First added /root/.ssh and /root/.ssh/* to allow people to place keys in /root directory and have them labeled by restorcond

Fix transaction handling in semanage so you can update multiple records simultaniously.

Clean up permissive domains creation in semanage so it does not leave crap in /var/lib/selinux

restorecond/restorecond.conf +4 -0
diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.conf policycoreutils-2.0.62/restorecond/restorecond.conf
@@ -5,3 +5,7 @@
 /var/run/utmp
 /var/log/wtmp
 ~/*
+/root/.ssh
+/root/.ssh/*
+
+
scripts/fixfiles +1 -1
diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.62/scripts/fixfiles
@@ -122,7 +122,7 @@
 fi
 if [ ! -z "$RPMFILES" ]; then
     for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do
-	rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -i -f - 2>&1 >> $LOGFILE
+	rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -R -i -f - 2>&1 >> $LOGFILE
     done
     exit $?
 fi
semanage/semanage +2 -2
diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/semanage policycoreutils-2.0.62/semanage/semanage
@@ -464,10 +464,10 @@
                       else:
                              fd = open(input, 'r')
                       trans = seobject.semanageRecords(store)
-                      trans.begin()
+                      trans.start()
                       for l in fd.readlines():
                              process_args(mkargv(l))
-                      trans.commit()
+                      trans.finish()
                else:
                       process_args(sys.argv[1:])
 			
semanage/seobject.py +21 -6
diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/seobject.py policycoreutils-2.0.62/semanage/seobject.py
@@ -281,15 +281,20 @@
                global handle
                       
                if handle != None:
-                      self.transaction = True
                       self.sh = handle
                else:
                       self.sh=get_handle(store)
-                      self.transaction = False
+               self.transaction = False
 
         def deleteall(self):
                raise ValueError(_("Not yet implemented"))
 
+        def start(self):
+               if self.transaction:
+                      raise ValueError(_("Semanage transaction already in progress"))
+               self.begin()
+               self.transaction = True
+
         def begin(self):
                if self.transaction:
                       return
@@ -303,6 +308,12 @@
                if rc < 0:
                       raise ValueError(_("Could not commit semanage transaction"))
 
+        def finish(self):
+               if not self.transaction:
+                      raise ValueError(_("Semanage transaction not in progress"))
+               self.transaction = False
+               self.commit()
+
 class permissiveRecords(semanageRecords):
 	def __init__(self, store):
                semanageRecords.__init__(self, store)
@@ -328,6 +339,7 @@
 
 
 	def add(self, type):
+               import glob
                name = "permissive_%s" % type
                dirname = "/var/lib/selinux"
                os.chdir(dirname)
@@ -351,16 +363,19 @@
                fd.close()
 
                rc = semanage_module_install(self.sh, data, len(data));
-               if rc < 0:
-			raise ValueError(_("Could not set permissive domain %s (module installation failed)") % name)
-
-               self.commit()
+               if rc >= 0:
+                      self.commit()
 
                for root, dirs, files in os.walk("tmp", topdown=False):
                       for name in files:
                              os.remove(os.path.join(root, name))
                       for name in dirs:
                              os.rmdir(os.path.join(root, name))
+               os.removedirs("tmp")
+               for i in glob.glob("permissive_%s.*" % type):
+                      os.remove(i)
+               if rc < 0:
+			raise ValueError(_("Could not set permissive domain %s (module installation failed)") % name)
 
 	def delete(self, name):
                for n in name.split():
#1 lore raw
Quoted 40 lines · Daniel J Walsh

Multiple patches to policycoreutils.

First added /root/.ssh and /root/.ssh/* to allow people to place keys in /root directory and have them labeled by restorcond

Fix transaction handling in semanage so you can update multiple records simultaniously.

Clean up permissive domains creation in semanage so it does not leave crap in /var/lib/selinux

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.conf policycoreutils-2.0.62/restorecond/restorecond.conf
--- nsapolicycoreutils/restorecond/restorecond.conf 2009-02-18
16:44:47.000000000 -0500
+++ policycoreutils-2.0.62/restorecond/restorecond.conf 2009-02-23
11:32:21.000000000 -0500

restorecond/restorecond.conf +4 -0
@@ -5,3 +5,7 @@
 /var/run/utmp
 /var/log/wtmp
 ~/*
+/root/.ssh
+/root/.ssh/*
+
+

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.62/scripts/fixfiles

scripts/fixfiles 2009-02-19 10:07:49.000000000 renamed from scripts/fixfiles 2009-02-18 16:44:47.000000000 -0500 +0 -2
-0500
@@ -122,7 +122,7 @@
 fi
 if [ ! -z "$RPMFILES" ]; then
     for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do
-    rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -i -f - 2>&1 >>

$LOGFILE
+ rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -R -i -f - 2>&1 >>
$LOGFILE

Quoted 3 lines
     done
     exit $?

fi

Not sure I understand this one, and it didn't seem to be mentioned in your comment. You're changing fixfiles to relabel recursively when it's fixing files from an rpm? Wouldn't an rpm already list all the files it owned?

<snip due to previously ack'd patch>

Quoted 47 lines
scripts/fixfiles 2009-02-19 10:07:49.000000000 renamed from scripts/fixfiles 2009-02-18 16:44:47.000000000 -0500 +6 -0
@@ -303,6 +308,12 @@
                if rc < 0:
                       raise ValueError(_("Could not commit semanage
 transaction"))
 
+        def finish(self):
+               if not self.transaction:
+                      raise ValueError(_("Semanage transaction not in
 progress"))
+               self.transaction = False
+               self.commit()
+
 class permissiveRecords(semanageRecords):
     def __init__(self, store):
                semanageRecords.__init__(self, store)
scripts/fixfiles 2009-02-19 10:07:49.000000000 renamed from scripts/fixfiles 2009-02-18 16:44:47.000000000 -0500 +8 -4
@@ -328,6 +339,7 @@
 
 
     def add(self, type):
+               import glob
                name = "permissive_%s" % type
                dirname = "/var/lib/selinux"
                os.chdir(dirname)
@@ -351,16 +363,19 @@
                fd.close()
 
                rc = semanage_module_install(self.sh, data, len(data));
-               if rc < 0:
-            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
-
-               self.commit()
+               if rc >= 0:
+                      self.commit()
 
                for root, dirs, files in os.walk("tmp", topdown=False):
                       for name in files:
                              os.remove(os.path.join(root, name))
                       for name in dirs:
                              os.rmdir(os.path.join(root, name))
+               os.removedirs("tmp")
+               for i in glob.glob("permissive_%s.*" % type):
+                      os.remove(i)
+               if rc < 0:
+            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
 
Quoted 2 lines

def delete(self, name):
for n in name.split():

Other than that one thing, this looks fine to me.

Thanks,
Chad

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw
Quoted 102 lines · Chad Sellers
Quoted 40 lines · Daniel J Walsh

Multiple patches to policycoreutils.

First added /root/.ssh and /root/.ssh/* to allow people to place keys in /root directory and have them labeled by restorcond

Fix transaction handling in semanage so you can update multiple records simultaniously.

Clean up permissive domains creation in semanage so it does not leave crap in /var/lib/selinux

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.conf policycoreutils-2.0.62/restorecond/restorecond.conf
--- nsapolicycoreutils/restorecond/restorecond.conf 2009-02-18
16:44:47.000000000 -0500
+++ policycoreutils-2.0.62/restorecond/restorecond.conf 2009-02-23
11:32:21.000000000 -0500

restorecond/restorecond.conf +4 -0
@@ -5,3 +5,7 @@
  /var/run/utmp
  /var/log/wtmp
  ~/*
+/root/.ssh
+/root/.ssh/*
+
+

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.62/scripts/fixfiles

scripts/fixfiles 2009-02-19 10:07:49.000000000 renamed from scripts/fixfiles 2009-02-18 16:44:47.000000000 -0500 +0 -2
-0500
@@ -122,7 +122,7 @@
  fi
  if [ ! -z "$RPMFILES" ]; then
      for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do
-    rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -i -f - 2>&1>>

$LOGFILE
+ rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -R -i -f - 2>&1>>
$LOGFILE

Quoted 3 lines
      done
      exit $?

fi

Not sure I understand this one, and it didn't seem to be mentioned in your comment. You're changing fixfiles to relabel recursively when it's fixing files from an rpm? Wouldn't an rpm already list all the files it owned?

<snip due to previously ack'd patch>

Quoted 47 lines
scripts/fixfiles 2009-02-19 10:07:49.000000000 renamed from scripts/fixfiles 2009-02-18 16:44:47.000000000 -0500 +6 -0
@@ -303,6 +308,12 @@
                 if rc<  0:
                        raise ValueError(_("Could not commit semanage
 transaction"))
 
+        def finish(self):
+               if not self.transaction:
+                      raise ValueError(_("Semanage transaction not in
 progress"))
+               self.transaction = False
+               self.commit()
+
  class permissiveRecords(semanageRecords):
      def __init__(self, store):
                 semanageRecords.__init__(self, store)
scripts/fixfiles 2009-02-19 10:07:49.000000000 renamed from scripts/fixfiles 2009-02-18 16:44:47.000000000 -0500 +8 -4
@@ -328,6 +339,7 @@
 
 
      def add(self, type):
+               import glob
                 name = "permissive_%s" % type
                 dirname = "/var/lib/selinux"
                 os.chdir(dirname)
@@ -351,16 +363,19 @@
                 fd.close()
 
                 rc = semanage_module_install(self.sh, data, len(data));
-               if rc<  0:
-            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
-
-               self.commit()
+               if rc>= 0:
+                      self.commit()
 
                 for root, dirs, files in os.walk("tmp", topdown=False):
                        for name in files:
                               os.remove(os.path.join(root, name))
                        for name in dirs:
                               os.rmdir(os.path.join(root, name))
+               os.removedirs("tmp")
+               for i in glob.glob("permissive_%s.*" % type):
+                      os.remove(i)
+               if rc<  0:
+            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
 
Quoted 2 lines

def delete(self, name):
for n in name.split():

Other than that one thing, this looks fine to me.

Quoted 8 lines

Thanks,
Chad

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

If a package owned a directory like /var/lib/libvirt/images, when it is relabeling we would want it to relabel not only the directory but the contents of the directory

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Acked-by
#3 lore raw
Quoted 109 lines · Daniel J Walsh
Quoted 108 lines · Chad Sellers
Quoted 42 lines · Daniel J Walsh

Multiple patches to policycoreutils.

First added /root/.ssh and /root/.ssh/* to allow people to place keys in /root directory and have them labeled by restorcond

Fix transaction handling in semanage so you can update multiple records simultaniously.

Clean up permissive domains creation in semanage so it does not leave crap in /var/lib/selinux

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.conf policycoreutils-2.0.62/restorecond/restorecond.conf
--- nsapolicycoreutils/restorecond/restorecond.conf 2009-02-18
16:44:47.000000000 -0500
+++ policycoreutils-2.0.62/restorecond/restorecond.conf 2009-02-23
11:32:21.000000000 -0500

restorecond/restorecond.conf +4 -0
@@ -5,3 +5,7 @@
  /var/run/utmp
  /var/log/wtmp
  ~/*
+/root/.ssh
+/root/.ssh/*
+
+

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.62/scripts/fixfiles
--- nsapolicycoreutils/scripts/fixfiles 2009-02-18 16:44:47.000000000
-0500
+++ policycoreutils-2.0.62/scripts/fixfiles 2009-02-19 10:07:49.000000000
-0500

scripts/fixfiles +0 -1
@@ -122,7 +122,7 @@
  fi
  if [ ! -z "$RPMFILES" ]; then
      for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do
-    rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -i -f - 2>&1>>

$LOGFILE
+ rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -R -i -f -
2>&1>>
$LOGFILE

Quoted 3 lines
      done
      exit $?

fi

Not sure I understand this one, and it didn't seem to be mentioned in your comment. You're changing fixfiles to relabel recursively when it's fixing files from an rpm? Wouldn't an rpm already list all the files it owned?

<snip due to previously ack'd patch>

Quoted 47 lines
semanage/seobject.py +6 -0
@@ -303,6 +308,12 @@
                 if rc<  0:
                        raise ValueError(_("Could not commit semanage
 transaction"))
 
+        def finish(self):
+               if not self.transaction:
+                      raise ValueError(_("Semanage transaction not in
 progress"))
+               self.transaction = False
+               self.commit()
+
  class permissiveRecords(semanageRecords):
      def __init__(self, store):
                 semanageRecords.__init__(self, store)
semanage/seobject.py +8 -4
@@ -328,6 +339,7 @@
 
 
      def add(self, type):
+               import glob
                 name = "permissive_%s" % type
                 dirname = "/var/lib/selinux"
                 os.chdir(dirname)
@@ -351,16 +363,19 @@
                 fd.close()
 
                 rc = semanage_module_install(self.sh, data, len(data));
-               if rc<  0:
-            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
-
-               self.commit()
+               if rc>= 0:
+                      self.commit()
 
                 for root, dirs, files in os.walk("tmp", topdown=False):
                        for name in files:
                               os.remove(os.path.join(root, name))
                        for name in dirs:
                               os.rmdir(os.path.join(root, name))
+               os.removedirs("tmp")
+               for i in glob.glob("permissive_%s.*" % type):
+                      os.remove(i)
+               if rc<  0:
+            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
 
Quoted 2 lines

def delete(self, name):
for n in name.split():

Other than that one thing, this looks fine to me.

Thanks,
Chad

Quoted 7 lines
Quoted 4 lines

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

If a package owned a directory like /var/lib/libvirt/images, when it is relabeling we would want it to relabel not only the directory but the contents of the directory

Makes sense.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
Quoted 114 lines · Chad Sellers
Quoted 112 lines · Daniel J Walsh
Quoted 111 lines · Chad Sellers
Quoted 42 lines · Daniel J Walsh

Multiple patches to policycoreutils.

First added /root/.ssh and /root/.ssh/* to allow people to place keys in /root directory and have them labeled by restorcond

Fix transaction handling in semanage so you can update multiple records simultaniously.

Clean up permissive domains creation in semanage so it does not leave crap in /var/lib/selinux

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.conf policycoreutils-2.0.62/restorecond/restorecond.conf
--- nsapolicycoreutils/restorecond/restorecond.conf 2009-02-18
16:44:47.000000000 -0500
+++ policycoreutils-2.0.62/restorecond/restorecond.conf 2009-02-23
11:32:21.000000000 -0500

restorecond/restorecond.conf +4 -0
@@ -5,3 +5,7 @@
  /var/run/utmp
  /var/log/wtmp
  ~/*
+/root/.ssh
+/root/.ssh/*
+
+

diff --exclude-from=exclude --exclude=sepolgen-1.0.16 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.62/scripts/fixfiles
--- nsapolicycoreutils/scripts/fixfiles 2009-02-18 16:44:47.000000000
-0500
+++ policycoreutils-2.0.62/scripts/fixfiles 2009-02-19 10:07:49.000000000
-0500

scripts/fixfiles +0 -1
@@ -122,7 +122,7 @@
  fi
  if [ ! -z "$RPMFILES" ]; then
      for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do
-    rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -i -f - 2>&1>>

$LOGFILE
+ rpmlist $i | ${RESTORECON} ${OUTFILES} ${FORCEFLAG} $* -R -i -f -
2>&1>>
$LOGFILE

Quoted 3 lines
      done
      exit $?

fi

Not sure I understand this one, and it didn't seem to be mentioned in your comment. You're changing fixfiles to relabel recursively when it's fixing files from an rpm? Wouldn't an rpm already list all the files it owned?

<snip due to previously ack'd patch>

Quoted 47 lines
semanage/seobject.py +6 -0
@@ -303,6 +308,12 @@
                 if rc<  0:
                        raise ValueError(_("Could not commit semanage
 transaction"))
 
+        def finish(self):
+               if not self.transaction:
+                      raise ValueError(_("Semanage transaction not in
 progress"))
+               self.transaction = False
+               self.commit()
+
  class permissiveRecords(semanageRecords):
      def __init__(self, store):
                 semanageRecords.__init__(self, store)
semanage/seobject.py +8 -4
@@ -328,6 +339,7 @@
 
 
      def add(self, type):
+               import glob
                 name = "permissive_%s" % type
                 dirname = "/var/lib/selinux"
                 os.chdir(dirname)
@@ -351,16 +363,19 @@
                 fd.close()
 
                 rc = semanage_module_install(self.sh, data, len(data));
-               if rc<  0:
-            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
-
-               self.commit()
+               if rc>= 0:
+                      self.commit()
 
                 for root, dirs, files in os.walk("tmp", topdown=False):
                        for name in files:
                               os.remove(os.path.join(root, name))
                        for name in dirs:
                               os.rmdir(os.path.join(root, name))
+               os.removedirs("tmp")
+               for i in glob.glob("permissive_%s.*" % type):
+                      os.remove(i)
+               if rc<  0:
+            raise ValueError(_("Could not set permissive domain %s (module
 installation failed)") % name)
 
Quoted 2 lines

def delete(self, name):
for n in name.split():

Other than that one thing, this looks fine to me.

Thanks,
Chad

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Quoted 8 lines
Quoted 3 lines

If a package owned a directory like /var/lib/libvirt/images, when it is relabeling we would want it to relabel not only the directory but the contents of the directory

Makes sense.

Merged in policycoreutils-2.0.63

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.