mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 05:50:08 +01:00
cli: handle empty/unset values for "gsm.apn" property
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.
This commit is contained in:
parent
10567386f0
commit
ea67f48050
2 changed files with 17 additions and 14 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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::
|
||||
|
||||
<<<
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue