From: "Christopher J. PeBenito" <cpebenito@tresys.com>
To: Richard Haines <richard_c_haines@btinternet.com>,
William Roberts <bill.c.roberts@gmail.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
"selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>
Subject: Re: initial_sid context via libsepol
Date: Tue, 8 Mar 2016 08:49:21 -0500 [thread overview]
Message-ID: <56DED861.8060101@tresys.com> (raw)
In-Reply-To: <1439711485.8727172.1457442762500.JavaMail.yahoo@mail.yahoo.com>
On 3/8/2016 8:12 AM, Richard Haines wrote:
> On Tuesday, 8 March 2016, 1:32, William Roberts <bill.c.roberts@gmail.com> wrote:
>> On Mon, Mar 7, 2016 at 12:32 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
>> On 03/07/2016 01:44 PM, Stephen Smalley wrote:
>>> On 03/07/2016 10:41 AM, Richard Haines wrote:
>>>>> On Saturday, 5 March 2016, 14:48, Richard Haines
>>>>>> <richard_c_haines@btinternet.com> wrote:
>>>>>> On Friday, 4 March 2016, 21:18, "Roberts, William C"
>>>>>> <william.c.roberts@intel.com> wrote:
>>>>>>>
>>>>>>> How can one obtain the same value as
>>>>>>> /sys/fs/selinux/initial_contexts/file via libsepol?
>>>>>>
>
> From what I can see the only ways for you to get the context of a specifically
> named initial sid, is to:
>
> 1) If working on the active policy then read /sys/fs/selinux/initial_contexts
> for the specific name.
>
> 2) If working on a binary policy that has been loaded by libsepol for
> investigation, then I guess the official answer would be "you cannot do
> this", simply because the names are not held in the binary policy.
>
> What you could do is:
>
> a) Load the initial_sid_to_string.h or the policy initial_sids file and search
> through it for a match. This will give the offset and would (by magic) give
> the initial SID value (e.g. "file" = 5) as it just so happens that the
> initial SIDs start at '1' in a standard SELinux system. You can then obtain
> the context string.
>
> b) Or you could just say they start at 1 and I know "file" is the 5th entry !!
>
> c) Modify policy, kernel etc. to add the names.
>
> Unless someone knows another way !!!!
I realize this is about libsepol, but if you happen to have setools3
available, it can also retrieve this information, e.g.
$ seinfo --initialsid=node -x
node: system_u:object_r:node_t:s0
So in your program you could use the libapol library functions and look
it up in /sys/fs/selinux/policy.
--
Chris PeBenito
Tresys Technology, LLC
www.tresys.com | oss.tresys.com
next prev parent reply other threads:[~2016-03-08 13:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 21:16 initial_sid context via libsepol Roberts, William C
2016-03-05 14:43 ` Richard Haines
2016-03-07 15:41 ` Richard Haines
2016-03-07 18:44 ` Stephen Smalley
2016-03-07 20:32 ` Stephen Smalley
2016-03-08 1:32 ` William Roberts
2016-03-08 13:12 ` Richard Haines
2016-03-08 13:35 ` Richard Haines
2016-03-08 13:49 ` Christopher J. PeBenito [this message]
2016-03-08 13:42 ` Stephen Smalley
2016-03-09 5:18 ` William Roberts
2016-03-09 14:09 ` Stephen Smalley
2016-03-09 15:37 ` William Roberts
2016-03-09 17:12 ` William Roberts
2016-03-09 15:42 ` Stephen Smalley
2016-03-09 15:45 ` William Roberts
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=56DED861.8060101@tresys.com \
--to=cpebenito@tresys.com \
--cc=bill.c.roberts@gmail.com \
--cc=richard_c_haines@btinternet.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.