Commit graph

21 commits

Author SHA1 Message Date
Jelle van der Waa
e204cd130c selinux: allow cockpit-ws to get attributes of pidfs
Addresses the following AVC denial introduced by systemd 260:
avc:  denied  { getattr } for  pid=16530 comm="cockpit-ws" name="/" dev="pidfs" ino=1 scontext=system_u:system_r:cockpit_ws_t:s0 tcontext=system_u:object_r:pidfs_t:s0 tclass=filesystem permissive=0

systemd 260 refactored internal code to use pidfs in most places which
is the likely cause of the new violation.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2449605
2026-03-23 20:41:30 +01:00
Martin Pitt
b3df5a2b5b selinux: Allow pidfs_t access to cockpit-session
systemd 258 requires this for setting up logind sessions via
pam_systemd.so.

That policy has to be optional, as RHEL 9's SELinux does not yet know
about `pidfs_t`.

Fixes #22219
2025-08-04 15:33:52 +02:00
Martin Pitt
0098eb7024 selinux: Allow systemd to clean up cockpit's temporary files
On RHEL 9 (although only on bootc, curiously), systemd sometimes has
trouble with cleaning up beiboot's temp files:

> avc:  denied  { remove_name } for  pid=1 comm="systemd" name="user-known-hosts" dev="tmpfs" ino=77 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:cockpit_tmp_t:s0 tclass=dir permissive=0

Allow this, this is harmless enough.
2025-01-31 10:37:27 +01:00
Martin Pitt
129035b8d9 selinux: Fix policy for socket-activated cockpit-session
Run socket-activated cockpit-session with correct context. By default it
is `init_t`, but that will produce a memfd with the wrong permissions, which
the session cannot read.

Allow cockpit-ws to connect to /run/cockpit/session.

Allow restricted user_t and sysadm_t sessions to communicate (but not
connect) to cockpit-ws through the session unix socket. (Covered by
TestLogin.testSELinuxRestrictedUser)
2024-11-19 08:54:56 +01:00
Martin Pitt
dc2085e951 Drop remaining libssh references
Cleanup after #19441. In particular, drop the dependency in the Arch
packaging.
2024-10-01 10:40:05 +02:00
Martin Pitt
2ec1f4fd70 selinux: Allow cockpit-ws to read systemd config files
In Fedora 41, systemd ships a new file
/etc/ssh/ssh_config.d/20-systemd-ssh-proxy.conf which is owned by
systemd_conf_t. Allow cockpit-ws to read that, otherwise the whole `ssh`
command fails with a SELinux denial as it can't read that config file.
2024-09-02 14:29:02 +02:00
Martin Pitt
acbc460fa0 selinux: Allow cockpit_ws_t to read /sys
On Fedora 39 we get this rejection:

  avc:  denied  { read } for comm="cockpit-askpass" name="possible" dev="sysfs"
  scontext=system_u:system_r:cockpit_ws_t:s0 tcontext=system_u:object_r:sysfs_t:s0

This also happens for "cockpit-beiboot". Our code doesn't directly
access sysfs (at least not /devices/system/cpu/possible), but glibc
does, and Python somehow inherits this.

There is no harm in letting it read sysfs, and it may even be necessary
for hardware based authentication schemas, so allow it.
2023-09-29 17:06:44 +02:00
Martin Pitt
97f5dc3c5f selinux: Allow cockpit-ws to run ssh(1)
This is a prerequisite for switching the login page from cockpit-ssh to
the cockpit-beiboot implementation, which runs ssh(1) directly.
2023-09-29 17:06:44 +02:00
Martin Pitt
1a84ad594c selinux: Allow cockpit-session to run gnome-keyring
https://bugzilla.redhat.com/show_bug.cgi?id=2165996
2023-02-02 13:41:54 +01:00
Martin Pitt
160116b0db selinux: Allow cockpit-session to write user's home
pam_google_authenticator creates a new ~/.google_authenticator.TMPSUFFIX
and renames it.

https://bugzilla.redhat.com/show_bug.cgi?id=2157901
2023-01-13 16:50:35 +01:00
Allison Karlitskaya
b15528cf0c systemd: install units for /run/cockpit/session
This is not enabled yet.

