All of lore.kernel.org
 help / color / mirror / Atom feed
* [refpolicy] How to give _admin rights?
@ 2012-08-09 18:38 Sven Vermeulen
  2012-08-09 18:50 ` Daniel J Walsh
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sven Vermeulen @ 2012-08-09 18:38 UTC (permalink / raw)
  To: refpolicy

Hi guys,

Currently all administration I do is handled through the sysadm_r:sysadm_t
context. As a result, I never needed to explicitly grant an admin interface
(like nscd_admin) to a specific role.

I'm now trying to allow a role (be it user_r, staff_r or a newly created
role) to (re)start the NSCD init script (which is labeled
nscd_initrc_exec_t) so I thought it would be sufficient to just add in:
	nscd_admin(staff_t, staff_r)

However, a user (SELinux user staff_u) doesn't seem to be able to really use
it properly, unless I also give that user the root password (which I don't)
for the run_init command...

I've tried:
	~$ /etc/init.d/nscd status
	-bash: /etc/init.d/nscd: /sbin/runscript: bad interpreter:
	Permission denied
which is because of:
	security_compute_sid:  invalid context staff_u:system_r:initrc_t for
	scontext=staff_u:staff_r:staff_t tcontext=system_u:object_r:nscd_initrc_exec_t
	tclass=process

I've tried:
	~$ /usr/sbin/run_init /etc/init.d/nscd status
	Authenticating oper.
	Password: 
	Could not set exec context to system_u:system_r:initrc_t
which is because of:
	avc:  denied  { setexec } for  pid=18505 comm="run_init"
	scontext=staff_u:staff_r:staff_t tcontext=staff_u:staff_r:staff_t
	tclass=process

I've tried:
	~$ sudo /usr/sbin/run_init /etc/init.d/nscd status
but then, after authenticating, run_init asks for the root password which I
don't want to grant.

I've tried:
	~$ sudo /etc/init.d/nscd status
	sudo: unable to execute /etc/init.d/nscd: Permission denied
For this I don't know what is causing this - only see the standard denials
(rlimitinh, noatsecure, ...) and a getattr on a tty device.

It it "normal" that I would need to allow setexec for the user domain? 

What is the correct way to, once a role/user is defined, grant him the
_admin interface and have him start/stop the init scripts?

Wkr,
	Sven Vermeulen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [refpolicy] How to give _admin rights?
  2012-08-09 18:38 [refpolicy] How to give _admin rights? Sven Vermeulen
@ 2012-08-09 18:50 ` Daniel J Walsh
  2012-08-09 18:57   ` Sven Vermeulen
  2012-08-09 18:58 ` Christopher J. PeBenito
  2012-08-10 17:05 ` Sven Vermeulen
  2 siblings, 1 reply; 6+ messages in thread
From: Daniel J Walsh @ 2012-08-09 18:50 UTC (permalink / raw)
  To: refpolicy

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/09/2012 02:38 PM, Sven Vermeulen wrote:
> Hi guys,
> 
> Currently all administration I do is handled through the sysadm_r:sysadm_t
> context. As a result, I never needed to explicitly grant an admin interface
> (like nscd_admin) to a specific role.
> 
> I'm now trying to allow a role (be it user_r, staff_r or a newly created
> role) to (re)start the NSCD init script (which is labeled
> nscd_initrc_exec_t) so I thought it would be sufficient to just add in:
> 	nscd_admin(staff_t, staff_r)
> 
> However, a user (SELinux user staff_u) doesn't seem to be able to really
> use it properly, unless I also give that user the root password (which I
> don't) for the run_init command...
> 
> I've tried: ~$ /etc/init.d/nscd status -bash: /etc/init.d/nscd:
> /sbin/runscript: bad interpreter: Permission denied which is because of: 
> security_compute_sid: invalid context staff_u:system_r:initrc_t for 
> scontext=staff_u:staff_r:staff_t
> tcontext=system_u:object_r:nscd_initrc_exec_t tclass=process
> 
> I've tried: ~$ /usr/sbin/run_init /etc/init.d/nscd status Authenticating
> oper. Password: Could not set exec context to system_u:system_r:initrc_t 
> which is because of: avc: denied { setexec } for pid=18505 comm="run_init" 
> scontext=staff_u:staff_r:staff_t tcontext=staff_u:staff_r:staff_t 
> tclass=process
> 
> I've tried: ~$ sudo /usr/sbin/run_init /etc/init.d/nscd status but then,
> after authenticating, run_init asks for the root password which I don't
> want to grant.
> 
> I've tried: ~$ sudo /etc/init.d/nscd status sudo: unable to execute
> /etc/init.d/nscd: Permission denied For this I don't know what is causing
> this - only see the standard denials (rlimitinh, noatsecure, ...) and a
> getattr on a tty device.
> 
> It it "normal" that I would need to allow setexec for the user domain?
> 
> What is the correct way to, once a role/user is defined, grant him the 
> _admin interface and have him start/stop the init scripts?
> 
> Wkr, Sven Vermeulen _______________________________________________ 
> refpolicy mailing list refpolicy at oss.tresys.com 
> http://oss.tresys.com/mailman/listinfo/refpolicy
> 
What OS are you seeing this on?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAkBmsACgkQrlYvE4MpobP53gCggEL0SK5vtlCeRHgnAUKpAmKD
mpIAoMkmepAq3LYXh7/5lEcEoxSuHiJi
=0YHe
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [refpolicy] How to give _admin rights?
  2012-08-09 18:50 ` Daniel J Walsh
