Skip to content

Commit f844239

Browse files
committed
nixos/attestation-server: fix boot failure #80
As already noted previously, using the service name as the user and group name in conjunction with DynamicUser sporadically fails. There is a better way to provision secrets for services with upcoming systemd 247, but for now we use a SupplementaryGroup to install the secret.
1 parent 40a71e5 commit f844239

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

nixos/attestation-server/module.nix

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,15 @@ in
118118
"('emailLocal', '${if local then "1" else "0"}')"
119119
];
120120
in optionals (passwordFile != null) [
121-
# Note the leading + on the second command. The passwordFile could be
121+
# Note the leading + on the first command. The passwordFile could be
122122
# anywhere in the file system, so it has to be copied as root and
123-
# permissions fixed to be accessible by the service. However, if the
124-
# first command is run as root the allocation of uid and gid for the
125-
# service seems to be delayed, so we just run something else first.
126-
"${pkgs.coreutils}/bin/touch %S/attestation/emailPassword"
127-
"+${pkgs.coreutils}/bin/install -m 0600 -o %N -g %N ${passwordFile} %S/attestation/emailPassword"
123+
# permissions fixed to be accessible by the service.
124+
"+${pkgs.coreutils}/bin/install -m 0640 -g keys ${passwordFile} %S/attestation/emailPassword"
125+
''${pkgs.sqlite}/bin/sqlite3 %S/attestation/attestation.db "CREATE TABLE IF NOT EXISTS Configuration (key TEXT PRIMARY KEY NOT NULL, value NOT NULL)"''
128126
''${pkgs.sqlite}/bin/sqlite3 %S/attestation/attestation.db "INSERT OR REPLACE INTO Configuration VALUES ${values}"''
129127
"${pkgs.coreutils}/bin/rm -f %S/attestation/emailPassword"
130128
];
129+
SupplementaryGroups = [ "keys" ];
131130

132131
# When sending TERM, e.g. for restart, AttestationServer fails with
133132
# this exit code.

nixos/attestation-server/test.nix

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import "${pkgs.path}/nixos/tests/make-test-python.nix" ({ pkgs, ... }: {
1212
device = "crosshatch";
1313
signatureFingerprint = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1414
avbFingerprint = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
15-
# TODO: Uncomment when https://github.com/danielfullmer/robotnix/issues/80 is resolved
16-
# email = {
17-
# host = "example.com";
18-
# username = "test";
19-
# passwordFile = "${pkgs.writeText "fake-password" "testing123"}"; # NOTE: Don't use writeText like this with a real password!
20-
# };
15+
email = {
16+
host = "example.com";
17+
username = "test";
18+
passwordFile = "${pkgs.writeText "fake-password" "testing123"}"; # NOTE: Don't use writeText like this with a real password!
19+
};
2120
nginx.enable = false;
2221
};
2322
};

0 commit comments

Comments
 (0)