All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Brindle <method@manicmethod.com>
To: William Roberts <bill.c.roberts@gmail.com>
Cc: selinux@tycho.nsa.gov, Stephen Smalley <sds@tycho.nsa.gov>,
	Joshua Brindle <jbrindle@tresys.com>
Subject: Re: sepol help
Date: Thu, 23 Aug 2012 22:34:12 -0400	[thread overview]
Message-ID: <5036E824.7030007@manicmethod.com> (raw)
In-Reply-To: <CAFftDdrcyjQ53iEjQBK=tHROVR5fZVEPvC8wRxTT9ddx2j6FVA@mail.gmail.com>

William Roberts wrote:
> I am working on a tool for parsing, and allowing overrides to occur in
> seapp_contexts. I also want it to check the output selectors against
> the compiled binary. After looking at sepol, it wasn't quite clear to
> me how to get going with it. Can anyone give me function calls to do
> something like this?
>
> 1. Load the compiled binary

look at checkpolicy/test/dispol.c for examples. requires you to be 
statically linked against libsepol.

         fd = open(argv[1], O_RDONLY);
         if (fd < 0) {
...        }
         if (fstat(fd, &sb) < 0) {
...        }
         map =
             mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, 
fd, 0);
         if (map == MAP_FAILED) {
...        }
         policy_file_init(&pf);
         pf.type = PF_USE_MEMORY;
         pf.data = map;
         pf.len = sb.st_size;
         if (policydb_init(&policydb)) {
...        }
         ret = policydb_read(&policydb, &pf, 1);


> 2. Check to see if a boolean exists

bool = hashtab_search(policydb->p_bools.table, "some_boolean");
if (bool == null) {
	//no such boolean
}


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  parent reply	other threads:[~2012-08-24  2:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-24  2:01 sepol help William Roberts
2012-08-24  2:03 ` William Roberts
2012-08-24  2:34 ` Joshua Brindle [this message]
2012-08-24  2:41   ` William Roberts
2012-08-24  4:41     ` William Roberts
2012-08-24 12:10       ` Stephen Smalley
2012-08-24 21:22         ` William Roberts
2012-08-24 23:56           ` William Roberts
2012-08-25  2:35             ` William Roberts
2012-08-27 12:21               ` Stephen Smalley
2012-08-27 12:27             ` Stephen Smalley
2012-08-24 12:04   ` Stephen Smalley
2012-08-24 12:00 ` Stephen Smalley

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=5036E824.7030007@manicmethod.com \
    --to=method@manicmethod.com \
    --cc=bill.c.roberts@gmail.com \
    --cc=jbrindle@tresys.com \
    --cc=sds@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.