From: Dominick Grift <dominick.grift@defensec.nl>
To: Vit Mojzis <vmojzis@redhat.com>
Cc: selinux@vger.kernel.org
Subject: Re: generating new type name using CIL macro
Date: Tue, 12 Sep 2023 05:50:59 +0200 [thread overview]
Message-ID: <87pm2ouk0s.fsf@defensec.nl> (raw)
In-Reply-To: <324bb6b0-3d6c-707d-c0d1-1fdc1f43e845@redhat.com> (Vit Mojzis's message of "Mon, 11 Sep 2023 17:42:03 +0200")
Vit Mojzis <vmojzis@redhat.com> writes:
> Hello all,
> while trying to recreate some selinux-policy templates using CIL
> macros I got stuck on creating new type/role/attribute names.
> For example consider ssh_role_template [1], which uses its first
> parameter to create a new type $1_ssh_agent_t.
>
> Is there a way to recreate such functionality in a CIL macro (or
> another CIL feature)?
CIL uses blocks for it implementation of templating. If you want to leverage
native CIL then look into blocks.
Example:
cat > mytest.cil <<EOF
(typeattribute foo)
(block t
(blockabstract t)
(type t)
(typeattributeset .foo t))
(block bar
(blockinherit t))
(block baz
(blockinherit t))
(allow .foo .foo (process (signal)))
EOF
sudo semodule -i mytest.cil
seinfo -xafoo
Type Attributes: 1
attribute foo;
bar.t
baz.t
sesearch -A -s foo -ds
allow foo foo:process signal;
>
> Something along the lines of:
> (macro new_type_macro ((string type_prefix))
> (type (type_prefix)_t)
> )
> which when called (call new_type_macro ("yolo")) would produce
> (type yolo_t)
>
> I searched through CIL reference guide [2] and SELinuxProject CIL wiki
> on github, but didn't find anything close (maybe there is a better
> resource I don't know about).
> I'd appreciate any hints or links to other resources related to CIL macros.
>
> Thank you,
> Vit
>
> [1] -
> https://github.com/TresysTechnology/refpolicy/blob/master/policy/modules/services/ssh.if#L301
> [2] -
> https://raw.githubusercontent.com/SELinuxProject/selinux-notebook/main/src/notebook-examples/selinux-policy/cil/CIL_Reference_Guide.pdf
> [3] - https://github.com/SELinuxProject/cil/wiki#macros
>
--
gpg --locate-keys dominick.grift@defensec.nl (wkd)
Key fingerprint = FCD2 3660 5D6B 9D27 7FC6 E0FF DA7E 521F 10F6 4098
Dominick Grift
Mastodon: @kcinimod@defensec.nl
next prev parent reply other threads:[~2023-09-12 3:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 15:42 generating new type name using CIL macro Vit Mojzis
2023-09-12 3:50 ` Dominick Grift [this message]
2023-09-12 9:42 ` Vit Mojzis
2023-09-12 9:49 ` Dominick Grift
2023-09-12 13:13 ` James Carter
2023-09-12 18:29 ` Vit Mojzis
2023-09-12 20:56 ` James Carter
2023-09-25 21:03 ` James Carter
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=87pm2ouk0s.fsf@defensec.nl \
--to=dominick.grift@defensec.nl \
--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.