From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 572A9C34031 for ; Wed, 19 Feb 2020 02:35:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1EA1D2176D for ; Wed, 19 Feb 2020 02:35:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=coker.com.au header.i=@coker.com.au header.b="B0WzrJmw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726777AbgBSCfE (ORCPT ); Tue, 18 Feb 2020 21:35:04 -0500 Received: from smtp.sws.net.au ([46.4.88.250]:51704 "EHLO smtp.sws.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbgBSCfE (ORCPT ); Tue, 18 Feb 2020 21:35:04 -0500 Received: from xev.coker.com.au (localhost [127.0.0.1]) by smtp.sws.net.au (Postfix) with ESMTP id 308D7ECAC for ; Wed, 19 Feb 2020 13:35:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1582079702; bh=p/G+NIrLAR476i6cfAEmQGeix86d6aAUEdGeZlwd7Pk=; l=5875; h=Date:From:To:Subject:From; b=B0WzrJmw5R0ETm9R/f5ih+aRCxcgdLdvQsdO73EkQ+4erxnE6xjY7uggdxfPu2YAg usmsQ50l/Cv2Ji9XUSB26++eovu6HFf0F0/bP6XN9642jpj5tIT/ny9nNBWMY4fbnz sTLAcQMlCFCqj6EB+vs5mThC5mIFuEG6YIR/PxRc= Received: by xev.coker.com.au (Postfix, from userid 1001) id D498EF32298; Wed, 19 Feb 2020 13:34:57 +1100 (AEDT) Date: Wed, 19 Feb 2020 13:34:57 +1100 From: Russell Coker To: selinux-refpolicy@vger.kernel.org Subject: new certbot patch Message-ID: <20200219023457.GA4968@xev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org With the changes PeBenito requested. Signed off by Russell. Index: refpolicy-2.20200219/policy/modules/services/certbot.fc =================================================================== --- /dev/null +++ refpolicy-2.20200219/policy/modules/services/certbot.fc @@ -0,0 +1,4 @@ +/usr/bin/certbot -- gen_context(system_u:object_r:certbot_exec_t,s0) +/usr/bin/letsencrypt -- gen_context(system_u:object_r:certbot_exec_t,s0) +/var/log/letsencrypt(/.*)? gen_context(system_u:object_r:certbot_log_t,s0) +/var/lib/letsencrypt(/.*)? gen_context(system_u:object_r:certbot_lib_t,s0) Index: refpolicy-2.20200219/policy/modules/services/certbot.if =================================================================== --- /dev/null +++ refpolicy-2.20200219/policy/modules/services/certbot.if @@ -0,0 +1,46 @@ +## SSL certificate requesting tool certbot AKA letsencrypt. + +######################################## +## +## Execute certbot/letsencrypt in the certbot +## domain. +## +## +## +## Domain allowed to transition. +## +## +# +interface(`certbot_domtrans',` + gen_require(` + type certbot_t, certbot_exec_t; + ') + + domtrans_pattern($1, certbot_exec_t, certbot_t) +') + +######################################## +## +## Execute certbot/letsencrypt in the certbot +## domain, and allow the specified role +## the firstboot domain. +## +## +## +## Role allowed access. +## +## +## +## +## Domain allowed to transition. +## +## +# +interface(`certbot_run',` + gen_require(` + type certbot_t; + ') + + certbot_domtrans($2) + role $1 types certbot_t; +') Index: refpolicy-2.20200219/policy/modules/services/certbot.te =================================================================== --- /dev/null +++ refpolicy-2.20200219/policy/modules/services/certbot.te @@ -0,0 +1,99 @@ +policy_module(certbot, 1.0.0) + +######################################## +# +# Declarations +# + +type certbot_t; +type certbot_exec_t; +init_daemon_domain(certbot_t, certbot_exec_t) + +type certbot_log_t; +logging_log_file(certbot_log_t) + +type certbot_runtime_t; +files_pid_file(certbot_runtime_t) + +type certbot_tmp_t; +files_tmp_file(certbot_tmp_t) + +type certbot_tmpfs_t; +files_tmpfs_file(certbot_tmpfs_t) + +type certbot_lib_t; +files_type(certbot_lib_t) + +######################################## +# +# Local policy +# + +allow certbot_t self:fifo_file { getattr ioctl read write }; + +allow certbot_t self:capability { chown dac_override sys_resource }; + +files_search_var_lib(certbot_t) +manage_dirs_pattern(certbot_t, certbot_lib_t, certbot_lib_t) +manage_files_pattern(certbot_t, certbot_lib_t, certbot_lib_t) + +manage_files_pattern(certbot_t, certbot_tmp_t, certbot_tmp_t) +files_tmp_filetrans(certbot_t, certbot_tmp_t, { file }) + +manage_files_pattern(certbot_t, certbot_tmpfs_t, certbot_tmpfs_t) +fs_tmpfs_filetrans(certbot_t, certbot_tmpfs_t, { file }) + +# this is for certbot to have write-exec memory, I know it is bad +allow certbot_t self:process execmem; +allow certbot_t certbot_tmp_t:file { map execute }; +allow certbot_t certbot_tmpfs_t:file { map execute }; +allow certbot_t certbot_runtime_t:file { map execute }; + +logging_search_logs(certbot_t) +allow certbot_t certbot_log_t:dir manage_dir_perms; +allow certbot_t certbot_log_t:file manage_file_perms; + +kernel_search_fs_sysctls(certbot_t) + +allow certbot_t self:udp_socket all_udp_socket_perms; +allow certbot_t self:tcp_socket all_tcp_socket_perms; +allow certbot_t self:netlink_route_socket create_netlink_socket_perms; +corenet_tcp_bind_generic_node(certbot_t) +corenet_tcp_connect_http_port(certbot_t) + +# bind to http port for standalone mode +corenet_tcp_bind_http_port(certbot_t) + +sysnet_read_config(certbot_t) +files_read_etc_files(certbot_t) + +# for /usr/bin/x86_64-linux-gnu-gcc-8 why? +corecmd_exec_bin(certbot_t) +# for /usr/lib/gcc/x86_64-linux-gnu/8/collect2 +libs_exec_lib_files(certbot_t) + +libs_exec_ldconfig(certbot_t) + +apache_search_config(certbot_t) + +# for bin_t map +corecmd_mmap_bin_files(certbot_t) +corecmd_list_bin(certbot_t) +miscfiles_read_localization(certbot_t) + +miscfiles_read_generic_certs(certbot_t) +miscfiles_manage_generic_tls_privkey_dirs(certbot_t) +miscfiles_manage_generic_tls_privkey_files(certbot_t) +miscfiles_manage_generic_tls_privkey_lnk_files(certbot_t) + +manage_files_pattern(certbot_t, certbot_runtime_t, certbot_runtime_t) +files_pid_filetrans(certbot_t, certbot_runtime_t, file) + +domain_use_interactive_fds(certbot_t) +userdom_use_user_ptys(certbot_t) +userdom_dontaudit_search_user_home_dirs(certbot_t) + +optional_policy(` + # for writing to webroot + apache_manage_sys_content(certbot_t) +') Index: refpolicy-2.20200219/policy/modules/system/miscfiles.if =================================================================== --- refpolicy-2.20200219.orig/policy/modules/system/miscfiles.if +++ refpolicy-2.20200219/policy/modules/system/miscfiles.if @@ -254,6 +254,26 @@ interface(`miscfiles_manage_generic_tls_ ######################################## ## +## Manage generic SSL/TLS private +## keys. +## +## +## +## Domain allowed access. +## +## +## +# +interface(`miscfiles_manage_generic_tls_privkey_lnk_files',` + gen_require(` + type tls_privkey_t; + ') + + manage_lnk_files_pattern($1, tls_privkey_t, tls_privkey_t) +') + +######################################## +## ## Read fonts. ## ##