generic pam authentication
Hi,
I'm trying to configure my system to use Kerberos, and I've been hacking Kerry Thompson's kerberos.te. One issue that has seemed common among many programs is that they require many additional privileges when pam_krb5 is inserted into the stack. For example, when I use "passwd", I get at least:
allow passwd_t krb5_conf_t:file { getattr }; allow passwd_t net_conf_t:file { read }; allow passwd_t passwd_t:udp_socket { create }; allow passwd_t urandom_device_t:chr_file { read };
What I think might be nice is a generic macro, say uses_pam(passwd) which would grant any privileges necessary to use the libraries in the PAM stack. This macro would be defined in domains/pam.te, and would be intended for customization by the administrator. For example, if the administrator decided to use PostgreSQL for holding user data, they could insert the necessary privileges to talk to postgresql_port_t.
Before doing something this invasive, I'd like to see what opinions are.
You would need a macro that provides all the capabilities needed by each plugin that is (or might be, I guess) in the pam stack. Each plugin might require different capabilities.
Idealy, what would be nice is to have capabilities for the code that belongs to shared libraries---so that as long as that code is executing, it has certain privileges and those privileges go away as soon as the shared library code returns to the caller.
--Dean
Quoted 13 lines · Colin Walters
Hi,
I'm trying to configure my system to use Kerberos, and I've been hacking Kerry Thompson's kerberos.te. One issue that has seemed common among many programs is that they require many additional privileges when
pam_krb5is inserted into the stack. For example, when I use "passwd", I get at least:allow
passwd_tkrb5_conf_t:file { getattr }; allowpasswd_tnet_conf_t:file { read }; allowpasswd_tpasswd_t:udp_socket { create }; allowpasswd_turandom_device_t:chr_file { read };
Quoted 10 lines
What I think might be nice is a generic macro, say
uses_pam(passwd)which would grant any privileges necessary to use the libraries in the PAM stack. This macro would be defined in domains/pam.te, and would be intended for customization by the administrator. For example, if the administrator decided to use PostgreSQL for holding user data, they could insert the necessary privileges to talk topostgresql_port_t.Before doing something this invasive, I'd like to see what opinions are.
--
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.
Quoted 3 lines · Dean Anderson
You would need a macro that provides all the capabilities needed by each plugin that is (or might be, I guess) in the pam stack. Each plugin might require different capabilities.
Yes, that's what I was saying.
Quoted 4 lines
Idealy, what would be nice is to have capabilities for the code that belongs to shared libraries---so that as long as that code is executing, it has certain privileges and those privileges go away as soon as the shared library code returns to the caller.
Not possible in the current SELinux model.
Ok, here is a first cut at this. Instead of having a uses_pam macro, I realized that the existing attributes "auth", "auth_chkpwd", and "auth_write" were conceptually what I want, except they only work withpam_unix. All the attributes did before was grant various privileges
to read/write shadow_t or exec unix_chkpwd. At a higher level, I think it makes sense to simply extend the meaning of those attributes to allow the permissions corresponding to the pam stack.
What this patch does is move most of the relevant permissions inside pam.te. Additionally, I started on generic permissions for Kerberos authentication, which seems to work for GSSAPI+ssh and passwd (with pam_krb5 in the password stack).
* added files
{arch}/policy/policy--main/policy--main--0/[email protected]/patch-log/patch-8* modified files
domains/program/kerberos.te +0 -14
@@ -88,17 +88,3 @@ # Allow user programs to talk to KDC allow krb5kdc_t userdomain:udp_socket { recvfrom }; allow userdomain krb5kdc_t:udp_socket { recvfrom }; - -ifdef(`ssh.te', ` -# -# Rules for OpenSSH sshd server and ssh client compiled -# with Kerberos support -# see also macros/program/ssh_macros.te -allow krb5kdc_t sshd_t:udp_socket { recvfrom }; -allow sshd_t krb5kdc_t:udp_socket { recvfrom }; -allow sshd_t krb5_keytab_t:file { lock read }; - -# sshd destroys kinit-created tickets on exit - -allow sshd_t tmp_t:file { getattr read write }; -')
domains/program/pam.te +38 -0
@@ -34,3 +34,41 @@ allow pam_t local_login_t:fd { use }; dontaudit pam_t pam_t:capability { sys_tty_config }; + +## pam_unix +# auth +allow auth shadow_t:file { getattr read }; +# auth_chkpwd +ifdef(`chkpwd.te',` +domain_auto_trans(auth_chkpwd, chkpwd_exec_t, system_chkpwd_t) +role system_r types system_chkpwd_t; +') +dontaudit auth_chkpwd shadow_t:file { getattr read }; +allow auth_chkpwd sbin_t:dir search; + +# auth_write +allow auth_write { etc_t shadow_t }:file { relabelfrom relabelto }; + +## pam_krb5 +ifdef(`kerberos.te',` + +# auth, auth_chkpwd +define(`kerberos_auth_privs',` +allow $1 krb5_conf_t:file { getattr read }; +dontaudit $1 krb5_conf_t:file { write }; +allow $1 net_conf_t:file { getattr read }; +can_network($1) +can_tcp_connect($1, kerberos_port_t) +can_udp_send($1, kerberos_port_t) +allow $1 urandom_device_t:chr_file { getattr read }; +') +kerberos_auth_privs(auth) +kerberos_auth_privs(auth_chkpwd) + +# auth_write +kerberos_auth_privs(auth_write) +can_tcp_connect(auth_write, kerberos_admin_port_t) +can_udp_send(auth_write, kerberos_admin_port_t) + +') +
domains/program/passwd.te +0 -1
@@ -66,7 +66,6 @@ base_passwd_domain($1, `auth_write, privowner') # Update /etc/shadow and /etc/passwd file_type_auto_trans($1_t, etc_t, shadow_t, file) -allow $1_t { etc_t shadow_t }:file { relabelfrom relabelto }; can_setfscreate($1_t) ')
domains/program/ssh.te +4 -0
@@ -221,6 +221,10 @@ dontaudit sshd_t krb5_conf_t:file { write }; allow sshd_t krb5_conf_t:file { getattr read }; +ifdef(`kerberos.te',` +allow sshd_t krb5_keytab_t:file { lock read }; +') + # ssh_keygen_t is the type of the ssh-keygen program when run at install time # and by sysadm_t daemon_base_domain(ssh_keygen)
macros/program/chkpwd_macros.te +1 -6
@@ -22,12 +22,7 @@ can_getcon($1_chkpwd_t) can_ypbind($1_chkpwd_t) # Transition from the user domain to this domain. -ifelse($1, system, ` -domain_auto_trans(auth_chkpwd, chkpwd_exec_t, system_chkpwd_t) -role system_r types system_chkpwd_t; -dontaudit auth_chkpwd shadow_t:file { getattr read }; -allow auth_chkpwd sbin_t:dir search; -', ` +ifelse($1, system, `', ` domain_auto_trans($1_t, chkpwd_exec_t, $1_chkpwd_t) allow $1_t sbin_t:dir search;
Quoted 6 lines · Colin Walters
What I think might be nice is a generic macro, say
uses_pam(passwd)which would grant any privileges necessary to use the libraries in the PAM stack. This macro would be defined in domains/pam.te, and would be intended for customization by the administrator. For example, if the administrator decided to use PostgreSQL for holding user data, they could insert the necessary privileges to talk topostgresql_port_t.
That sounds like the correct approach.
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- 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.
Quoted 9 lines · Russell Coker
Quoted 6 lines · Colin Walters
What I think might be nice is a generic macro, say
uses_pam(passwd)which would grant any privileges necessary to use the libraries in the PAM stack. This macro would be defined in domains/pam.te, and would be intended for customization by the administrator. For example, if the administrator decided to use PostgreSQL for holding user data, they could insert the necessary privileges to talk topostgresql_port_t.That sounds like the correct approach.
Are you saying this after having seen my patch which uses the existing attributes?