Skip to contentSkip to conversation

semanage and RHPL

DISCUSSION Stephen Bennett 2 participants 4 messages Jul 12, 2006 – Jul 27, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,

After encountering some problems with modular policy in the released toolchain packages, it was suggested to me that I try the svn toolchain. I did this, and found that semanage and genhomedircon both traceback when run, failing to import functions from rhpl.translate. This package doesn't appear to be available in Gentoo's repository, and a quick bit of searching suggests that it's a Red Hat-specific library. Is this dependency intentional or desirable? If yes, where can we get the sources to package it for other distros?

Thanks in advance for any input.

--
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.

#1 lore raw
Quoted 11 lines · Stephen Bennett

Hi,

After encountering some problems with modular policy in the released toolchain packages, it was suggested to me that I try the svn toolchain. I did this, and found that semanage and genhomedircon both traceback when run, failing to import functions from rhpl.translate. This package doesn't appear to be available in Gentoo's repository, and a quick bit of searching suggests that it's a Red Hat-specific library. Is this dependency intentional or desirable? If yes, where can we get the sources to package it for other distros?

Quoted 1 line

Thanks in advance for any input.

rhpl.translate is described as a "persistent global gettext service for python programs". Not sure why that is RH specific.

The source is available from the Fedora CVS tree
(http://cvs.fedora.redhat.com) as well as in the SRPMS. You can grab it
via:
curl -O -R -S --fail --show-error http://cvs.fedora.redhat.com/repo/dist/rhpl/rhpl-0.187.tar.gz/7979e7677a5cb32c06d176052403c707/rhpl-0.187.tar.gz

Signature · 8 lines
Stephen Smalley
National Security Agency


--
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
In reply to Stephen Bennett

Having investigated this some more and discussed it on IRC, it seems that rhpl is only being used for one function (_), which it seems can be replaced by Python's standard gettext interface. A patch to do this is attached, tested with LC_* both unset and set to en_GB. semanage and genhomedircon are known to work in these situations; the changes to the other scripts are identical so they ought to work as well. Please comment.

Quoted 11 lines · On Wed, 12 Jul 2006 21:09:09 +0100 Stephen Bennett <[email protected]> wrote:

Hi,

After encountering some problems with modular policy in the released toolchain packages, it was suggested to me that I try the svn toolchain. I did this, and found that semanage and genhomedircon both traceback when run, failing to import functions from rhpl.translate. This package doesn't appear to be available in Gentoo's repository, and a quick bit of searching suggests that it's a Red Hat-specific library. Is this dependency intentional or desirable? If yes, where can we get the sources to package it for other distros?

Quoted 8 lines

Thanks in advance for any input.

Signature · 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.
semanage/semanage (working copy) renamed from semanage/semanage (revision 33) +6 -1
Index: policycoreutils/semanage/semanage
===================================================================
@@ -23,8 +23,13 @@
 import os, sys, getopt
 import seobject
 import selinux
-from rhpl.translate import _, N_
+import gettext
 
+try:
+       gettext.install('policycoreutils')
+except:
+       pass
+
 is_mls_enabled=selinux.is_selinux_mls_enabled()
 
 if __name__ == '__main__':
semanage/seobject.py (working copy) renamed from semanage/seobject.py (revision 33) +7 -1
Index: policycoreutils/semanage/seobject.py
===================================================================
@@ -23,8 +23,14 @@
 
 import pwd, string, selinux, tempfile, os, re, sys
 from semanage import *;
-from rhpl.translate import _, N_
+import gettext
 
+try:
+       t = gettext.translation('policycoreutils', '/usr/share/locale')
+       _ = t.ugettext
+except:
+       pass
+
 is_mls_enabled = selinux.is_selinux_mls_enabled()
 
 import syslog
audit2allow/audit2allow (working copy) renamed from audit2allow/audit2allow (revision 33) +5 -1
Index: policycoreutils/audit2allow/audit2allow
===================================================================
@@ -27,8 +27,12 @@
 from avc import *
 
 if __name__ == '__main__':
-       from rhpl.translate import _, N_
        import commands, sys, os, getopt, selinux
+       import gettext
+       try:
+               gettext.install('policycoreutils')
+       except:
+               pass
        def get_mls_flag():
                if selinux.is_selinux_mls_enabled():
                        return "-M"
scripts/genhomedircon (working copy) renamed from scripts/genhomedircon (revision 33) +2 -1
Index: policycoreutils/scripts/genhomedircon
===================================================================
@@ -26,7 +26,8 @@
 
 import sys, os, pwd, string, getopt, re
 from semanage import *;
-from rhpl.translate import _, N_
+import gettext
+gettext.install('policycoreutils')
 
 try:
        fd = open("/etc/shells", 'r')
scripts/chcat (working copy) renamed from scripts/chcat (revision 33) +6 -1
Index: policycoreutils/scripts/chcat
===================================================================
@@ -24,8 +24,13 @@
 #
 import commands, sys, os, pwd, string, getopt, selinux
 import seobject
-from rhpl.translate import _, N_
+import gettext
 
+try:
+    gettext.install('policycoreutils')
+except:
+    pass
+
 def verify_users(users):
     for u in users:
         try:
#3 lore raw
Quoted 7 lines · Stephen Bennett

Having investigated this some more and discussed it on IRC, it seems that rhpl is only being used for one function (_), which it seems can be replaced by Python's standard gettext interface. A patch to do this is attached, tested with LC_* both unset and set to en_GB. semanage and genhomedircon are known to work in these situations; the changes to the other scripts are identical so they ought to work as well. Please comment.

Thanks, merged upstream.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
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.