]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
wireguard-tools: avoid temp file for key gen
authorPaul Donald <newtwen+github@gmail.com>
Sat, 31 Jan 2026 14:47:30 +0000 (15:47 +0100)
committerRobert Marko <robimarko@gmail.com>
Mon, 2 Feb 2026 11:25:52 +0000 (12:25 +0100)
- 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>
package/network/utils/wireguard-tools/files/wireguard.sh

index 78a432a8d10be900670b85ad437292edf48d9ce2..8226c327da8938c0821be5f496d97f8c4a955ece 100644 (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
 }