Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3184634pxb; Sun, 20 Feb 2022 11:50:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu7SXIj5R3iEWdp/wRlYwvqARfok4GE2UhJml70RhOUSC4lXxLVowsgL2c5zJ2uoujmLwV X-Received: by 2002:a63:de46:0:b0:364:cad7:bf3b with SMTP id y6-20020a63de46000000b00364cad7bf3bmr13687833pgi.491.1645386612371; Sun, 20 Feb 2022 11:50:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645386612; cv=none; d=google.com; s=arc-20160816; b=em1AW7qh1J1Q/TSI6Alw4nwbJKJs/orjQuUbMyDEolbsxeu2GUqXkly3ojrkVfdLkX ycjH9CJc95NK2AiqmNjl7zga3AsCYL5lJ8u6JE4MLYmdxrW3O7k32wDAhQGzNR0uZ1hR M9oqb0fzCRtxBTHLElVtv2Ody1iZjaHCpNK5f6Wl0qCMudHXAmLnOI22tDzxu2SIIN6S mdkRMmh4Uq5KsaUuD9B4fqfMUvd9tTdPFqv/NO/RRPRKsvQzfS6tXw9+vSoOrKUInHdZ povMPAPbioRlHQjBJUcjIPbd5taU2lUMFNTo8AH4la2xfDn2m+AA4LRcOSv5SHzssRiE P8cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=qMfVpuNtZqm9MqS0r0eUnCrkI1KE10QcpmjT2+vXlIU=; b=FBkrtUaB7MbWXQdlU6RZi+yy2/sJkTmgl21Iugk1c2iwyxGoW1o0Td4GWyKrBBZ2GX 8ykpSHq+Im7gS+JnD4rG0EQkrffvjb+N5iPnQX+RNjLWldFTsz/DwrCPC50UagIiujj3 rob5uA0gNkvgost1Zpd+dV9RbkTXmvXnbhuyopbw88LCqY9BETPVuDfwAYO6IxE54el0 s/g99Z0ElaO/tKwzXT3pZZzc9M/VMZfO0gwYkEGEYdmOrrlQJHGdgpqtpQBmxu81ui9z X9p0rAwXUpXfhmFh9Ztv4nFyntlb53zYnZtcDDcznepLfIe+AJSAwUwfhR3DUrTmOP3V yRZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=F+2qcqDL; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s36si9065560pga.801.2022.02.20.11.50.05; Sun, 20 Feb 2022 11:50:11 -0800 (PST) Received-SPF: pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=F+2qcqDL; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S241085AbiBSCqE (ORCPT + 22 others); Fri, 18 Feb 2022 21:46:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232054AbiBSCqE (ORCPT ); Fri, 18 Feb 2022 21:46:04 -0500 Received: from smtp.sws.net.au (smtp.sws.net.au [144.76.241.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB92579C65 for ; Fri, 18 Feb 2022 18:45:45 -0800 (PST) Received: from xev.coker.com.au (localhost [127.0.0.1]) by smtp.sws.net.au (Postfix) with ESMTP id 3AD81F0E9 for ; Sat, 19 Feb 2022 13:45:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1645238742; bh=qMfVpuNtZqm9MqS0r0eUnCrkI1KE10QcpmjT2+vXlIU=; l=3826; h=Date:From:To:Subject:From; b=F+2qcqDLiW8LWmgbH9G9AzvngYOV0yN5C+1/q4an9kffxJfFsiKBo3TZsom4K5xvg Qe/WYWTODXQsPZsjUNSXurQKG/TJJk7eB6V9eMQgPoucNaKMJW/hdTS7e6YWPLO7io mhKZoBS7V8qI9Aan4T2v6cAaGJFL7SI/5tfbnO8w= Received: by xev.coker.com.au (Postfix, from userid 1001) id BC98A1738F23; Sat, 19 Feb 2022 13:45:37 +1100 (AEDT) Date: Sat, 19 Feb 2022 13:45:37 +1100 From: Russell Coker To: selinux-refpolicy@vger.kernel.org Subject: [PATCH] certbot Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Allow certbot to create /var/lib/letsencrypt and /var/og/letsencrypt with the correct contexts. Allow it to read /dev/urandom, dontaudit attempts to write python cache files (would be good to fix python for this), and reload web server to get new keys. I think this is good to merge. Signed-off-by: Russell Coker Index: refpolicy-2.20220106/policy/modules/services/apache.if =================================================================== --- refpolicy-2.20220106.orig/policy/modules/services/apache.if +++ refpolicy-2.20220106/policy/modules/services/apache.if @@ -238,6 +238,24 @@ interface(`apache_domtrans',` ######################################## ## +## Execute httpd +## +## +## +## Domain allowed to execute it. +## +## +# +interface(`apache_exec',` + gen_require(` + type httpd_t, httpd_exec_t; + ') + + can_exec($1, httpd_exec_t) +') + +######################################## +## ## Execute httpd server in the httpd domain. ## ## @@ -1430,3 +1448,21 @@ interface(`apache_admin',` apache_run_all_scripts($1, $2) apache_run_helper($1, $2) ') + +######################################## +## +## rw httpd_runtime_t files +## +## +## +## Domain allowed access. +## +## +# +interface(`apache_rw_runtime_files',` + gen_require(` + type httpd_runtime_t; + ') + + allow $1 httpd_runtime_t:file rw_file_perms; +') Index: refpolicy-2.20220106/policy/modules/services/certbot.te =================================================================== --- refpolicy-2.20220106.orig/policy/modules/services/certbot.te +++ refpolicy-2.20220106/policy/modules/services/certbot.te @@ -43,9 +43,10 @@ allow certbot_t self:udp_socket all_udp_ allow certbot_t self:tcp_socket all_tcp_socket_perms; allow certbot_t self:netlink_route_socket create_netlink_socket_perms; -files_search_var_lib(certbot_t) +files_var_lib_filetrans(certbot_t, certbot_lib_t, dir, "letsencrypt") manage_dirs_pattern(certbot_t, certbot_lib_t, certbot_lib_t) manage_files_pattern(certbot_t, certbot_lib_t, certbot_lib_t) +allow certbot_t certbot_lib_t:file relabelfrom; manage_dirs_pattern(certbot_t, certbot_tmp_t, certbot_tmp_t) manage_files_pattern(certbot_t, certbot_tmp_t, certbot_tmp_t) @@ -62,7 +63,7 @@ allow certbot_t certbot_tmp_t:file mmap_ allow certbot_t certbot_tmpfs_t:file mmap_exec_file_perms; allow certbot_t certbot_runtime_t:file mmap_exec_file_perms; -logging_search_logs(certbot_t) +logging_log_filetrans(certbot_t, certbot_log_t, dir, "letsencrypt") allow certbot_t certbot_log_t:dir manage_dir_perms; allow certbot_t certbot_log_t:file manage_file_perms; @@ -80,11 +81,15 @@ corenet_tcp_connect_dns_port(certbot_t) # bind to http port for standalone mode corenet_tcp_bind_http_port(certbot_t) +dev_read_urand(certbot_t) + domain_use_interactive_fds(certbot_t) files_read_etc_files(certbot_t) files_read_usr_files(certbot_t) +# dontaudit for attempts to write python cache files +libs_dontaudit_write_lib_dirs(certbot_t) libs_exec_ldconfig(certbot_t) # for /usr/lib/gcc/x86_64-linux-gnu/8/collect2 libs_exec_lib_files(certbot_t) @@ -110,5 +115,17 @@ optional_policy(` # for writing to webroot apache_manage_sys_content(certbot_t) - apache_search_config(certbot_t) + apache_append_log(certbot_t) + apache_exec(certbot_t) + apache_exec_modules(certbot_t) + + # for certbot to create nginx config + apache_manage_config(certbot_t) + + apache_rw_runtime_files(certbot_t) + apache_signal(certbot_t) +') + +optional_policy(` + xdg_search_config_dirs(certbot_t) ')