More Samba
Ok, here is an updated version of my Samba policy. It requires that a few lines be added to other files, namely.
to net_contexts:
ifdef(samba.te', portcon tcp 137 system_u:object_r:samba_port_t portcon tcp 138 system_u:object_r:samba_port_t
portcon tcp 139 system_u:object_r:samba_port_t')
to logrotate.te:
ifdef(samba.te', allow logrotate_t samba_log_t: dir { read search getattr };
allow logrotate_t samba_log_t: file { getattr };
allow logrotate_t samba_var_t: dir { read search getattr }; allow logrotate_t samba_var_t: file { read getattr };')
I'm also receiving the following denied message, and I'm like some suggestions on the best way to handle it.
avc: denied { read } for pid=3486 exe=/bin/cat
path=/var/log/samba/log.nmbd dev=03:02 ino=1753604 scontext=system_u:object_r:system_crond_t tcontext=system_u:object_r:samba_log_t tclass=file
And that does it. Thanks again, everyone.
Quoted 8 lines · Ryan Bergauer
Ok, here is an updated version of my Samba policy. It requires that a few lines be added to other files, namely.
to
net_contexts:ifdef(
samba.te',portcon tcp 137 system_u:object_r:samba_port_t portcon tcp 138 system_u:object_r:samba_port_t
portcon tcp 139 system_u:object_r:samba_port_t')
I've just added the following to my tree:
ifdef(samba.te', portcon tcp 137 system_u:object_r:smbd_port_t portcon udp 137 system_u:object_r:nmbd_port_t
portcon tcp 138 system_u:object_r:smbd_port_t
portcon udp 138 system_u:object_r:nmbd_port_t
portcon tcp 139 system_u:object_r:smbd_port_t
portcon udp 139 system_u:object_r:nmbd_port_t')
Quoted 7 lines
to logrotate.te:
ifdef(
samba.te',allowlogrotate_tsamba_log_t: dir { read search getattr };
allowlogrotate_tsamba_log_t: file { getattr };
allowlogrotate_tsamba_var_t: dir { read search getattr }; allowlogrotate_tsamba_var_t: file { read getattr };')
Why does logrotate just need read access?
Quoted 7 lines
I'm also receiving the following denied message, and I'm like some suggestions on the best way to handle it.
avc: denied { read } for pid=3486 exe=/bin/cat
path=/var/log/samba/log.nmbd dev=03:02 ino=1753604 scontext=system_u:object_r:system_crond_t tcontext=system_u:object_r:samba_log_t tclass=file
What script calls it?
I've attached my latest samba.te file...
Signature · 3 lines
I do not get viruses because I do not use MS software. If you use Outlook then please do not put my email address in your address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line
From field.
#
# Author: Ryan Bergauer ([email protected])
#
#################################
#
# Declarations for Samba
#
daemon_domain(smbd)daemon_domain(nmbd)
type samba_etc_t, file_type, sysadmfile;
type samba_log_t, file_type, sysadmfile;
type samba_var_t, file_type, sysadmfile;
type samba_share_t, file_type, sysadmfile;
#################################
#
# Rules for the smbd_t domain.
#
# Permissions normally found in every_domain.general_domain_access(smbd_t)general_file_read_access(smbd_t)general_proc_read_access(smbd_t)
type smbd_port_t, port_type;
allow smbd_t smbd_port_t:tcp_socket name_bind;
# Use capabilities.
allow smbd_t smbd_t:capability { setgid setuid sys_resource net_bind_service lease };
# Use the network.can_network(smbd_t)
# Read/Write user home directories.
allow smbd_t user_home_t:dir create_dir_perms;
allow smbd_t user_home_t:file create_file_perms;
# Permissions for Samba files in /etc/samba
#allow smbd_t samba_etc_t:file { write setattr getattr read lock }; allow smbd_t samba_etc_t:file { getattr read };
allow smbd_t samba_etc_t:dir { search getattr };
# Permissions for Samba cache files in /var/cache/samba
allow smbd_t samba_var_t:dir { write remove_name add_name lock getattr search }; allow smbd_t samba_var_t:file { lock unlink create write setattr read getattr rename };
# Permissions to write log files.
allow smbd_t samba_log_t:file { append getattr create }; allow smbd_t samba_log_t:dir { search };
# Access Samba shares.
allow smbd_t samba_share_t:dir create_dir_perms; allow smbd_t samba_share_t:file create_file_perms;
#################################
#
# Rules for the nmbd_t domain.
#
# Permissions normally found in every_domain.general_domain_access(nmbd_t)general_file_read_access(nmbd_t)general_proc_read_access(nmbd_t)
type nmbd_port_t, port_type;
allow nmbd_t nmbd_port_t:udp_socket name_bind;
# Use capabilities.
allow nmbd_t nmbd_t:capability { net_bind_service };
# Use the network.can_network(nmbd_t)
# Permissions for Samba files in /etc/samba
allow nmbd_t samba_etc_t:file { getattr read };
allow nmbd_t samba_etc_t:dir { search getattr };
# Permissions for Samba cache files in /var/cache/samba
allow nmbd_t samba_var_t:dir { write remove_name add_name lock getattr search }; allow nmbd_t samba_var_t:file { lock unlink create write setattr read getattr rename };
# Permissions to write log files.
allow nmbd_t samba_log_t:file { append getattr create }; allow nmbd_t samba_log_t:dir { search };
allow nmbd_t nmbd_t: udp_socket recvfrom;
Quoted 1 line · Russell Coker
Why does logrotate just need read access?
I'm not totally sure. I received messages denying the read access, noted that they were necessary, and added those - however, in the month that I've been running this policy, I haven't yet needed anything else.
On a related note, I just realized that I didn't take into consideration the case where the log files need to be created. In those cases, smbd_t and nmbd_t both need add_name and write access for dir in samba_log_t.
Quoted 9 lines
Quoted 7 lines
I'm also receiving the following denied message, and I'm like some suggestions on the best way to handle it.
avc: denied { read } for pid=3486 exe=/bin/cat
path=/var/log/samba/log.nmbd dev=03:02 ino=1753604 scontext=system_u:object_r:system_crond_t tcontext=system_u:object_r:samba_log_t tclass=fileWhat script calls it?
00-logwatch in cron.daily
Thanks.
--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 6 lines · Ryan Bergauer
Quoted 1 line · Russell Coker
Why does logrotate just need read access?
I'm not totally sure. I received messages denying the read access, noted that they were necessary, and added those - however, in the month that I've been running this policy, I haven't yet needed anything else.
Strange, could you please send me the logrotate configuration file in question?
Quoted 3 lines
On a related note, I just realized that I didn't take into consideration the case where the log files need to be created. In those cases,
smbd_tandnmbd_tboth needadd_nameand write access for dir insamba_log_t.
rw_dir_create_file({ smbd_t nmbd_t }, samba_log_t)
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
I'm also receiving the following denied message, and I'm like some suggestions on the best way to handle it.
avc: denied { read } for pid=3486 exe=/bin/cat
path=/var/log/samba/log.nmbd dev=03:02 ino=1753604 scontext=system_u:object_r:system_crond_t tcontext=system_u:object_r:samba_log_t tclass=fileWhat script calls it?
00-logwatch in cron.daily
Please send me a copy of that file.
Signature · 3 lines
I do not get viruses because I do not use MS software. If you use Outlook then please do not put my email address in your address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line
From field.
--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Russell Coker
Quoted 3 lines
On a related note, I just realized that I didn't take into consideration the case where the log files need to be created. In those cases,
smbd_tandnmbd_tboth needadd_nameand write access for dir insamba_log_t.
rw_dir_create_file({ smbd_t nmbd_t }, samba_log_t)
Actually, that's not so good. I think we need a new macro something like the following:
define(create_append_log_file',
allow $1 $2:dir { read getattr access search add_name write }; allow $1 $2:file { create getattr access setattr append link }; ')
What do you think? There's probably quite a few places where rw_dir_create_file() could be replaced with such a macro...
Signature · 3 lines
I do not get viruses because I do not use MS software. If you use Outlook then please do not put my email address in your address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line
From field.
--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.