Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 691720 - sys-libs/libselinux-2.9: ImportError: cannot import name '_selinux' with dev-lang/swig-4.0.0
Summary: sys-libs/libselinux-2.9: ImportError: cannot import name '_selinux' with dev-...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: SELinux (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: SE Linux Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-07 21:03 UTC by Jan Breig
Modified: 2019-09-01 10:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Change location of _selinux.so (import_selinux.patch,580 bytes, patch)
2019-08-07 21:03 UTC, Jan Breig
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Breig 2019-08-07 21:03:49 UTC
Created attachment 586096 [details, diff]
Change location of _selinux.so

Executing 'rlpkg -a -r' gives:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.6/rlpkg", line 18, in <module>
    import selinux
  File "/usr/lib64/python3.6/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux'

with sys-libs/libselinux-2.9 and dev-lang/swig-4.0.0.
It works fine with swig version 3.x.

The issue is also referenced here: https://src.fedoraproject.org/rpms/libselinux/c/5d8ec18db09e97729be68029ace116c5f91e7755?branch=master

I fixed it by changing the path of _selinux.so in the Makefile (see attached patch). It works so far but this could possibly break something?
Comment 1 Fulgurance 2019-08-12 21:17:01 UTC
I confirm, i have the same problem:

msi-gs73vr-6rf /home/zohran # rlpkg -a -r
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.6/rlpkg", line 18, in <module>
    import selinux
  File "/usr/lib64/python3.6/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux'
msi-gs73vr-6rf /home/zohran # setsebool -P global_ssp on
msi-gs73vr-6rf /home/zohran # semanage login -a -s staff_u zohran
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.6/semanage", line 28, in <module>
    import seobject
  File "/usr/lib64/python3.6/site-packages/seobject.py", line 25, in <module>
    import selinux
  File "/usr/lib64/python3.6/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux'
msi-gs73vr-6rf /home/zohran # restorecon -R -F /home/zohran
msi-gs73vr-6rf /home/zohran # semanage user -m -R "staff_r sysadm_r system_r" root
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.6/semanage", line 28, in <module>
    import seobject
  File "/usr/lib64/python3.6/site-packages/seobject.py", line 25, in <module>
    import selinux
  File "/usr/lib64/python3.6/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux'
msi-gs73vr-6rf /home/zohran # semanage user -m -R "staff_r sysadm_r system_r" staff_u
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.6/semanage", line 28, in <module>
    import seobject
  File "/usr/lib64/python3.6/site-packages/seobject.py", line 25, in <module>
    import selinux
  File "/usr/lib64/python3.6/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux'
msi-gs73vr-6rf /home/zohran # eix libselinux
[I] sys-libs/libselinux
     Available versions:  2.8-r1 (~)2.9_rc1 (~)2.9 **9999*l {pcre2 python ruby static-libs ABI_MIPS="n32 n64 o32" ABI_RISCV="lp64 lp64d" ABI_S390="32 64" ABI_X86="32 64 x32" PYTHON_TARGETS="python2_7 python3_5 python3_6 python3_7" RUBY_TARGETS="ruby24 ruby25"}
     Installed versions:  2.9(18:16:49 11/08/2019)(python static-libs -pcre2 -ruby ABI_MIPS="-n32 -n64 -o32" ABI_RISCV="-lp64 -lp64d" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" PYTHON_TARGETS="python2_7 python3_6 -python3_5 -python3_7" RUBY_TARGETS="ruby24 -ruby25")
     Homepage:            https://github.com/SELinuxProject/selinux/wiki
     Description:         SELinux userland library
Comment 2 Larry the Git Cow gentoo-dev 2019-09-01 10:19:54 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=079ce1fb1893c226c1cdbbff9e85e0450cae8839

commit 079ce1fb1893c226c1cdbbff9e85e0450cae8839
Author:     Jason Zaman <perfinion@gentoo.org>
AuthorDate: 2019-09-01 09:31:58 +0000
Commit:     Jason Zaman <perfinion@gentoo.org>
CommitDate: 2019-09-01 09:32:32 +0000

    sys-libs/libselinux: Add compatibility with swig-4
    
    Swig-4 changed how the native lib is imported, so backport
    2efa06857575e4118e91ca250b6b92da68b130d5 to fix.
    
    Closes: https://bugs.gentoo.org/691720
    Package-Manager: Portage-2.3.69, Repoman-2.3.16
    Signed-off-by: Jason Zaman <perfinion@gentoo.org>

 ...Use-Python-distutils-to-install-SELinux-p.patch | 205 +++++++++++++++++++++
 sys-libs/libselinux/libselinux-2.9-r1.ebuild       | 157 ++++++++++++++++
 sys-libs/libselinux/libselinux-2.9.ebuild          |   4 +-
 3 files changed, 364 insertions(+), 2 deletions(-)