wireguard-tools: avoid temp file for key gen

- no longer write any temporary file for key gen

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21784
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Paul Donald 2026-01-31 15:47:30 +01:00 committed by Robert Marko
parent 400742a855
commit 97789875d5

View file

@ -112,16 +112,10 @@ ensure_key_is_generated() {
local private_key
private_key="$(uci get network."$1".private_key)"
if [ "$private_key" == "generate" ]; then
local ucitmp
oldmask="$(umask)"
umask 077
ucitmp="$(mktemp -d)"
if [ "$private_key" = "generate" ] || [ -z "$private_key" ]; then
private_key="$("${WG}" genkey)"
uci -q -t "$ucitmp" set network."$1".private_key="$private_key" && \
uci -q -t "$ucitmp" commit network
rm -rf "$ucitmp"
umask "$oldmask"
uci -q set network."$1".private_key="$private_key" && \
uci -q commit network
fi
}