Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7420289ybl; Tue, 24 Dec 2019 02:11:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxB6QkalsCZWdOU7BCSyMElkOlaMVvpjrRjhaypEpPxd3PnWPbPYLr0f/Vf51+P8mXBlsVF X-Received: by 2002:a9d:65da:: with SMTP id z26mr29328977oth.197.1577182262869; Tue, 24 Dec 2019 02:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577182262; cv=none; d=google.com; s=arc-20160816; b=C0TURJfLBCV/8+cJvDhuenxdq4oQBOMgZZLk4lfPZNCQkntTbFk4zb53tO1OyGdOiD lmY0OH+YOFizJbvpuWWvknBDykJ6W45jDvFSKRt7+xovc8vOpa7oYkNd/jNB+pX+70VE CnmFUw2+Gj9CdABWQPgrqh0UBI9n2Qexfo05OMD79AuW7vLv4oF4RrFXqEzZM+dc+Djk VNx5bz87XNtbUJyVgRsDbwrXEs4WK8U5cvLUrWv/qVSPLZbjyONGX5HMTyFOQe5t+M7w 0oIJvUxJfIj4rvEloVB/2anwyM1U5/yxrW8NKNk8CVDyrxL4GyNIInEKMM6i/MvOVraY oBPQ== 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:cc:to:from:dkim-signature; bh=F37g0/wFQKG8tqnMU+D1ML/vrVJoj9QDiSKjAs5V0E8=; b=A3lCW1rSMTNNo7eh5KaFRPgJ9Pl6c29bQPOGOfU4haHVnCBiIv0gBYrO7piqcoIWjx pK4B/dSKYBBxe9u4qqPgCu7XdzrqiZPNlTaRB5CnLMZIpCxaef57coMtLaYY3OCL6GAQ JkZcH/P8KWVzs74gDInSsOwHUDhYqvBEpuaMJvdr2V+TA30d8ntaZqO/6wMu9Utq5SVu lQ7tko8Ql67MozTpdGJDudFyR/bvM8lESpNoL1V0yA12M7GZ0UP11OeuVe/buSO8JkYq Ce/itpzmExSLDxmq7S5wJIyBbq5AGy3uSG92P9VlL5bgT/fWulAtBmJ3SzLgrelYOMFw Zaaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=OWAaxuwu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r132si9737519oig.263.2019.12.24.02.10.59; Tue, 24 Dec 2019 02:11:02 -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=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=OWAaxuwu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726206AbfLXKK4 (ORCPT + 11 others); Tue, 24 Dec 2019 05:10:56 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36460 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbfLXKK4 (ORCPT ); Tue, 24 Dec 2019 05:10:56 -0500 Received: by mail-pf1-f194.google.com with SMTP id x184so10553719pfb.3 for ; Tue, 24 Dec 2019 02:10:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F37g0/wFQKG8tqnMU+D1ML/vrVJoj9QDiSKjAs5V0E8=; b=OWAaxuwuxIbS8K2FDbQjYnMqVOYA4ylJe9Y9x5L4kZ0F0UyInddB+VLuNOj/I/0ubQ 4D/5a6qgL1eiMEU+iVIYJLptI8hH2u0r+GNndwvitUa/hgT61LrEEK02UOUpz+rL9f9u MLRDhynBvZJQIWV8o9xLnJJbHtBop273hZTd45nVb/u//NafMs9j6famUoP1U7ZMl5GO iMSomTVicXWqflTDTA14b2d500Uh8y0H4QKfT5tjrIF8ZZxZO1a9rmdFqS7h4Ah6bDRq MMPb7lTQjp94M0ExYigKl66HXMkN1vbz1AODEcqM95/KoGVTTrUUEnRGZhJWyQPs+AqE dGGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F37g0/wFQKG8tqnMU+D1ML/vrVJoj9QDiSKjAs5V0E8=; b=QBhoIsX1DHuyiP4y+bjJoPwbHrYC343OPVXBTZGhGKLqV2LZAIt3ojTTFfAoW4nRcE 91IgIMIwdO/h/ErkvScQzF1ETvNDX8PFz9kGbU53WMLqmofzyecrY3tTZK93Xe6G9sXe 9LZl6M18n+76bnPeiWaSR/nbTf1xBakUB9oC21zmSlTWAdzlvHLUKZBoCLuLT5k8zm1M Fzlx3IYqSz6ONdmxyH3HyGm2l7zc+q8PgCmo+B9LsXwmWrxwGI5i8Ps7WdU0TLHzWd9s 3UjdxYWic16XQg3go+gFfu04rX2n0P54M4x50njYOmAJm5lDNHaeffNrXLrO+1Bt8uxu NiVw== X-Gm-Message-State: APjAAAWPLvueibnr2buZrnberNFl3lMVSMYA6i23400gwGhEJ16+r7Om m2C8lCJ4ajn6AFfImx9rOgpFDcb18gKb5A== X-Received: by 2002:a65:66d7:: with SMTP id c23mr37152195pgw.40.1577182255463; Tue, 24 Dec 2019 02:10:55 -0800 (PST) Received: from localhost ([101.127.140.252]) by smtp.gmail.com with ESMTPSA id 18sm20902957pfj.3.2019.12.24.02.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2019 02:10:54 -0800 (PST) From: Jason Zaman To: selinux-refpolicy@vger.kernel.org Cc: Jason Zaman Subject: [PATCH 1/9] systemd: Add elogind support Date: Tue, 24 Dec 2019 18:10:35 +0800 Message-Id: <20191224101043.58122-1-jason@perfinion.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Elogind is based off systemd-logind extracted to stand alone. Signed-off-by: Jason Zaman --- policy/modules/admin/sudo.if | 2 ++ policy/modules/system/authlogin.if | 5 +++++ policy/modules/system/systemd.fc | 5 +++++ policy/modules/system/systemd.te | 27 ++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/policy/modules/admin/sudo.if b/policy/modules/admin/sudo.if index c1459364..4f08af28 100644 --- a/policy/modules/admin/sudo.if +++ b/policy/modules/admin/sudo.if @@ -159,6 +159,8 @@ template(`sudo_role_template',` optional_policy(` dbus_system_bus_client($1_sudo_t) + systemd_dbus_chat_logind($1_sudo_t) + systemd_write_inherited_logind_sessions_pipes($1_sudo_t) ifdef(`init_systemd',` init_dbus_chat($1_sudo_t) diff --git a/policy/modules/system/authlogin.if b/policy/modules/system/authlogin.if index c16748f2..83837458 100644 --- a/policy/modules/system/authlogin.if +++ b/policy/modules/system/authlogin.if @@ -71,6 +71,11 @@ interface(`auth_use_pam',` optional_policy(` fprintd_dbus_chat($1) ') + + optional_policy(` + systemd_dbus_chat_logind($1) + systemd_write_inherited_logind_sessions_pipes($1) + ') ') optional_policy(` diff --git a/policy/modules/system/systemd.fc b/policy/modules/system/systemd.fc index 607b1d88..e6831465 100644 --- a/policy/modules/system/systemd.fc +++ b/policy/modules/system/systemd.fc @@ -16,6 +16,10 @@ /usr/bin/systemd-tty-ask-password-agent -- gen_context(system_u:object_r:systemd_passwd_agent_exec_t,s0) /usr/bin/systemd-notify -- gen_context(system_u:object_r:systemd_notify_exec_t,s0) +/usr/lib/elogind/elogind -- gen_context(system_u:object_r:systemd_logind_exec_t,s0) +/usr/lib/elogind/elogind-cgroups-agent -- gen_context(system_u:object_r:systemd_logind_exec_t,s0) +/usr/lib/elogind/elogind-uaccess-command -- gen_context(system_u:object_r:systemd_logind_exec_t,s0) + # Systemd generators /usr/lib/systemd/system-generators/systemd-gpt-auto-generator -- gen_context(system_u:object_r:systemd_gpt_generator_exec_t,s0) @@ -56,6 +60,7 @@ /var/lib/systemd/rfkill(/.*)? gen_context(system_u:object_r:systemd_rfkill_var_lib_t,s0) /run/\.nologin[^/]* -- gen_context(system_u:object_r:systemd_sessions_runtime_t,s0) +/run/elogind\.pid -- gen_context(system_u:object_r:systemd_logind_runtime_t,s0) /run/nologin -- gen_context(system_u:object_r:systemd_sessions_runtime_t,s0) /run/systemd/ask-password(/.*)? gen_context(system_u:object_r:systemd_passwd_runtime_t,s0) diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te index 1422d8e2..f13b7252 100644 --- a/policy/modules/system/systemd.te +++ b/policy/modules/system/systemd.te @@ -99,6 +99,7 @@ init_system_domain(systemd_locale_t, systemd_locale_exec_t) type systemd_logind_t; type systemd_logind_exec_t; +dbus_system_domain(systemd_logind_t, systemd_logind_exec_t) init_daemon_domain(systemd_logind_t, systemd_logind_exec_t) init_named_socket_activation(systemd_logind_t, systemd_logind_runtime_t) @@ -108,6 +109,7 @@ files_pid_file(systemd_logind_inhibit_runtime_t) type systemd_logind_runtime_t alias systemd_logind_var_run_t; files_pid_file(systemd_logind_runtime_t) init_daemon_pid_file(systemd_logind_runtime_t, dir, "systemd_logind") +init_daemon_pid_file(systemd_logind_runtime_t, file, "elogind") type systemd_logind_var_lib_t; files_type(systemd_logind_var_lib_t) @@ -427,7 +429,7 @@ logging_send_syslog_msg(systemd_log_parse_env_type) # Logind local policy # -allow systemd_logind_t self:capability { chown dac_override dac_read_search fowner sys_admin sys_tty_config }; +allow systemd_logind_t self:capability { chown dac_override dac_read_search fowner fsetid sys_admin sys_resource sys_tty_config }; allow systemd_logind_t self:process { getcap setfscreate }; allow systemd_logind_t self:netlink_kobject_uevent_socket create_socket_perms; allow systemd_logind_t self:unix_dgram_socket create_socket_perms; @@ -439,6 +441,9 @@ init_var_lib_filetrans(systemd_logind_t, systemd_logind_var_lib_t, dir) manage_fifo_files_pattern(systemd_logind_t, systemd_logind_runtime_t, systemd_logind_runtime_t) manage_files_pattern(systemd_logind_t, systemd_logind_runtime_t, systemd_logind_runtime_t) allow systemd_logind_t systemd_logind_runtime_t:dir manage_dir_perms; +files_pid_filetrans(systemd_logind_t, systemd_logind_runtime_t, file) + +create_dirs_pattern(systemd_logind_t, systemd_machined_runtime_t, systemd_machined_runtime_t) manage_dirs_pattern(systemd_logind_t, systemd_logind_inhibit_runtime_t, systemd_logind_inhibit_runtime_t) manage_files_pattern(systemd_logind_t, systemd_logind_inhibit_runtime_t, systemd_logind_inhibit_runtime_t) @@ -451,6 +456,8 @@ allow systemd_logind_t systemd_sessions_runtime_t:fifo_file manage_fifo_file_per kernel_read_kernel_sysctls(systemd_logind_t) +auth_write_login_records(systemd_logind_t) + dev_getattr_dri_dev(systemd_logind_t) dev_getattr_generic_usb_dev(systemd_logind_t) dev_getattr_kvm_dev(systemd_logind_t) @@ -470,10 +477,13 @@ dev_setattr_video_dev(systemd_logind_t) domain_obj_id_change_exemption(systemd_logind_t) +files_purge_tmp(systemd_logind_t) files_read_etc_files(systemd_logind_t) files_search_pids(systemd_logind_t) fs_getattr_cgroup(systemd_logind_t) +fs_manage_cgroup_dirs(systemd_logind_t) +fs_manage_cgroup_files(systemd_logind_t) fs_getattr_tmpfs(systemd_logind_t) fs_getattr_tmpfs_dirs(systemd_logind_t) fs_list_tmpfs(systemd_logind_t) @@ -483,6 +493,8 @@ fs_read_efivarfs_files(systemd_logind_t) fs_relabelfrom_tmpfs_dirs(systemd_logind_t) fs_unmount_tmpfs(systemd_logind_t) +logging_send_audit_msgs(systemd_logind_t) + selinux_get_enforce_mode(systemd_logind_t) storage_getattr_removable_dev(systemd_logind_t) @@ -495,6 +507,7 @@ term_use_unallocated_ttys(systemd_logind_t) auth_manage_faillog(systemd_logind_t) +init_create_runtime_dirs(systemd_logind_t) init_dbus_send_script(systemd_logind_t) init_get_all_units_status(systemd_logind_t) init_get_system_status(systemd_logind_t) @@ -537,6 +550,14 @@ userdom_relabelto_user_runtime_dirs(systemd_logind_t) userdom_setattr_user_ttys(systemd_logind_t) userdom_use_user_ttys(systemd_logind_t) +tunable_policy(`use_nfs_home_dirs',` + fs_read_nfs_files(systemd_logind_t) +') + +tunable_policy(`use_samba_home_dirs',` + fs_read_cifs_files(systemd_logind_t) +') + # Needed to work around patch not yet merged into the systemd-logind supported on RHEL 7.x # The change in systemd by Nicolas Iooss on 02-Feb-2016 with hash 4b51966cf6c06250036e428608da92f8640beb96 # should fix the problem where user directories in /run/user/$UID/ are not getting the proper context @@ -568,6 +589,10 @@ optional_policy(` policykit_dbus_chat(systemd_logind_t) ') +optional_policy(` + shutdown_domtrans(systemd_logind_t) +') + optional_policy(` xserver_read_state(systemd_logind_t) xserver_dbus_chat(systemd_logind_t) -- 2.24.1