When enabled, this allows spawning cockpit-session via connecting to
/run/cockpit/session.  You need to be in the cockpit-wsinstance group to
connect.

SELinux doesn't think that cockpit-session ought to be spawned directly
by systemd, so teach it about that.

So far nothing will run this unit.  There are also known problems with
trying to use this arrangement in many scenarios, including with client
certificate authentication.  This feature not officially supported yet.
Accordingly, the unit files are only included in the cockpit-tests
package.

Add a proof of concept integration test.
2023-01-04 15:27:52 +01:00
Allison Karlitskaya
755d372e50 selinux: avoid AT_SECURE on exec from cockpit-session
Since cockpit-session has its own selinux label, executing other
(differently-labelled) processes from it is considered to be a privilege
boundary transition, similar to executing a setuid binary.

Because of this, `AT_SECURE` gets set in the auxiliary vector, causing
the libc of the spawned process to enter "secure execution" mode.  Among
other things, that causes `secure_getenv()` to return NULL, even if a
particular variable is in the environment.

libsystemd uses `secure_getenv()` to look for the user's D-Bus.  If
`AT_SECURE` is set, that will fail, causing `sd_bus_default_user()` to
return `-ENOMEDIUM`.  This breaks the Python bridge.

The solution to this problem is to mark the state transition as
`noatsecure`. That makes sense: there's no real scenario where
cockpit-session attacks cockpit-bridge via its environment —
cockpit-session is the (substantially) higher-privileged process here.
2022-12-12 14:19:07 +01:00
Martin Pitt
179990b97b selinux: Allow fowner capability to cockpit-session
Most recent Fedora 37's pam_faillock tries to chown/chmod/etc.
some state files, which requires `CAP_FOWNER`. Grant this, as it's less
dangerous than `CAP_DAC_OVERRIDE`.

See https://github.com/cockpit-project/bots/pull/3974
2022-10-24 09:29:16 +02:00
Martin Pitt
e2f0a6b257 selinux: Fix policy for pam_faillock
pam_faillock tries to chown its state files to the target user. That's
legit, so allow this in our policy. Drop the test hack that we've been
dragging around for a while.
2022-03-16 18:17:21 +01:00
Allison Karlitskaya
f050d12f02 selinux: fix a deprecation warning
selinux/cockpit.te:17: Warning: userdom_user_tmpfs_file(cockpit_tmpfs_t) has been deprecated, use userdom_user_tmp_file() instead.
2022-01-18 18:44:11 +01:00
Allison Karlitskaya
b83d91e929 selinux: allow systemd to clean up /run/cockpit/tls
systemd is currently enable to clean up the files and directories in
/run/cockpit/tls, but if we add symlinks there, we see

    avc:  denied  { unlink } for  pid=1 comm="systemd" name="certificate.source" dev="tmpfs" ino=1410 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:cockpit_var_run_t:s0 tclass=lnk_file permissive=0

Mark cockpit_var_run_t as systemd_private_tmp to make sure systemd has
full permissions to clean these files up.
2021-11-10 15:47:17 +01:00
Ludwig Nussel
474de14781 selinux: allow login to read motd file
If pam_motd is enabled, login needs to be able to read cockpit's file
2021-08-26 07:25:59 +02:00
Matej Marusak
b5a07d6cf1 selinux: Allow cockpit_ws_t get attributes of fs_t filesystems
This permission is required by a cockpit.socket ExecStartPost script
which executes
"systemctl show --property Listen cockpit.socket"
in the cockpit-ws caller domain.

Resolves: rhbz#197918
Picked from https://github.com/fedora-selinux/selinux-policy/commit/95b6d266399
2021-08-11 12:03:59 +02:00
Vit Mojzis
dfcaebdd97 selinux: fix permission ordering
Stylistic issue only. Detected by "selint".

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2021-06-10 08:08:12 +02:00
Ludwig Nussel
ded7977a4d selinux: allow cockpit socket to bind nodes
Looks like this setting is implicit with kerberos enabled.
cockpit.socket fails to start if kerberos_enabled=false
2021-04-30 17:49:51 +02:00
Matej Marusak
cd8e673253 Add custom selinux policy 2021-04-23 14:12:38 +02:00