summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-03-01 15:52:19 +0100
committerThomas Haller <thaller@redhat.com>2019-03-07 22:22:39 +0100
commit76828262299729e718924d5c14a69cfdc5cf48fa (patch)
tree8393f120393102624fe52e636b89d5c711ff92a3 /examples
parent4a137f919b452255eef985ef1eee52c277599dd0 (diff)
downloadNetworkManager-76828262299729e718924d5c14a69cfdc5cf48fa.tar.gz
libnm: change nm_wireguard_peer_set_preshared_key() API to allow validation
This is an API break since 1.16-rc1. The functions like _nm_utils_wireguard_decode_key() are internal API and not accessible to a libnm user. Maybe this should be public API, but for now it is not. That makes it cumbersome for a client to validate the setting. The client could only reimplement the validation (bad) or go ahead and set invalid value. When setting an invalid value, the user can afterwards detect it via nm_wireguard_peer_is_valid(), but at that point, it's not clear which exact property is invalid. First I wanted to keep the API conservative and not promissing too much. For example, not promising to do any validation when setting the key. However, libnm indeed validates the key at the time of setting it instead of doing lazy validation later. This makes sense, so we can keep this promise and just expose the validation result to the caller. Another downside of this is that the API just got more complicated. But it not provides a validation API, that we previously did not have. (cherry picked from commit d7bc1750c1bcc5082528d1f277e09454b2cbf1c2)
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/python/gi/nm-wg-set4
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/python/gi/nm-wg-set b/examples/python/gi/nm-wg-set
index fc60f069e6..308e4c74ca 100755
--- a/examples/python/gi/nm-wg-set
+++ b/examples/python/gi/nm-wg-set
@@ -355,11 +355,11 @@ def do_set(nm_client, conn, argv):
if peer and argv[idx] == 'preshared-key':
psk = argv_get_one(argv, idx + 1, None, idx)
if psk == '':
- peer.set_preshared_key(None)
+ peer.set_preshared_key(None, True)
if peer_secret_flags is not None:
peer_secret_flags = NM.SettingSecretFlags.NOT_REQUIRED
else:
- peer.set_preshared_key(wg_read_private_key(psk))
+ peer.set_preshared_key(wg_read_private_key(psk), True)
if peer_secret_flags is not None:
peer_secret_flags = NM.SettingSecretFlags.NONE
idx += 2