Skip to contentSkip to conversation

Question about newrole

DISCUSSION Dennis Wronka 4 participants 15 messages Aug 5, 2008 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi folks,

I'd like to ask about a problem I am experiencing with newrole. When I use newrole in permissive-mode I have no problems changing the role. Also I don't get any audit-messages.
But when I switch to enforcing-mode I cannot use newrole, it keeps telling me "incorrect password for root", although it clearly is correct. I suspect a problem in interaction between newrole and unix_chkpwd, but am not entirely sure about it.

Problem is that I don't get any audits from SELinux, only errors in auth.log from unix_chkpwd:
check_pass; user unknown
password check failer for user (root)

I am working with the latest reference-policy, adjusted here and there to fit the needs of my distro.

Thanks for any suggestions.

Dennis

#1 lore raw
Quoted 15 lines · Dennis Wronka

Hi folks,

I'd like to ask about a problem I am experiencing with newrole. When I use newrole in permissive-mode I have no problems changing the role. Also I don't get any audit-messages.
But when I switch to enforcing-mode I cannot use newrole, it keeps telling me "incorrect password for root", although it clearly is correct. I suspect a problem in interaction between newrole and unix_chkpwd, but am not entirely sure about it.

Problem is that I don't get any audits from SELinux, only errors in auth.log from unix_chkpwd:
check_pass; user unknown
password check failer for user (root)

Quoted 4 lines

I am working with the latest reference-policy, adjusted here and there to fit the needs of my distro.

Thanks for any suggestions.

What version of pam are you using? What distro?
There were changes made to pam_unix and unix_chkpwd for selinux. Also, how are you building newrole?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

Just for the record, sent the initial reply to Stephen only. Sorry for the glitch.

Rest at the bottom.

Quoted 16 lines · On Tuesday 05 August 2008 22:13:34 Stephen Smalley wrote:
Quoted 15 lines · Dennis Wronka

Hi folks,

I'd like to ask about a problem I am experiencing with newrole. When I use newrole in permissive-mode I have no problems changing the role. Also I don't get any audit-messages.
But when I switch to enforcing-mode I cannot use newrole, it keeps telling me "incorrect password for root", although it clearly is correct. I suspect a problem in interaction between newrole and unix_chkpwd, but am not entirely sure about it.

Problem is that I don't get any audits from SELinux, only errors in auth.log from unix_chkpwd:
check_pass; user unknown
password check failer for user (root)

Quoted 8 lines
Quoted 4 lines

I am working with the latest reference-policy, adjusted here and there to fit the needs of my distro.

Thanks for any suggestions.

What version of pam are you using? What distro?
There were changes made to pam_unix and unix_chkpwd for selinux. Also, how are you building newrole?

I am using PAM 1.0.1 on the current development-version of EasyLFS. I am currently working on the integration of SELinux and seem to be hanging on this point.
I haven't set much focus towards newrole in the previous releases, but want to do so now.
newrole is the one from the policycoreutils 2.0.49, built simply with make && make install.

Btw, I think the same problem applies to run_init, will have to check to confirm though.

#3 lore raw
In reply to Dennis Wronka
Quoted 15 lines · Dennis Wronka

Hi folks,

I'd like to ask about a problem I am experiencing with newrole. When I use newrole in permissive-mode I have no problems changing the role. Also I don't get any audit-messages.
But when I switch to enforcing-mode I cannot use newrole, it keeps telling me "incorrect password for root", although it clearly is correct. I suspect a problem in interaction between newrole and unix_chkpwd, but am not entirely sure about it.

Problem is that I don't get any audits from SELinux, only errors in auth.log from unix_chkpwd:
check_pass; user unknown
password check failer for user (root)

Quoted 7 lines

I am working with the latest reference-policy, adjusted here and there to fit the needs of my distro.

Thanks for any suggestions.

Dennis

You can try using semodule -DB to turn off the dontaudits and see if you get any AVCs then.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

Quoted 25 lines · On Tuesday 05 August 2008 22:17:19 Xavier Toth wrote:
Quoted 15 lines · Dennis Wronka

