All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Andrew Holway <andrew.holway@native-instruments.de>,
	selinux@tycho.nsa.gov
Subject: Re: virtualenv
Date: Wed, 04 Feb 2015 09:05:06 -0500	[thread overview]
Message-ID: <54D22712.5020104@tycho.nsa.gov> (raw)
In-Reply-To: <54D207CA.20301@native-instruments.de>

On 02/04/2015 06:51 AM, Andrew Holway wrote:
> 
>> What's the init.d script look like for this service?  If you can prefix
>> the /usr/bin/sh command with runcon -t myapp_t --, then it should also
>> run in myapp_t.  But you'll then need to allow myapp_t shell_exec_t:file
>> entrypoint in your policy.  Is the only domain transition into myapp_t
>> from initrc_t?
> 
> Hi Stephen,
> 
> We're using Centos7 and systemd. I guess we can still throw a runcon in
> there. We used the system-config-selinux tool to generate the base
> policy module but the rules it creates are a bit opaque to me.
> 
> I think this is the interface that allows initd_t(systemd) to transition
> our app into its domain. I'm a little unsure how I should be making a
> new entrypoint.

The refpolicy interface is domain_entry_file() in domain.if.  Add the
following to your .te file:
domain_entry_file(myapp_t, shell_exec_t)

> 
>        interface(`myapp_domtrans',`
>            gen_require(`
>                 type myapp_t, myapp_exec_t;
>            ')
>            corecmd_search_bin($1)
>                 domtrans_pattern($1, myapp_exec_t, myapp_t)
>        ')
> 
> 
> # /usr/lib/systemd/system/myapp.service
> 
> [Unit]
> Description=MyAPP
> After=network.target
> 
> [Service]
> User=myapp
> Group=myapp
> ExecStart=/usr/bin/sh -c 'source /var/lib/myapp/env/bin/activate &&
> gunicorn --bind 0.0.0.0:8080 --debug --reload wsgi:app'

Insert /usr/bin/runcon -t myapp_t -- before /usr/bin/sh above.  This
will jump into the myapp_t domain before launching the shell, so the
shell and all of its descendants will run in your domain.

> ExecReload=/bin/kill -s HUP $MAINPID
> ExecStop=/bin/kill -s TERM $MAINPID
> PrivateTmp=true
> 
> [Install]
> WantedBy=multi-user.target

  reply	other threads:[~2015-02-04 14:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 16:43 virtualenv Andrew Holway
2015-01-30 17:28 ` virtualenv Stephen Smalley
2015-02-04 11:51   ` virtualenv Andrew Holway
2015-02-04 14:05     ` Stephen Smalley [this message]
2015-01-30 17:31 ` virtualenv 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=54D22712.5020104@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=andrew.holway@native-instruments.de \
    --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.