Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp7152881pxu; Fri, 25 Dec 2020 03:41:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhr4RgyZAx6ZRVljpqpL+kzsy86OL1lHgC4ImWNp3bRgYDjUrHsI6mXumPOo9uuTLIb1PB X-Received: by 2002:a05:6402:3c3:: with SMTP id t3mr32108135edw.86.1608896460850; Fri, 25 Dec 2020 03:41:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608896460; cv=none; d=google.com; s=arc-20160816; b=KKlboSa1aYsudTbGRNrXuhxu356JhCLJAXcJAOsZWUBK+ErwyoJ0Gh7C6sDOhvwwsl XPrPru9R/xJkSkCQaB4PobUTCr/rkcBbHFgtKW5q0xBc6L/+ze26exSQvBR82GWMzTOM b0Hr8gKyjHhh88PUO5HwHrm7a8BEZ58YjwLqmYNKR5lOzBLrGVJDqosTUPrRsv8lINeQ 1QeJO35xp//MetfPrWro+7dm6fRasEREpJHBx154mYrn2ex13u3wUVX0dt0o0IXhjxdm 1vH45Osu7GlJvE96CHNQq48ZgLCJbIrkBgAoE2+dus4UridoW7ZkIWyjPLu5R7wRRiuO ZWEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature:dkim-filter; bh=0IODsH9OFMx4/oA0ZaCVlYkps02N1Se/m5NjgWIro10=; b=gXTTJMlXWYpXdNQbtZuJ5UbeJ7n/CA6Fo78i9jb8TYOcpgRL+QtzA9tFkz3QUIPbGz GvIg/nThyo4SI2dpFI3LQTE+bjp+gb4v7bb3+iuncTz0Hg871VAotkBPnYwDzRzGE+Dm iGDRUjykITlNipj0qPlxcjB/8iSwySI9Tqe1SI5SppP8na5X5l0cVjo2Z3TEXeZCb7b2 BtyIPAmjQ7I1Y4quUd0nPrGrPmpJMskqziRO23a45L++dNlkKfdCKK+8Sy46EJc1IGO3 RbFuF9SKSbG92dXH2tURzQvLkPeGSaQVAY02wvVosi5wUv2uxujWAB3J4mhhSMTkH2Ik /Grw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@defensec.nl header.s=default header.b=swnBE0YP; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z5si15738839ejj.425.2020.12.25.03.40.53; Fri, 25 Dec 2020 03:41:00 -0800 (PST) Received-SPF: pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@defensec.nl header.s=default header.b=swnBE0YP; spf=pass (google.com: domain of selinux-refpolicy-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729231AbgLYLiE (ORCPT + 18 others); Fri, 25 Dec 2020 06:38:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729108AbgLYLiE (ORCPT ); Fri, 25 Dec 2020 06:38:04 -0500 X-Greylist: delayed 97115 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 25 Dec 2020 03:37:23 PST Received: from agnus.defensec.nl (agnus.defensec.nl [IPv6:2001:985:d55d::711]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7D85CC061573 for ; Fri, 25 Dec 2020 03:37:23 -0800 (PST) Received: from brutus (brutus.defensec.nl [IPv6:2001:985:d55d::438]) by agnus.defensec.nl (Postfix) with ESMTPSA id 4C7B22A12B1; Fri, 25 Dec 2020 12:37:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 agnus.defensec.nl 4C7B22A12B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=defensec.nl; s=default; t=1608896240; bh=0IODsH9OFMx4/oA0ZaCVlYkps02N1Se/m5NjgWIro10=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=swnBE0YP8JpSCNj1jxpLOqw0BXT9HCX2AgAHbNhvNVtVokVnzXTio37zmFnL37QKr tfXvJYs7j7w85GLjTV+s05nZmEyPumKhMIibeBlU34dXyZgSYdy3YQ77FpoY7ZFIg6 JANkduv4NiKTpZiIxvCQwWn2muQaeEoma7SQz14g= From: Dominick Grift To: Russell Coker Cc: selinux-refpolicy@vger.kernel.org Subject: Re: machinectl shell policy References: <8322849.62pqQp6Oog@liv> <1723812.Y751QtlBzf@liv> <5735537.jZnottUgFY@liv> Date: Fri, 25 Dec 2020 12:37:17 +0100 In-Reply-To: <5735537.jZnottUgFY@liv> (Russell Coker's message of "Fri, 25 Dec 2020 20:16:07 +1100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Russell Coker writes: > On Friday, 25 December 2020 6:58:41 PM AEDT Dominick Grift wrote: >> Russell Coker writes: >> > On Thursday, 24 December 2020 7:37:50 PM AEDT Dominick Grift wrote: >> >> > To enable "machinectl shell" on recent versions of systemd we need >> >> > something like the above policy (which is not complete or ideal, still >> >> > doesn't work so no point polishing it) and something for the below. >> >> > What >> >> > is the below about? >> >> >> >> this should be thoroughly addressed. machined creates a login pty that >> >> gets relabeled on login as per type_change rules. >> > >> > Currently it's not being relabeled on Debian, but that's a separate issue. >> >> Maybe the required type_change rules arent present? > > Here is all the policy to make it work. Maybe we should have a type like > system_dbusd_devpts_t for this. This is not policy for inclusion, this is > policy to discuss before writing that policy. I created a machined_pty_t, and then allowed both systemd (unconfined & user_systemd_t) as well as the various user types to type change from machined_pty_t to user_pty_t [root@brutus ~]# sesearch --type_change | grep machine type_change sys.isid machine.daemon.loginpty:chr_file sys.pty; # unconfined_t and systemd --system are "system" is sys.isid, sys.pty is system/unconfined pty) type_change user.subj machine.daemon.loginpty:chr_file user.pty; # all my confined login user shell domains are "user.subj" type_change user.systemd.subj machine.daemon.loginpty:chr_file user.pty; # this is systemd --user on behalf of confined login users my systemd-machined policy: https://git.defensec.nl/?p=dssp3.git;a=blob_plain;f=policy/systemd/systemd_machine.cil;hb=HEAD > > term_user_pty(user_systemd_t, user_devpts_t) > term_login_pty(devpts_t) > allow user_systemd_t user_devpts_t:chr_file rw_file_perms; > > # for machinectl shell > allow sysadm_t systemd_machined_t:dbus send_msg; > systemd_manage_userdb_runtime_dirs(systemd_machined_t) > systemd_manage_userdb_runtime_sock_files(systemd_machined_t) > term_use_ptmx(systemd_machined_t) > dev_getattr_fs(systemd_machined_t) > term_getattr_pty_fs(systemd_machined_t) > allow systemd_machined_t sysadm_t:dbus send_msg; > allow systemd_machined_t devpts_t:chr_file rw_file_perms; > allow system_dbusd_t systemd_machined_t:fd use; > allow system_dbusd_t devpts_t:chr_file { read write }; > allow system_dbusd_t ptmx_t:chr_file { read write }; > allow sysadm_t systemd_machined_t:fd use; > allow user_systemd_t shell_exec_t:file entrypoint; > allow user_systemd_t systemd_machined_t:fd use; > allow user_systemd_t self:process signal; > allow user_t systemd_machined_t:fd use; > allow user_t user_systemd_t:fifo_file { getattr write }; > allow user_t init_t:process signal; > >> > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892001 >> > >> > We have work in progress on dbus-broker in Debian. Would it make sense to >> > only support dbus-broker in SE Linux policy? Being forced to use only 1 >> > of >> > the 2 dbus programs (and the newer and faster 1 of the 2) is a very small >> > trade-off, smaller than some of the other trade-offs for running SE Linux. >> >> should probably be able to support both (conditionally) but could get messy > > Currently we have a heap of ifdef systemd in the policy, as probably the only > people not wanting dbus-broker will be the ones not wanting systemd we could > include it in the same ifdef rules. -- gpg --locate-keys dominick.grift@defensec.nl Key fingerprint = FCD2 3660 5D6B 9D27 7FC6 E0FF DA7E 521F 10F6 4098 https://sks-keyservers.net/pks/lookup?op=get&search=0xDA7E521F10F64098 Dominick Grift