Hi folks,

I'd like to ask about a problem I am experiencing with newrole. When I use newrole in permissive-mode I have no problems changing the role. Also I don't get any audit-messages.
But when I switch to enforcing-mode I cannot use newrole, it keeps telling me "incorrect password for root", although it clearly is correct. I suspect a problem in interaction between newrole and unix_chkpwd, but am not entirely sure about it.

Problem is that I don't get any audits from SELinux, only errors in auth.log from unix_chkpwd:
check_pass; user unknown
password check failer for user (root)

Quoted 6 lines

I am working with the latest reference-policy, adjusted here and there to fit the needs of my distro.

Thanks for any suggestions.

Dennis

You can try using semodule -DB to turn off the dontaudits and see if you get any AVCs then.

#5 lore raw
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
Quoted 34 lines · Stephen Smalley
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

--
Stephen Smalley
National Security Agency

Quoted 5 lines

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

I usually just type passwd in a terminal
and update the database. then choose you're role
and do the same for that role if need be.
but depending on what you have, this might be a different case. hope this helps.
regards;

Signature · 6 lines
Justin P. Mattock

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw

-------- Original-Nachricht --------

Quoted 48 lines

Datum: Tue, 5 Aug 2008 08:04:34 -0700
Von: "Justin Mattock" <[email protected]>
An: "Stephen Smalley" <[email protected]>
CC: "Dennis Wronka" <[email protected]>, "Xavier Toth" <[email protected]>, "SELinux Mailing List" <[email protected]>
Betreff: Re: Question about newrole

Quoted 29 lines · Stephen Smalley
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Quoted 8 lines

--
Stephen Smalley
National Security Agency

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected]

with

Quoted 2 lines

the words "unsubscribe selinux" without quotes as the message.

Quoted 9 lines

I usually just type passwd in a terminal
and update the database. then choose you're role
and do the same for that role if need be.
but depending on what you have, this might be a different case. hope this helps.
regards;

Signature · 1 line
Justin P. Mattock

What I actually want to use newrole for is not resetting passwords. I was thinking to introduce MLS to the next release and thus require the user to transition to secadm_r if he wants to switch from enforcing to permissive.

Signature · 7 lines
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw
Quoted 57 lines · Dennis Wronka

-------- Original-Nachricht --------

Quoted 55 lines

Datum: Tue, 5 Aug 2008 08:04:34 -0700
Von: "Justin Mattock" <[email protected]>
An: "Stephen Smalley" <[email protected]>
CC: "Dennis Wronka" <[email protected]>, "Xavier Toth" <[email protected]>, "SELinux Mailing List" <[email protected]>
Betreff: Re: Question about newrole

Quoted 29 lines · Stephen Smalley
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Quoted 8 lines

--
Stephen Smalley
National Security Agency

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected]

with

Quoted 2 lines

the words "unsubscribe selinux" without quotes as the message.

I usually just type passwd in a terminal
and update the database. then choose you're role
and do the same for that role if need be.
but depending on what you have, this might be a different case. hope this helps.
regards;

Quoted 8 lines
Quoted 2 lines

--
Justin P. Mattock

What I actually want to use newrole for is not resetting passwords. I was thinking to introduce MLS to the next release and thus require the user to transition to secadm_r if he wants to switch from enforcing to permissive. --
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

O.k.
I thaught you were getting
a permisions denied when entering newrole -r *
I receive this normally on a fresh install, then
after updating the database, everything is good.
regards;

Signature · 6 lines
Justin P. Mattock

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#9 lore raw
In reply to Stephen Smalley

-------- Original-Nachricht --------

Quoted 26 lines

Datum: Tue, 05 Aug 2008 10:48:55 -0400
Von: Stephen Smalley <[email protected]>
An: Dennis Wronka <[email protected]>
CC: Xavier Toth <[email protected]>, SELinux Mailing List <[email protected]>
Betreff: Re: Question about newrole

Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

Quoted 19 lines

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Signature · 9 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected]
with
the words "unsubscribe selinux" without quotes as the message.

