selinux-refpolicy.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why is /usr/include matched with /usr/inclu.e?
@ 2019-08-21 19:57 Nicolas Iooss
  2019-08-21 20:02 ` Dominick Grift
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Iooss @ 2019-08-21 19:57 UTC (permalink / raw)
  To: selinux-refpolicy

Hi all,

While checking the patterns in refpolicy, I stumbled upon the
following line in
https://github.com/SELinuxProject/refpolicy/blob/RELEASE_2_20190609/policy/modules/kernel/files.fc#L200

/usr/inclu.e(/.*)? gen_context(system_u:object_r:usr_t,s0)

This pattern matches /usr/include and its content, but why is a dot
used? Which other directories can it match?

The issue there is that a dot can match a slash, so the pattern also
matches /usr/inclu/e/, which seems strange. This pattern has been
introduced in the very early days of refpolicy's git repository,
according to https://github.com/SELinuxProject/refpolicy/commit/f8ec0ad43b54437e2d9f0e48a773a64dbd9e543c#diff-e333cb52d2139f7a71f0dfbd32c06f70R117.
Does anyone remember why the pattern for /usr/include is so special?

Thanks,
Nicolas


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

* Re: Why is /usr/include matched with /usr/inclu.e?
  2019-08-21 19:57 Why is /usr/include matched with /usr/inclu.e? Nicolas Iooss
@ 2019-08-21 20:02 ` Dominick Grift
  2019-08-21 20:29   ` Nicolas Iooss
  0 siblings, 1 reply; 4+ messages in thread
From: Dominick Grift @ 2019-08-21 20:02 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: selinux-refpolicy

[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]

On Wed, Aug 21, 2019 at 09:57:14PM +0200, Nicolas Iooss wrote:
> Hi all,
> 
> While checking the patterns in refpolicy, I stumbled upon the
> following line in
> https://github.com/SELinuxProject/refpolicy/blob/RELEASE_2_20190609/policy/modules/kernel/files.fc#L200
> 
> /usr/inclu.e(/.*)? gen_context(system_u:object_r:usr_t,s0)

Probably to work around an m4-ism. There seems to be an m4 "include" built-in.

> 
> This pattern matches /usr/include and its content, but why is a dot
> used? Which other directories can it match?
> 
> The issue there is that a dot can match a slash, so the pattern also
> matches /usr/inclu/e/, which seems strange. This pattern has been
> introduced in the very early days of refpolicy's git repository,
> according to https://github.com/SELinuxProject/refpolicy/commit/f8ec0ad43b54437e2d9f0e48a773a64dbd9e543c#diff-e333cb52d2139f7a71f0dfbd32c06f70R117.
> Does anyone remember why the pattern for /usr/include is so special?
> 
> Thanks,
> Nicolas
> 

-- 
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: Why is /usr/include matched with /usr/inclu.e?
  2019-08-21 20:02 ` Dominick Grift
@ 2019-08-21 20:29   ` Nicolas Iooss
  2019-08-27  4:06     ` Chris PeBenito
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Iooss @ 2019-08-21 20:29 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: selinux-refpolicy

On Wed, Aug 21, 2019 at 10:02 PM Dominick Grift <dac.override@gmail.com> wrote:
>
> On Wed, Aug 21, 2019 at 09:57:14PM +0200, Nicolas Iooss wrote:
> > Hi all,
> >
> > While checking the patterns in refpolicy, I stumbled upon the
> > following line in
> > https://github.com/SELinuxProject/refpolicy/blob/RELEASE_2_20190609/policy/modules/kernel/files.fc#L200
> >
> > /usr/inclu.e(/.*)? gen_context(system_u:object_r:usr_t,s0)
>
> Probably to work around an m4-ism. There seems to be an m4 "include" built-in.

This seems to be a good explanation. The policy also uses workarounds
for "index" built-in, with:

/etc/amanda/.*/index`'(/.*)?
/var/lib/apt-xapian-inde(x)(/.*)?

In order not to introduce parentheses (which might change some
ordering in the way the paths are matched with the patterns), I am
thinking of replacing the pattern of /usr/include with:

/usr/includ[e](/.*)? gen_context(system_u:object_r:usr_t,s0)

... with a comment about working around a m4 issue.

Thanks,
Nicolas

> >
> > This pattern matches /usr/include and its content, but why is a dot
> > used? Which other directories can it match?
> >
> > The issue there is that a dot can match a slash, so the pattern also
> > matches /usr/inclu/e/, which seems strange. This pattern has been
> > introduced in the very early days of refpolicy's git repository,
> > according to https://github.com/SELinuxProject/refpolicy/commit/f8ec0ad43b54437e2d9f0e48a773a64dbd9e543c#diff-e333cb52d2139f7a71f0dfbd32c06f70R117.
> > Does anyone remember why the pattern for /usr/include is so special?
> >
> > Thanks,
> > Nicolas
> >
>
> --
> Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
> https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
> Dominick Grift


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

* Re: Why is /usr/include matched with /usr/inclu.e?
  2019-08-21 20:29   ` Nicolas Iooss
@ 2019-08-27  4:06     ` Chris PeBenito
  0 siblings, 0 replies; 4+ messages in thread
From: Chris PeBenito @ 2019-08-27  4:06 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: selinux-refpolicy

On 8/21/19 4:29 PM, Nicolas Iooss wrote:
> On Wed, Aug 21, 2019 at 10:02 PM Dominick Grift <dac.override@gmail.com> wrote:
>>
>> On Wed, Aug 21, 2019 at 09:57:14PM +0200, Nicolas Iooss wrote:
>>> Hi all,
>>>
>>> While checking the patterns in refpolicy, I stumbled upon the
>>> following line in
>>> https://github.com/SELinuxProject/refpolicy/blob/RELEASE_2_20190609/policy/modules/kernel/files.fc#L200
>>>
>>> /usr/inclu.e(/.*)? gen_context(system_u:object_r:usr_t,s0)
>>
>> Probably to work around an m4-ism. There seems to be an m4 "include" built-in.
> 
> This seems to be a good explanation. The policy also uses workarounds
> for "index" built-in, with:
> 
> /etc/amanda/.*/index`'(/.*)?
> /var/lib/apt-xapian-inde(x)(/.*)?
> 
> In order not to introduce parentheses (which might change some
> ordering in the way the paths are matched with the patterns), I am
> thinking of replacing the pattern of /usr/include with:
> 
> /usr/includ[e](/.*)? gen_context(system_u:object_r:usr_t,s0)
> 
> ... with a comment about working around a m4 issue.

My preference would be an empty m4 string (`') over some regex trick, if 
possible, so the sorting isn't upset.

-- 
Chris PeBenito

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

end of thread, other threads:[~2019-08-27  4:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 19:57 Why is /usr/include matched with /usr/inclu.e? Nicolas Iooss
2019-08-21 20:02 ` Dominick Grift
2019-08-21 20:29   ` Nicolas Iooss
2019-08-27  4:06     ` Chris PeBenito

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).