After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 529694 - SELinux context setting support
SELinux context setting support
Status: RESOLVED OBSOLETE
Product: nautilus
Classification: Core
Component: File Properties Dialog
2.23.x
Other All
: Normal enhancement
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-04-24 10:50 UTC by Tomas Bzatek
Modified: 2021-06-18 15:29 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
nautilus-2.22.2-selinux.diff (50.17 KB, patch)
2008-04-24 10:52 UTC, Tomas Bzatek
needs-work Details | Review
glib-selinux-set-support.diff (3.07 KB, patch)
2008-04-24 10:53 UTC, Tomas Bzatek
committed Details | Review
latest version of the downstream patch (52.82 KB, patch)
2012-08-16 14:10 UTC, Cosimo Cecchi
needs-work Details | Review

Description Tomas Bzatek 2008-04-24 10:50:37 UTC
This is a modified patch adding ability to change SELinux context within Nautilus File Properties dialog. The original patch was written by James Antill, previous review request is available at https://bugzilla.redhat.com/show_bug.cgi?id=204030.

By default, combobox with list of available contexts is shown. In Advanced Permissions mode, combo is replaced by entry for direct context string input, implementing context autocomplete.
Both combo and entry are disabled when selinux is disabled in the system and controls are hidden when Nautilus is built without selinux support.

Please review the patch and let me know your concerns. It would be great to have this feature in trunk before final 2.24 release.

Some screenshots:
  http://fedorapeople.org/~tbzatek/Screenshot-selinux.png
  http://fedorapeople.org/~tbzatek/Screenshot-selinux2.png
Comment 1 Tomas Bzatek 2008-04-24 10:52:29 UTC
Created attachment 109812 [details] [review]
nautilus-2.22.2-selinux.diff
Comment 2 Tomas Bzatek 2008-04-24 10:53:45 UTC
Created attachment 109813 [details] [review]
glib-selinux-set-support.diff

Required patch to glib/gio adding 'selinux::context' attribute set support
Comment 3 Matthias Clasen 2008-07-21 18:16:50 UTC
Grr, not fun to hide glib patches in nautilus bugs.

Please commit the glib patch.
Comment 4 Matthias Clasen 2008-07-23 04:11:31 UTC
        * gfileinfo.c: Support setting selinux attributes.
        Patch by Tomas Bzatek
Comment 5 Christian Neumair 2008-07-23 10:02:25 UTC
Confirming.

IIRC Thomas and I already discussed on IRC that the Nautilus part can not go in, due to the display name hack:

selinux__hack_conv_type(scan->data);

SELinux should provide means of generating a user-visible name for an internal context name, and should do all the translation handling.
Comment 6 Dave Malcolm 2008-11-26 17:57:31 UTC
As I understand it, this is setting the SELinux context of the file in the extended attrs, but not adjusting the policy, so that next time a relabel happens, the xattr will get overwritten back.

Would it make more sense to show both:
(i) the current xattr context of the file 
(ii) the context the file should have according to policy
and highlight when they are different (matchpathcon, which it looks like the code is reading, but can't edit yet)

Maybe only show (ii) when they're different?

Should the UI allow the user to adjust the policy (e.g. to set policy so that /srv/www has httpd context)?  Otherwise you're going to be constantly having to relabel by hand after an automatic relabel happens.
Comment 7 Cosimo Cecchi 2010-10-14 20:09:15 UTC
(In reply to comment #5)

> IIRC Thomas and I already discussed on IRC that the Nautilus part can not go
> in, due to the display name hack:
> 
> selinux__hack_conv_type(scan->data);

Setting patch as 'needs-work' for this reason, though I'm not sure this patch still applies cleanly to master.

Tomas, will you do further work to upstream this beast? :)
Comment 8 Tomas Bzatek 2010-10-15 12:43:29 UTC
(In reply to comment #6)
> As I understand it, this is setting the SELinux context of the file in the
> extended attrs, but not adjusting the policy, so that next time a relabel
> happens, the xattr will get overwritten back.
Yes, that's right. Not even sure how many users are actually using Nautilus to change SELinux context. 

I guess modifying the policy would require root permissions, that means involving PolicyKit, with preferred way through GIO (perhaps with help of gvfs). We should teach the libs beneath to use PolicyKit first.

> Would it make more sense to show both:
> (i) the current xattr context of the file 
> (ii) the context the file should have according to policy
> and highlight when they are different (matchpathcon, which it looks like the
> code is reading, but can't edit yet)
> 
> Maybe only show (ii) when they're different?
> 
> Should the UI allow the user to adjust the policy (e.g. to set policy so that
> /srv/www has httpd context)?  Otherwise you're going to be constantly having to
> relabel by hand after an automatic relabel happens.
It makes sense but I would do this as a step two, because of the concerns above. Perhaps we can show a warning to let user know what he's doing.


(In reply to comment #7)
> Setting patch as 'needs-work' for this reason, though I'm not sure this patch
> still applies cleanly to master.
With minor modifications, it still does. We continue to maintain it in Fedora git.
 
> Tomas, will you do further work to upstream this beast? :)
I plan to but not in near timeframe, my TODO list is way too long at the moment.
Comment 9 William Jon McCann 2012-08-16 13:36:01 UTC
Modifying the policy really looks like a sysadmin or OS vendor type of operation. Do we really think that Nautilus is the right place for this?
Comment 10 dwalsh 2012-08-16 14:02:37 UTC
An oldy but goody.  

The only thing nautilus should do would be to have the ability to alter the label (context) on a file.  Probably just needs restrorecon capability, But modifying a piece of content to be https_sys_content_t would be as advanced as you would need.  I don't see a need to add any priv ops to nautlus as far as modifying policy.
Comment 11 Cosimo Cecchi 2012-08-16 14:10:29 UTC
Created attachment 221387 [details] [review]
latest version of the downstream patch

FWIW, here's the latest version of the downstream patch (I don't think it applies to nautilus git anymore).
Comment 12 Cosimo Cecchi 2012-08-16 14:52:03 UTC
Review of attachment 221387 [details] [review]:

[ Marking needs-work as it doesn't apply and is probably not what we really want ]
Comment 13 Fiable.biz 2014-01-28 09:44:58 UTC
You said "need-work", but the tag is "need-info"...
This would be a real improvement. At list, Nautilus should be able to display the security context.
Comment 14 André Klapper 2014-08-25 18:28:26 UTC
No, the patch is needs-work. The bug itself is not NEEDINFO.
Comment 15 André Klapper 2021-06-18 15:29:39 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version of Files (nautilus), then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/nautilus/-/issues/

Thank you for your understanding and your help.