All of lore.kernel.org
 help / color / mirror / Atom feed
* is the string "<<none>>" in a header anywhere?
@ 2007-11-12 11:06 Jim Meyering
  2007-11-13 14:58 ` Stephen Smalley
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Meyering @ 2007-11-12 11:06 UTC (permalink / raw)
  To: SE Linux

Coreutils' install.c currently compares a context against the
magic string, "<<none>>":

  /* If there's an error determining the context, or it has none,
     return to allow default context */
  if ((matchpathcon (file, st.st_mode, &scontext) != 0) ||
      STREQ (scontext, "<<none>>"))
    {
      if (scontext != NULL)
        freecon (scontext);
      return;
    }

BTW, matchpathcon(8) does, too.
Is there a better way to test for that condition?
It'd be nice if that string were available via a libselinux header,
but I don't see it on rawhide:

    $ grep none $(rpm -ql libselinux-devel|grep -F .h)
    [Exit 1]

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: is the string "<<none>>" in a header anywhere?
  2007-11-12 11:06 is the string "<<none>>" in a header anywhere? Jim Meyering
@ 2007-11-13 14:58 ` Stephen Smalley
  2007-11-13 15:23   ` Jim Meyering
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2007-11-13 14:58 UTC (permalink / raw)
  To: Jim Meyering; +Cc: SE Linux

On Mon, 2007-11-12 at 12:06 +0100, Jim Meyering wrote:
> Coreutils' install.c currently compares a context against the
> magic string, "<<none>>":
> 
>   /* If there's an error determining the context, or it has none,
>      return to allow default context */
>   if ((matchpathcon (file, st.st_mode, &scontext) != 0) ||
>       STREQ (scontext, "<<none>>"))
>     {
>       if (scontext != NULL)
>         freecon (scontext);
>       return;
>     }
> 
> BTW, matchpathcon(8) does, too.
> Is there a better way to test for that condition?
> It'd be nice if that string were available via a libselinux header,
> but I don't see it on rawhide:
> 
>     $ grep none $(rpm -ql libselinux-devel|grep -F .h)
>     [Exit 1]
> 

matchpathcon(3) should never return "<<none>>" at all to the caller.
If it hits a <<none>> in the spec, it returns -1 with errno ENOENT.

-- 
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: is the string "<<none>>" in a header anywhere?
  2007-11-13 14:58 ` Stephen Smalley
@ 2007-11-13 15:23   ` Jim Meyering
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Meyering @ 2007-11-13 15:23 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: SE Linux

Stephen Smalley <sds@tycho.nsa.gov> wrote:
> On Mon, 2007-11-12 at 12:06 +0100, Jim Meyering wrote:
>> Coreutils' install.c currently compares a context against the
>> magic string, "<<none>>":
>>
>>   /* If there's an error determining the context, or it has none,
>>      return to allow default context */
>>   if ((matchpathcon (file, st.st_mode, &scontext) != 0) ||
>>       STREQ (scontext, "<<none>>"))
>>     {
>>       if (scontext != NULL)
>>         freecon (scontext);
>>       return;
>>     }
>>
>> BTW, matchpathcon(8) does, too.
>> Is there a better way to test for that condition?
>> It'd be nice if that string were available via a libselinux header,
>> but I don't see it on rawhide:
>>
>>     $ grep none $(rpm -ql libselinux-devel|grep -F .h)
>>     [Exit 1]
>>
>
> matchpathcon(3) should never return "<<none>>" at all to the caller.
> If it hits a <<none>> in the spec, it returns -1 with errno ENOENT.

I'm sure that's the way it's supposed to work (now),
but I debugged a failure (over a year ago) in which matchpathcon
returned 0 with scontext equal to that string.
libselinux logs suggest that this was fixed in early 2005:

  1.20 2005-01-04
          * Changed matchpathcon to return -1 with errno ENOENT for
            <<none>> entries, and also for an empty file_contexts configuration.

so maybe we'll have to wait a while longer for all legacy implementations
to disappear.

Since this is solely to work around old, buggy behavior,
there's no reason to provide anything more aesthetic.

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-13 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-12 11:06 is the string "<<none>>" in a header anywhere? Jim Meyering
2007-11-13 14:58 ` Stephen Smalley
2007-11-13 15:23   ` Jim Meyering

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.