All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Sekidde <ssekidde@redhat.com>
To: Lennart Poettering <lennart@poettering.net>
Cc: Ian Pilcher <arequipeno@gmail.com>,
	Systemd <systemd-devel@lists.freedesktop.org>,
	selinux@tycho.nsa.gov
Subject: Re: [systemd-devel] SELinux type transition rule not working
Date: Thu, 2 Mar 2017 10:13:48 -0500 (EST)	[thread overview]
Message-ID: <944362898.27340550.1488467628547.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170301222511.GA29059@gardel-login>



----- Original Message -----
> From: "Lennart Poettering" <lennart@poettering.net>
> To: "Ian Pilcher" <arequipeno@gmail.com>
> Cc: "Systemd" <systemd-devel@lists.freedesktop.org>, selinux@tycho.nsa.gov
> Sent: Wednesday, March 1, 2017 5:25:11 PM
> Subject: Re: [systemd-devel] SELinux type transition rule not working
> 
> On Wed, 01.03.17 15:40, Ian Pilcher (arequipeno@gmail.com) wrote:
> 
> > I am using systemd's RuntimeDirectory to create a directory for a
> > service.
> > 
> >    RuntimeDirectory=squoxy
> > 
> > This causes systemd to create /run/squoxy before starting my service,
> > but I haven't been able to get the SELinux context set correctly on the
> > directory.
> > 
> > I've set file context rules for both /run/squoxy and /var/run/squoxy:
> > 
> > ^/var/run/squoxy(/.*)?  all files  system_u:object_r:squoxy_var_run_t:s0
> > ^/run/squoxy(/.*)?      all files  system_u:object_r:squoxy_var_run_t:s0
> > 
> > And, indeed, restorecon will set the context of the directory to
> > squoxy_var_run_t.
> > 
> > I've also added a type transition rule, attempting to get the correct
> > context applied automatically when systemd creates the directory:
> > 
> > type_transition init_t var_run_t : dir squoxy_var_run_t "squoxy";
> > 
> > But the directory is still being created as var_run_t:
> > 
> > drwxr-xr-x. nobody nobody system_u:object_r:var_run_t:s0   /run/squoxy
> > 
> > What am I doing wrong?
> 

Ian, 

I assume this would be a pid file?

If so then what you are probably looking for is a filename_trans rule and will require a new interface in squid.if for this. 

Try something like

interface(`squid_filetrans_named_content',`
        gen_require(`
		     type_squid_var_run_t; 
	')

        files_pid_filetrans($1, squid_var_run_t, dir, "squozy")
')

> Hmm, so the relevant code in systemd actually labels the dir after
> creating it after an selinux database lookup, so from our side all
> should be good:
> 
> https://github.com/systemd/systemd/blob/master/src/core/execute.c#L1857
> 
> (specifically, we all mkdir_p_label() instead of plain mkdir_p() there)
> 
> My own understanding of SELinux is finite however. I'd recommend
> pinging the SELinux folks for help on this,
> 

We got you covered! 

> Lennart
> 
> --
> Lennart Poettering, Red Hat
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to
> Selinux-request@tycho.nsa.gov.
> 

-- 
Simon Sekidde * Red Hat, Inc. * Tyson's Corner, VA
Solution Architect, NA Public Sector
ssekidde@redhat.com | (w) 978-392-1074 | (m) 571-551-9366 | @ssekidde
gpg: 5848 958E 73BA 04D3 7C06 F096 1BA1 2DBF 94BC 377E

  reply	other threads:[~2017-03-02 15:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01 21:40 SELinux type transition rule not working Ian Pilcher
2017-03-01 22:25 ` [systemd-devel] " Lennart Poettering
2017-03-02 15:13   ` Simon Sekidde [this message]
2017-03-03 15:44     ` Ian Pilcher
2017-03-03 16:01       ` Simon Sekidde
2017-03-03 16:45         ` Simon Sekidde
2017-03-03 19:32           ` Ian Pilcher
2017-03-03 20:19             ` Simon Sekidde
2017-03-03 21:00               ` Ian Pilcher
2017-03-01 22:28 ` cgzones
2017-03-01 23:28   ` Ian Pilcher
2017-03-01 23:51     ` Ian Pilcher
2017-03-02  6:12       ` Jason Zaman
2017-03-03 15:36         ` Ian Pilcher
2017-03-03 15:47           ` Stephen Smalley
2017-03-02  2:16 ` Russell Coker

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=944362898.27340550.1488467628547.JavaMail.zimbra@redhat.com \
    --to=ssekidde@redhat.com \
    --cc=arequipeno@gmail.com \
    --cc=lennart@poettering.net \
    --cc=selinux@tycho.nsa.gov \
    --cc=systemd-devel@lists.freedesktop.org \
    /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.