Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13890306pxu; Mon, 4 Jan 2021 07:14:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXXZekovarFR0asqFr5RlGPVPXPP0SvL5xu6cLsqW4kLdsvL8oyaUaeOGbBChZH7FZll8J X-Received: by 2002:a17:906:ce51:: with SMTP id se17mr66235504ejb.314.1609773299436; Mon, 04 Jan 2021 07:14:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609773299; cv=none; d=google.com; s=arc-20160816; b=GMxa/5Dr7n8l7aUSJiTchUX9K5RcU7g/WOHlb397UbCSX+p2b0derWMqS4eppRYgs8 OCgLcNiDrz1ex/NBJFhy5on2Ey6EIomp9VQR2W149W3cfxiBqsSAjGfeKNqt8K5YUdCa JcSlDu6N6tNMf2GVmmxLo5Rp2yqZnEYUTWX0fEoI2+n8+qOhCKEUWYJynyIQHKa7NAas M6L3dNmqta+vDOca61jWSJM7ml/QaJl6VP0HqDzLDzuMMAvf/zrUzrlnouYUE3cF36Xr RRveh+gd1ueGFBP0h2QdTXiOa8JZyWoRWc5zNtpl3b2kuDK+uXiAVlYrYpTAIvH8Vqsf RFMQ== 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=eDGBp6ntKgd5wey2d/AXRgHmNjg2JVhGvtm2SBYY57A=; b=PhXk50NUgDhzV727ZrazBO33/RO0xhXqYKTW9i0oe9Z7BygNVCQ2MnCom1AnkJ5K0L JAkO09/FrVLAKkHvQGDYkcLuZ+rAJI+bxr5RVUIf4zMJOHEURJfa3tbmPjsKSIcYasJf UIvZnrbr90ChvvXckXVEww11x8/yjmR1P09czjzSk104tGtXEcCN4e9KC9rteJrwLYkr 2qTuCg+gpyhxoFtTWjjANkpE0Wuc3p5m7zM1UoHy3rR+l6XYHa7GneEuyU8ilO+5HCvZ gjNsGk7aaIoTEy9ia9OopRwYv0Pi0GH1V1OXuwDE/MwZxTKVaTa5aenmMI2c3shZeuGP 2bJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@defensec.nl header.s=default header.b=p8mEIrqF; 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 m17si28719965ejn.194.2021.01.04.07.14.54; Mon, 04 Jan 2021 07:14:59 -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=p8mEIrqF; 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 S1727403AbhADPNr (ORCPT + 18 others); Mon, 4 Jan 2021 10:13:47 -0500 Received: from agnus.defensec.nl ([80.100.19.56]:57734 "EHLO agnus.defensec.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbhADPNr (ORCPT ); Mon, 4 Jan 2021 10:13:47 -0500 Received: from brutus (brutus.defensec.nl [IPv6:2001:985:d55d::438]) by agnus.defensec.nl (Postfix) with ESMTPSA id E23A32A12B1; Mon, 4 Jan 2021 16:13:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 agnus.defensec.nl E23A32A12B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=defensec.nl; s=default; t=1609773185; bh=eDGBp6ntKgd5wey2d/AXRgHmNjg2JVhGvtm2SBYY57A=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=p8mEIrqF2pQlcfIQ5GbSkjou6BFw56jnDRa+TTXcLGqQcKC0rWSHLEHYlFyguYbqk OmCyDbEgJ/jjFrBbOYAWxGnw5iOm2Acun0Z15M6eqEsA5oD1+n4LPgICaOL2jWNi/k wch+ltGHafOVbavvygcJ7qv8/e1JRG22paNOaBV8= From: Dominick Grift To: Chris PeBenito Cc: Russell Coker , selinux-refpolicy@vger.kernel.org Subject: Re: machinectl shell policy References: <8322849.62pqQp6Oog@liv> <1723812.Y751QtlBzf@liv> <5735537.jZnottUgFY@liv> Date: Mon, 04 Jan 2021 16:13:01 +0100 In-Reply-To: (Dominick Grift's message of "Mon, 04 Jan 2021 16:06:22 +0100") 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 Dominick Grift writes: > Dominick Grift writes: > >> Chris PeBenito writes: >> >>> On 12/25/20 4:16 AM, Russell Coker wrote: >>>> 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. >>>> 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; >>> >>> The pty stuff seems to make sense, but I'm curious why there is a >>> transition into user_systemd_t for the shell. >> >> The policy above is referencing "devpts_t", that is sub-optimal. there >> shouldnt be any pty chr files with the devpts_t filesystem type > > And I agree that then user_systemd_t shell_exec_t entrypoint should be > there. err, *should not be there* > >> >> >>> >>>> 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. >>> >>> I'd prefer to keep both unless it becomes onerous. >>> >>> >>>>> 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. >>> >>> The "else" of the ifdef can work. -- 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