|
| 1 | +policy_module(netatalk, 1.0.0) |
| 2 | + |
| 3 | +######################################## |
| 4 | +# |
| 5 | +# Declarations |
| 6 | +# |
| 7 | + |
| 8 | +type netatalk_t; |
| 9 | +type netatalk_exec_t; |
| 10 | +init_daemon_domain(netatalk_t, netatalk_exec_t) |
| 11 | + |
| 12 | +# Ensure proper entrypoint |
| 13 | +allow netatalk_t netatalk_exec_t:file entrypoint; |
| 14 | + |
| 15 | +# Allow netatalk to execute and transition to its child daemons |
| 16 | +# This handles the forking structure: netatalk -> afpd, cnid_metad -> cnid_dbd |
| 17 | +allow netatalk_t netatalk_exec_t:file execute; |
| 18 | +domtrans_pattern(netatalk_t, netatalk_exec_t, netatalk_t) |
| 19 | + |
| 20 | +# Configuration files |
| 21 | +type netatalk_etc_t; |
| 22 | +files_config_file(netatalk_etc_t) |
| 23 | + |
| 24 | +# Variable library files |
| 25 | +type netatalk_var_lib_t; |
| 26 | +files_type(netatalk_var_lib_t) |
| 27 | + |
| 28 | +# Lock files |
| 29 | +type netatalk_lock_t; |
| 30 | +files_lock_file(netatalk_lock_t) |
| 31 | + |
| 32 | +# Log files |
| 33 | +type netatalk_log_t; |
| 34 | +logging_log_file(netatalk_log_t) |
| 35 | + |
| 36 | +######################################## |
| 37 | +# |
| 38 | +# netatalk local policy |
| 39 | +# |
| 40 | + |
| 41 | +# Basic process and IPC permissions |
| 42 | +allow netatalk_t self:process { fork signal_perms }; |
| 43 | +allow netatalk_t self:fifo_file rw_fifo_file_perms; |
| 44 | +allow netatalk_t self:unix_stream_socket create_stream_socket_perms; |
| 45 | + |
| 46 | +# Process management for forking daemons |
| 47 | +allow netatalk_t self:process { setrlimit setpgid setsched }; |
| 48 | + |
| 49 | +# Allow netatalk to bind to privileged ports |
| 50 | +allow netatalk_t self:capability net_bind_service; |
| 51 | + |
| 52 | +# Socket permissions |
| 53 | +allow netatalk_t self:netlink_route_socket { bind create getattr nlmsg_read }; |
| 54 | +allow netatalk_t self:tcp_socket { bind create ioctl listen setopt }; |
| 55 | +allow netatalk_t self:udp_socket { connect create getattr }; |
| 56 | +allow netatalk_t self:unix_dgram_socket { connect create }; |
| 57 | + |
| 58 | +# Core command execution and binary mapping |
| 59 | +corecmd_exec_bin(netatalk_t) |
| 60 | +corecmd_exec_shell(netatalk_t) |
| 61 | +corecmd_mmap_bin_files(netatalk_t) |
| 62 | + |
| 63 | +# Network binding permissions |
| 64 | +corenet_tcp_bind_dhcpd_port(netatalk_t) |
| 65 | +corenet_tcp_bind_generic_node(netatalk_t) |
| 66 | +corenet_tcp_bind_generic_port(netatalk_t) |
| 67 | +corenet_udp_bind_generic_node(netatalk_t) |
| 68 | +corenet_udp_bind_generic_port(netatalk_t) |
| 69 | + |
| 70 | +# D-Bus communication |
| 71 | +dbus_read_pid_sock_files(netatalk_t) |
| 72 | +dbus_stream_connect_system_dbusd(netatalk_t) |
| 73 | +dbus_write_pid_sock_files(netatalk_t) |
| 74 | + |
| 75 | +# File and lock management |
| 76 | +files_create_lock_dirs(netatalk_t) |
| 77 | +files_manage_generic_locks(netatalk_t) |
| 78 | +files_rw_var_files(netatalk_t) |
| 79 | +files_search_locks(netatalk_t) |
| 80 | +files_read_etc_files(netatalk_t) |
| 81 | + |
| 82 | +# Kernel communication |
| 83 | +kernel_dgram_send(netatalk_t) |
| 84 | +kernel_read_proc_files(netatalk_t) |
| 85 | +kernel_read_system_state(netatalk_t) |
| 86 | + |
| 87 | +# Logging |
| 88 | +logging_create_devlog_dev(netatalk_t) |
| 89 | +logging_read_syslog_pid(netatalk_t) |
| 90 | +logging_send_syslog_msg(netatalk_t) |
| 91 | + |
| 92 | +# System network configuration |
| 93 | +sysnet_read_config(netatalk_t) |
| 94 | + |
| 95 | +# Interactive and standard daemon permissions |
| 96 | +domain_use_interactive_fds(netatalk_t) |
| 97 | + |
| 98 | +# Allow systemd to transition to netatalk |
| 99 | +init_domtrans_script(netatalk_exec_t) |
| 100 | + |
| 101 | +# Additional permissions that might be needed |
| 102 | +auth_use_nsswitch(netatalk_t) |
| 103 | +miscfiles_read_localization(netatalk_t) |
0 commit comments