Re: [PATCH] python/sepolgen: allow any policy statement in ifndef

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 11, 2021 at 10:16 PM Vit Mojzis <vmojzis@xxxxxxxxxx> 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@xxxxxxxxxx>
> ---
>  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.




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux