All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Ondrej Mosnacek <omosnace@redhat.com>
To: Vit Mojzis <vmojzis@redhat.com>
Cc: SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH v2] python/sepolgen: allow any policy statement in if(n)def
Date: Wed, 27 Jan 2021 17:18:06 +0100	[thread overview]
Message-ID: <CAFqZXNtq3BenouP21PHHRv20pUPtNK90WU2hGqZMUwDSxnD2EA@mail.gmail.com> (raw)
In-Reply-To: <CAFqZXNusUEjEqg1a80vPFbgPZLdcseC2ot6co8F4CEjb-a+vjQ@mail.gmail.com>

On Fri, Jan 22, 2021 at 5:32 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> On Fri, Jan 22, 2021 at 4:29 PM Vit Mojzis <vmojzis@redhat.com> wrote:
> > "ifdef/ifndef" statements can be used to conditionally define
> > an interface, but this syntax is not recognised by sepolgen-ifgen.
> > Fix sepolgen-ifgen to allow any policy statement inside an
> > "fidef/ifndef" statement.
> >
> > Fixes:
> >         $ cat <<EOF > i.if
> > ifndef(`apache_manage_pid_files',`
> >         interface(`apache_manage_pid_files',`
> >                 manage_files_pattern($1, httpd_var_run_t, httpd_var_run_t)
> >         ')
> > ')
> >
> >         #sepolgen-ifgen --interface=i.if
> >         i.if: Syntax error on line 2 interface [type=INTERFACE]
> >         i.if: Syntax error on line 4 ' [type=SQUOTE]
> >
> > Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
> > ---
> > Thanks. Fixed. And I replaced "statement" with "statements" to allow
> > multiple statements (as was possible with interface_stmts).
> > I'm not all that sure about the last line since I didn't manage to find
> > it's meaning (but I assume IF-THEN-ELSE).
>
> Yes, the third argument is basically an optional 'else' branch:
> https://www.gnu.org/software/m4/manual/m4-1.4.15/html_node/Ifdef.html
>
> >
> >  python/sepolgen/src/sepolgen/refparser.py | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/python/sepolgen/src/sepolgen/refparser.py b/python/sepolgen/src/sepolgen/refparser.py
> > index 9f850990..e611637f 100644
> > --- a/python/sepolgen/src/sepolgen/refparser.py
> > +++ b/python/sepolgen/src/sepolgen/refparser.py
> > @@ -433,9 +433,9 @@ def p_ifelse(p):
> >
> >
> >  def p_ifdef(p):
> > -    '''ifdef : IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi
> > -             | IFNDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi
> > -             | IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi
> > +    '''ifdef : IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK statements SQUOTE CPAREN optional_semi
> > +             | IFNDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK statements SQUOTE CPAREN optional_semi
> > +             | IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK statements SQUOTE COMMA TICK statements SQUOTE CPAREN optional_semi
> >      '''
> >      x = refpolicy.IfDef(p[4])
> >      if p[1] == 'ifdef':
> > --
> > 2.29.2
> >
>
> Acked-by: Ondrej Mosnacek <omosnace@redhat.com>

Merged:
https://github.com/SELinuxProject/selinux/commit/e12f71e82f523513c249dbe5a2e35c1916370992

-- 
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.


      reply	other threads:[~2021-01-27 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 21:14 [PATCH] python/sepolgen: allow any policy statement in ifndef Vit Mojzis
2021-01-19 13:55 ` Ondrej Mosnacek
2021-01-22 15:25   ` [PATCH v2] python/sepolgen: allow any policy statement in if(n)def Vit Mojzis
2021-01-22 16:32     ` Ondrej Mosnacek
2021-01-27 16:18       ` Ondrej Mosnacek [this message]

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=CAFqZXNtq3BenouP21PHHRv20pUPtNK90WU2hGqZMUwDSxnD2EA@mail.gmail.com \
    --to=omosnace@redhat.com \
    --cc=selinux@vger.kernel.org \
    --cc=vmojzis@redhat.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.