@ 2012-08-09 18:57   ` Sven Vermeulen
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Vermeulen @ 2012-08-09 18:57 UTC (permalink / raw)
  To: refpolicy

On Aug 9, 2012 8:50 PM, "Daniel J Walsh" <dwalsh@redhat.com> wrote:
> > Currently all administration I do is handled through the
sysadm_r:sysadm_t
> > context. As a result, I never needed to explicitly grant an admin
interface
> > (like nscd_admin) to a specific role.
> >
> > I'm now trying to allow a role (be it user_r, staff_r or a newly created
> > role) to (re)start the NSCD init script (which is labeled
> > nscd_initrc_exec_t) so I thought it would be sufficient to just add in:
> >       nscd_admin(staff_t, staff_r)
[... various trials and errors ...]
> >
> What OS are you seeing this on?

This is on Gentoo Hardened. What is the normal approach to take (say on
RedHat Enterprise Linux)? If the role/domain has the _admin interface, just
"sudo <initscript>"? Or is there still a need for run_init?

>From what I gather from the _admin interfaces, we grant the domain the
can_system_change attribute so that the user /can/ transition from (say)
staff_u to system_u, but as far as I can see, you need to run the run_init
command in order to actually change a SELinux user (or runcon) - there is
no way to automatically do that. So I guess I need to call run_init, so
that would leave me two options:

~$ run_init /etc/init.d/nscd

But in this case, my Linux credentials never become root so it'll fail
anyway.

~$ sudo run_init /etc/init.d/nscd

But in this case, run_init wants to get the root password
(re-authenticate), or do I need to enable pam_rootok.so for this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.tresys.com/pipermail/refpolicy/attachments/20120809/6b307336/attachment.html 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [refpolicy] How to give _admin rights?
  2012-08-09 18:38 [refpolicy] How to give _admin rights? Sven Vermeulen
  2012-08-09 18:50 ` Daniel J Walsh
@ 2012-08-09 18:58 ` Christopher J. PeBenito
  2012-08-10 12:50   ` Daniel J Walsh
  2012-08-10 17:05 ` Sven Vermeulen
  2 siblings, 1 reply; 6+ messages in thread
From: Christopher J. PeBenito @ 2012-08-09 18:58 UTC (permalink / raw)
  To: refpolicy

On 08/09/12 14:38, Sven Vermeulen wrote:
> Hi guys,
> 
> Currently all administration I do is handled through the sysadm_r:sysadm_t
> context. As a result, I never needed to explicitly grant an admin interface
> (like nscd_admin) to a specific role.
> 
> I'm now trying to allow a role (be it user_r, staff_r or a newly created
> role) to (re)start the NSCD init script (which is labeled
> nscd_initrc_exec_t) so I thought it would be sufficient to just add in:
> 	nscd_admin(staff_t, staff_r)
> 
> However, a user (SELinux user staff_u) doesn't seem to be able to really use
> it properly, unless I also give that user the root password (which I don't)
> for the run_init command...

There's a couple things going on here, which center around a clash between run_init and labeled init scripts:
 
> I've tried:
> 	~$ /etc/init.d/nscd status
> 	-bash: /etc/init.d/nscd: /sbin/runscript: bad interpreter:
> 	Permission denied
> which is because of:
> 	security_compute_sid:  invalid context staff_u:system_r:initrc_t for
> 	scontext=staff_u:staff_r:staff_t tcontext=system_u:object_r:nscd_initrc_exec_t
> 	tclass=process

Fails because there was no transition to run_init_t.  It needs something like seutil_init_script_run_runinit(), but only for using nscd_initrc_exec_t for the run_init_t entrypoint.

> I've tried:
> 	~$ /usr/sbin/run_init /etc/init.d/nscd status
> 	Authenticating oper.
> 	Password: 
> 	Could not set exec context to system_u:system_r:initrc_t
> which is because of:
> 	avc:  denied  { setexec } for  pid=18505 comm="run_init"
> 	scontext=staff_u:staff_r:staff_t tcontext=staff_u:staff_r:staff_t
> 	tclass=process

Same thing, but instead needs seutil_run_runinit().  But this exposes that with run_init right now, the usage of init labeled init scripts falls on its face, because when you're in run_init_t, it can transition to initrc_t using any entrypoint.  Run_init would need to be enhanced to do some extra checks to see if you're permitted to run the script.

[cut]
> It it "normal" that I would need to allow setexec for the user domain? 

No.


-- 
Chris PeBenito
Tresys Technology, LLC
www.tresys.com | oss.tresys.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [refpolicy] How to give _admin rights?
  2012-08-09 18:58 ` Christopher J. PeBenito
