From: Stephen Smalley <sds@tycho.nsa.gov>
To: Daniel J Walsh <dwalsh@redhat.com>
Cc: SELinux <selinux@tycho.nsa.gov>, Eric Paris <eparis@redhat.com>
Subject: Re: Another change we would like to make to libselinux
Date: Wed, 22 Feb 2012 08:29:13 -0500 [thread overview]
Message-ID: <1329917353.15569.8.camel@moss-pluto> (raw)
In-Reply-To: <4F44114F.4080005@redhat.com>
On Tue, 2012-02-21 at 16:49 -0500, Daniel J Walsh wrote:
> Right now we added selinux_current_policy_path and we are using it as
> the default for seinfo, audit2allow, sepolgen-ifgen
I'm not sure this is a good idea to always use it, as it is definitely
more costly to generate the policy image in the kernel than to just read
the policy file. I had only envisioned it being used by tools that want
to verify that the kernel policy matches the policy file.
> It currently looks like
>
> const char *selinux_current_policy_path(void)
> {
> int rc = 0;
> int vers = 0;
> static char policy_path[PATH_MAX];
>
> snprintf(policy_path, sizeof(policy_path), "%s/policy", selinux_mnt);
> if (access(policy_path, F_OK) != 0 ) {
> vers = security_policyvers();
The selinux_mkload_policy() logic starts with
sepol_policy_kern_vers_max() rather than security_policyvers() if
libsepol is available, since it can downgrade the policy file via
libsepol to the kernel version. So your logic may end up using the
wrong policy file.
> do {
> /* Check prior versions to see if old policy is available */
> snprintf(policy_path, sizeof(policy_path), "%s.%d",
> selinux_binary_policy_path(), vers);
> } while ((rc = access(policy_path, F_OK)) && --vers > 0);
>
> if (rc) return NULL;
> }
>
> return policy_path;
> }
--
Stephen Smalley
National Security Agency
--
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.
prev parent reply other threads:[~2012-02-22 13:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 14:47 Another change we would like to make to libselinux Daniel J Walsh
2012-02-21 20:43 ` Stephen Smalley
2012-02-21 21:49 ` Daniel J Walsh
2012-02-22 13:27 ` Christopher J. PeBenito
2012-02-22 13:34 ` Daniel J Walsh
2012-02-22 14:08 ` Stephen Smalley
2012-02-22 15:29 ` Daniel J Walsh
2012-02-22 13:29 ` Stephen Smalley [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=1329917353.15569.8.camel@moss-pluto \
--to=sds@tycho.nsa.gov \
--cc=dwalsh@redhat.com \
--cc=eparis@redhat.com \
--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.