summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-08-26 19:36:22 +0200
committerThomas Haller <thaller@redhat.com>2019-08-27 11:56:32 +0200
commit199ba58bed17bfdf8a7cc68874add6d522687408 (patch)
tree375474acf62a318e027144afe8b0648a54d9a9bf
parent68e8fe9419fa6358d862e0a5e8ff58c11deb4f3e (diff)
downloadNetworkManager-lr/gsm-default-apn-part2.tar.gz
cli: allow deleting the gsm.apnlr/gsm-default-apn-part2
Use "nmcli c modify -gsm.apn ''" to remove the APN.
-rw-r--r--clients/cli/connections.c6
-rw-r--r--clients/cli/settings.c12
-rw-r--r--clients/common/nm-meta-setting-desc.c1
-rw-r--r--clients/common/nm-meta-setting-desc.h3
4 files changed, 17 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 fb0ea3118e..f2d9bb0ff8 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -5416,6 +5416,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 7642f2cbcd..e6f9e06baf 100644
--- a/clients/common/nm-meta-setting-desc.h
+++ b/clients/common/nm-meta-setting-desc.h
@@ -386,12 +386,15 @@ struct _NMMetaPropertyInfo {
const char *property_alias;
NMMetaPropertyInfFlags inf_flags;
+
bool is_secret:1;
bool is_cli_option:1;
bool coerce_one_space_as_empty:1;
+ bool del_sets_null:1;
+
const char *prompt;
const char *def_hint;