Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5580685ybv; Tue, 11 Feb 2020 19:08:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzXKH7NsLO6QdJ58+QKVFeCjJXWpqvb7Fh2sqSDv0qN2v9yBx0JkcbJsq2ehIF1xFjOUEf3 X-Received: by 2002:aca:ab51:: with SMTP id u78mr4971799oie.21.1581476937532; Tue, 11 Feb 2020 19:08:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581476937; cv=none; d=google.com; s=arc-20160816; b=00yjCbf1W7aUN8SXACArbVkjIRJbro+Ok4mFdg6LAWqWBoV4wAKz7Jj+RNoHzZOAoC ItWmreVlokeczhAtT8YqX9i+y57yu04bKEdvy7rIl814hQZz5Cy3oxXQGzCjGZVh6PRI Y0WozCwR/llBMilN/xAQDKJYAlfJTX1kz0jY8R1Kr/WgPxp3NCezTNCC+R0DLjZjRhSG WfPR9KRDWx+rE/03FpA+HATqH6LEoVGO+Vjtc7J5/mNrKwiff8C8yJXsSmwBFGvauW4c UzI011Hcam2MbucSLjoh2fKwyV8OpBLr6ZoBqgSsKRkckxxdTqAnpkL5C6+7YR6MPB+j xVbQ== 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 :message-id:date:subject:reply-to:to:from:dkim-signature; bh=Pvy4G4DtnGgfrD2GA0lw7MQ+yLa4oil825gdiUCMTwo=; b=liqIiwURA7RkP2S/IpOBNZb3lGzmadQrp7HEvu0maFgVaxsMUI49uMOWBxtHm45H+J MunWrT0RIJnP/8SfnhZXtbw+2ollUiic2Q7c0JLognDz1raW7xCv7EFvJ5Y6OpJkOvto wm/LKB31vxGmP2DC2vsOjbGTn1LzKk87xsfO/tfTa97qXVnNrbt/wZzd4+yYbS+CyWi6 WIqbPl76/dTvcVQUaJ22PxFcu8jTHqF03UUVTwfhl8PHvLFPpkY7gA/b1AHGAze6bnCH Z3HYQsRXnik0z7wwgDYOwkL8mstJ8rIZr4QjIjxwie9184v9545+LfCmTyojJMywlm+F oDtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=RL7Rs7W1; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z199si2649937oia.192.2020.02.11.19.08.54; Tue, 11 Feb 2020 19:08:57 -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=@coker.com.au header.s=2008 header.b=RL7Rs7W1; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727641AbgBLDIv (ORCPT + 13 others); Tue, 11 Feb 2020 22:08:51 -0500 Received: from smtp.sws.net.au ([46.4.88.250]:44794 "EHLO smtp.sws.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727602AbgBLDIu (ORCPT ); Tue, 11 Feb 2020 22:08:50 -0500 Received: from xev.coker.com.au (localhost [127.0.0.1]) by smtp.sws.net.au (Postfix) with ESMTP id B43B4EC4E for ; Wed, 12 Feb 2020 14:08:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1581476929; bh=Pvy4G4DtnGgfrD2GA0lw7MQ+yLa4oil825gdiUCMTwo=; l=6459; h=From:To:Reply-To:Subject:Date:From; b=RL7Rs7W1UrrZjQeB7+YzyqAgYJUCtffr9ytKz1WnrcLhTqawjfo8DS7cqYaRRhjdr WtIK1wgQOi0PS0il+lcRdFLPBVRuPe1j/Qbgd86x5OAdRj6QzUts5uc5G2DBwRfnjh tKhsTxvMfnm4kb1N6ZBnQWSC/FnBkeQzd4LI5YoY= Received: by xev.coker.com.au (Postfix, from userid 1001) id 92A52F2C8AB; Wed, 12 Feb 2020 14:08:43 +1100 (AEDT) From: Russell Coker To: "selinux-refpolicy@vger.kernel.org" Reply-To: russell@coker.com.au Subject: certbot patch Date: Wed, 12 Feb 2020 14:08:43 +1100 Message-ID: <3935693.2ZXyPmJE1a@xev> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2358566.OTxKuW8Otu" Content-Transfer-Encoding: 7Bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org This is a multi-part message in MIME format. --nextPart2358566.OTxKuW8Otu Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" This patch against the git refpolicy adds a domain for the certbot client for letsencrypt. This allows automatic renewal of certbot certificates. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/ --nextPart2358566.OTxKuW8Otu Content-Disposition: attachment; filename="certbot.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="certbot.diff" Index: refpolicy-2.20200209/policy/modules/services/certbot.fc =================================================================== --- /dev/null +++ refpolicy-2.20200209/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_var_lib_t,s0) Index: refpolicy-2.20200209/policy/modules/services/certbot.if =================================================================== --- /dev/null +++ refpolicy-2.20200209/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.20200209/policy/modules/services/certbot.te =================================================================== --- /dev/null +++ refpolicy-2.20200209/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_var_run_t; +files_pid_file(certbot_var_run_t) + +type certbot_tmp_t; +files_tmp_file(certbot_tmp_t) + +type certbot_tmpfs_t; +files_tmpfs_file(certbot_tmpfs_t) + +type certbot_var_lib_t; +files_type(certbot_var_lib_t) + +######################################## +# +# Local policy +# + +allow certbot_t self:fifo_file { getattr ioctl read write }; + +allow certbot_t self:capability { chown dac_override sys_resource }; + +# 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_var_run_t:file { map execute }; + +kernel_search_fs_sysctls(certbot_t) + +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) + +allow certbot_t self:udp_socket all_udp_socket_perms; +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_bin_entry_type(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_var_run_t, certbot_var_run_t) +files_pid_filetrans(certbot_t, certbot_var_run_t, file) + +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; + +files_search_var_lib(certbot_t) +manage_dirs_pattern(certbot_t, certbot_var_lib_t, certbot_var_lib_t) +manage_files_pattern(certbot_t, certbot_var_lib_t, certbot_var_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 }) + +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.20200209/policy/modules/system/miscfiles.if =================================================================== --- refpolicy-2.20200209.orig/policy/modules/system/miscfiles.if +++ refpolicy-2.20200209/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. ## ## --nextPart2358566.OTxKuW8Otu--