0dc08b4138
Until now, the `touch + chmod 600 + write` approach made it possible for an unprivileged local user read the private key file, by opening the file after the touch, before the read permissions are restricted. This was only the case if `generatePrivateKeyFile = true` and the parent directory of `privateKeyFile` already existed and was readable. This commit fixes it by using `umask`, which ensures kernel-side that the `touch` creates the file with the correct permissions atomically. This commit also: * Removes `mkdir --mode 0644 -p "${dirOf values.privateKeyFile}"` because setting permissions `drw-r--r--` ("nobody can enter that dir") is awkward. `drwx------` would perhaps make sense, like for `.ssh`. However, setting the permissions on the private key file is enough, and likely better, because `privateKeyFile` is about that file specifically and no docs suggest that there's something special about its parent dir. * Removes the `chmod 0400 "${values.privateKeyFile}"` because there isn't really a point in removing write access from the owner of the private key. |
||
---|---|---|
.. | ||
config | ||
hardware | ||
i18n/input-method | ||
installer | ||
misc | ||
profiles | ||
programs | ||
security | ||
services | ||
system | ||
tasks | ||
testing | ||
virtualisation | ||
module-list.nix | ||
rename.nix |