Skip to content

Commit

Permalink
Merge pull request #114688 from rnhmjoj/tcsd-no-udev-settle
Browse files Browse the repository at this point in the history
nixos/tcsd: several improvements and fixes
  • Loading branch information
rnhmjoj committed Mar 27, 2021
2 parents 60b85e6 + 5383127 commit b01e00b
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions nixos/modules/services/hardware/tcsd.nix
Expand Up @@ -119,22 +119,31 @@ in

environment.systemPackages = [ pkgs.trousers ];

# system.activationScripts.tcsd =
# ''
# chown ${cfg.user}:${cfg.group} ${tcsdConf}
# '';
services.udev.extraRules = ''
# Give tcsd ownership of all TPM devices
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 = {
description = "TCSD";
after = [ "systemd-udev-settle.service" ];
description = "Manager for Trusted Computing resources";
documentation = [ "man:tcsd(8)" ];

requires = [ "dev-tpm0.device" ];
after = [ "dev-tpm0.device" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.trousers ];
preStart =
''
mkdir -m 0700 -p ${cfg.stateDir}
chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir}
'';
serviceConfig.ExecStart = "${pkgs.trousers}/sbin/tcsd -f -c ${tcsdConf}";

serviceConfig = {
User = cfg.user;
Group = cfg.group;
ExecStart = "${pkgs.trousers}/sbin/tcsd -f -c ${tcsdConf}";
};
};

users.users = optionalAttrs (cfg.user == "tss") {
Expand Down

0 comments on commit b01e00b

Please sign in to comment.