Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp377843pxb; Mon, 25 Apr 2022 11:47:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycKRBpUNmptuKcQWF/TKm789QNWZMZSeRtnd+Tuo7VY2FAEIDoudW2Xh+f2jnK4NYkU5WZ X-Received: by 2002:a17:90b:314a:b0:1d9:5ccf:baab with SMTP id ip10-20020a17090b314a00b001d95ccfbaabmr9927946pjb.110.1650912432552; Mon, 25 Apr 2022 11:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650912432; cv=none; d=google.com; s=arc-20160816; b=F4RutgAj9lmRazGkx9nE9QwD+Tgk3Yg6YTh+OITgUg2xeuQK7RT0jvU+ZM1wHYw0ky RsVc+LYYtp9KB+gqPKDeNHSMMqt6dwSfcstswq2TBAPlbfwnLJZJvnk3wy590toFDv3D 5OoctiTIG1gz6pfXKuHURPEHc7B8REPHvt75QYrKB6ypZkhpTcJPjQsrqMjLwQPgHNjc 4x9PZQQ4R1hh2L7L0MhNGZ584dcbaXK22oC64Rvn98AVJz/wSi4CQ6vv5seTTyaqJRgH SkqwTQQMn7C9YMN0bSmeH3Nt+0R6rjgvzx/xyHfry4R7W1axM4yTQPpVVNvVTk00VYUj EAfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=hg7YdCEkjYzckhrzkEHZeXMw8SfMgAi/6wubjSTlgNo=; b=alt1djltwVRXBJtzjiVL9OWAxItvEhjCM+geqCHuxB+ixG1uoTNQ6u6MwLrXwisnLV +PrVX2UbNf+aDaHn0IHf4H3vnWmRLRZImzgu6zgMVdcwzC+4tjyTNIEoK0U+NKvgIQqP 0J3oFDPr/G026TqIvigNdPCOM6xGKZGlsxfKBh1wyoU+6RPUxCjQb7KupxY7mFRUSMcF WPFE8Qt9qw9EEfqwxZdFV6c01nXdKapIQViNP+113gsRI5h8Zal2q6iKRpYOdC8CYaIw RY6S5PF76jCoxvztDTrvHM1SWz+yg8l5m/sodwZHivNjWQLrQ39ANJcJSg2ZoDBGASMY Djag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b=hBKiiK2f; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ieee.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c130-20020a624e88000000b0050aca65bc3dsi15273033pfb.169.2022.04.25.11.47.07; Mon, 25 Apr 2022 11:47:12 -0700 (PDT) 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=@ieee.org header.s=google header.b=hBKiiK2f; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ieee.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236316AbiDYNag (ORCPT + 22 others); Mon, 25 Apr 2022 09:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242033AbiDYNac (ORCPT ); Mon, 25 Apr 2022 09:30:32 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4579040A2D for ; Mon, 25 Apr 2022 06:27:26 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id s4so10762231qkh.0 for ; Mon, 25 Apr 2022 06:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=hg7YdCEkjYzckhrzkEHZeXMw8SfMgAi/6wubjSTlgNo=; b=hBKiiK2fCZ2grxbGDL0S5Zedr+Fq9jFNHN9VpUxr/HJhgslili2FNRHOjOJ7TBuab0 Tp6yJjTYvAzqrbCf8tBWRMP8Kk4wPRkV6QQQGMqflUl6BkhzCx1lGfXLAOMA5ymJPW8I ysQAdIbGF9Dsp6SyaOwq4j5w4mXsazRgyNDs0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=hg7YdCEkjYzckhrzkEHZeXMw8SfMgAi/6wubjSTlgNo=; b=e8V05DW+SgLIWraRu55lp29Ezc1RGEnAx3sNffu/fyJhzM7wqJ8jDg6g5wnghbQaph RAJk0dZ/ygYMevtlXxtS2lqKD6xVNbgboitI1pywPO4GgIrxLNvh+4MJL4lKW6ZcWvAL gVtDTR7WgWeLFSLF7kOef3Ku2C9Pc3b/j8urgTUxYPWTIUv059I7TqaUxsC3/ScPUKAG 4LVfSeale5ZvQZe33T6RF3gpBP4sUtzsn5L4butj4YAxw9h/bYLI7R88n809q22Nw9qi l0DJMqVTSxkDzCG7G5DVk8EIr+mgmCzbMiBR7jvrbvxdSoyIGM5X5PEM3RjKjv84AE3V Dn+g== X-Gm-Message-State: AOAM5336OvXPcYNgcQJmPMdmD8UsWBATJ1f51GiJCjK9iJ4Z2clcVNUc f+ovxLWU7p0AShxHpB/fALupQRy021lh4HgO X-Received: by 2002:a05:620a:270d:b0:69f:26e4:15f6 with SMTP id b13-20020a05620a270d00b0069f26e415f6mr7453945qkp.362.1650893245949; Mon, 25 Apr 2022 06:27:25 -0700 (PDT) Received: from [192.168.1.242] (pool-68-134-25-67.bltmmd.fios.verizon.net. [68.134.25.67]) by smtp.gmail.com with ESMTPSA id w6-20020a05622a190600b002f1f91ad3e7sm6282892qtc.22.2022.04.25.06.27.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Apr 2022 06:27:25 -0700 (PDT) Message-ID: <5b4dd97a-b070-ab60-003c-53f4472d6213@ieee.org> Date: Mon, 25 Apr 2022 09:23:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] machinectl shell and login fixes Content-Language: en-US To: Russell Coker , selinux-refpolicy@vger.kernel.org References: From: Chris PeBenito In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On 4/6/22 10:52, Russell Coker wrote: > This patch fixes a delay in login and allows machinectl shell to work. > > Signed-off-by: Russell Coker > > Index: refpolicy-2.20220325/policy/modules/system/init.if > =================================================================== > --- refpolicy-2.20220325.orig/policy/modules/system/init.if > +++ refpolicy-2.20220325/policy/modules/system/init.if > @@ -3301,6 +3301,24 @@ interface(`init_tcp_recvfrom_all_daemons > corenet_tcp_recvfrom_labeled($1, daemon) > ') > > +###################################### > +## > +## restart systemd units, for /run/systemd/transient/* There is a new type for these transient units. > +## > +## > +## > +## Domain allowed access. > +## > +## > +# > +interface(`init_restart_units',` > + gen_require(` > + type init_var_run_t; > + ') > + > + allow $1 init_var_run_t:service { start status stop }; > +') > + > ######################################## > ## > ## Allow the specified domain to connect to daemon with a udp socket > Index: refpolicy-2.20220325/policy/modules/system/locallogin.te > =================================================================== > --- refpolicy-2.20220325.orig/policy/modules/system/locallogin.te > +++ refpolicy-2.20220325/policy/modules/system/locallogin.te > @@ -129,7 +129,8 @@ auth_manage_pam_runtime_files(local_logi > auth_manage_pam_console_data(local_login_t) > auth_domtrans_pam_console(local_login_t) > > -init_dontaudit_use_fds(local_login_t) > +# if local_login_t can not inherit fd from init it takes ages to login > +init_use_fds(local_login_t) > > miscfiles_read_localization(local_login_t) > > Index: refpolicy-2.20220325/policy/modules/system/systemd.te > =================================================================== > --- refpolicy-2.20220325.orig/policy/modules/system/systemd.te > +++ refpolicy-2.20220325/policy/modules/system/systemd.te > @@ -851,6 +851,9 @@ init_start_system(systemd_logind_t) > init_stop_system(systemd_logind_t) > init_watch_utmp(systemd_logind_t) > > +# for /run/systemd/transient/* > +init_restart_units(systemd_logind_t) > + > locallogin_read_state(systemd_logind_t) > > seutil_libselinux_linked(systemd_logind_t) > Index: refpolicy-2.20220325/policy/modules/system/systemd.if > =================================================================== > --- refpolicy-2.20220325.orig/policy/modules/system/systemd.if > +++ refpolicy-2.20220325/policy/modules/system/systemd.if > @@ -19,11 +19,6 @@ > ## The user domain for the role. > ## > ## > -## > -## > -## The type for the user pty > -## > -## > # > template(`systemd_role_template',` > gen_require(` > @@ -33,6 +28,7 @@ template(`systemd_role_template',` > type systemd_conf_home_t, systemd_data_home_t; > type systemd_user_runtime_t, systemd_user_runtime_notify_t; > type systemd_user_unit_t, systemd_user_runtime_unit_t; > + type systemd_machined_t, user_devpts_t; > ') > > ################################# > @@ -60,6 +56,7 @@ template(`systemd_role_template',` > allow $1_systemd_t $3:process { setsched rlimitinh signal_perms }; > corecmd_shell_domtrans($1_systemd_t, $3) > corecmd_bin_domtrans($1_systemd_t, $3) > + corecmd_shell_entry_type($1_systemd_t) > > # systemctl --user rules > allow $1_systemd_t systemd_user_unix_stream_activated_socket_type:unix_stream_socket { create_socket_perms listen }; > @@ -114,6 +111,10 @@ template(`systemd_role_template',` > seutil_search_default_contexts($1_systemd_t) > seutil_read_file_contexts($1_systemd_t) > > + # for machinectl shell > + term_user_pty($1_systemd_t, user_devpts_t) > + allow $1_systemd_t user_devpts_t:chr_file rw_file_perms; > + > systemd_manage_conf_home_content($1_systemd_t) > systemd_manage_data_home_content($1_systemd_t) > > @@ -144,6 +145,12 @@ template(`systemd_role_template',` > allow $3 systemd_user_runtime_t:lnk_file { manage_lnk_file_perms relabel_lnk_file_perms }; > allow $3 systemd_user_runtime_t:sock_file { manage_sock_file_perms relabel_sock_file_perms }; > > + # for "machinectl shell" > + allow $1_systemd_t systemd_machined_t:fd use; > + allow $3 systemd_machined_t:fd use; > + allow $3 systemd_machined_t:dbus send_msg; > + allow systemd_machined_t $3:dbus send_msg; > + > allow $3 systemd_user_runtime_notify_t:sock_file { manage_sock_file_perms relabel_sock_file_perms }; > > allow $3 systemd_user_unit_t:service { reload start status stop }; -- Chris PeBenito