@ 2012-08-10 12:50   ` Daniel J Walsh
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel J Walsh @ 2012-08-10 12:50 UTC (permalink / raw)
  To: refpolicy

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/09/2012 02:58 PM, Christopher J. PeBenito wrote:
> On 08/09/12 14:38, Sven Vermeulen wrote:
>> Hi guys,
>> 
>> Currently all administration I do is handled through the
>> sysadm_r:sysadm_t context. As a result, I never needed to explicitly
>> grant an admin interface (like nscd_admin) to a specific role.
>> 
>> I'm now trying to allow a role (be it user_r, staff_r or a newly created 
>> role) to (re)start the NSCD init script (which is labeled 
>> nscd_initrc_exec_t) so I thought it would be sufficient to just add in: 
>> nscd_admin(staff_t, staff_r)
>> 
>> However, a user (SELinux user staff_u) doesn't seem to be able to really
>> use it properly, unless I also give that user the root password (which I
>> don't) for the run_init command...
> 
> There's a couple things going on here, which center around a clash between
> run_init and labeled init scripts:
> 
>> I've tried: ~$ /etc/init.d/nscd status -bash: /etc/init.d/nscd:
>> /sbin/runscript: bad interpreter: Permission denied which is because of: 
>> security_compute_sid:  invalid context staff_u:system_r:initrc_t for 
>> scontext=staff_u:staff_r:staff_t
>> tcontext=system_u:object_r:nscd_initrc_exec_t tclass=process
> 
> Fails because there was no transition to run_init_t.  It needs something
> like seutil_init_script_run_runinit(), but only for using
> nscd_initrc_exec_t for the run_init_t entrypoint.
> 
>> I've tried: ~$ /usr/sbin/run_init /etc/init.d/nscd status Authenticating
>> oper. Password: Could not set exec context to system_u:system_r:initrc_t 
>> which is because of: avc:  denied  { setexec } for  pid=18505
>> comm="run_init" scontext=staff_u:staff_r:staff_t
>> tcontext=staff_u:staff_r:staff_t tclass=process
> 
> Same thing, but instead needs seutil_run_runinit().  But this exposes that
> with run_init right now, the usage of init labeled init scripts falls on
> its face, because when you're in run_init_t, it can transition to initrc_t
> using any entrypoint.  Run_init would need to be enhanced to do some extra
> checks to see if you're permitted to run the script.
> 
> [cut]
>> It it "normal" that I would need to allow setexec for the user domain
> 
> No.
> 
> 

One of the best things about systemd is we can finally get away from the
run_init bologni..
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAlA6AACgkQrlYvE4MpobNCOgCcDzJEbf8kcwqdN+TQ/6UhE6LI
nCcAnijIKhbE2jpA3eNcKoqSMSMALhCv
=7Rne
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [refpolicy] How to give _admin rights?
  2012-08-09 18:38 [refpolicy] How to give _admin rights? Sven Vermeulen
  2012-08-09 18:50 ` Daniel J Walsh
  2012-08-09 18:58 ` Christopher J. PeBenito
@ 2012-08-10 17:05 ` Sven Vermeulen
  2 siblings, 0 replies; 6+ messages in thread
From: Sven Vermeulen @ 2012-08-10 17:05 UTC (permalink / raw)
  To: refpolicy

On Thu, Aug 09, 2012 at 08:38:51PM +0200, Sven Vermeulen wrote:
> Currently all administration I do is handled through the sysadm_r:sysadm_t
> context. As a result, I never needed to explicitly grant an admin interface
> (like nscd_admin) to a specific role.
> 
> I'm now trying to allow a role (be it user_r, staff_r or a newly created
> role) to (re)start the NSCD init script (which is labeled
> nscd_initrc_exec_t) so I thought it would be sufficient to just add in:
> 	nscd_admin(staff_t, staff_r)
> 
> However, a user (SELinux user staff_u) doesn't seem to be able to really use
> it properly, unless I also give that user the root password (which I don't)
> for the run_init command...
[...]

Thank you all for the feedback, especially Dominick who put me on the right
track.

What I failed to do was to grant the system_r role to the (SELinux) user
that I was giving _admin rights to. Because of that, no transition to
<user>:system_r:initrc_t was possible.

By giving the user the system_r access, it was sufficient to just grant the
_admin to the user/role and use
  ~$ sudo /etc/init.d/nscd start

Wkr,
	Sven Vermeulen

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-10 17:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-09 18:38 [refpolicy] How to give _admin rights? Sven Vermeulen
2012-08-09 18:50 ` Daniel J Walsh
2012-08-09 18:57   ` Sven Vermeulen
2012-08-09 18:58 ` Christopher J. PeBenito
2012-08-10 12:50   ` Daniel J Walsh
2012-08-10 17:05 ` Sven Vermeulen

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.