selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] libselinux: compile Python bytecode when installing Python files
@ 2019-11-02 17:28 Nicolas Iooss
  2019-11-02 17:28 ` [PATCH 2/4] libsemanage: " Nicolas Iooss
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Nicolas Iooss @ 2019-11-02 17:28 UTC (permalink / raw)
  To: selinux

When selinux module is imported from a Python script, the content of
__init__.py is compiled into bytecode and the result is saved into a
file if it is allowed. For example, when root runs with Python 3.7 a
script that uses "import selinux" on a system where SELinux is in
permissive mode, this file may be created:

    /usr/lib/python3.7/site-packages/selinux/__pycache__/__init__.cpython-37.pyc

Prevent this file from being dynamically created by creating it when
libselinux is installed, using "python -m compileall".

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 3b8bad810de0..349f957355c1 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -176,6 +176,7 @@ install-pywrap: pywrap
 	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
 	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
 	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
+	$(PYTHON) -m compileall $(DESTDIR)$(PYTHONLIBDIR)/selinux
 
 install-rubywrap: rubywrap
 	test -d $(DESTDIR)$(RUBYINSTALL) || install -m 755 -d $(DESTDIR)$(RUBYINSTALL) 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-09 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-02 17:28 [PATCH 1/4] libselinux: compile Python bytecode when installing Python files Nicolas Iooss
2019-11-02 17:28 ` [PATCH 2/4] libsemanage: " Nicolas Iooss
2019-11-02 17:28 ` [PATCH 3/4] python: " Nicolas Iooss
2019-11-02 17:28 ` [PATCH 4/4] gui: " Nicolas Iooss
2019-11-02 20:18 ` [PATCH 1/4] libselinux: " Thomas Petazzoni
2019-11-03 20:57   ` Nicolas Iooss
2019-11-09 15:55     ` Nicolas Iooss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).