Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Fedora SELinux Support (http://www.linux-archive.org/fedora-selinux-support/)
-   -   ImportError: No module named selinux (http://www.linux-archive.org/fedora-selinux-support/670784-importerror-no-module-named-selinux.html)

Mr Dash Four 05-25-2012 01:48 AM

ImportError: No module named selinux
 
I am trying to compile and build version 3.10.0-86 of the selinux policy, but during compilation I get the following:

/usr/bin/semodule_expand tmp/test.lnk tmp/policy.bin
/usr/bin/sepolgen-ifgen -p tmp/policy.bin -i policy -o tmp/output
Traceback (most recent call last):
File "/usr/bin/sepolgen-ifgen", line 34, in <module>
import selinux
ImportError: No module named selinux
make: *** [validate] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.bEqivE (%install)


RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.bEqivE (%install)


What could be the cause for this?
--
selinux mailing list
selinux@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/selinux

Daniel J Walsh 05-25-2012 10:10 AM

ImportError: No module named selinux
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/24/2012 09:48 PM, Mr Dash Four wrote:
> I am trying to compile and build version 3.10.0-86 of the selinux policy,
> but during compilation I get the following:
>
> /usr/bin/semodule_expand tmp/test.lnk tmp/policy.bin
> /usr/bin/sepolgen-ifgen -p tmp/policy.bin -i policy -o tmp/output Traceback
> (most recent call last): File "/usr/bin/sepolgen-ifgen", line 34, in
> <module> import selinux ImportError: No module named selinux make: ***
> [validate] Error 1 error: Bad exit status from /var/tmp/rpm-tmp.bEqivE
> (%install)
>
>
> RPM build errors: Bad exit status from /var/tmp/rpm-tmp.bEqivE (%install)
>
>
> What could be the cause for this? -- selinux mailing list
> selinux@lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/selinux
yum install libselinux-python
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+/WoEACgkQrlYvE4MpobNhkQCgp9HXM+rGX6qv/YzmACSsY2BO
hrUAoOtp6AFvRZaSNueSxUY3LiRTZ2Sc
=6EDL
-----END PGP SIGNATURE-----
--
selinux mailing list
selinux@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/selinux

Mr Dash Four 05-25-2012 12:43 PM

ImportError: No module named selinux
 
/usr/bin/semodule_expand tmp/test.lnk tmp/policy.bin
/usr/bin/sepolgen-ifgen -p tmp/policy.bin -i policy -o tmp/output Traceback

(most recent call last): File "/usr/bin/sepolgen-ifgen", line 34, in
<module> import selinux ImportError: No module named selinux make: ***
[validate] Error 1 error: Bad exit status from /var/tmp/rpm-tmp.bEqivE
(%install)



yum install libselinux-python


I have it installed, though I think I found what is causing the above error.

When I compiled all core selinux-related dependencies, I based them on
python 3 instead of python 2. I am still on the "old" version of python
2 (the one which comes with FC13), because in order to upgrade it I have
to also do that for another 100+ packages I have on my system and that
it is something I can't undertake at the moment.


I assumed, wrongly as it turned out, that python 3 would be 100%
replacement for python 2 and since I remember the nightmare I had to go
through when I did the same exercise when upgrading the core selinux
tools in order to bring them to the FC15 level and trying to make this
work with the "old" python 2 version I've had on my system, I thought I
could get away with just using python 3 this time.


Well, that didn't work and it looks as though python 2 is also needed (a
fact I confirmed a couple of hours after writing my original post as
/usr/bin/sepolgen-ifgen uses python 2, not python 3), so I am probably
going to have to go through the same exercise as before. Luckily for me,
I still keep my old patches, so I am hoping that all is not lost.


On an unrelated note - I seem to remember (probably by reading it on
this ML) that there are changes in the language syntax for the new
version of the tools/policy. What are these changes and where can I find
a doc/man pages to get myself up to speed?


--
selinux mailing list
selinux@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/selinux

Mr Dash Four 05-26-2012 01:46 AM

ImportError: No module named selinux
 
> Well, that didn't work and it looks as though python 2 is also needed (a
> fact I confirmed a couple of hours after writing my original post as
> /usr/bin/sepolgen-ifgen uses python 2, not python 3), so I am probably
> going to have to go through the same exercise as before. Luckily for me,
> I still keep my old patches, so I am hoping that all is not lost.
checkpolicy and libsepol do not need python and build successfully.
libselinux, libsemanage and policycoreutils *can* be build with an older version of python2 (I've got 2.6.4), provided a few tweaks are done to the .spec file.
setools definitely needs python 2.7+, so I used python3 there instead in addition to quite extensive set of tweaks to the .spec file (I did the same trick with the previous version of the policy as well).

After that, everything is fine, though during build of the minimum policy I get the following rpm packaging error:

File not found: /builddir/build/BUILDROOT/selinux-policy-3.10.0-86.fc13.x86_64/etc/selinux/minimum/contexts/users/staff_u/usr/share/selinux/minimum/modules.lst

Don't know whether this is a bug or not. It only happens with the minimum policy (mls and targeted build without problems). I don't use the minimum policy anyway so it is not that important in my case.
--
selinux mailing list
selinux@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/selinux


All times are GMT. The time now is 02:29 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.