Merge pull request #114688 from rnhmjoj/tcsd-no-udev-settle

nixos/tcsd: several improvements and fixes
This commit is contained in:
Michele Guerini Rocco 2021-03-27 16:31:17 +01:00 committed by GitHub
commit b01e00ba8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,22 +119,31 @@ in
environment.systemPackages = [ pkgs.trousers ]; environment.systemPackages = [ pkgs.trousers ];
# system.activationScripts.tcsd = services.udev.extraRules = ''
# '' # Give tcsd ownership of all TPM devices
# chown ${cfg.user}:${cfg.group} ${tcsdConf} KERNEL=="tpm[0-9]*", MODE="0660", OWNER="${cfg.user}", GROUP="${cfg.group}"
# ''; # Tag TPM devices to create a .device unit for tcsd to depend on
ACTION=="add", KERNEL=="tpm[0-9]*", TAG+="systemd"
'';
systemd.tmpfiles.rules = [
# Initialise the state directory
"d ${cfg.stateDir} 0770 ${cfg.user} ${cfg.group} - -"
];
systemd.services.tcsd = { systemd.services.tcsd = {
description = "TCSD"; description = "Manager for Trusted Computing resources";
after = [ "systemd-udev-settle.service" ]; documentation = [ "man:tcsd(8)" ];
requires = [ "dev-tpm0.device" ];
after = [ "dev-tpm0.device" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
path = [ pkgs.trousers ];
preStart = serviceConfig = {
'' User = cfg.user;
mkdir -m 0700 -p ${cfg.stateDir} Group = cfg.group;
chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir} ExecStart = "${pkgs.trousers}/sbin/tcsd -f -c ${tcsdConf}";
''; };
serviceConfig.ExecStart = "${pkgs.trousers}/sbin/tcsd -f -c ${tcsdConf}";
}; };
users.users = optionalAttrs (cfg.user == "tss") { users.users = optionalAttrs (cfg.user == "tss") {