selinux/libselinux/src
Petr Lautrbach 2efa068575 libselinux: Use Python distutils to install SELinux python bindings
Follow officially documented way how to build C extension modules using
distutils - https://docs.python.org/3.8/extending/building.html#building

Fixes:

- selinux python module fails to load when it's built using SWIG-4.0:

>>> import selinux
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.7/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux' from 'selinux' (/usr/lib64/python3.7/site-packages/selinux/__init__.py)

SWIG-4.0 changed (again?) its behavior so that it uses: from . import _selinux
which looks for _selinux module in the same directory as where __init__.py is -
$(PYLIBDIR)/site-packages/selinux. But _selinux module is installed into
$(PYLIBDIR)/site-packages/ since a9604c30a5 ("libselinux: Change the location
of _selinux.so").

- audit2why python module fails to build with Python 3.8

cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DOVERRIDE_GETTID=0 -I../include -D_GNU_SOURCE -DDISABLE_RPM -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L. -shared -o python-3.8audit2why.so python-3.8audit2why.lo -lselinux -l:libsepol.a  -Wl,-soname,audit2why.so,--version-script=audit2why.map,-z,defs
/usr/bin/ld: python-3.8audit2why.lo: in function `finish':
/builddir/build/BUILD/libselinux-2.9/src/audit2why.c:166: undefined reference to `PyArg_ParseTuple'
/usr/bin/ld: python-3.8audit2why.lo: in function `_Py_INCREF':
/usr/include/python3.8/object.h:449: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /usr/include/python3.8/object.h:449: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: python-3.8audit2why.lo: in function `check_booleans':
/builddir/build/BUILD/libselinux-2.9/src/audit2why.c:84: undefined reference to `PyExc_RuntimeError'
...

It's related to the following Python change
https://docs.python.org/dev/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build

Python distutils adds correct link options automatically.

- selinux python module doesn't provide any Python metadata

When selinux python module was built manually, it didn't provide any metadata.
distutils takes care about that so that selinux Python module is visible for
pip:

$ pip3 list | grep selinux
selinux              2.9

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
2019-07-26 18:15:46 +02:00
..
.gitignore libselinux: Use Python distutils to install SELinux python bindings 2019-07-26 18:15:46 +02:00
audit2why.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
audit2why.map libselinux/audit2why.so: Filter out non-python related symbols 2019-01-21 12:13:41 +01:00
avc_internal.c libselinux: normalize enforce values from the kernel 2016-11-18 09:48:25 -05:00
avc_internal.h
avc_sidtab.c Fix -Wformat errors 2015-03-13 14:14:23 -04:00
avc_sidtab.h Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
avc.c checkpolicy,libselinux,libsepol,policycoreutils: Update my email address 2017-08-17 14:17:12 -04:00
booleans.c libselinux: Fix security_get_boolean_names build error 2019-07-21 22:59:37 +02:00
callbacks.c libselinux: add ifdef'ing for ANDROID and BUILD_HOST 2016-09-26 15:15:31 -04:00
callbacks.h Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
canonicalize_context.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
check_context.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
checkAccess.c libselinux: Fix RESOURCE_LEAK defects reported by coverity scan 2019-02-10 17:52:09 +01:00
checkreqprot.c libselinux: add security_get_checkreqprot 2017-05-08 12:44:07 -04:00
compute_av.c libselinux: selinux_set_mapping: fix handling of unknown classes/perms 2019-03-01 12:51:31 +01:00
compute_create.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
compute_member.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
compute_relabel.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
compute_user.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
context_internal.h
context.c
deny_unknown.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
disable.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
dso.h
enabled.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
exception.sh libselinux, libsemanage: swig: use SWIG_fail when an error occurs 2016-11-15 11:11:25 -05:00
fgetfilecon.c libselinux: Fix unitialized variable compiler warnings 2017-01-06 12:15:12 -05:00
file_path_suffixes.h libselinux: Add openrc_contexts functions 2016-09-22 13:27:45 -04:00
freecon.c Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
freeconary.c Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
fsetfilecon.c Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
get_context_list_internal.h
get_context_list.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
get_default_type_internal.h
get_default_type.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
get_initial_context.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
getenforce.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
getfilecon.c libselinux: Fix unitialized variable compiler warnings 2017-01-06 12:15:12 -05:00
getpeercon.c Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
init.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
is_customizable_type.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
label_backends_android.c Revert "libselinux: verify file_contexts when using restorecon" 2018-04-20 10:12:57 -04:00
label_db.c libselinux: Fix RESOURCE_LEAK defects reported by coverity scan 2019-02-10 17:52:09 +01:00
label_file.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
label_file.h Fix build break around __atomic_*() with GCC<4.7 2018-08-22 22:56:08 +02:00
label_internal.h Revert "libselinux: verify file_contexts when using restorecon" 2018-04-20 10:12:57 -04:00
label_media.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
label_support.c read_spec_entry: fail on non-ascii 2016-02-17 09:10:41 -05:00
label_x.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
label.c Revert "libselinux: verify file_contexts when using restorecon" 2018-04-20 10:12:57 -04:00
lgetfilecon.c libselinux: Fix unitialized variable compiler warnings 2017-01-06 12:15:12 -05:00
libselinux.pc.in libselinux: build: follow standard semantics for DESTDIR and PREFIX 2018-02-14 15:59:36 +01:00
load_policy.c libselinux: Fix RESOURCE_LEAK defects reported by coverity scan 2019-02-10 17:52:09 +01:00
lsetfilecon.c Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
Makefile libselinux: Use Python distutils to install SELinux python bindings 2019-07-26 18:15:46 +02:00
mapping.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
mapping.h libselinux: drop DISABLE_AVC=y 2016-09-28 11:43:36 -04:00
matchmediacon.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
matchpathcon.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
policy.h Fix redefinition of XATTR_NAME_SELINUX 2016-09-22 13:21:39 -04:00
policyvers.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
procattr.c libselinux: Do not define gettid() if glibc >= 2.30 is used 2019-03-13 13:23:50 -04:00
query_user_context.c Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
regex.c libselinux: fix overly strict validation of file_contexts.bin 2018-11-05 09:31:45 -05:00
regex.h libselinux: fix thread safety issues with lookup_common() 2017-07-26 16:23:04 -04:00
reject_unknown.c libselinux: selinux_set_mapping: fix handling of unknown classes/perms 2019-03-01 12:51:31 +01:00
selinux_check_securetty_context.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
selinux_config.c libselinux: Fix RESOURCE_LEAK defects reported by coverity scan 2019-02-10 17:52:09 +01:00
selinux_internal.h Add security_validatetrans support 2019-04-09 06:51:02 -07:00
selinux_netlink.h
selinux_restorecon.c libselinux: fix selinux_restorecon() on non-SELinux hosts 2019-02-20 11:21:33 +01:00
selinuxswig_python.i python/restorecon: add force option 2019-02-04 20:23:32 +01:00
selinuxswig_ruby.i libselinux: remove rpm_execcon from SWIG wrappers 2016-11-07 15:55:08 -05:00
selinuxswig.i libselinux: initialize temp value in SWIG wrapper to prevent freeing garbage 2017-03-01 10:42:45 -05:00
sestatus.c
setenforce.c libselinux: add O_CLOEXEC 2017-04-12 14:51:41 -04:00
setexecfilecon.c Deprecate use of flask.h and av_permissions.h. 2014-07-09 13:49:18 -04:00
setfilecon.c Get rid of security_context_t and fix const declarations. 2014-02-19 16:11:48 -05:00
setrans_client.c libselinux: include errno.h instead of sys/errno.h 2017-01-09 16:00:22 -05:00
setrans_internal.h
setup.py libselinux: Use Python distutils to install SELinux python bindings 2019-07-26 18:15:46 +02:00
seusers.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
sha1.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
sha1.h libselinux: Replace selabel_digest hash function 2015-10-22 11:55:02 -04:00
stringrep.c Unify code style to preserve my sanity 2019-05-15 17:35:43 -07:00
validatetrans.c Add security_validatetrans support 2019-04-09 06:51:02 -07:00