All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Xavier Toth <txtoth@gmail.com>, SELinux List <selinux@tycho.nsa.gov>
Subject: Re: problem with capabilities inheritance and auditing in python
Date: Mon, 9 Feb 2009 14:42:00 -0600	[thread overview]
Message-ID: <20090209204200.GA25401@us.ibm.com> (raw)
In-Reply-To: <1234210633.28831.87.camel@localhost.localdomain>

Quoting Stephen Smalley (sds@tycho.nsa.gov):
> On Mon, 2009-02-09 at 10:42 -0600, Xavier Toth wrote:
> > On Mon, Feb 9, 2009 at 8:02 AM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> > > On Fri, 2009-02-06 at 15:56 -0600, Xavier Toth wrote:
> > >> On Thu, Feb 5, 2009 at 12:10 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> > >> > On Thu, 2009-02-05 at 11:08 -0600, Xavier Toth wrote:
> > >> >> I've set the capabilities on a script that runs some python code with
> > >> >> auditing calls in it but I'm not getting audit records written to the
> > >> >> audit log. From what I've read I thought the +i would all the
> > >> >> capability to be inherited across execve but this doesn't appear to be
> > >> >> the case. Can anyone help me understand what's going wrong here? Is
> > >> >> there a way in the python code to get the capabilities to see if
> > >> >> indeed cap_audit_write was inherited?
> > >> >
> > >> > Linux doesn't honor setuid on scripts, and file capabilities are
> > >> > supposed to have the same behavior (they didn't for a while due to an
> > >> > oversight, but that was corrected).  You need an executable wrapper
> > >> > program that invokes the script, like:
> > >> > http://oss.tresys.com/projects/clip/browser/trunk/RHEL5.2/scripts/wrappers/wrapper.c
> > >> >
> > >> > --
> > >> > Stephen Smalley
> > >> > National Security Agency
> > >> >
> > >> >
> > >>
> > >> Having used this wrapper code pretty much as is I'm now seeing
> > >> self:capability dac_override and dac_read_search AVCs. Do I need to do
> > >> something similar to what newrole does to drop capabilities that I
> > >> don't need my python script to have after all I'm only trying to give
> > >> it the ability to audit?
> > >
> > > You can just dontaudit those denials if you don't need those
> > > capabilities.
> > >
> > > --
> > > Stephen Smalley
> > > National Security Agency
> > >
> > >
> > 
> > Unfortunately python doesn't survive the dac_read_search AVC. I also
> > tried removing the setreuid/setregid calls, doing a setcap
> > cap_audit_write=ep on the wrapper and not running the wrapper as
> > setuid but that doesn't work.
> 
> So what is it trying to access (enable syscall auditing with at least
> one audit syscall filter defined so the kernel will collect PATH records
> for you and emit them after any AVC denials)?
> 
> On the separate question of capability inheritance on exec of a script
> from a wrapper with file capabilities, I'll defer to Serge.

Right, file capabilities on scripts are disregarded.  So things to do
would include:

1. set capabilities on the interpreter (in which case you'll likely
want to make sure the interpreter can't be called by anyone else)

2. keep capabilities in pI, and place capabilities in fI (and if you
must fE) on all of the compiled programs called by the script.

3. Make the whole thing a compiled program...

-serge

--
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.

  reply	other threads:[~2009-02-09 20:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05 17:08 problem with capabilities inheritance and auditing in python Xavier Toth
2009-02-05 18:10 ` Stephen Smalley
2009-02-06 21:56   ` Xavier Toth
2009-02-09 14:02     ` Stephen Smalley
2009-02-09 16:42       ` Xavier Toth
2009-02-09 20:17         ` Stephen Smalley
2009-02-09 20:42           ` Serge E. Hallyn [this message]
2009-02-10 17:00             ` Xavier Toth
2009-02-10 18:34               ` Serge E. Hallyn
2009-02-10 20:20                 ` Xavier Toth
2009-02-10 20:33                   ` Stephen Smalley
2009-02-10 20:59                     ` Xavier Toth
2009-02-10 21:08                       ` Stephen Smalley
2009-02-10 21:30                         ` Serge E. Hallyn
2009-02-10 21:38                       ` Serge E. Hallyn
2009-02-10 21:45                         ` Xavier Toth
2009-02-10 21:25                   ` Stephen Smalley
2009-02-10 21:37                     ` Xavier Toth
2009-02-10 21:38                       ` Stephen Smalley
2009-02-10 21:46                       ` Serge E. Hallyn
2009-02-10 21:44                     ` Serge E. Hallyn

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=20090209204200.GA25401@us.ibm.com \
    --to=serue@us.ibm.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=txtoth@gmail.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.