bind and SE Linux
A message that is not in the archive (sent off-list or not yet received): [email protected]
After receiving the following message I changed my SE Policy for named to allow receiving on TCP port 53 as well.
I currently have this in my net_contexts file:
ifdef(named.te', udp 53 system_u:object_r:named_port_t tcp 53 system_u:object_r:named_port_t')
And I have this in my named.te:
# Bind to the named port.
allow named_t named_port_t:udp_socket name_bind;
allow named_t named_port_t:tcp_socket name_bind;
I have attached the full named.te file I'm using now because it's totally different from the old one.
Quoted 31 lines · LaMont Jones
Quoted 1 line
Why does postfix make TCP connections to the name server instead of UDP?
The most likely situation is that the answer came back claiming that it was truncated, and so the resolver switched over to TCP (as it's supposed to...)
From the postfix source (flags is passed in, the only non-zero value ever used is
RES_DEFNAMES.):
/*
* Set search options: debugging, parent domain search, append local
* domain. Do not allow the user to control other features. */
#defineUSER_FLAGS(RES_DEBUG|RES_DNSRCH|RES_DEFNAMES)if ((flags & USER_FLAGS) != flags) msg_panic("dns_query: bad flags: %d", flags); _res.options &= ~(USER_FLAGS); _res.options |= flags;From there, postfix uses
res_searchto do the query, so any failover to TCP is going to be the resolver library's decision.lamont
Quoted 2 lines
I expected it to use UDP only. See below for SE Linux logs to show the TCP connections.
TCP queries are a perfectly valid fact of life. blocking them will cause problems, regardless of how well it works 95% of the time...
lamont
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: Yuichi Nakamura <[email protected]> #
#################################
#
# Rules for the named_t domain.
#
type named_port_t,port_type;
daemon_domain(named)
# ndc_t is the domain for the ndc program type ndc_t, domain, privlog; role sysadm_r types ndc_t;
can_exec(named_t, named_exec_t)
# A type for configuration files of named.
type named_conf_t, file_type,sysadmfile;
# for primary zone files type named_zone_t, file_type, sysadmfile;
# for secondary zone files type named_cache_t, file_type, sysadmfile;
# Use capabilities. Surplus capabilities may be allowed.
allow named_t named_t:capability { setuid setgid net_bind_service chown fowner dac_override sys_nice };
allow named_t etc_t:{ file lnk_file } { getattr read }; allow named_t resolv_conf_t:file { getattr read };
#Named can use networkcan_network(named_t)
# allow UDP transfer to/from any program can_udp_send(domain, named_t) can_udp_send(named_t, domain)
# Bind to the named port.
allow named_t named_port_t:udp_socket name_bind;
allow named_t named_port_t:tcp_socket name_bind;
#read configuration filesr_dir_file(named_t, named_conf_t)
#read zone files - change this to rw_dir_create_file() to
# enable domain auto updates. r_dir_file(named_t, named_zone_t)
#write cache for secondary zonesrw_dir_create_file(named_t, named_cache_t)
allow named_t self:unix_stream_socket create_stream_socket_perms; allow named_t self:unix_dgram_socket create_socket_perms;
#A type for /usr/sbin/ndc
type ndc_exec_t, file_type,sysadmfile, exec_type;domain_auto_trans(sysadm_t, ndc_exec_t, ndc_t)uses_shlib(ndc_t)
allow ndc_t etc_t:dir r_dir_perms;
allow ndc_t self:unix_stream_socket create_stream_socket_perms; allow ndc_t self:unix_stream_socket connect;
allow ndc_t self:capability dac_override;
allow ndc_t var_run_named_t:sock_file rw_file_perms; allow ndc_t named_t:unix_stream_socket connectto;