Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 371831 - python_merge_intermediate_installation_image fails on SELinux
Summary: python_merge_intermediate_installation_image fails on SELinux
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: SE Linux Bugs
URL:
Whiteboard: python-overlay
Keywords: InOverlay, InVCS
Depends on:
Blocks:
 
Reported: 2011-06-15 19:25 UTC by Sven Vermeulen
Modified: 2011-11-15 10:55 UTC (History)
1 user (show)

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


Attachments
Suggested update to python.eclass (python.eclass.patch,1001 bytes, patch)
2011-06-21 19:53 UTC, Sven Vermeulen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Vermeulen 2011-06-15 19:25:08 UTC
With SELinux enabled, packages that call python.eclass' python_merge_intermediate_installation_image will fail to install. The reason is that this method calls "cp --preserve=all" (which includes extended attributes) which will return non-0 because SELinux does not allow the portage_sandbox_t domain to "setfscreate".

Allowing this in the policy might make it more troublesome, as this would result in the package' files to be installed on the file system with label portage_tmp_t. Generally, that's okay (portage will relabel afterwards to the correct label) but if the package itself offers the relabelling binaries, it might brake Portage / the system altogether.

The latter still needs to be verified (one example of package that fails is policycoreutils which gentoo hardened manages itself ... just for SELinux). 

Reproducible: Always
Comment 1 Sven Vermeulen 2011-06-19 18:26:48 UTC
A couple of alternatives to resolve this...

1/ Give portage_sandbox_t the setfscreate privilege. It doesn't need it per se (apart from making "cp --preserve=all" happy) but doesn't seem to harm the system (files installed do not suddenly get the portage_tmp_t label, so also setfiles isn't relabeled differently when the privilege is given, because there is no relabelto privilege)

2/ Use "cp --preserve=all --no-preserve=context" in said python.eclass function. The --no-preserve=context does not fail systems that are not SELinux aware, and it should cause SELinux-aware systems to continue gracefully. Testing this out right now.
Comment 2 Sven Vermeulen 2011-06-19 19:56:50 UTC
The --no-preserve=context works. This would be my personal preference too. 

Arfrever, as you're apparently the developer that manages the python.eclass, what is your take on this? Could you validate if using "cp -fr --preserve=all --no-preserve=context" on line 1453 in python.eclass (instead of "cp -fr --preserve=all") is okay for you? I'd like to consider this as the preferential solution to this issue.

Why? Well, because we do not want to preserve the contexts during the installation (merging) of a package from /var/tmp/portage/whatever to /. The contexts of the files will be wrong (all labeled portage_tmp_t) anyway. By copying files without preserving the context, the files inherit their parent's context (be it lib_t or bin_t) which usually is sufficient. After merging, Portage labels the files correctly anyway (from within the portage_t domain) using the setfiles command.

I've also checked if we can "duplicate" the file context rules for / towards /var/tmp/portage/<whatever>/work but that tends to make things a *lot* more complicated.
Comment 3 Sven Vermeulen 2011-06-21 19:53:56 UTC
Created attachment 277711 [details, diff]
Suggested update to python.eclass

This patch shows the suggested, small update to the eclass. It uses "cp -fr --preserve=all --no-preserve=context" to make sure that the SELinux context isn't part of the copying.
Comment 4 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-28 16:31:26 UTC
Fixed in python overlay.
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2011-11-15 10:55:37 UTC
Is in main portage tree (since october 7th).