diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2019-08-26 19:36:22 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2019-08-26 20:14:03 +0200 |
commit | 8668b4e8afd2ffaab57623d0203ed2a12c82e4e3 (patch) | |
tree | ce93dc955ec2960b93fb374ca703beed27c3fa07 | |
parent | 50c5f5b0a58e185fa199e835bc9da1707f45e2fb (diff) | |
download | NetworkManager-lr/th/keyfile-fix-empty-settings.tar.gz |
cli: allow deleting the gsm.apnlr/th/keyfile-fix-empty-settings
Use "nmcli c modify -gsm.apn ''" to remove the APN.
-rw-r--r-- | clients/cli/connections.c | 6 | ||||
-rw-r--r-- | clients/cli/settings.c | 12 | ||||
-rw-r--r-- | clients/common/nm-meta-setting-desc.c | 1 | ||||
-rw-r--r-- | clients/common/nm-meta-setting-desc.h | 2 |
4 files changed, 16 insertions, 5 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 0e42831c7a..01fd4edf65 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -4694,11 +4694,7 @@ get_value (const char **value, int *argc, char ***argv, const char *option, GErr return FALSE; } - /* Empty string will reset the value to default */ - if (**argv[0] == '\0') - *value = NULL; - else - *value = *argv[0]; + *value = *argv[0]; (*argc)--; (*argv)++; diff --git a/clients/cli/settings.c b/clients/cli/settings.c index fec36a89fd..74b642b0ad 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -549,6 +549,18 @@ nmc_setting_set_property (NMClient *client, if (!property_info->property_type->set_fcn) goto out_fail_read_only; + if (property_info->del_sets_null) { + /* Attempting to delete this property sets it to NULL */ + if (modifier == NM_META_ACCESSOR_MODIFIER_DEL) { + modifier = NM_META_ACCESSOR_MODIFIER_SET; + value = NULL; + } + } else if (!value && value[0] == '\0') { + /* Empty string will reset the value to default */ + value = NULL; + } + + if ( modifier == NM_META_ACCESSOR_MODIFIER_DEL && !property_info->property_type->set_supports_remove) { /* The property is a plain property. It does not support '-'. diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index fad407aed7..e1ffbf1ffc 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -5417,6 +5417,7 @@ static const NMMetaPropertyInfo *const property_infos_GSM[] = { ), PROPERTY_INFO_WITH_DESC (NM_SETTING_GSM_APN, .is_cli_option = TRUE, + .del_sets_null = TRUE, .property_alias = "apn", .prompt = N_("APN"), .property_type = &_pt_gobject_string, diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h index e539904628..882d2e96d6 100644 --- a/clients/common/nm-meta-setting-desc.h +++ b/clients/common/nm-meta-setting-desc.h @@ -391,6 +391,8 @@ struct _NMMetaPropertyInfo { bool is_cli_option:1; + bool del_sets_null:1; + const char *prompt; const char *def_hint; |