Skip to contentSkip to conversation

Making Fedora a contributer friendly environment

DISCUSSION Karl MacMillan 2 participants 3 messages May 10, 2007 5 messages not in the archive SELinux security module

lore
Share & tools
lore
#4 lore raw
In reply to a message not in the archive

[CC'd the selinux development list so that the developers are aware of these issues]

Quoted 10 lines · Till Maas
Quoted 4 lines · Karl MacMillan

When selinux is turned on again a full relabel of the filesystem is done to correct these problems. If the custom file context wasn't added to the database of file contexts (via a module or semanage) the file is set to the default label.

So will chcon in a scriptlet work, when an rpm is installed while selinux is not active?

Unfortunately it won't - does semanage / semodule work in this instance (it probably should so that users can turn selinux back on after disabling and doing package management).

Quoted 16 lines
Quoted 3 lines

Not sure what you mean - you should be able to run semanage in a post. Perhaps you should also need to do chcon (as opposed to restorecon) because the command may not have run before the file was created.

When I tested semanage, the problem occured, how to update the labels with semanage. E.g. when the regex is changed that desribes, which files should be labeled in a certain way. And when one wants to remove the old labels when uninstalling the package. E.g

version 1 of the package:

%post
semanage add RULE1
%postun
semanage remove RULE1

Quoted 6 lines

As far as I understand rpm, when updating the release of version 1, first semanage add RULE1 from release two runs from %post and then semanage remove RULE1 from release one. This effectivly removes the rule from the /etc/selinux, because identical rules seem not be added more than once to /etc/selinux. When I restrict the %postun only to complete removals of the package,

Which seems like the right answer.

Quoted 7 lines

than when one changes the RULES, e.g. in a version 2:

%post
semanage add RULE2
%postun
semanage remove RULE2

Quoted 5 lines

then RULE1 will not be removed (it is not the final remove). Then every release has to include "semanage remove RULE1" in "%post" maybe forever. I hope you understand the problem I try to describe, because I did not really use the correct selinux-terms.

Seems like there are two cases:

1) The context changes but the file spec stays the same - blindly adding should always work here (it will overwrite the old file context).

2) The file spec changes (doesn't matter if the context changes) - you will have to carry around the removal in the post forever.

Quoted 4 lines

I would be happy, if I am wrong with this. But if this problem is not solvable with semanage, imho semanage is not a good way to add selinux support to a package.

Maybe - we can make changes as necessary to make it usable.

Karl

--
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.

#7 lore raw
In reply to a message not in the archive
Quoted 3 lines · Paul Howarth
Quoted 2 lines · Till Maas

On Do Mai 10 2007, Karl MacMillan wrote:

[...]

Quoted 5 lines
Quoted 4 lines

I would be happy, if I am wrong with this. But if this problem is not solvable with semanage, imho semanage is not a good way to add selinux support to a package.

Quoted 7 lines

I agree entirely, and would advocate using a policy module instead of semanage, even if all the module contains are file contexts and no rules (you may need a dummy rule that duplicates an existing one to get the module to build and install properly though). Policy modules have versioning built in and so upgrades work as expected. It's just a lot more work to package them.

I'm not convinced of this yet, but I can be. The modules seem like overkill in many ways, though we could make it possible to make a file context only module. That would ease some of the pain.

Quoted 3 lines

For simple context fixes, getting them into the main selinux-policy package is almost certainly the best and least hassle method though.

Agreed.

Karl

--
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.

#5 lore raw
In reply to Karl MacMillan
Quoted 11 lines · Karl MacMillan

[CC'd the selinux development list so that the developers are aware of these issues]

Quoted 7 lines · Till Maas
Quoted 4 lines · Karl MacMillan

When selinux is turned on again a full relabel of the filesystem is done to correct these problems. If the custom file context wasn't added to the database of file contexts (via a module or semanage) the file is set to the default label.

Quoted 7 lines
Quoted 3 lines

So will chcon in a scriptlet work, when an rpm is installed while selinux is not active?

Unfortunately it won't - does semanage / semodule work in this instance (it probably should so that users can turn selinux back on after disabling and doing package management).

semodule works with selinux disabled (it won't load the resulting policy naturally, but it manipulates the policy store and regenerates the policy files appropriately, so they would be used when selinux is next enabled, and a relabel would happen at that time). semanage has some dependencies on libselinux (e.g. is_selinux_mls_enabled, security_check_context) that should be converted to using libsemanage or libsepol interfaces, and then there is the separate issue of the context translation support.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
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.