Commit 4963c83
committed
wg-quick linux: Add strip-and-eval cmd to extract keys from PostUp
The manpage mentions the trick to use PostUp to read the PrivateKey (or
PresharedKey) from a command (or file). However, when you actually use
that you notice that this is currently not fully supported. The issue is
that
```Shell
wg syncconf wgnet0 <(wg-quick strip wgnet0)
```
from the manpage now breaks the VPN because it *removes* the private key
from the WireGuard interface. The reason is that `strip` removes PostUp
of course.
This patch tries to add full support to read WireGuard keys from files
or command outputs by evaluating PostUp using a best effort approach
(using regex). It will not work for everything but when you follow the
manpage closely, it will work.
I also propose to update the systemd template to make seamless use of
this. This is not a must because the sysadmin can easily change the
ExecReload using systemd drop-in files.
Note that the patchset is incomplete (currently only for Linux).
I don’t have all the other OSes laying around. When the patch looks ok,
I can apply it to the other versions also.
Example use of this patch:
https://github.com/ypid/ansible-wireguard/tree/prepare-for-debops
Signed-off-by: Robin Schneider <[email protected]>1 parent 265e81a commit 4963c83
File tree
3 files changed
+43
-4
lines changed- src
- man
- systemd
- wg-quick
3 files changed
+43
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
256 | 259 | | |
257 | 260 | | |
258 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
259 | 268 | | |
260 | 269 | | |
261 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
66 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
67 | 90 | | |
68 | 91 | | |
69 | 92 | | |
70 | 93 | | |
71 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
72 | 98 | | |
73 | 99 | | |
74 | 100 | | |
| |||
224 | 250 | | |
225 | 251 | | |
226 | 252 | | |
227 | | - | |
| 253 | + | |
228 | 254 | | |
229 | 255 | | |
230 | 256 | | |
| |||
298 | 324 | | |
299 | 325 | | |
300 | 326 | | |
301 | | - | |
| 327 | + | |
302 | 328 | | |
303 | 329 | | |
304 | 330 | | |
| |||
381 | 407 | | |
382 | 408 | | |
383 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
384 | 414 | | |
385 | 415 | | |
386 | 416 | | |
| |||
0 commit comments