diff options
author | Thomas Haller <thaller@redhat.com> | 2021-04-28 10:26:25 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-04-28 23:40:28 +0200 |
commit | 285850e1491aaa47a3b32b08fe77ac71bcf273e1 (patch) | |
tree | 937d567afea573c55d41215789113c8b9adb78ea | |
parent | 26861d38e9ae179739207eb5d8c70b436afdf421 (diff) | |
download | NetworkManager-th/nmcli-gsm-fixes.tar.gz |
cli: handle empty/unset values for "gsm.apn" propertyth/nmcli-gsm-fixes
Most string properties can be either %NULL (unset) or a non-empty
string.
For a few properties, like "gsm.apn", also the empty word is a valid
value. That makes it problematic to use from nmcli, because
nmcli connection modify "$PROFILE" gsm.apn ""
means to reset the default (NULL). How to configure the empty word?
For the APN, "" has a specific meaning, distinct from NULL, so we
need to be able to represent that.
The other problem with nmcli is that
nmcli -g gsm.apn connection show "$PROFILE"
is supposed to give you a value that you an set again, like
X="$(nmcli -g gsm.apn connection show "$PROFILE"; echo x)"
nmcli connection modify "$PROFILE2" gsm.apn "${X%$'\n'x}"
but for %NULL and "" the output would be the same.
The "solution" to that is interpreting "" as NULL (like we always did)
and a non-empty string that contains all whitespace, like a string with
one whitespace less. This way, all values can be expressed.
Note that in case of "gsm.apn", the string is anyway internally
normalized with g_strstrip(), so a string with all whitespace was
not expressable.
-rw-r--r-- | src/libnmc-setting/nm-meta-setting-desc.c | 3 | ||||
-rw-r--r-- | src/tests/client/test-client.check-on-disk/test_003.expected | 28 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/libnmc-setting/nm-meta-setting-desc.c b/src/libnmc-setting/nm-meta-setting-desc.c index 161cc8d217..51507913b7 100644 --- a/src/libnmc-setting/nm-meta-setting-desc.c +++ b/src/libnmc-setting/nm-meta-setting-desc.c @@ -5692,6 +5692,9 @@ static const NMMetaPropertyInfo *const property_infos_GSM[] = { .property_alias = "apn", .prompt = N_("APN"), .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_string, + .handle_emptyunset = TRUE, + ), ), PROPERTY_INFO_WITH_DESC (NM_SETTING_GSM_NETWORK_ID, .property_type = &_pt_gobject_string, diff --git a/src/tests/client/test-client.check-on-disk/test_003.expected b/src/tests/client/test-client.check-on-disk/test_003.expected index 9d93c45412..c710081a84 100644 --- a/src/tests/client/test-client.check-on-disk/test_003.expected +++ b/src/tests/client/test-client.check-on-disk/test_003.expected @@ -182,12 +182,12 @@ id path uuid <<< -size: 4536 +size: 4538 location: src/tests/client/test-client.py:test_003()/14 cmd: $NMCLI con s con-gsm1 lang: C returncode: 0 -stdout: 4403 bytes +stdout: 4405 bytes >>> connection.id: con-gsm1 connection.uuid: UUID-con-gsm1-REPLACED-REPLACED-REPL @@ -273,7 +273,7 @@ gsm.number: -- gsm.username: -- gsm.password: <hidden> gsm.password-flags: 0 (none) -gsm.apn: xyz.con-gsm1 +gsm.apn: "xyz.con-gsm1" gsm.network-id: -- gsm.pin: <hidden> gsm.pin-flags: 0 (none) @@ -288,12 +288,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4566 +size: 4568 location: src/tests/client/test-client.py:test_003()/15 cmd: $NMCLI con s con-gsm1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4423 bytes +stdout: 4425 bytes >>> connection.id: con-gsm1 connection.uuid: UUID-con-gsm1-REPLACED-REPLACED-REPL @@ -379,7 +379,7 @@ gsm.number: -- gsm.username: -- gsm.password: <hidden> gsm.password-flags: 0 (brak) -gsm.apn: xyz.con-gsm1 +gsm.apn: "xyz.con-gsm1" gsm.network-id: -- gsm.pin: <hidden> gsm.pin-flags: 0 (brak) @@ -757,7 +757,7 @@ gsm.number: -- gsm.username: -- gsm.password: <hidden> gsm.password-flags: 0 (none) -gsm.apn: -- +gsm.apn: "" gsm.network-id: -- gsm.pin: <hidden> gsm.pin-flags: 0 (none) @@ -863,7 +863,7 @@ gsm.number: -- gsm.username: -- gsm.password: <hidden> gsm.password-flags: 0 (brak) -gsm.apn: -- +gsm.apn: "" gsm.network-id: -- gsm.pin: <hidden> gsm.pin-flags: 0 (brak) @@ -878,33 +878,33 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 465 +size: 466 location: src/tests/client/test-client.py:test_003()/24 cmd: $NMCLI -g all con s con-gsm3 lang: C returncode: 0 -stdout: 326 bytes +stdout: 327 bytes >>> connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 -gsm:no:::<hidden>:0:::<hidden>:0:no::::auto +gsm:no:::<hidden>:0: ::<hidden>:0:no::::auto proxy:none:no:: <<< -size: 475 +size: 476 location: src/tests/client/test-client.py:test_003()/25 cmd: $NMCLI -g all con s con-gsm3 lang: pl_PL.UTF-8 returncode: 0 -stdout: 326 bytes +stdout: 327 bytes >>> connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 -gsm:no:::<hidden>:0:::<hidden>:0:no::::auto +gsm:no:::<hidden>:0: ::<hidden>:0:no::::auto proxy:none:no:: <<< |