* [PATCH] wg: syncconf: also handle psk changes
@ 2025-03-14 9:39 Patrick Havelange
2025-05-23 18:28 ` Jason A. Donenfeld
0 siblings, 1 reply; 3+ messages in thread
From: Patrick Havelange @ 2025-03-14 9:39 UTC (permalink / raw)
To: wireguard; +Cc: Patrick Havelange
This fixes the case where the removal of a psk would not be reflected with wg syncconf.
Signed-off-by: Patrick Havelange <patrick.havelange_ext@softathome.com>
---
src/setconf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/setconf.c b/src/setconf.c
index 1c5b138..8f40124 100644
--- a/src/setconf.c
+++ b/src/setconf.c
@@ -15,6 +15,7 @@
struct pubkey_origin {
uint8_t *pubkey;
+ uint8_t *psk;
bool from_file;
};
@@ -64,11 +65,13 @@ static bool sync_conf(struct wgdevice *file)
for_each_wgpeer(file, peer) {
pubkeys[i].pubkey = peer->public_key;
+ pubkeys[i].psk = peer->preshared_key;
pubkeys[i].from_file = true;
++i;
}
for_each_wgpeer(runtime, peer) {
pubkeys[i].pubkey = peer->public_key;
+ pubkeys[i].psk = peer->preshared_key;
pubkeys[i].from_file = false;
++i;
}
@@ -77,7 +80,7 @@ static bool sync_conf(struct wgdevice *file)
for (i = 0; i < peer_count; ++i) {
if (pubkeys[i].from_file)
continue;
- if (i == peer_count - 1 || !pubkeys[i + 1].from_file || memcmp(pubkeys[i].pubkey, pubkeys[i + 1].pubkey, WG_KEY_LEN)) {
+ if (i == peer_count - 1 || !pubkeys[i + 1].from_file || memcmp(pubkeys[i].pubkey, pubkeys[i + 1].pubkey, WG_KEY_LEN) || memcmp(pubkeys[i].psk, pubkeys[i + 1].psk, WG_KEY_LEN)) {
peer = calloc(1, sizeof(struct wgpeer));
if (!peer) {
free_wgdevice(runtime);
--
2.30.2
-- This message and any attachments herein are, unless otherwise stated, confidential, intended solely for the addressees and are SoftAtHome’s ownership. Any unauthorized use, reproduction or dissemination is prohibited unless formaly agreed beforehand by the sender. If you are not the intended addressee of this message, please immediately delete it and all its attachments from your computer system and notify the sender. SoftAtHome reserves the right to monitor all email communications through its networks. Any views or opinions presented are solely those of its author and do not necessarily represent those of SoftAtHome. The internet cannot guarantee the integrity of this message. SoftAtHome not shall be liable for the message if altered, changed or falsified. While we take all reasonable precautions to ensure that viruses are not transmitted via emails, we recommend that you take your own measures to prevent viruses from entering your computer system. SoftAtHome is a French Société Anonyme with a Board of Directors, having a capital of 6 450 699 Euros having its registered office located at 9-11 rue du débarcadère – 92700 – Colombes – France – Tel + 33 (0)1 57 66 88 88 – Fax + 33 (0)1 57 66 88 89 - RCS Nanterre B 500 440 813 – Intra-Community VAT: FR 04500440813 -- Ce message et toutes les pièces jointes qui y sont incluses sont, sauf indication contraire, confidentiels, destinés uniquement aux destinataires et sont la propriété de SoftAtHome. Toute utilisation non autorisée, reproduction ou diffusion est interdite, sauf accord formel préalable de l'expéditeur. Si vous n'êtes pas le destinataire prévu de ce message, veuillez le supprimer immédiatement ainsi que toutes ses pièces jointes de votre système informatique et en informer l'expéditeur. SoftAtHome se réserve le droit de surveiller toutes les communications par e-mail via ses réseaux. Les opinions exprimées dans ce message sont celles de leur auteur et ne représentent pas nécessairement celles de SoftAtHome. L’Internet ne permettant pas d’assurer l’intégrité de ce message, SoftAtHome décline toute responsabilité à ce titre, dans l’hypothèse où il aurait été altéré, déformé ou falsifié. Par ailleurs et malgré toutes les précautions prises pour éviter la présence de virus dans nos envois, nous vous recommandons de prendre, de votre côté, les mesures permettant d'assurer la non-introduction de virus dans votre système informatique. SoftAtHome est une Société Anonyme française à Conseil d’Administration ayant un capital de 6 450 699 euros, dont le siège social est situé au 9-11 rue du débarcadère - 92700 - Colombes - France - Tel + 33 (0)1 57 66 88 88 - Fax + 33 (0)1 57 66 88 89 RCS Nanterre B 500 440 813 - TVA intracommunautaire : FR 04500440813
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wg: syncconf: also handle psk changes
2025-03-14 9:39 [PATCH] wg: syncconf: also handle psk changes Patrick Havelange
@ 2025-05-23 18:28 ` Jason A. Donenfeld
2025-05-26 6:55 ` Patrick HAVELANGE (EXT)
0 siblings, 1 reply; 3+ messages in thread
From: Jason A. Donenfeld @ 2025-05-23 18:28 UTC (permalink / raw)
To: Patrick Havelange; +Cc: wireguard
Your patch is wrong; did you test it? When it detects a mismatch in
PSK, it removes the peer, rather than removing the PSK.
I implemented a different fix:
https://git.zx2c4.com/wireguard-tools/commit/?id=780182e37d2b5981171766b8f31bcefd64da7a43
It seems to work for me, but please test this and let me know.
Either way, thanks for the bug report.
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wg: syncconf: also handle psk changes
2025-05-23 18:28 ` Jason A. Donenfeld
@ 2025-05-26 6:55 ` Patrick HAVELANGE (EXT)
0 siblings, 0 replies; 3+ messages in thread
From: Patrick HAVELANGE (EXT) @ 2025-05-26 6:55 UTC (permalink / raw)
To: wireguard
Hello Jason,
I indeed tested it. The peer is indeed removed but is then added in a step later (if I remember correctly) so it produces the proper result in the end. At least it looked correct from my point of view.
P.H.
________________________________________
From: Jason A. Donenfeld <Jason@zx2c4.com>
Sent: 23 May 2025 20:28
To: Patrick HAVELANGE (EXT) <patrick.havelange_ext@softathome.com>
Cc: wireguard@lists.zx2c4.com <wireguard@lists.zx2c4.com>
Subject: Re: [PATCH] wg: syncconf: also handle psk changes
This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.
Your patch is wrong; did you test it? When it detects a mismatch in
PSK, it removes the peer, rather than removing the PSK.
I implemented a different fix:
https://git.zx2c4.com/wireguard-tools/commit/?id=780182e37d2b5981171766b8f31bcefd64da7a43
It seems to work for me, but please test this and let me know.
Either way, thanks for the bug report.
Thanks,
Jason
-- This message and any attachments herein are, unless otherwise stated, confidential, intended solely for the addressees and are SoftAtHome’s ownership. Any unauthorized use, reproduction or dissemination is prohibited unless formaly agreed beforehand by the sender. If you are not the intended addressee of this message, please immediately delete it and all its attachments from your computer system and notify the sender. SoftAtHome reserves the right to monitor all email communications through its networks. Any views or opinions presented are solely those of its author and do not necessarily represent those of SoftAtHome. The internet cannot guarantee the integrity of this message. SoftAtHome not shall be liable for the message if altered, changed or falsified. While we take all reasonable precautions to ensure that viruses are not transmitted via emails, we recommend that you take your own measures to prevent viruses from entering your computer system. SoftAtHome is a French Société Anonyme with a Board of Directors, having a capital of 6 450 699 Euros having its registered office located at 9-11 rue du débarcadère – 92700 – Colombes – France – Tel + 33 (0)1 57 66 88 88 – Fax + 33 (0)1 57 66 88 89 - RCS Nanterre B 500 440 813 – Intra-Community VAT: FR 04500440813 -- Ce message et toutes les pièces jointes qui y sont incluses sont, sauf indication contraire, confidentiels, destinés uniquement aux destinataires et sont la propriété de SoftAtHome. Toute utilisation non autorisée, reproduction ou diffusion est interdite, sauf accord formel préalable de l'expéditeur. Si vous n'êtes pas le destinataire prévu de ce message, veuillez le supprimer immédiatement ainsi que toutes ses pièces jointes de votre système informatique et en informer l'expéditeur. SoftAtHome se réserve le droit de surveiller toutes les communications par e-mail via ses réseaux. Les opinions exprimées dans ce message sont celles de leur auteur et ne représentent pas nécessairement celles de SoftAtHome. L’Internet ne permettant pas d’assurer l’intégrité de ce message, SoftAtHome décline toute responsabilité à ce titre, dans l’hypothèse où il aurait été altéré, déformé ou falsifié. Par ailleurs et malgré toutes les précautions prises pour éviter la présence de virus dans nos envois, nous vous recommandons de prendre, de votre côté, les mesures permettant d'assurer la non-introduction de virus dans votre système informatique. SoftAtHome est une Société Anonyme française à Conseil d’Administration ayant un capital de 6 450 699 euros, dont le siège social est situé au 9-11 rue du débarcadère - 92700 - Colombes - France - Tel + 33 (0)1 57 66 88 88 - Fax + 33 (0)1 57 66 88 89 RCS Nanterre B 500 440 813 - TVA intracommunautaire : FR 04500440813
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-26 6:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-14 9:39 [PATCH] wg: syncconf: also handle psk changes Patrick Havelange
2025-05-23 18:28 ` Jason A. Donenfeld
2025-05-26 6:55 ` Patrick HAVELANGE (EXT)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).