Gentoo Archives: gentoo-hardened

From: Marc Schiffbauer <mschiff@g.o>
To: gentoo-hardened@l.g.o
Subject: Re: [gentoo-hardened] RFC: Improving support for (re)labeling packages when SELinux dependency is added
Date: Mon, 25 Aug 2014 22:57:23
Message-Id: 20140825225718.GB6389@schiffbauer.net
In Reply to: [gentoo-hardened] RFC: Improving support for (re)labeling packages when SELinux dependency is added by Sven Vermeulen
1 * Sven Vermeulen schrieb am 21.08.14 um 20:13 Uhr:
2 >During a discussion about dependencies and SELinux labeling, I noticed that
3 >we might want to improve how we currently handle pure policy-related
4 >dependencies.
5 >
6 >What we want to get at, is that the installation of a SELinux policy package
7 >results in the (re)labeling of the files of the packages it holds policy
8 >data (well, file contexts to be exact) of.
9 >
10 >What we currently do is a subset of that: when a package is installed, its
11 >associated SELinux policy package is merged before the package itself, so
12 >that Portage can correctly label the files of the package. This means both a
13 >DEPEND (has to be installed before the package) and RDEPEND (because of
14 >binary packages) is used.
15 >
16 >This doesn't implement what we really need fully though: updates on the
17 >SELinux policy do not reflect upon the labels of the packages if they are
18 >already installed. For instance, if we would change the label of the
19 >"emerge" command in the policy, then this label is not applied unless the
20 >administrator rebuilds Portage, relabels Portage or relabels the file
21 >system.
22 >
23 >This also means that we currently abuse the Portage dependency system to
24 >accomplish a reasonable implementation. So... why not see how we can fix
25 >things?
26 >
27 >It would be nice if we could only mark the dependencies are RDEPEND, and in
28 >the policy installation phase (its pkg_postinst() method) find out what
29 >package(s) are RDEPEND'ing on this package, and then relabel the files of
30 >those packages.
31 >
32 >Something like so (which we can do in the selinux-policy-2.eclass):
33 >
34 >pkg_postinst() {
35 > # Find all packages with this package in their RDEPEND
36 > PKGSET=$(equery -q depends ${CATEGORY}/${PN})
37 > for PKG in ${PKGSET};
38 > do
39 > rlpkg ${PKG};
40 > done
41 >}
42 >
43 >This simple implementation would allow us to only use RDEPEND, and would
44 >also relabel the files after a policy update (which we don't do now) and
45 >also doesn't require any changes to Portage or EAPI or whatever and does not
46 >trigger any unnecessary rebuilds...
47 >
48 >... but (there is always a but) uses a currently optional tool (equery)
49 >which is probably also quite slow for some users. Still, I do like this
50 >idea as it is very simple. And I like simple. Simple is nice.
51 >
52 >Anyone know of a way to do something similar without depending on equery (it
53 >doesn't seem like portageq has the necessary features for this)?
54 >
55 >Anyone know of a better approach?
56
57 It may be more likely that user have app-portage/portage-utils
58 installed and the package is much smaller (6.4M vs 130k). Apart from
59 that, qdepends is *much* faster:
60
61 pkg_postinst() {
62 # Find all packages with this package in their RDEPEND
63 PKGSET=$(qdepends -rCQ ${CATEGORY}/${PN})
64 for PKG in ${PKGSET};
65 do
66 rlpkg ${PKG};
67 done
68 }
69
70 anyway, a DEPEND on app-portage/portage-utils should not hurt too
71 much (IMO).
72
73 -Marc
74
75
76 --
77 0x35A64134 - 8AAC 5F46 83B4 DB70 8317
78 3723 296C 6CCA 35A6 4134

Attachments

File name MIME type
signature.asc application/pgp-signature