mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-03-14 23:09:45 +01:00
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:
parent
400742a855
commit
97789875d5
1 changed files with 3 additions and 9 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue