All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: CoreutilsBugs <bug-coreutils@gnu.org>,
	"Ondřej Vašík" <ovasik@redhat.com>,
	"SE Linux" <selinux@tycho.nsa.gov>,
	yaneti@declera.com
Subject: Re: [PATCH]: chcon: no longer abort on SELinux disabled kernel
Date: Wed, 07 Oct 2009 15:34:58 +0200	[thread overview]
Message-ID: <87vdirxr7h.fsf@meyering.net> (raw)
In-Reply-To: <1254920045.2251.202.camel@moss-pluto.epoch.ncsc.mil> (Stephen Smalley's message of "Wed, 07 Oct 2009 08:54:05 -0400")

Stephen Smalley wrote:

> On Wed, 2009-10-07 at 14:48 +0200, Jim Meyering wrote:
>> Stephen Smalley wrote:
>> ...
>> > FWIW, there is a subtle difference here:
>> > - chcon can in fact work on a SELinux-disabled kernel, as you can still
>> > set the security.* extended attributes as long as the filesystem
>> > provides handlers for the security.* namespace.
>> > - runcon cannot work without a SELinux-enabled kernel, as only a
>> > SELinux-enabled kernel allows you to set the security context of a
>> > running process.
>> >
>> > So by preventing chcon from running in the SELinux-disabled case, you
>> > are imposing a restriction above and beyond what is strictly required.
>> > The user can of course still use setfattr -n security.selinux -v
>> > <context> <path> to set a SELinux security context on a file when
>> > SELinux is disabled, or can run the setfiles program to set SELinux
>> > security contexts on an entire file tree even when SELinux is disabled.
>> ...
>> >> diff --git a/src/chcon.c b/src/chcon.c
>> >> index fbfdb4d..c0da694 100644
>> >> --- a/src/chcon.c
>> >> +++ b/src/chcon.c
>> >> @@ -519,6 +519,10 @@ main (int argc, char **argv)
>> >>        usage (EXIT_FAILURE);
>> >>      }
>> >>
>> >> +  if (is_selinux_enabled () != 1)
>> >> +    error (EXIT_FAILURE, 0,
>> >> +           _("%s may be used only on a SELinux kernel"), program_name);
>> >> +
>>
>> Thanks for the tip.
>> I'll revert that part of the patch.
>>
>> I'll address the original problem by adding
>> getfilecon and lgetfilecon wrappers that
>> map those unusual cases (10,"unlabeled" and 0,NULL)
>> to a return value of -1 with errno == ENOTSUPP.
>
> I'd suggest ENODATA instead - that means that the filesystem supports
> attributes but there was no value set for the particular file.

ENODATA makes sense for the 10,"unlabeled" case.
I viewed "using a library so old that its getfilecon
can return 0 and set context to NULL" as lacking support (ENOTSUPP).
But I'll do whatever is more consistent with the rest of SELinux.

Here's the first part: revert the above:

  reply	other threads:[~2009-10-07 13:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1254727932.3849.8.camel@dhcp-lab-219.englab.brq.redhat.com>
2009-10-05 18:44 ` [PATCH]: chcon: no longer abort on SELinux disabled kernel Jim Meyering
2009-10-05 19:17   ` Stephen Smalley
2009-10-05 20:02     ` Jim Meyering
2009-10-06  8:14       ` Jim Meyering
2009-10-07 12:37         ` Stephen Smalley
2009-10-07 12:48           ` Jim Meyering
2009-10-07 12:54             ` Stephen Smalley
2009-10-07 13:34               ` Jim Meyering [this message]
2009-10-07 15:30                 ` Stephen Smalley
2009-10-10  9:59                   ` Jim Meyering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vdirxr7h.fsf@meyering.net \
    --to=jim@meyering.net \
    --cc=bug-coreutils@gnu.org \
    --cc=ovasik@redhat.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=yaneti@declera.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.