Listing 1. echoclient.te # Simple echoclient policy for Linux Journal article # File: domains/program/echoclient.te # Define the echoclient_t type as a domain. type echoclient_t, domain; # Define echoclient_exec_t as a type of executable # file. type echoclient_exec_t, file_type, exec_type; # This is a macro which will allow a correctly # labeled executable to transition into the # echoclient_t domain from the staff_t domain. domain_auto_trans(staff_t, echoclient_exec_t, echoclient_t) # Designate which roles may enter the echoclient_t # domain. role staff_r types echoclient_t; # This is macro which allows the domain to use # shared libraries. uses_shlib(echoclient_t); # Provide the permissions required to run the # program when when logged in via SSH as staff_t, # allowing diagnostic and error messages to be # written to the user's tty. allow echoclient_t sshd_t:fd use; allow echoclient_t staff_devpts_t:chr_file { getattr read write }; # Network configuration # These are the socket permissions required by the # domain. Note that they are locked down to TCP # sockets. allow echoclient_t echoclient_t:tcp_socket { connect create read shutdown write }; # Allow the program to send and receive TCP messages # to the echo port. In standard policy, the port is # labeled as an inetd_port_t as it is one of a group # of ports managed by inetd. You could modify the # policy in net_contexts to lock this down to one # port if needed. allow echoclient_t inetd_port_t:tcp_socket { recv_msg send_msg }; # Allow only TCP traffic over the intranet interface. allow echoclient_t netif_intranet_t:netif { tcp_recv tcp_send }; # Allow only TCP communication with internal IP # addresses. allow echoclient_t node_internal_t:node { tcp_recvtcp_send };