2021-08-04 15:49:01 -07:00
|
|
|
{ config, lib, pkgs, ... }:
|
2020-07-27 10:26:45 -07:00
|
|
|
|
2021-08-04 15:49:01 -07:00
|
|
|
with lib;
|
2020-08-20 04:11:07 -07:00
|
|
|
{
|
2020-08-20 04:11:10 -07:00
|
|
|
options = {
|
2021-08-04 15:49:01 -07:00
|
|
|
nix-bitcoin.security.dbusHideProcessInformation = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-12-18 04:13:47 -08:00
|
|
|
description = mdDoc ''
|
|
|
|
Only allow users with group `proc` to retrieve systemd unit information like
|
2021-08-04 15:49:01 -07:00
|
|
|
cgroup paths (i.e. (sub)process command lines) via D-Bus.
|
|
|
|
|
|
|
|
This mitigates a systemd security issue where (sub)process command lines can
|
|
|
|
be retrieved by services even when their access to /proc is restricted
|
|
|
|
(via ProtectProc).
|
|
|
|
|
2022-12-18 04:13:47 -08:00
|
|
|
This option works by restricting the D-Bus method `GetUnitProcesses`, which
|
|
|
|
is also used internally by {command}`systemctl status`.
|
2021-08-04 15:49:01 -07:00
|
|
|
'';
|
|
|
|
};
|
2020-08-20 04:11:10 -07:00
|
|
|
};
|
2020-07-27 10:26:45 -07:00
|
|
|
|
2021-08-04 15:49:01 -07:00
|
|
|
config = mkIf config.nix-bitcoin.security.dbusHideProcessInformation {
|
|
|
|
users.groups.proc = {};
|
|
|
|
nix-bitcoin.operator.groups = [ "proc" ]; # Enable operator access to systemd-status
|
2020-08-20 04:11:10 -07:00
|
|
|
|
|
|
|
services.dbus.packages = lib.mkAfter [ # Apply at the end to override the default policy
|
|
|
|
(pkgs.writeTextDir "etc/dbus-1/system.d/dbus.conf" ''
|
|
|
|
<busconfig>
|
|
|
|
<policy context="default">
|
|
|
|
<deny
|
|
|
|
send_destination="org.freedesktop.systemd1"
|
|
|
|
send_interface="org.freedesktop.systemd1.Manager"
|
|
|
|
send_member="GetUnitProcesses"
|
|
|
|
/>
|
|
|
|
</policy>
|
|
|
|
<policy group="proc">
|
|
|
|
<allow
|
|
|
|
send_destination="org.freedesktop.systemd1"
|
|
|
|
send_interface="org.freedesktop.systemd1.Manager"
|
|
|
|
send_member="GetUnitProcesses"
|
|
|
|
/>
|
|
|
|
</policy>
|
|
|
|
</busconfig>
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
};
|
2020-07-27 10:26:45 -07:00
|
|
|
}
|