Also running newrole as regular user (running as staff_u:staff_r:staff_t, trying to transition to sysadm_r) gets me the same message, just with dennis as username.

I also tried setting unix_chkpwd set-uid root already, but even that didn't help.

I'll turn on the audit-messages again and see if there's anything that maybe shows that unix_chkpwd is not allowed to read shadow.

Signature · 7 lines
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#10 lore raw
Quoted 57 lines · Dennis Wronka

-------- Original-Nachricht --------

Quoted 40 lines

Datum: Tue, 05 Aug 2008 10:48:55 -0400
Von: Stephen Smalley <[email protected]>
An: Dennis Wronka <[email protected]>
CC: Xavier Toth <[email protected]>, SELinux Mailing List <[email protected]>
Betreff: Re: Question about newrole

Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

--
Stephen Smalley
National Security Agency

Quoted 5 lines

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.

Also running newrole as regular user (running as staff_u:staff_r:staff_t, trying to transition to sysadm_r) gets me the same message, just with dennis as username.

I also tried setting unix_chkpwd set-uid root already, but even that didn't help.

I'll turn on the audit-messages again and see if there's anything that maybe shows that unix_chkpwd is not allowed to read shadow. --
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196

Quoted 5 lines

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Could be, you might need to make enableaudit
in you're policy directory to see:
allow system_chkpwd_t security_t:dir { getattr search }; allow system_chkpwd_t security_t:file read; allow system_chkpwd_t security_t:filesystem getattr;

these types of contexts or allow rules to login the role you want to use.

Signature · 7 lines
Justin P. Mattock


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#11 lore raw
In reply to Stephen Smalley
Quoted 19 lines · On Tuesday 05 August 2008 22:48:55 Stephen Smalley wrote:
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

Quoted 8 lines

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Okay, it looks like that unix_chkpwd is not allowed to read /etc/shadow when running in newrole_t.

Here's the message:
type=1400 audit(1217920543.235:26): avc: denied { read } for pid=1210 comm="unix_chkpwd" name="shadow" dev=dm-0 ino=29366926 scontext=staff_u:staff_r:newrole_t tcontext=system_u:object_r:shadow_t tclass=file

Is it safe to add the rule suggested by audit2allow "allow newrole_t shadow_t:file read;" to the policy or would there be a better way?

Wouldn't it in general be better if unix_chkpwd would transition into a domain for itself which then in turn is allowed to access /etc/shadow?

#12 lore raw
Quoted 38 lines · Dennis Wronka
Quoted 19 lines · On Tuesday 05 August 2008 22:48:55 Stephen Smalley wrote:
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

Quoted 8 lines

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Okay, it looks like that unix_chkpwd is not allowed to read /etc/shadow when running in newrole_t.

Here's the message:
type=1400 audit(1217920543.235:26): avc: denied { read } for pid=1210 comm="unix_chkpwd" name="shadow" dev=dm-0 ino=29366926 scontext=staff_u:staff_r:newrole_t tcontext=system_u:object_r:shadow_t tclass=file

Quoted 5 lines

Is it safe to add the rule suggested by audit2allow "allow newrole_t shadow_t:file read;" to the policy or would there be a better way?

Wouldn't it in general be better if unix_chkpwd would transition into a domain for itself which then in turn is allowed to access /etc/shadow?

unix_chkpwd is supposed to transition into its own domain already. Is it properly labeled (ls -Z /sbin/unix_chkpwd)? It should have the chkpwd_exec_t type. And newrole_t should transition to the system_chkpwd_t domain upon executing it.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#13 lore raw
Quoted 43 lines · On Tuesday 05 August 2008 23:36:40 Stephen Smalley wrote:
Quoted 42 lines · Dennis Wronka
Quoted 20 lines · On Tuesday 05 August 2008 22:48:55 Stephen Smalley wrote:
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

Quoted 8 lines

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Okay, it looks like that unix_chkpwd is not allowed to read /etc/shadow when running in newrole_t.

