Skip to contentSkip to conversation

How to give _admin rights?

refpolicy Sven Vermeulen 3 participants 6 messages Aug 9, 2012 – Aug 10, 2012

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

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

Quoted 36 lines · Sven Vermeulen

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.

Quoted 9 lines

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

#2 lore raw
Quoted 1 line · Daniel J Walsh
Quoted 1 line

Currently all administration I do is handled through the

sysadm_r:sysadm_t

Quoted 1 line
Quoted 1 line

context. As a result, I never needed to explicitly grant an admin

interface

Quoted 6 lines
Quoted 6 lines

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

Quoted 2 lines
Quoted 1 line

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?

Quoted 1 line

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

#3 lore raw
In reply to Sven Vermeulen
Quoted 6 lines · Sven Vermeulen

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.

Quoted 8 lines

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:

Quoted 8 lines

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.

Quoted 9 lines

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]

Quoted 1 line

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

No.

Signature · 3 lines
Chris PeBenito
Tresys Technology, LLC
www.tresys.com | oss.tresys.com
#4 lore raw

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

Quoted 41 lines · Christopher J. PeBenito
Quoted 6 lines · Sven Vermeulen

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.

Quoted 8 lines

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:

Quoted 5 lines

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.

Quoted 5 lines

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.

Quoted 6 lines

[cut]

Quoted 1 line

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

#5 lore raw
In reply to Sven Vermeulen
Quoted 4 lines · Sven Vermeulen

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.

Quoted 8 lines

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