Skip to contentSkip to conversation

sshd policy

PATCH Russell Coker 3 participants 6 messages Jun 23, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

I have attached the source files and the diff for a change to the way sshd works.

Recent versions of OpenSSH by default will re-exec the sshd as part of the login process. This means that there is no need for one process to have all the permissions that sshd is usually granted. So I have split up the sshd policy into two domains, one of which listens on the port and the other does most of the sshd work.

Signature · 4 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
program/ssh.te renamed from program/ssh.te.orig +41 -17
@@ -9,6 +9,9 @@
 # Allow ssh logins as sysadm_r:sysadm_t
 bool ssh_sysadm_login false;
 
+# allow host key based authentication
+bool allow_ssh_keysign false;
+
 ifdef(`inetd.te', `
 # Allow ssh to run from inetd instead of as a daemon.
 bool run_ssh_inetd false;
@@ -23,12 +26,34 @@
 # privowner is for changing the identity on the terminal device
 # privfd is for passing the terminal file handle to the user process
 # auth_chkpwd is for running unix_chkpwd and unix_verify.
+type $1_launcher_t, domain, privlog, nscd_client_domain;
 type $1_t, domain, privuser, privrole, privlog, privowner, privfd, auth_chkpwd, nscd_client_domain, mlsfileread, mlsfilewrite, mlsfileupgrade, mlsfiledowngrade, mlsprocsetsl;
-can_exec($1_t, sshd_exec_t)
+domain_auto_trans($1_launcher_t, sshd_exec_t, $1_t)
+allow $1_t $1_launcher_t:tcp_socket rw_socket_perms;
+allow $1_t $1_launcher_t:unix_stream_socket rw_socket_perms;
+allow $1_launcher_t devtty_t:chr_file { read write };
+allow $1_launcher_t selinux_config_t:dir search;
+allow $1_launcher_t selinux_config_t:file { getattr read };
+allow $1_launcher_t self:dir r_dir_perms;
+
+allow $1_launcher_t { proc_t self }:dir search;
+allow $1_launcher_t proc_t:lnk_file read;
+allow $1_launcher_t self:file { getattr read };
+can_network_server($1_launcher_t)
+allow $1_launcher_t var_t:dir getattr;
+allow $1_launcher_t self:process { fork sigchld };
+allow $1_launcher_t sbin_t:dir search;
+
+allow $1_launcher_t { random_device_t urandom_device_t }:chr_file { getattr read };
+allow $1_launcher_t self:capability { setgid sys_chroot };
+allow $1_launcher_t self:unix_dgram_socket create_socket_perms;
+allow $1_launcher_t self:unix_stream_socket create_stream_socket_perms;
+allow $1_launcher_t { etc_t sshd_key_t }:file { getattr read };
+
 r_dir_file($1_t, self)
-role system_r types $1_t;
+role system_r types { $1_t $1_launcher_t };
 dontaudit $1_t shadow_t:file { getattr read };
-uses_shlib($1_t)
+uses_shlib({ $1_launcher_t $1_t })
 allow $1_t self:unix_dgram_socket create_socket_perms;
 allow $1_t self:unix_stream_socket create_stream_socket_perms;
 allow $1_t self:fifo_file rw_file_perms;
@@ -48,8 +73,9 @@
 # Read /var.
 allow $1_t var_t:dir { getattr search };
 
-# Read /var/log.
+# write failure logs
 allow $1_t var_log_t:dir search;
+allow $1_t faillog_t:file { append getattr };
 
 # Read /etc.
 allow $1_t etc_t:dir search;
@@ -104,7 +130,7 @@
 # Update /var/log/lastlog.
 allow $1_t lastlog_t:file rw_file_perms;
 
-read_locale($1_t)
+read_locale({ $1_launcher_t $1_t })
 read_sysctl($1_t)
 
 # Can create ptys
@@ -157,7 +183,7 @@
 sshd_spawn_domain(sshd_extern, user_mini_domain, mini_pty_type)
 
 # for when the network connection breaks after running newrole -r sysadm_r
-dontaudit sshd_t sysadm_devpts_t:chr_file setattr;
+dontaudit sshd_launcher_t sysadm_devpts_t:chr_file setattr;
 
 # Allow checking users mail at login
 allow sshd_t { var_spool_t mail_spool_t }:dir search;
@@ -174,30 +200,30 @@
 allow { sshd_t sshd_extern_t } self:process signal;
 } else {
 ')
-allow { sshd_t sshd_extern_t } initrc_devpts_t:chr_file rw_file_perms;
-allow { sshd_t sshd_extern_t } self:capability net_bind_service;
-allow { sshd_t sshd_extern_t } ssh_port_t:tcp_socket name_bind;
+allow { sshd_launcher_t sshd_extern_launcher_t } initrc_devpts_t:chr_file rw_file_perms;
+allow { sshd_launcher_t sshd_extern_launcher_t } self:capability net_bind_service;
+allow { sshd_launcher_t sshd_extern_launcher_t } ssh_port_t:tcp_socket name_bind;
 
 # for port forwarding
 can_tcp_connect(userdomain, sshd_t)
 
-domain_auto_trans(initrc_t, sshd_exec_t, sshd_t)
-domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
+domain_auto_trans(initrc_t, sshd_exec_t, sshd_launcher_t)
+domain_trans(initrc_t, sshd_exec_t, sshd_extern_launcher_t)
 dontaudit initrc_t sshd_key_t:file { getattr read };
 
 # Inherit and use descriptors from init.
-allow { sshd_t sshd_extern_t } init_t:fd use;
+allow { sshd_launcher_t sshd_extern_launcher_t } init_t:fd use;
 ifdef(`inetd.te', `
 }
 ')
 
 # Create /var/run/sshd.pid
-var_run_domain(sshd)
-var_run_domain(sshd_extern)
+var_run_domain(sshd_launcher)
+var_run_domain(sshd_extern_launcher)
 
 ifdef(`direct_sysadm_daemon', `
 # Direct execution by sysadm_r.
-domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
+domain_auto_trans(sysadm_t, sshd_exec_t, sshd_launcher_t)
 role_transition sysadm_r sshd_exec_t system_r;
 ')
 
@@ -227,5 +253,3 @@
 allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
 allow ssh_keygen_t sysadm_tty_device_t:chr_file { read write };
 allow ssh_keygen_t urandom_device_t:chr_file { getattr read };
-allow sshd_t faillog_t:file { append getattr };
-allow sshd_t sbin_t:file getattr;
program/ssh.fc renamed from program/ssh.fc.orig +1 -1
@@ -8,7 +8,7 @@
 /etc/ssh/ssh_host_dsa_key --	system_u:object_r:sshd_key_t
 /etc/ssh/ssh_host_rsa_key --	system_u:object_r:sshd_key_t
 /usr/sbin/sshd	        --	system_u:object_r:sshd_exec_t
-/var/run/sshd\.init\.pid	--	system_u:object_r:sshd_var_run_t
+/var/run/sshd\.init\.pid	--	system_u:object_r:sshd_launcher_var_run_t
 # subsystems
 /usr/lib(64)?/misc/sftp-server --	system_u:object_r:bin_t
 /usr/libexec/openssh/sftp-server -- system_u:object_r:bin_t
# ssh
/usr/bin/ssh		--	system_u:object_r:ssh_exec_t
/usr/libexec/openssh/ssh-keysign -- system_u:object_r:ssh_keysign_exec_t
/usr/bin/ssh-keygen	--	system_u:object_r:ssh_keygen_exec_t
# sshd
/etc/ssh/primes		--	system_u:object_r:sshd_key_t
/etc/ssh/ssh_host_key 	--	system_u:object_r:sshd_key_t
/etc/ssh/ssh_host_dsa_key --	system_u:object_r:sshd_key_t
/etc/ssh/ssh_host_rsa_key --	system_u:object_r:sshd_key_t
/usr/sbin/sshd	        --	system_u:object_r:sshd_exec_t
/var/run/sshd\.init\.pid	--	system_u:object_r:sshd_launcher_var_run_t
# subsystems
/usr/lib(64)?/misc/sftp-server --	system_u:object_r:bin_t
/usr/libexec/openssh/sftp-server -- system_u:object_r:bin_t
/usr/lib(64)?/sftp-server	--	system_u:object_r:bin_t
ifdef(`distro_suse', `
/usr/lib(64)?/ssh/.*	--	system_u:object_r:bin_t
')
ifdef(`targeted_policy', `', `
HOME_DIR/\.ssh(/.*)?		system_u:object_r:ROLE_home_ssh_t
')
#DESC SSH - SSH daemon
#
# Authors:  Anthony Colatrella (NSA) <[email protected]>
#           Stephen Smalley <[email protected]>
#           Russell Coker <[email protected]>

# X-Debian-Packages: ssh
#

# Allow ssh logins as sysadm_r:sysadm_t
bool ssh_sysadm_login false;

# allow host key based authentication
bool allow_ssh_keysign false;

ifdef(inetd.te',
# Allow ssh to run from inetd instead of as a daemon. bool run_ssh_inetd false;
')

# sshd_exec_t is the type of the sshd executable.
# sshd_key_t is the type of the ssh private key files
type sshd_exec_t, file_type, exec_type, sysadmfile;
type sshd_key_t, file_type, sysadmfile;

define(sshd_program_domain',

# privowner is for changing the identity on the terminal device
# privfd is for passing the terminal file handle to the user process
# auth_chkpwd is for running unix_chkpwd and unix_verify.
type $1_launcher_t, domain, privlog, nscd_client_domain;
type $1_t, domain, privuser, privrole, privlog, privowner, privfd, auth_chkpwd, nscd_client_domain, mlsfileread, mlsfilewrite, mlsfileupgrade, mlsfiledowngrade, mlsprocsetsl;
domain_auto_trans($1_launcher_t, sshd_exec_t, $1_t)
allow $1_t $1_launcher_t:tcp_socket rw_socket_perms;
allow $1_t $1_launcher_t:unix_stream_socket rw_socket_perms;
allow $1_launcher_t devtty_t:chr_file { read write };
allow $1_launcher_t selinux_config_t:dir search;
allow $1_launcher_t selinux_config_t:file { getattr read };
allow $1_launcher_t self:dir r_dir_perms;

allow $1_launcher_t { proc_t self }:dir search; allow $1_launcher_t proc_t:lnk_file read; allow $1_launcher_t self:file { getattr read }; can_network_server($1_launcher_t)
allow $1_launcher_t var_t:dir getattr; allow $1_launcher_t self:process { fork sigchld }; allow $1_launcher_t sbin_t:dir search;

allow $1_launcher_t { random_device_t urandom_device_t }:chr_file { getattr read }; allow $1_launcher_t self:capability { setgid sys_chroot };
allow $1_launcher_t self:unix_dgram_socket create_socket_perms;
allow $1_launcher_t self:unix_stream_socket create_stream_socket_perms; allow $1_launcher_t { etc_t sshd_key_t }:file { getattr read };

r_dir_file($1_t, self)
role system_r types { $1_t $1_launcher_t };
dontaudit $1_t shadow_t:file { getattr read }; uses_shlib({ $1_launcher_t $1_t })
allow $1_t self:unix_dgram_socket create_socket_perms; allow $1_t self:unix_stream_socket create_stream_socket_perms; allow $1_t self:fifo_file rw_file_perms;
allow $1_t self:process { fork sigchld signal setsched setrlimit };

dontaudit $1_t self:lnk_file read;

# do not allow statfs()
dontaudit $1_t fs_type:filesystem getattr;

allow $1_t bin_t:dir search;
allow $1_t bin_t:lnk_file read;

# for sshd subsystems, such as sftp-server.
allow $1_t bin_t:file getattr;

# Read /var.
allow $1_t var_t:dir { getattr search };

# write failure logs
allow $1_t var_log_t:dir search;
allow $1_t faillog_t:file { append getattr };

# Read /etc.
allow $1_t etc_t:dir search;

# ioctl is for pam_console
dontaudit $1_t etc_t:file ioctl;
allow $1_t etc_t:file { getattr read };
allow $1_t etc_t:lnk_file { getattr read };
allow $1_t etc_runtime_t:file { getattr read };

# Read and write /dev/tty and /dev/null.
allow $1_t devtty_t:chr_file rw_file_perms;
allow $1_t { null_device_t zero_device_t }:chr_file rw_file_perms;

# Read /dev/urandom
allow $1_t urandom_device_t:chr_file { getattr read };

can_network($1_t)
allow $1_t port_type:tcp_socket name_connect;
can_kerberos($1_t)

allow $1_t self:capability { audit_control kill sys_chroot sys_resource chown dac_override fowner fsetid setgid setuid sys_tty_config }; allow $1_t { home_root_t home_dir_type }:dir { search getattr };
if (use_nfs_home_dirs) {
allow $1_t autofs_t:dir { search getattr };
allow $1_t nfs_t:dir { search getattr };
allow $1_t nfs_t:file { getattr read };
}

if (use_samba_home_dirs) {
allow $1_t cifs_t:dir { search getattr };
allow $1_t cifs_t:file { getattr read };
}

# Set exec context.
can_setexec($1_t)

# Update utmp.
allow $1_t initrc_var_run_t:file rw_file_perms;

# Update wtmp.
allow $1_t wtmp_t:file rw_file_perms;

# Get security policy decisions.
can_getsecurity($1_t)

# Allow read access to login context
r_dir_file( $1_t, default_context_t)

# Access key files
allow $1_t sshd_key_t:file { getattr read };

# Update /var/log/lastlog.
allow $1_t lastlog_t:file rw_file_perms;

read_locale({ $1_launcher_t $1_t })
read_sysctl($1_t)

# Can create ptys
can_create_pty($1, `, server_pty')
allow $1_t $1_devpts_t:chr_file { setattr getattr relabelfrom }; dontaudit sshd_t userpty_type:chr_file relabelfrom; ')dnl end sshd_program_domain

# macro for defining which domains a sshd can spawn
# $1_t is the domain of the sshd, $2 is the domain to be spawned, $3 is the
# type of the pty for the child
define(`sshd_spawn_domain', `
login_spawn_domain($1, $2)
ifdef(`xauth.te', `
domain_trans($1_t, xauth_exec_t, $2)
')

# Relabel and access ptys created by sshd

# ioctl is necessary for logout() processing for utmp entry and for w to
# display the tty.
# some versions of sshd on the new SE Linux require setattr
allow $1_t $3:chr_file { relabelto read write getattr ioctl setattr };
# inheriting stream sockets is needed for "ssh host command" as no pty
# is allocated
allow $2 $1_t:unix_stream_socket rw_stream_socket_perms;
')dnl end sshd_spawn_domain definition

#################################
#
# Rules for the sshd_t domain, et al.
#

# sshd_t is the domain for the sshd program.
# sshd_extern_t is the domain for ssh from outside our network
#
sshd_program_domain(sshd)
if (ssh_sysadm_login) {
sshd_spawn_domain(sshd, userdomain, { sysadm_devpts_t userpty_type })
} else {
sshd_spawn_domain(sshd, unpriv_userdomain, userpty_type)
}

ifdef(use_x_ports',

# for X forwarding
allow sshd_t xserver_port_t:tcp_socket name_bind;
')

r_dir_file(sshd_t, selinux_config_t) sshd_program_domain(sshd_extern) sshd_spawn_domain(sshd_extern, user_mini_domain, mini_pty_type)

# for when the network connection breaks after running newrole -r sysadm_r
dontaudit sshd_launcher_t sysadm_devpts_t:chr_file setattr;

# Allow checking users mail at login
allow sshd_t { var_spool_t mail_spool_t }:dir search; allow sshd_t mail_spool_t:lnk_file read; allow sshd_t mail_spool_t:file getattr;

ifdef(inetd.te',
if (run_ssh_inetd) {
allow inetd_t ssh_port_t:tcp_socket name_bind;
domain_auto_trans(inetd_t, sshd_exec_t, sshd_t)
domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
allow { sshd_t sshd_extern_t } inetd_t:tcp_socket rw_socket_perms;
allow { sshd_t sshd_extern_t } var_run_t:dir { getattr search };
allow { sshd_t sshd_extern_t } self:process signal;
} else {
')
allow { sshd_launcher_t sshd_extern_launcher_t } initrc_devpts_t:chr_file rw_file_perms; allow { sshd_launcher_t sshd_extern_launcher_t } self:capability net_bind_service; allow { sshd_launcher_t sshd_extern_launcher_t } ssh_port_t:tcp_socket name_bind;

# for port forwarding
can_tcp_connect(userdomain, sshd_t)

domain_auto_trans(initrc_t, sshd_exec_t, sshd_launcher_t) domain_trans(initrc_t, sshd_exec_t, sshd_extern_launcher_t) dontaudit initrc_t sshd_key_t:file { getattr read };

# Inherit and use descriptors from init.
allow { sshd_launcher_t sshd_extern_launcher_t } init_t:fd use; ifdef(inetd.te',
}
')

# Create /var/run/sshd.pid
var_run_domain(sshd_launcher)
var_run_domain(sshd_extern_launcher)

ifdef(direct_sysadm_daemon',
# Direct execution by sysadm_r. domain_auto_trans(sysadm_t, sshd_exec_t, sshd_launcher_t) role_transition sysadm_r sshd_exec_t system_r; ')

undefine(`sshd_program_domain')

# so a tunnel can point to another ssh tunnel...
can_tcp_connect(sshd_t, sshd_t)

tmp_domain(sshd, `', { dir file sock_file })
ifdef(pam.te',
can_exec(sshd_t, pam_exec_t)
')

# 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)
allow ssh_keygen_t etc_t:file { getattr read };
file_type_auto_trans(ssh_keygen_t, etc_t, sshd_key_t, file)

# Type for the ssh executable.
type ssh_exec_t, file_type, exec_type, sysadmfile; type ssh_keysign_exec_t, file_type, exec_type, sysadmfile;

# Everything else is in the ssh_domain macro in

# macros/program/ssh_macros.te.

allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms; allow ssh_keygen_t sysadm_tty_device_t:chr_file { read write }; allow ssh_keygen_t urandom_device_t:chr_file { getattr read };

#1 lore raw
Quoted 10 lines · Russell Coker

I have attached the source files and the diff for a change to the way sshd works.

Recent versions of OpenSSH by default will re-exec the sshd as part of the login process. This means that there is no need for one process to have all the permissions that sshd is usually granted. So I have split up the sshd policy into two domains, one of which listens on the port and the other does most of the sshd work.

can_network_server($1_launcher_t)

Protocol? Port?

Quoted 2 lines

allow $1_launcher_t self:unix_dgram_socket create_socket_perms; allow $1_launcher_t self:unix_stream_socket

create_stream_socket_perms;
...

Quoted 2 lines

allow $1_t $1_launcher_t:tcp_socket rw_socket_perms; allow $1_t $1_launcher_t:unix_stream_socket rw_socket_perms;

Should launcher be able to rw the dgram socket as well? Should those rules be put together, or am I misunderstanding how it works?

Quoted 2 lines
# do not allow statfs()
dontaudit $1_t fs_type:filesystem getattr;

Is this sufficient? Can you look and see if samba needs this as well? In particular, after mounting SMB filesystem, df generates denials, and that's a bugzilla currently. However, I think fs_type didn't quite work for that case - I was seeing denials on the top level directory, whether it was fs_type or not. Related rules are also in gnome-vfs-daemon.te (not sure if that's merged).

Quoted 1 line

allow $1_t port_type:tcp_socket name_connect;

Protocol? Port?

Quoted 11 lines

allow $1_t { home_root_t home_dir_type }:dir { search getattr }; if (use_nfs_home_dirs) {
allow $1_t autofs_t:dir { search getattr };
allow $1_t nfs_t:dir { search getattr };
allow $1_t nfs_t:file { getattr read };
}

if (use_samba_home_dirs) {
allow $1_t cifs_t:dir { search getattr };
allow $1_t cifs_t:file { getattr read };
}

Please no more NFS/CIFS block of this kind - I specifically tried to macro-ize this. Also, why is this necessary? Why is sshd reading the home directories?

Signature · 8 lines
Ivan Gyurdiev <[email protected]>
Cornell University


--
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
Quoted 3 lines · Ivan Gyurdiev
Quoted 1 line

can_network_server($1_launcher_t)

Protocol? Port?

I had just copied the policy from $1_t. It seems that none of this will work, but if in future we find a way to make it work then you are correct that the above statement can be restricted.

Quoted 10 lines
Quoted 2 lines

allow $1_launcher_t self:unix_dgram_socket create_socket_perms; allow $1_launcher_t self:unix_stream_socket

create_stream_socket_perms;
...

Quoted 2 lines

allow $1_t $1_launcher_t:tcp_socket rw_socket_perms; allow $1_t $1_launcher_t:unix_stream_socket rw_socket_perms;

Should launcher be able to rw the dgram socket as well?

It doesn't seem to need it, I merely allowed what was necessary to get it working.

Quoted 2 lines

Should those rules be put together, or am I misunderstanding how it works?

As they are different they don't go together well.

Quoted 9 lines
Quoted 2 lines
# do not allow statfs()
dontaudit $1_t fs_type:filesystem getattr;

Is this sufficient? Can you look and see if samba needs this as well? In particular, after mounting SMB filesystem, df generates denials, and that's a bugzilla currently. However, I think fs_type didn't quite work for that case - I was seeing denials on the top level directory, whether it was fs_type or not. Related rules are also in gnome-vfs-daemon.te (not sure if that's merged).

Strange, a quick inspection of the latest rawhide policy indicates that this shouldn't happen.

Quoted 3 lines
Quoted 1 line

allow $1_t port_type:tcp_socket name_connect;

Protocol? Port?

We need sshd to connect to most/all ports. ssh tunneling is widely used to create secure network access for protocols such as POP (NB POP-SSL isn't much use because most clients don't seem to support checking the server certificate).

Quoted 8 lines
Quoted 4 lines

if (use_samba_home_dirs) {
allow $1_t cifs_t:dir { search getattr };
allow $1_t cifs_t:file { getattr read };
}

Please no more NFS/CIFS block of this kind - I specifically tried to macro-ize this. Also, why is this necessary? Why is sshd reading the home directories?

~/.ssh/authorized_keys

Signature · 9 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.
#3 lore raw
Quoted 12 lines
Quoted 11 lines
Quoted 3 lines

allow $1_launcher_t self:unix_dgram_socket create_socket_perms; allow $1_launcher_t self:unix_stream_socket

create_stream_socket_perms;
...

Quoted 2 lines

allow $1_t $1_launcher_t:tcp_socket rw_socket_perms; allow $1_t $1_launcher_t:unix_stream_socket rw_socket_perms;

Should launcher be able to rw the dgram socket as well?

Quoted 7 lines

It doesn't seem to need it, I merely allowed what was necessary to get it working.

Quoted 2 lines

Should those rules be put together, or am I misunderstanding how it works?

As they are different they don't go together well.

Different? One side gets the rights to create sockets, and the other side gets the right to write to given sockets... seems like a communication channel to me. That's why I asked about the dgram socket.

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
# do not allow statfs()
dontaudit $1_t fs_type:filesystem getattr;

Is this sufficient? Can you look and see if samba needs this as well? In particular, after mounting SMB filesystem, df generates denials, and that's a bugzilla currently. However, I think fs_type didn't quite work for that case - I was seeing denials on the top level directory, whether it was fs_type or not. Related rules are also in gnome-vfs-daemon.te (not sure if that's merged).

Quoted 2 lines

Strange, a quick inspection of the latest rawhide policy indicates that this shouldn't happen.

How do you figure that - test samba?
I have to admit that I haven't rechecked that in a while, but last I checked it generated denials..

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

allow $1_t port_type:tcp_socket name_connect;

Protocol? Port?

We need sshd to connect to most/all ports. ssh tunneling is widely used to create secure network access for protocols such as POP (NB POP-SSL isn't much use because most clients don't seem to support checking the server certificate).

Okay.

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines

if (use_samba_home_dirs) {
allow $1_t cifs_t:dir { search getattr };
allow $1_t cifs_t:file { getattr read };
}

Please no more NFS/CIFS block of this kind - I specifically tried to macro-ize this. Also, why is this necessary? Why is sshd reading the home directories?

~/.ssh/authorized_keys

I don't see where it's allowed access to ROLE_home_ssh_t..

--
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
In reply to Russell Coker
Quoted 8 lines · Russell Coker

I have attached the source files and the diff for a change to the way sshd works.

Recent versions of OpenSSH by default will re-exec the sshd as part of the login process. This means that there is no need for one process to have all the permissions that sshd is usually granted. So I have split up the sshd policy into two domains, one of which listens on the port and the other does most of the sshd work.

How does sshd respond to SIGHUP? Also a re-exec? If so, then this could be problematic, as it would transition domains on the initial daemon incorrectly, right?

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.
#5 lore raw
Quoted 10 lines · Stephen Smalley
Quoted 8 lines · Russell Coker

I have attached the source files and the diff for a change to the way sshd works.

Recent versions of OpenSSH by default will re-exec the sshd as part of the login process. This means that there is no need for one process to have all the permissions that sshd is usually granted. So I have split up the sshd policy into two domains, one of which listens on the port and the other does most of the sshd work.

Quoted 3 lines

How does sshd respond to SIGHUP? Also a re-exec? If so, then this could be problematic, as it would transition domains on the initial daemon incorrectly, right?

Correct. I tested all the functions I use, but I never kill -1 the sshd so it didn't occur to me to test it.

It looks like my idea is not usable.

Signature · 9 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.