Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp835036ybl; Fri, 13 Dec 2019 05:25:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwrg8NgReJ5xjBX4Gze1VKLqxz3lOHKzv/9IGfEwKCdhE/d/lJq5VJ1iJEfhHKi5kPa9xOF X-Received: by 2002:a9d:2264:: with SMTP id o91mr5649930ota.328.1576243554989; Fri, 13 Dec 2019 05:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576243554; cv=none; d=google.com; s=arc-20160816; b=VrE3J/IDtFJcYkWm7qB73csVANAeHoFZCrahtj6s/ZYFtabQwANJJW4p9IAWO2NRnt mUGWJuZvrQQklk70lwI14lDQ4nW5IJHCGQzQFwioBnTq/AGhnPf0tATom+9ao7A5WswS Ik6hKKfz2AvoUSxO1fqPi3+abbbJBd+ddiYd5ZyDdrA2wInr/ItsD8W4eW44STPpDAbN LZzzSdYaP0b4X5MWlNJuw093SM0Fnkd43jEx19QCF1D2RI2OL8WNBWiFXHyR9zwilO5Z O27cCg0ltJ9ZOdFjrg+THa9KWlz/gyfVNKl+eXx3/8lxt6Lchr6Y/FLFMEbz9tVFDbL3 z2oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=TTT6GrOLbvoa3i9+2hqi86OT24AAqf59C1oggfuXv4g=; b=ONg3Tml8UN+2qLkEj5uih1hUXd5VXYIqn54uAKOzJRXTLVnDxT75sSMOAiPGIzXEcA jQAURXhWgvxtgxsqZ7ogW+N3THCrUXKhl9qlXJa1NsBSsLsd8EAgbGOeOnmU/nL/+VVT QHgWG4Qn2US8bHTMGVEIrIr9HWnCFwtV5NIj1wE9k/n/9OPGzpss5xLJ6tN9+Zyqt3Vh ZHt9030Sxe+UNNUsZGdk990K+JxnHqsikheJG6/r4ghXM88UIKnQFWHfcFzl6cjXaT69 RYl5F8SFvVxDo8S320Ue8s57xLVtSRTaOfBmEecFf1esuUkjmnz90kSG4QFUZxtmx59R ABXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bigon.be header.s=key1 header.b=U9w2f74L; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si5447877otn.33.2019.12.13.05.25.51; Fri, 13 Dec 2019 05:25:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bigon.be header.s=key1 header.b=U9w2f74L; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726930AbfLMNZu (ORCPT + 12 others); Fri, 13 Dec 2019 08:25:50 -0500 Received: from ithil.bigon.be ([163.172.57.153]:33696 "EHLO ithil.bigon.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726928AbfLMNZu (ORCPT ); Fri, 13 Dec 2019 08:25:50 -0500 X-Greylist: delayed 323 seconds by postgrey-1.27 at vger.kernel.org; Fri, 13 Dec 2019 08:25:48 EST Received: from localhost (localhost [IPv6:::1]) by ithil.bigon.be (Postfix) with ESMTP id 7C6E61FDF8 for ; Fri, 13 Dec 2019 14:20:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bigon.be; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received:received; s=key1; t=1576243224; x=1578057625; bh=M3+x+nzGVQCyijk7a4oRU3M/1m7R27pKZTPs2TWkR4g=; b=U9w2f74L99Xg UPaUc38HIu+ZQvflHLHWIfdVEWlFuoCHhzrWuO+xp7g/ZMDNxnkmHE/DtvdS+E/E rbuTRB/X0RQWshiYw6Pcnt410OeY/AKJ/tnm1uEwvxWZsiKGRFj6zG90vRY8hSmO ekcaXVXl5fDBZnp/98qqRrjT9c48koI= Received: from ithil.bigon.be ([IPv6:::1]) by localhost (ithil.bigon.be [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id Bxk_ivSYXZCL for ; Fri, 13 Dec 2019 14:20:24 +0100 (CET) Received: from edoras.bigon.be (unknown [193.53.238.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bigon@bigon.be) by ithil.bigon.be (Postfix) with ESMTPSA for ; Fri, 13 Dec 2019 14:20:24 +0100 (CET) Received: from bigon (uid 1000) (envelope-from bigon@bigon.be) id 230aa by edoras.bigon.be (DragonFly Mail Agent v0.12); Fri, 13 Dec 2019 14:20:23 +0100 From: Laurent Bigonville To: selinux-refpolicy@vger.kernel.org Subject: [RFC 2/3] Add policy for apt-cacher-ng Date: Fri, 13 Dec 2019 14:20:15 +0100 Message-Id: <20191213132016.308556-3-bigon@debian.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191213132016.308556-1-bigon@debian.org> References: <20191213132016.308556-1-bigon@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org From: Laurent Bigonville Signed-off-by: Laurent Bigonville --- policy/modules/kernel/corenetwork.te.in | 1 + policy/modules/services/aptcacher.fc | 11 ++++ policy/modules/services/aptcacher.if | 21 +++++++ policy/modules/services/aptcacher.te | 81 +++++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 policy/modules/services/aptcacher.fc create mode 100644 policy/modules/services/aptcacher.if create mode 100644 policy/modules/services/aptcacher.te diff --git a/policy/modules/kernel/corenetwork.te.in b/policy/modules/kernel/corenetwork.te.in index 97870f84..abf0e8d7 100644 --- a/policy/modules/kernel/corenetwork.te.in +++ b/policy/modules/kernel/corenetwork.te.in @@ -89,6 +89,7 @@ network_port(amqp, udp,5671-5672,s0, tcp,5671-5672,s0) network_port(aol, udp,5190-5193,s0, tcp,5190-5193,s0) network_port(apcupsd, tcp,3551,s0, udp,3551,s0) network_port(apertus_ldp, tcp,539,s0, udp,539,s0) +network_port(aptcacher, tcp,3142,s0) network_port(armtechdaemon, tcp,9292,s0, udp,9292,s0) network_port(asterisk, tcp,1720,s0, udp,2427,s0, udp,2727,s0, udp,4569,s0) network_port(audit, tcp,60,s0) diff --git a/policy/modules/services/aptcacher.fc b/policy/modules/services/aptcacher.fc new file mode 100644 index 00000000..6835bab0 --- /dev/null +++ b/policy/modules/services/aptcacher.fc @@ -0,0 +1,11 @@ +/etc/apt-cacher-ng(/.*)? gen_context(system_u:object_r:aptcacher_etc_t,s0) + +/usr/sbin/apt-cacher-ng -- gen_context(system_u:object_r:aptcacher_exec_t,s0) + +/run/apt-cacher-ng(/.*)? gen_context(system_u:object_r:aptcacher_runtime_t,s0) + +/var/cache/apt-cacher-ng(/.*)? gen_context(system_u:object_r:aptcacher_var_cache_t,s0) + +/var/lib/apt-cacher-ng(/.*)? gen_context(system_u:object_r:aptcacher_var_lib_t,s0) + +/var/log/apt-cacher-ng(/.*)? gen_context(system_u:object_r:aptcacher_var_log_t,s0) diff --git a/policy/modules/services/aptcacher.if b/policy/modules/services/aptcacher.if new file mode 100644 index 00000000..82538dd5 --- /dev/null +++ b/policy/modules/services/aptcacher.if @@ -0,0 +1,21 @@ +## apt-cacher, cache for Debian APT repositories. + +###################################### +## +## read aptcacher config +## +## +## +## Domain allowed to read it. +## +## +# +interface(`aptcacher_read_config',` + gen_require(` + type aptcacher_etc_t; + ') + + files_search_etc($1) + allow $1 aptcacher_etc_t:dir list_dir_perms; + allow $1 aptcacher_etc_t:file mmap_read_file_perms; +') diff --git a/policy/modules/services/aptcacher.te b/policy/modules/services/aptcacher.te new file mode 100644 index 00000000..502ce6e6 --- /dev/null +++ b/policy/modules/services/aptcacher.te @@ -0,0 +1,81 @@ +policy_module(aptcacher, 1.0.0) + +######################################## +# +# Declarations +# + +type aptcacher_t; +type aptcacher_exec_t; +init_daemon_domain(aptcacher_t, aptcacher_exec_t) + +type aptcacher_etc_t; +files_config_file(aptcacher_etc_t) + +type aptcacher_var_cache_t; +files_type(aptcacher_var_cache_t) + +type aptcacher_var_lib_t; +files_type(aptcacher_var_lib_t) + +type aptcacher_var_log_t; +logging_log_file(aptcacher_var_log_t) + +type aptcacher_runtime_t; +files_pid_file(aptcacher_runtime_t) + +######################################## +# +# Local policy +# + +allow aptcacher_t self:process signal; + +allow aptcacher_t self:fifo_file { read write }; +allow aptcacher_t self:netlink_route_socket r_netlink_socket_perms; +allow aptcacher_t self:tcp_socket create_stream_socket_perms; +allow aptcacher_t self:unix_dgram_socket create_socket_perms; +allow aptcacher_t self:unix_stream_socket create_stream_socket_perms; + +allow aptcacher_t aptcacher_etc_t:file map; +list_dirs_pattern(aptcacher_t, aptcacher_etc_t, aptcacher_etc_t) +read_files_pattern(aptcacher_t, aptcacher_etc_t, aptcacher_etc_t) +# /etc/apt-cacher-ng/ contains symlinks that point to /var/lib/apt-cacher-ng/ +read_lnk_files_pattern(aptcacher_t, aptcacher_etc_t, aptcacher_etc_t) + +allow aptcacher_t aptcacher_var_cache_t:file map; +manage_dirs_pattern(aptcacher_t, aptcacher_var_cache_t, aptcacher_var_cache_t) +manage_files_pattern(aptcacher_t, aptcacher_var_cache_t, aptcacher_var_cache_t) +manage_lnk_files_pattern(aptcacher_t, aptcacher_var_cache_t, aptcacher_var_cache_t) + +allow aptcacher_t aptcacher_var_lib_t:file map; +files_search_var_lib(aptcacher_t) +read_files_pattern(aptcacher_t, aptcacher_var_lib_t, aptcacher_var_lib_t) + +allow aptcacher_t aptcacher_var_log_t:file map; +logging_search_logs(aptcacher_t) +manage_files_pattern(aptcacher_t, aptcacher_var_log_t, aptcacher_var_log_t) + +manage_sock_files_pattern(aptcacher_t, aptcacher_runtime_t, aptcacher_runtime_t) + +kernel_read_vm_overcommit_sysctl(aptcacher_t) + +##corecmd_exec_shell(aptcacher_t) + +corenet_tcp_bind_aptcacher_port(aptcacher_t) +corenet_tcp_bind_generic_node(aptcacher_t) +corenet_tcp_connect_http_port(aptcacher_t) + +auth_use_nsswitch(aptcacher_t) + +# Uses sd_notify() to inform systemd it has properly started +init_search_pids(aptcacher_t) +init_write_runtime_socket(aptcacher_t) + +miscfiles_read_generic_certs(aptcacher_t) + +# Reads /usr/share/zoneinfo/ +miscfiles_read_localization(aptcacher_t) + +# For some reasons it's trying to mmap /etc/hosts.deny +sysnet_map_config(aptcacher_t) -- 2.24.0