All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan <dtdevore64@yahoo.com>
To: James Carter <jwcart2@tycho.nsa.gov>, selinux@tycho.nsa.gov
Subject: Re: Cil Macros
Date: Thu, 24 Sep 2015 23:20:02 -0400	[thread overview]
Message-ID: <5604BD62.5090909@yahoo.com> (raw)
In-Reply-To: <56042DF4.3020205@tycho.nsa.gov>

Sorry for replying again but I wanted to paste my code in case anyone 
wanted to see an example of a process transition with a domain using a 
macro.

(macro domain_auto_trans ((type ARG1) (type ARG2) (type ARG3))
    (allow ARG1 ARG2 (file (read getattr execute open)))
    (allow ARG1 ARG3 (process (transition)))
    (allow ARG3 ARG2 (file (ioctl entrypoint read getattr lock execute 
execute_no_trans open)))
    (typetransition ARG1 ARG2 process ARG3)
)

(call domain_trans (staff_t mytest_exec_t mytest_t))


On 09/24/2015 01:08 PM, James Carter wrote:
> On 09/24/2015 01:02 PM, Dan wrote:
>> The only thing I am confused on now is on what to put for the "ARG" 
>> statements.
>> Now when it says "ARG1" am I supposed to put my mytest_t type there 
>> or just
>> leave it as it says like ARG1? I took out the typeattributeset 
>> statement like
>> you said and tried to build it with the following, but it still 
>> failed. Thanks.
>>
>> (macro mytest_t_domain_auto_trans ((type ARG1))
>>    (call domain_trans (type ARG1))
>>    (allow ARG1  mytest_t (process (exec read write getattr transition)))
>> )
>>
>
> You had the call right before: (call domain_trans (ARG1))
>
> ARG1 is just the parameter, so it is replaced in the call.
> Somewhere else you would have (call mytest_t_domain_auto_trans 
> (sometype_t)), and sometype_t will replace ARG1.
>
> Is this clearer?
>
> Jim
>
>>
>>
>> On 09/24/2015 08:20 AM, James Carter wrote:
>>> On 09/24/2015 12:42 AM, Dan wrote:
>>>> Hello everyone, I've been trying to play around with macros with 
>>>> the CIL
>>>> language and have come across some problems on how they work. I'm 
>>>> just trying to
>>>> simple create a macro that will do a type transition with a process 
>>>> called
>>>> mytest_t domain.
>>>>
>>>> Here is what I have so far:
>>>>
>>>>
>>>>
>>>>
>>>> (macro mytest_t_domain_auto_trans ((ARG1))
>>>>    (typeattributeset cil_gen_require application_domain_type)
>>>>    (call domain_trans (ARG1))
>>>>    (allow ARG1 mytest_t (process (exec read write getattr 
>>>> transition)))
>>>> )
>>>>
>>>
>>> You are probably getting a message saying invalid syntax.
>>> The macro definition needs to say what the argument is, like this:
>>> (macro mytest_t_domain_auto_trans ((type ARG1))
>>>
>>> We use (typeattributeset cil_gen_require SOME_TYPE) when converting 
>>> pp files
>>> to cil to make optional blocks work when a type is required, but not 
>>> used. I
>>> don't think that you need it here.
>>>
>>> I hope that helps.
>>>
>>> Jim
>>>
>>>>
>>>>
>>>> ...but when I try to run it it obviously doesn't work. If anyone 
>>>> has any input
>>>> on what I am doing wrong I'm all ears. Thanks.
>>>> _______________________________________________
>>>> Selinux mailing list
>>>> Selinux@tycho.nsa.gov
>>>> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
>>>> To get help, send an email containing "help" to 
>>>> Selinux-request@tycho.nsa.gov.
>>>>
>>>
>>>
>
>

      parent reply	other threads:[~2015-09-25  3:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24  4:42 Cil Macros Dan
2015-09-24 12:20 ` James Carter
2015-09-24 17:02   ` Dan
2015-09-24 17:08     ` James Carter
2015-09-25  2:26       ` Dan
2015-09-25  3:20       ` Dan [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=5604BD62.5090909@yahoo.com \
    --to=dtdevore64@yahoo.com \
    --cc=jwcart2@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /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.