Supporting multiple python versions
Hi,
Supporting multiple python versions is far from easy, as you might not be aware of...
Python, when it encounters a .py file via "import", will try to compile this file into a .pyc file residing in the same directory. If it encounters an incompatible .pyc file, it will try to delete and replace it. And of course different python versions may require different .pyc files.
Most linux distributions try to precompile all .py files, to avoid .pyc files being created by random processes when ran by root (users won't have write permissions there).
However, if you have two python versions, that still might happen.
Debian therefore has moved the .pyc files to the /var/lib/python-support directories, and a helper application that will precompile them for all installed python versions (along with building an appropriate search path)
However this means that many applications that so far only needed access to usr_t will now need (read) access to var_lib_python_t.
Since these files are supposedly not secret, I'd be fine with allowing any application access to them. They need a python interpreter running to use them anyway, and python will want to read the .py file (which is symlinked to the original one in /usr).
So what is the proper way of giving access to this type to "just about every" domain? Or should we add an interface and try to find out which domains need it?
I mean - bind doesn't need it. Samba shouldn't (except when someone writes a password changing backend in python maybe). Apache probably when mod_python is used...
best regards,
Erich Schubert
Signature · 11 lines
erich@(vitavonni.de|debian.org) -- GPG Key ID: 4B3A135C (o_
It's not denial. I'm just selective about the reality I accept. //\
Mathematik ist die Kunst, verschiedene Dinge mit demselben V_/_
Namen zu belegen. --- Henri Poincaré
--
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.Quoted 5 lines · Erich Schubert
Most linux distributions try to precompile all .py files, to avoid .pyc files being created by random processes when ran by root (users won't have write permissions there).
However, if you have two python versions, that still might happen.
Quoted 7 lines
Debian therefore has moved the .pyc files to the
/var/lib/python-supportdirectories, and a helper application that will precompile them for all installed python versions (along with building an appropriate search path)However this means that many applications that so far only needed access to
usr_twill now need (read) access tovar_lib_python_t.
One option is to relabel /var/lib/python-support as usr_t. It's a little ugly, but I think that naming types after directories was a mistake anyway and this is just the symptom.
Another option is to have a new type python_compiled_t that can be used for all distributions.
Signature · 9 lines
http://etbe.blogspot.com/ My Blog http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/sponsorship.html Sponsoring Free Software development -- 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.
Quoted 7 lines · Russell Coker
Quoted 2 lines · Erich Schubert
However this means that many applications that so far only needed access to
usr_twill now need (read) access tovar_lib_python_t.One option is to relabel
/var/lib/python-supportasusr_t. It's a little ugly, but I think that naming types after directories was a mistake anyway and this is just the symptom.
I agree on types like python_var_lib_t, but not something like usr_t where the contents are so varied.
Quoted 2 lines
Another option is to have a new type
python_compiled_tthat can be used for all distributions.
Signature · 9 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150 -- 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.
Hello Christopher,
Attached is my current version of adding python multiversion precompilation support. It supports the multiversion case okay, but I fear it doesn't support private modules yet.
Some applications, lets say mailman, won't be run with different python versions. They'll always use the default python version (in constrast to python libraries). These won't have their .pyc files
in /var/lib/python-support apparently...
But that would mean python-support also needs to be able to write /usr (python-support is called during package installation or python upgrade; lets say Debian switches /usr/bin/python from 2.4 to 2.5, then upgrade-python-modules will recompile all private python modules). Should we
- allow python-support to write usr_t (it's only run by dpkg_t or sysadm_t, both of which can write usr_t anyway; no regular user should be allowed into pythoncompile_t)
- make a file context like ^/usr/(.*)\.pyc$ -f as python_compiled_t and add a filetrans rule usr_t python_compiled_t for pythoncompile_t?
best regards,
Erich Schubert
Signature · 5 lines
erich@(vitavonni.de|debian.org) -- GPG Key ID: 4B3A135C (o_
There is no branch of mathematics, however abstract, which may not //\
some day be applied to phenomena of the real world. --- Lobatchevsky V_/_
Für jedes Problem gibt es eine Lösung,
die einfach, klar und falsch ist.modules/system/pythonsupport.fc +2 -0
@@ -0,0 +1,2 @@ +/usr/sbin/update-python-modules -- gen_context(system_u:object_r:pythoncompile_exec_t,s0) +/var/lib/python-support(/.*)? gen_context(system_u:object_r:python_compiled_t,s0)
modules/system/userdomain.if +4 -0
@@ -835,6 +835,10 @@ ') optional_policy(` + pythonsupport_compiled_read($1_t) + ') + + optional_policy(` quota_dontaudit_getattr_db($1_t) ')
modules/system/pythonsupport.te +44 -0
44 lines not on this page · raw message
modules/system/selinuxutil.te +4 -0
@@ -624,6 +624,10 @@ userdom_read_generic_user_home_content_files(semanage_t) ') +optional_policy(` + pythonsupport_compiled_read(semanage_t) +') + ######################################## # # Setfiles local policy
modules/system/pythonsupport.if +55 -0
55 lines not on this page · raw message
modules/admin/apt.te +4 -0
@@ -125,6 +125,10 @@ #') optional_policy(` + pythonsupport_domtrans(apt_t) +') + +optional_policy(` # dpkg interaction dpkg_read_db(apt_t) dpkg_domtrans(apt_t)
Quoted 6 lines · Christopher J. PeBenito
Quoted 3 lines
One option is to relabel
/var/lib/python-supportasusr_t. It's a little ugly, but I think that naming types after directories was a mistake anyway and this is just the symptom.I agree on types like
python_var_lib_t, but not something likeusr_twhere the contents are so varied.
I think that Erich is on the right track here. python_var_lib_t is not a good name as Fedora will use it for files under /usr.
Signature · 10 lines
http://etbe.blogspot.com/ My Blog http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/sponsorship.html Sponsoring Free Software development -- 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.