Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/nsd: prefer 'install' over 'chmod' #299581

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions nixos/modules/services/networking/nsd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ let
copyKeys = concatStrings (mapAttrsToList (keyName: keyOptions: ''
secret=$(cat "${keyOptions.keyFile}")
dest="${stateDir}/private/${keyName}"
echo " secret: \"$secret\"" > "$dest"
chown ${username}:${username} "$dest"
chmod 0400 "$dest"
install -m 0400 -o "${username}" -g "${username}" <(echo " secret: \"$secret\"") "$dest"
'') cfg.keys);


Expand Down Expand Up @@ -447,9 +445,7 @@ let
dnssecTools = pkgs.bind.override { enablePython = true; };

signZones = optionalString dnssec ''
mkdir -p ${stateDir}/dnssec
chown ${username}:${username} ${stateDir}/dnssec
chmod 0600 ${stateDir}/dnssec
install -m 0600 -o "${username}" -g "${username}" -d "${stateDir}/dnssec"

${concatStrings (mapAttrsToList signZone dnssecZones)}
'';
Expand Down Expand Up @@ -940,20 +936,16 @@ in
rm -Rf "${stateDir}/private/"
rm -Rf "${stateDir}/tmp/"

mkdir -m 0700 -p "${stateDir}/private"
mkdir -m 0700 -p "${stateDir}/tmp"
mkdir -m 0700 -p "${stateDir}/var"
install -dm 0700 -o "${username}" -g "${username}" "${stateDir}/private"
install -dm 0700 -o "${username}" -g "${username}" "${stateDir}/tmp"
install -dm 0700 -o "${username}" -g "${username}" "${stateDir}/var"

cat > "${stateDir}/don't touch anything in here" << EOF
Everything in this directory except NSD's state in var and dnssec
is automatically generated and will be purged and redeployed by
the nsd.service pre-start script.
EOF

chown ${username}:${username} -R "${stateDir}/private"
chown ${username}:${username} -R "${stateDir}/tmp"
chown ${username}:${username} -R "${stateDir}/var"

rm -rf "${stateDir}/zones"
cp -rL "${nsdEnv}/zones" "${stateDir}/zones"

Expand Down