Here's the message:
type=1400 audit(1217920543.235:26): avc: denied { read } for pid=1210 comm="unix_chkpwd" name="shadow" dev=dm-0 ino=29366926 scontext=staff_u:staff_r:newrole_t tcontext=system_u:object_r:shadow_t tclass=file

Is it safe to add the rule suggested by audit2allow "allow newrole_t shadow_t:file read;" to the policy or would there be a better way?

Quoted 7 lines
Quoted 2 lines

Wouldn't it in general be better if unix_chkpwd would transition into a domain for itself which then in turn is allowed to access /etc/shadow?

unix_chkpwd is supposed to transition into its own domain already. Is it properly labeled (ls -Z /sbin/unix_chkpwd)? It should have the chkpwd_exec_t type. And newrole_t should transition to the system_chkpwd_t domain upon executing it.

Thanks Stephen, that was the magic hint I believe.
My unix_chkpwd and unix_update were still in the position they got put by the PAM-installation (gotta check the install-script if there's a way to put them directly into /sbin). I moved them over, checked with restorecon and now it works.
Just had to put symlinks back to the original place because otherwise login didn't work. Will have to check if I really need these symlinks or if I can do without (Fedora 9 seems to get along without, so there must be a way for me to do it too).

#14 lore raw
Quoted 52 lines · Dennis Wronka
Quoted 43 lines · On Tuesday 05 August 2008 23:36:40 Stephen Smalley wrote:
Quoted 42 lines · Dennis Wronka
Quoted 20 lines · On Tuesday 05 August 2008 22:48:55 Stephen Smalley wrote:
Quoted 5 lines · Dennis Wronka

Thanks.
That seems to help quite a bit.
I now get some messages. For example it seems that newrole wants to read /etc/shadow directly.
Will check those messages and play around with the policy.

The way it works is that pam_unix attempts to open /etc/shadow directly for reading, and if it fails, it falls back to running unix_chkpwd to perform the password check. SELinux policy prohibits most programs from directly reading /etc/shadow, including even ones that run as root, and forces them to go through unix_chkpwd instead, in order to limit the set of processes that have full read access to the shadow password file.

The logic to try to open /etc/shadow and fall back to unix_chkpwd already existed before SELinux in order to support non-root processes re-authenticating the current user. What changed with SELinux was that it could also happen for root processes.

Quoted 8 lines

The current policy dontaudit's the attempt to directly read /etc/shadow to avoid noise. When you did semodule -DB, you turned on that auditing. But those denials are what is expected, and allowing them will mean giving newrole direct read access to /etc/shadow (although that will only work if running as root, of course, as otherwise it has to use a suid helper like unix_chkpwd anyway).

Does newrole work for you as a non-root user?

Okay, it looks like that unix_chkpwd is not allowed to read /etc/shadow when running in newrole_t.

Here's the message:
type=1400 audit(1217920543.235:26): avc: denied { read } for pid=1210 comm="unix_chkpwd" name="shadow" dev=dm-0 ino=29366926 scontext=staff_u:staff_r:newrole_t tcontext=system_u:object_r:shadow_t tclass=file

Is it safe to add the rule suggested by audit2allow "allow newrole_t shadow_t:file read;" to the policy or would there be a better way?

Quoted 7 lines
Quoted 2 lines

Wouldn't it in general be better if unix_chkpwd would transition into a domain for itself which then in turn is allowed to access /etc/shadow?

unix_chkpwd is supposed to transition into its own domain already. Is it properly labeled (ls -Z /sbin/unix_chkpwd)? It should have the chkpwd_exec_t type. And newrole_t should transition to the system_chkpwd_t domain upon executing it.

Quoted 10 lines

Thanks Stephen, that was the magic hint I believe.
My unix_chkpwd and unix_update were still in the position they got put by the PAM-installation (gotta check the install-script if there's a way to put them directly into /sbin). I moved them over, checked with restorecon and now it works.
Just had to put symlinks back to the original place because otherwise login didn't work. Will have to check if I really need these symlinks or if I can do without (Fedora 9 seems to get along without, so there must be a way for me to do it too).

Cool, glad to see you're up and running.

Signature · 6 lines
Justin P. Mattock

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.