From: Ondrej Mosnacek <omosnace@redhat.com>
To: Vit Mojzis <vmojzis@redhat.com>
Cc: SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH] python/sepolgen: allow any policy statement in ifndef
Date: Tue, 19 Jan 2021 14:55:20 +0100 [thread overview]
Message-ID: <CAFqZXNuE3CbwGDv7mvxh67iX3zeLKTu6AJC_VoeALb_o26+zOg@mail.gmail.com> (raw)
In-Reply-To: <20210111211405.2215410-1-vmojzis@redhat.com>
On Mon, Jan 11, 2021 at 10:16 PM Vit Mojzis <vmojzis@redhat.com> wrote:
> "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 "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>
> ---
> python/sepolgen/src/sepolgen/refparser.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/python/sepolgen/src/sepolgen/refparser.py b/python/sepolgen/src/sepolgen/refparser.py
> index 9f850990..3c69904a 100644
> --- a/python/sepolgen/src/sepolgen/refparser.py
> +++ b/python/sepolgen/src/sepolgen/refparser.py
> @@ -434,7 +434,7 @@ 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
> + | IFNDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK statement SQUOTE CPAREN optional_semi
> | IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi
IMHO we should be consistent and allow any statements also in ifdefs
(i.e. make an equivalent change in the line before and after).
> '''
> x = refpolicy.IfDef(p[4])
> --
> 2.29.2
>
--
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.
next prev parent reply other threads:[~2021-01-19 23:57 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 [this message]
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
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=CAFqZXNuE3CbwGDv7mvxh67iX3zeLKTu6AJC_VoeALb_o26+zOg@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.