From 80ec1decc49c72efec2a8b87c06245c92c0ab807 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 11 Feb 2021 18:11:46 +0100 Subject: New upstream version 1.29.90 --- clients/cli/agent.c | 4 +- clients/cli/common.c | 4 +- clients/cli/common.h | 2 +- clients/cli/connections.c | 225 ++-- clients/cli/connections.h | 2 +- clients/cli/devices.c | 9 +- clients/cli/devices.h | 2 +- clients/cli/general.c | 4 +- clients/cli/generate-docs-nm-settings-nmcli.c | 4 +- clients/cli/generate-docs-nm-settings-nmcli.xml | 35 +- clients/cli/generate-docs-nm-settings-nmcli.xml.in | 1131 ++++++++++++++++++++ clients/cli/meson.build | 40 +- clients/cli/nmcli.c | 283 ++--- clients/cli/nmcli.h | 10 +- clients/cli/polkit-agent.c | 4 +- clients/cli/polkit-agent.h | 2 +- clients/cli/settings.c | 4 +- clients/cli/settings.h | 3 +- clients/cli/utils.c | 20 +- clients/cli/utils.h | 2 +- 20 files changed, 1503 insertions(+), 287 deletions(-) create mode 100644 clients/cli/generate-docs-nm-settings-nmcli.xml.in (limited to 'clients/cli') diff --git a/clients/cli/agent.c b/clients/cli/agent.c index 293ff655..a3c60c46 100644 --- a/clients/cli/agent.c +++ b/clients/cli/agent.c @@ -1,9 +1,9 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2014 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include #include diff --git a/clients/cli/common.c b/clients/cli/common.c index e5306568..934ff70e 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -1,9 +1,9 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2012 - 2018 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "common.h" diff --git a/clients/cli/common.h b/clients/cli/common.h index 2c7339fe..70773ed3 100644 --- a/clients/cli/common.h +++ b/clients/cli/common.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2012 - 2014 Red Hat, Inc. */ diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 3714485a..ee7b8fbb 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -1,9 +1,9 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2018 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "connections.h" @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -858,30 +857,31 @@ const NmcMetaGenericInfo /*****************************************************************************/ -#define NMC_FIELDS_SETTINGS_NAMES_ALL \ - NM_SETTING_CONNECTION_SETTING_NAME \ - "," NM_SETTING_MATCH_SETTING_NAME "," NM_SETTING_WIRED_SETTING_NAME \ - "," NM_SETTING_802_1X_SETTING_NAME "," NM_SETTING_WIRELESS_SETTING_NAME \ - "," NM_SETTING_WIRELESS_SECURITY_SETTING_NAME "," NM_SETTING_IP4_CONFIG_SETTING_NAME \ - "," NM_SETTING_IP6_CONFIG_SETTING_NAME "," NM_SETTING_SERIAL_SETTING_NAME \ - "," NM_SETTING_WIFI_P2P_SETTING_NAME "," NM_SETTING_PPP_SETTING_NAME \ - "," NM_SETTING_PPPOE_SETTING_NAME "," NM_SETTING_ADSL_SETTING_NAME \ - "," NM_SETTING_GSM_SETTING_NAME "," NM_SETTING_CDMA_SETTING_NAME \ - "," NM_SETTING_BLUETOOTH_SETTING_NAME "," NM_SETTING_OLPC_MESH_SETTING_NAME \ - "," NM_SETTING_VPN_SETTING_NAME "," NM_SETTING_INFINIBAND_SETTING_NAME \ - "," NM_SETTING_BOND_SETTING_NAME "," NM_SETTING_VLAN_SETTING_NAME \ - "," NM_SETTING_BRIDGE_SETTING_NAME "," NM_SETTING_BRIDGE_PORT_SETTING_NAME \ - "," NM_SETTING_TEAM_SETTING_NAME "," NM_SETTING_TEAM_PORT_SETTING_NAME \ - "," NM_SETTING_OVS_BRIDGE_SETTING_NAME "," NM_SETTING_OVS_INTERFACE_SETTING_NAME \ - "," NM_SETTING_OVS_PATCH_SETTING_NAME "," NM_SETTING_OVS_PORT_SETTING_NAME \ - "," NM_SETTING_DCB_SETTING_NAME "," NM_SETTING_TUN_SETTING_NAME \ - "," NM_SETTING_IP_TUNNEL_SETTING_NAME "," NM_SETTING_MACSEC_SETTING_NAME \ - "," NM_SETTING_MACVLAN_SETTING_NAME "," NM_SETTING_VXLAN_SETTING_NAME \ - "," NM_SETTING_VRF_SETTING_NAME "," NM_SETTING_WPAN_SETTING_NAME \ - "," NM_SETTING_6LOWPAN_SETTING_NAME "," NM_SETTING_WIREGUARD_SETTING_NAME \ - "," NM_SETTING_PROXY_SETTING_NAME "," NM_SETTING_TC_CONFIG_SETTING_NAME \ - "," NM_SETTING_SRIOV_SETTING_NAME "," NM_SETTING_ETHTOOL_SETTING_NAME \ - "," NM_SETTING_OVS_DPDK_SETTING_NAME /* NM_SETTING_DUMMY_SETTING_NAME NM_SETTING_WIMAX_SETTING_NAME */ +#define NMC_FIELDS_SETTINGS_NAMES_ALL \ + NM_SETTING_CONNECTION_SETTING_NAME \ + "," NM_SETTING_MATCH_SETTING_NAME "," NM_SETTING_WIRED_SETTING_NAME \ + "," NM_SETTING_VETH_SETTING_NAME "," NM_SETTING_802_1X_SETTING_NAME \ + "," NM_SETTING_WIRELESS_SETTING_NAME "," NM_SETTING_WIRELESS_SECURITY_SETTING_NAME \ + "," NM_SETTING_IP4_CONFIG_SETTING_NAME "," NM_SETTING_IP6_CONFIG_SETTING_NAME \ + "," NM_SETTING_SERIAL_SETTING_NAME "," NM_SETTING_WIFI_P2P_SETTING_NAME \ + "," NM_SETTING_PPP_SETTING_NAME "," NM_SETTING_PPPOE_SETTING_NAME \ + "," NM_SETTING_ADSL_SETTING_NAME "," NM_SETTING_GSM_SETTING_NAME \ + "," NM_SETTING_CDMA_SETTING_NAME "," NM_SETTING_BLUETOOTH_SETTING_NAME \ + "," NM_SETTING_OLPC_MESH_SETTING_NAME "," NM_SETTING_VPN_SETTING_NAME \ + "," NM_SETTING_INFINIBAND_SETTING_NAME "," NM_SETTING_BOND_SETTING_NAME \ + "," NM_SETTING_VLAN_SETTING_NAME "," NM_SETTING_BRIDGE_SETTING_NAME \ + "," NM_SETTING_BRIDGE_PORT_SETTING_NAME "," NM_SETTING_TEAM_SETTING_NAME \ + "," NM_SETTING_TEAM_PORT_SETTING_NAME "," NM_SETTING_OVS_BRIDGE_SETTING_NAME \ + "," NM_SETTING_OVS_INTERFACE_SETTING_NAME "," NM_SETTING_OVS_PATCH_SETTING_NAME \ + "," NM_SETTING_OVS_PORT_SETTING_NAME "," NM_SETTING_DCB_SETTING_NAME \ + "," NM_SETTING_TUN_SETTING_NAME "," NM_SETTING_IP_TUNNEL_SETTING_NAME \ + "," NM_SETTING_MACSEC_SETTING_NAME "," NM_SETTING_MACVLAN_SETTING_NAME \ + "," NM_SETTING_VXLAN_SETTING_NAME "," NM_SETTING_VRF_SETTING_NAME \ + "," NM_SETTING_WPAN_SETTING_NAME "," NM_SETTING_6LOWPAN_SETTING_NAME \ + "," NM_SETTING_WIREGUARD_SETTING_NAME "," NM_SETTING_PROXY_SETTING_NAME \ + "," NM_SETTING_TC_CONFIG_SETTING_NAME "," NM_SETTING_SRIOV_SETTING_NAME \ + "," NM_SETTING_ETHTOOL_SETTING_NAME "," NM_SETTING_OVS_DPDK_SETTING_NAME \ + "," NM_SETTING_HOSTNAME_SETTING_NAME /* NM_SETTING_DUMMY_SETTING_NAME NM_SETTING_WIMAX_SETTING_NAME */ const NmcMetaGenericInfo *const nmc_fields_con_active_details_groups[] = { NMC_META_GENERIC_WITH_NESTED("GENERAL", metagen_con_active_general), /* 0 */ @@ -1102,7 +1102,7 @@ usage_connection_add(void) " mode vepa|bridge|private|passthru|source\n" " [tap yes|no]\n\n" " vxlan: id \n" - " remote \n" + " [remote ]\n" " [local ]\n" " [dev ]\n" " [source-port-min <0-65535>]\n" @@ -4957,6 +4957,10 @@ nmc_process_connection_properties(NmCli * nmc, const char * option; const char * value = NULL; const char * tmp; + const NMMetaAbstractInfo * chosen = NULL; + const char * chosen_setting_name = NULL; + const char * chosen_option = NULL; + NMMetaSettingType s; if (!con_settings(connection, &type_settings, &slv_settings, error)) return FALSE; @@ -5020,25 +5024,24 @@ nmc_process_connection_properties(NmCli * nmc, ss = is_setting_valid(connection, type_settings, slv_settings, setting_name); if (!ss) { - if (check_valid_name(setting_name, type_settings, slv_settings, NULL)) { - g_set_error(error, - NMCLI_ERROR, - NMC_RESULT_ERROR_USER_INPUT, - _("Setting '%s' is not present in the connection."), - setting_name); - } else { + if (!check_valid_name(setting_name, type_settings, slv_settings, NULL)) { g_set_error(error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT, _("Error: invalid setting argument '%s'."), setting_name); + return FALSE; } - return FALSE; + continue; } if (!connection_remove_setting(connection, ss, error)) return FALSE; - } else if ((tmp = strchr(option, '.'))) { + + continue; + } + + if ((tmp = strchr(option, '.'))) { gs_free char *option_sett = g_strndup(option, tmp - option); const char * option_prop = &tmp[1]; const char * option_sett_expanded; @@ -5081,58 +5084,35 @@ nmc_process_connection_properties(NmCli * nmc, modifier, error)) return FALSE; - } else { - const NMMetaAbstractInfo *chosen = NULL; - const char * chosen_setting_name = NULL; - const char * chosen_option = NULL; - NMMetaSettingType s; - - /* Let's see if this is an property alias (such as "id", "mode", "type" or "con-name")*/ - for (s = 0; s < _NM_META_SETTING_TYPE_NUM; s++) { - const NMMetaPropertyInfo *const *property_infos; - guint p; - - if (!check_valid_name(nm_meta_setting_infos[s].setting_name, - type_settings, - slv_settings, - NULL)) - continue; - property_infos = nm_meta_setting_infos_editor[s].properties; - if (!property_infos) - continue; - for (p = 0; property_infos[p]; p++) { - const NMMetaPropertyInfo *property_info = property_infos[p]; - - if (_meta_property_needs_bond_hack(property_info)) { - guint i; - - for (i = 0; i < nm_meta_property_typ_data_bond.nested_len; i++) { - const NMMetaNestedPropertyInfo *bi = - &nm_meta_property_typ_data_bond.nested[i]; - - if (!nm_streq0(bi->base.property_alias, option)) - continue; - if (chosen) { - g_set_error(error, - NMCLI_ERROR, - NMC_RESULT_ERROR_USER_INPUT, - _("Error: '%s' is ambiguous (%s.%s or %s.%s)."), - option, - chosen_setting_name, - chosen_option, - nm_meta_setting_infos[s].setting_name, - option); - return FALSE; - } - chosen_setting_name = nm_meta_setting_infos[s].setting_name; - chosen_option = option; - chosen = (const NMMetaAbstractInfo *) bi; - } - } else { - if (!property_info->is_cli_option) - continue; - if (!nm_streq0(property_info->property_alias, option)) + continue; + } + + /* Let's see if this is an property alias (such as "id", "mode", "type" or "con-name")*/ + for (s = 0; s < _NM_META_SETTING_TYPE_NUM; s++) { + const NMMetaPropertyInfo *const *property_infos; + guint p; + + if (!check_valid_name(nm_meta_setting_infos[s].setting_name, + type_settings, + slv_settings, + NULL)) + continue; + + property_infos = nm_meta_setting_infos_editor[s].properties; + if (!property_infos) + continue; + for (p = 0; property_infos[p]; p++) { + const NMMetaPropertyInfo *property_info = property_infos[p]; + + if (_meta_property_needs_bond_hack(property_info)) { + guint i; + + for (i = 0; i < nm_meta_property_typ_data_bond.nested_len; i++) { + const NMMetaNestedPropertyInfo *bi = + &nm_meta_property_typ_data_bond.nested[i]; + + if (!nm_streq0(bi->base.property_alias, option)) continue; if (chosen) { g_set_error(error, @@ -5148,39 +5128,60 @@ nmc_process_connection_properties(NmCli * nmc, } chosen_setting_name = nm_meta_setting_infos[s].setting_name; chosen_option = option; - chosen = (const NMMetaAbstractInfo *) property_info; + chosen = (const NMMetaAbstractInfo *) bi; } + } else { + if (!property_info->is_cli_option) + continue; + if (!nm_streq0(property_info->property_alias, option)) + continue; + if (chosen) { + g_set_error(error, + NMCLI_ERROR, + NMC_RESULT_ERROR_USER_INPUT, + _("Error: '%s' is ambiguous (%s.%s or %s.%s)."), + option, + chosen_setting_name, + chosen_option, + nm_meta_setting_infos[s].setting_name, + option); + return FALSE; + } + chosen_setting_name = nm_meta_setting_infos[s].setting_name; + chosen_option = option; + chosen = (const NMMetaAbstractInfo *) property_info; } } + } - if (!chosen) { - if (*argc == 1 && nmc->complete) { - if (allow_setting_removal && g_str_has_prefix("remove", option)) - g_print("remove\n"); - complete_property_name(nmc, connection, modifier, option, NULL); - } - g_set_error(error, - NMCLI_ERROR, - NMC_RESULT_ERROR_USER_INPUT, - _("Error: invalid . '%s'."), - option); - return FALSE; + if (!chosen) { + if (*argc == 1 && nmc->complete) { + if (allow_setting_removal && g_str_has_prefix("remove", option)) + g_print("remove\n"); + complete_property_name(nmc, connection, modifier, option, NULL); } + g_set_error(error, + NMCLI_ERROR, + NMC_RESULT_ERROR_USER_INPUT, + _("Error: invalid . '%s'."), + option); + return FALSE; + } - if (*argc == 1 && nmc->complete) - complete_property_name(nmc, connection, modifier, option, NULL); + if (*argc == 1 && nmc->complete) + complete_property_name(nmc, connection, modifier, option, NULL); - (*argc)--; - (*argv)++; - if (!get_value(&value, argc, argv, option_orig, error)) - return FALSE; + (*argc)--; + (*argv)++; + if (!get_value(&value, argc, argv, option_orig, error)) + return FALSE; - if (!*argc && nmc->complete) - complete_option(nmc, chosen, value ?: "", connection); + if (!*argc && nmc->complete) + complete_option(nmc, chosen, value ?: "", connection); + + if (!set_option(nmc, connection, chosen, value, error)) + return FALSE; - if (!set_option(nmc, connection, chosen, value, error)) - return FALSE; - } } while (*argc); return TRUE; diff --git a/clients/cli/connections.h b/clients/cli/connections.h index cedf354d..74c1fe00 100644 --- a/clients/cli/connections.h +++ b/clients/cli/connections.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2018 Red Hat, Inc. */ diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 62f4fed1..eea82653 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1,15 +1,16 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2018 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "devices.h" #include #include #include +#include #include "nm-glib-aux/nm-secret-utils.h" #include "common.h" @@ -53,6 +54,8 @@ ap_wpa_rsn_flags_to_string(NM80211ApSecurityFlags flags, NMMetaAccessorGetType g flags_str[i++] = "802.1X"; if (flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) flags_str[i++] = "sae"; + if (flags & NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192) + flags_str[i++] = "wpa-eap-suite-b-192"; if (NM_FLAGS_ANY(flags, NM_802_11_AP_SEC_KEY_MGMT_OWE | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM)) flags_str[i++] = "owe"; @@ -896,7 +899,7 @@ static void usage_device_modify(void) { g_printerr(_( - "Usage: nmcli device modify { ARGUMENTS | --help }\n" + "Usage: nmcli device modify { ARGUMENTS | help }\n" "\n" "ARGUMENTS := ([+|-]. )+\n" "\n" diff --git a/clients/cli/devices.h b/clients/cli/devices.h index 8e586334..6214ea03 100644 --- a/clients/cli/devices.h +++ b/clients/cli/devices.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2018 Red Hat, Inc. */ diff --git a/clients/cli/general.c b/clients/cli/general.c index 16eb810b..1dae57e1 100644 --- a/clients/cli/general.c +++ b/clients/cli/general.c @@ -1,9 +1,9 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2018 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include diff --git a/clients/cli/generate-docs-nm-settings-nmcli.c b/clients/cli/generate-docs-nm-settings-nmcli.c index 204851f6..d277b132 100644 --- a/clients/cli/generate-docs-nm-settings-nmcli.c +++ b/clients/cli/generate-docs-nm-settings-nmcli.c @@ -1,6 +1,6 @@ -/* SPDX-License-Identifier: LGPL-2.1+ */ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "nm-meta-setting-desc.h" diff --git a/clients/cli/generate-docs-nm-settings-nmcli.xml b/clients/cli/generate-docs-nm-settings-nmcli.xml index 7907e038..1044ae0d 100644 --- a/clients/cli/generate-docs-nm-settings-nmcli.xml +++ b/clients/cli/generate-docs-nm-settings-nmcli.xml @@ -63,7 +63,7 @@ + description="Key management used for the connection. One of "none" (WEP), "ieee8021x" (Dynamic WEP), "wpa-psk" (infrastructure WPA-PSK), "sae" (SAE), "owe" (Opportunistic Wireless Encryption), "wpa-eap" (WPA-Enterprise) or "wpa-eap-suite-b-192" (WPA3-Enterprise Suite B). This property must be set for any Wi-Fi connection that uses security." /> + description="Specifies the allowed "phase 2" inner authentication method when an EAP method that uses an inner TLS tunnel is specified in the "eap" property. For TTLS this property selects one of the supported non-EAP inner methods: "pap", "chap", "mschap", "mschapv2" while "phase2-autheap" selects an EAP inner method. For PEAP this selects an inner EAP method, one of: "gtc", "otp", "md5" and "tls". Each "phase 2" inner method requires specific parameters for successful authentication; see the wpa_supplicant documentation for more details. Both "phase2-auth" and "phase2-autheap" cannot be specified." /> + description="Specifies the allowed "phase 2" inner EAP-based authentication method when TTLS is specified in the "eap" property. Recognized EAP-based "phase 2" methods are "md5", "mschapv2", "otp", "gtc", and "tls". Each "phase 2" inner method requires specific parameters for successful authentication; see the wpa_supplicant documentation for more details." /> + @@ -467,12 +468,15 @@ + + + @@ -486,6 +490,7 @@ + @@ -498,6 +503,7 @@ + @@ -564,6 +570,16 @@ + + + + + + + description="Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties. The currently supported options are "attempts", "debug", "edns0", "inet6", "ip6-bytestring", "ip6-dotint", "ndots", "no-check-names", "no-ip6-dotint", "no-reload", "no-tld-query", "rotate", "single-request", "single-request-reopen", "timeout", "trust-ad", "use-vc". The "trust-ad" setting is only honored if the profile contributes name servers to resolv.conf, and if all contributing profiles have "trust-ad" enabled. When using a caching DNS plugin (dnsmasq or systemd-resolved in NetworkManager.conf) then "edns0" and "trust-ad" are automatically added." /> + description="A string sent to the DHCP server to identify the local machine which the DHCP server may use to customize the DHCP lease and options. When the property is a hex string ('aa:bb:cc') it is interpreted as a binary client ID, in which case the first byte is assumed to be the 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet ARP type and the rest is a MAC address). If the property is not a hex string it is considered as a non-hardware-address client ID and the 'type' field is set to 0. The special values "mac" and "perm-mac" are supported, which use the current or permanent MAC address of the device to generate a client identifier with type ethernet (01). Currently, these options only work for ethernet type of links. The special value "ipv6-duid" uses the DUID from "ipv6.dhcp-duid" property as an RFC4361-compliant client identifier. As IAID it uses "ipv4.dhcp-iaid" and falls back to "ipv6.dhcp-iaid" if unset. The special value "duid" generates a RFC4361-compliant client identifier based on "ipv4.dhcp-iaid" and uses a DUID generated by hashing /etc/machine-id. The special value "stable" is supported to generate a type 0 client identifier based on the stable-id (see connection.stable-id) and a per-host key. If you set the stable-id, you may want to include the "${DEVICE}" or "${MAC}" specifier to get a per-device key. If unset, a globally configured default is used. If still unset, the default depends on the DHCP plugin." /> + description="Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties. The currently supported options are "attempts", "debug", "edns0", "inet6", "ip6-bytestring", "ip6-dotint", "ndots", "no-check-names", "no-ip6-dotint", "no-reload", "no-tld-query", "rotate", "single-request", "single-request-reopen", "timeout", "trust-ad", "use-vc". The "trust-ad" setting is only honored if the profile contributes name servers to resolv.conf, and if all contributing profiles have "trust-ad" enabled. When using a caching DNS plugin (dnsmasq or systemd-resolved in NetworkManager.conf) then "edns0" and "trust-ad" are automatically added." /> + + @@ -974,6 +992,11 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/clients/cli/meson.build b/clients/cli/meson.build index 517deffa..f8e6a823 100644 --- a/clients/cli/meson.build +++ b/clients/cli/meson.build @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: LGPL-2.1+ +# SPDX-License-Identifier: LGPL-2.1-or-later if enable_nmcli @@ -27,7 +27,9 @@ executable( readline_dep, libnm_libnm_aux_dep, ], - c_args: clients_c_flags + ['-DG_LOG_DOMAIN="@0@"'.format('nmcli')], + c_args: [ + '-DG_LOG_DOMAIN="nmcli"', + ], link_args: ldflags_linker_script_binary, link_depends: linker_script_binary, install: true, @@ -45,14 +47,34 @@ generate_docs_nm_settings_nmcli = executable( libnmc_dep, libnm_libnm_aux_dep, ], - c_args: clients_c_flags + ['-DG_LOG_DOMAIN="@0@"'.format('nmcli')], + c_args: [ + '-DG_LOG_DOMAIN="nmcli"', + ], link_args: ldflags_linker_script_binary, link_depends: linker_script_binary, ) -generate_docs_nm_settings_nmcli_xml = custom_target( - 'generate-docs-nm-settings-nmcli.xml', - output: 'generate-docs-nm-settings-nmcli.xml', - command: [ generate_docs_nm_settings_nmcli ], - capture: true, -) +if enable_docs + generate_docs_nm_settings_nmcli_xml = custom_target( + 'generate-docs-nm-settings-nmcli.xml', + output: 'generate-docs-nm-settings-nmcli.xml', + command: [ generate_docs_nm_settings_nmcli ], + capture: true, + ) + + test( + 'check-local-generate-docs-nm-settings-nmcli', + find_program(join_paths(source_root, 'tools', 'check-compare-generated.sh')), + args: [ + source_root, + build_root, + 'clients/cli/generate-docs-nm-settings-nmcli.xml', + ], + ) +else + settings_docs_source = configure_file( + input: 'generate-docs-nm-settings-nmcli.xml.in', + output: '@BASENAME@', + configuration: configuration_data(), + ) +endif diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 44795408..39457211 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -1,10 +1,10 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Jiri Klimes * Copyright (C) 2010 - 2018 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "nmcli.h" @@ -33,26 +33,48 @@ #define NMCLI_VERSION VERSION #endif -#define DEFAULT_PALETTE_INIT \ - [NM_META_COLOR_CONNECTION_ACTIVATED] = "32", [NM_META_COLOR_CONNECTION_ACTIVATING] = "33", \ - [NM_META_COLOR_CONNECTION_DISCONNECTING] = "31", [NM_META_COLOR_CONNECTION_INVISIBLE] = "2", \ - [NM_META_COLOR_CONNECTION_EXTERNAL] = "32;2", [NM_META_COLOR_CONNECTIVITY_FULL] = "32", \ - [NM_META_COLOR_CONNECTIVITY_LIMITED] = "33", [NM_META_COLOR_CONNECTIVITY_NONE] = "31", \ - [NM_META_COLOR_CONNECTIVITY_PORTAL] = "33", [NM_META_COLOR_DEVICE_ACTIVATED] = "32", \ - [NM_META_COLOR_DEVICE_ACTIVATING] = "33", [NM_META_COLOR_DEVICE_DISCONNECTED] = "31", \ - [NM_META_COLOR_DEVICE_FIRMWARE_MISSING] = "31", [NM_META_COLOR_DEVICE_PLUGIN_MISSING] = "31", \ - [NM_META_COLOR_DEVICE_UNAVAILABLE] = "2", [NM_META_COLOR_DEVICE_DISABLED] = "31", \ - [NM_META_COLOR_DEVICE_EXTERNAL] = "32;2", [NM_META_COLOR_MANAGER_RUNNING] = "32", \ - [NM_META_COLOR_MANAGER_STARTING] = "33", [NM_META_COLOR_MANAGER_STOPPED] = "31", \ - [NM_META_COLOR_PERMISSION_AUTH] = "33", [NM_META_COLOR_PERMISSION_NO] = "31", \ - [NM_META_COLOR_PERMISSION_YES] = "32", [NM_META_COLOR_STATE_ASLEEP] = "31", \ - [NM_META_COLOR_STATE_CONNECTED_GLOBAL] = "32", [NM_META_COLOR_STATE_CONNECTED_LOCAL] = "32", \ - [NM_META_COLOR_STATE_CONNECTED_SITE] = "32", [NM_META_COLOR_STATE_CONNECTING] = "33", \ - [NM_META_COLOR_STATE_DISCONNECTED] = "31", [NM_META_COLOR_STATE_DISCONNECTING] = "33", \ - [NM_META_COLOR_WIFI_SIGNAL_EXCELLENT] = "32", [NM_META_COLOR_WIFI_SIGNAL_FAIR] = "35", \ - [NM_META_COLOR_WIFI_SIGNAL_GOOD] = "33", [NM_META_COLOR_WIFI_SIGNAL_POOR] = "36", \ - [NM_META_COLOR_WIFI_SIGNAL_UNKNOWN] = "2", [NM_META_COLOR_ENABLED] = "32", \ - [NM_META_COLOR_DISABLED] = "31", +#define _NMC_COLOR_PALETTE_INIT() \ + { \ + .ansi_seq = { \ + [NM_META_COLOR_CONNECTION_ACTIVATED] = "32", \ + [NM_META_COLOR_CONNECTION_ACTIVATING] = "33", \ + [NM_META_COLOR_CONNECTION_DISCONNECTING] = "31", \ + [NM_META_COLOR_CONNECTION_INVISIBLE] = "2", \ + [NM_META_COLOR_CONNECTION_EXTERNAL] = "32;2", \ + [NM_META_COLOR_CONNECTIVITY_FULL] = "32", \ + [NM_META_COLOR_CONNECTIVITY_LIMITED] = "33", \ + [NM_META_COLOR_CONNECTIVITY_NONE] = "31", \ + [NM_META_COLOR_CONNECTIVITY_PORTAL] = "33", \ + [NM_META_COLOR_DEVICE_ACTIVATED] = "32", \ + [NM_META_COLOR_DEVICE_ACTIVATING] = "33", \ + [NM_META_COLOR_DEVICE_DISCONNECTED] = "31", \ + [NM_META_COLOR_DEVICE_FIRMWARE_MISSING] = "31", \ + [NM_META_COLOR_DEVICE_PLUGIN_MISSING] = "31", \ + [NM_META_COLOR_DEVICE_UNAVAILABLE] = "2", \ + [NM_META_COLOR_DEVICE_DISABLED] = "31", \ + [NM_META_COLOR_DEVICE_EXTERNAL] = "32;2", \ + [NM_META_COLOR_MANAGER_RUNNING] = "32", \ + [NM_META_COLOR_MANAGER_STARTING] = "33", \ + [NM_META_COLOR_MANAGER_STOPPED] = "31", \ + [NM_META_COLOR_PERMISSION_AUTH] = "33", \ + [NM_META_COLOR_PERMISSION_NO] = "31", \ + [NM_META_COLOR_PERMISSION_YES] = "32", \ + [NM_META_COLOR_STATE_ASLEEP] = "31", \ + [NM_META_COLOR_STATE_CONNECTED_GLOBAL] = "32", \ + [NM_META_COLOR_STATE_CONNECTED_LOCAL] = "32", \ + [NM_META_COLOR_STATE_CONNECTED_SITE] = "32", \ + [NM_META_COLOR_STATE_CONNECTING] = "33", \ + [NM_META_COLOR_STATE_DISCONNECTED] = "31", \ + [NM_META_COLOR_STATE_DISCONNECTING] = "33", \ + [NM_META_COLOR_WIFI_SIGNAL_EXCELLENT] = "32", \ + [NM_META_COLOR_WIFI_SIGNAL_FAIR] = "35", \ + [NM_META_COLOR_WIFI_SIGNAL_GOOD] = "33", \ + [NM_META_COLOR_WIFI_SIGNAL_POOR] = "36", \ + [NM_META_COLOR_WIFI_SIGNAL_UNKNOWN] = "2", \ + [NM_META_COLOR_ENABLED] = "32", \ + [NM_META_COLOR_DISABLED] = "31", \ + }, \ + } static NmCli nm_cli = { .client = NULL, @@ -76,7 +98,7 @@ static NmCli nm_cli = { .complete = FALSE, .nmc_config.show_secrets = FALSE, .nmc_config.in_editor = FALSE, - .nmc_config.palette = {DEFAULT_PALETTE_INIT}, + .nmc_config.palette = _NMC_COLOR_PALETTE_INIT(), .editor_status_line = FALSE, .editor_save_confirmation = TRUE, }; @@ -486,97 +508,101 @@ check_colors(NmcColorOption color_option, char **out_palette_str) return TRUE; } -static const char * -resolve_color_alias(const char *color) -{ - static const struct { - const char *name; - const char *alias; - } aliases[] = { - {"reset", "0"}, {"bold", "1"}, {"white", "1;37"}, - {"halfbright", "2"}, {"underscore", "4"}, {"blink", "5"}, - {"reverse", "7"}, {"black", "30"}, {"red", "31"}, - {"green", "32"}, {"brown", "33"}, {"yellow", "33"}, /* well, yellow */ - {"blue", "34"}, {"magenta", "35"}, {"cyan", "36"}, - {"gray", "37"}, {"darkgray", "90"}, {"lightred", "91"}, - {"lightgreen", "92"}, {"lightblue", "94"}, {"lightmagenta", "95"}, - {"lightcyan", "96"}, {"lightgray", "97"}, - }; - int i; - - /* Shortcut literal sequences. */ - if (g_ascii_isdigit(*color)) - return color; - - for (i = 0; i < G_N_ELEMENTS(aliases); i++) { - if (strcmp(color, aliases[i].name) == 0) - return aliases[i].alias; - } - - return color; -} +static NM_UTILS_STRING_TABLE_LOOKUP_DEFINE( + _resolve_color_alias, + const char *, + { nm_assert(name); }, + { return NULL; }, + {"black", "30"}, + {"blink", "5"}, + {"blue", "34"}, + {"bold", "1"}, + {"brown", "33"}, + {"cyan", "36"}, + {"darkgray", "90"}, + {"gray", "37"}, + {"green", "32"}, + {"halfbright", "2"}, + {"lightblue", "94"}, + {"lightcyan", "96"}, + {"lightgray", "97"}, + {"lightgreen", "92"}, + {"lightmagenta", "95"}, + {"lightred", "91"}, + {"magenta", "35"}, + {"red", "31"}, + {"reset", "0"}, + {"reverse", "7"}, + {"underscore", "4"}, + {"white", "1;37"}, + {"yellow", "33" /* well, yellow */}, ); + +static NM_UTILS_STRING_TABLE_LOOKUP_DEFINE( + _nm_meta_color_from_name, + NMMetaColor, + { nm_assert(name); }, + { return NM_META_COLOR_NONE; }, + {"connection-activated", NM_META_COLOR_CONNECTION_ACTIVATED}, + {"connection-activating", NM_META_COLOR_CONNECTION_ACTIVATING}, + {"connection-disconnecting", NM_META_COLOR_CONNECTION_DISCONNECTING}, + {"connection-external", NM_META_COLOR_CONNECTION_EXTERNAL}, + {"connection-invisible", NM_META_COLOR_CONNECTION_INVISIBLE}, + {"connection-unknown", NM_META_COLOR_CONNECTION_UNKNOWN}, + {"connectivity-full", NM_META_COLOR_CONNECTIVITY_FULL}, + {"connectivity-limited", NM_META_COLOR_CONNECTIVITY_LIMITED}, + {"connectivity-none", NM_META_COLOR_CONNECTIVITY_NONE}, + {"connectivity-portal", NM_META_COLOR_CONNECTIVITY_PORTAL}, + {"connectivity-unknown", NM_META_COLOR_CONNECTIVITY_UNKNOWN}, + {"device-activated", NM_META_COLOR_DEVICE_ACTIVATED}, + {"device-activating", NM_META_COLOR_DEVICE_ACTIVATING}, + {"device-disabled", NM_META_COLOR_DEVICE_DISABLED}, + {"device-disconnected", NM_META_COLOR_DEVICE_DISCONNECTED}, + {"device-external", NM_META_COLOR_DEVICE_EXTERNAL}, + {"device-firmware-missing", NM_META_COLOR_DEVICE_FIRMWARE_MISSING}, + {"device-plugin-missing", NM_META_COLOR_DEVICE_PLUGIN_MISSING}, + {"device-unavailable", NM_META_COLOR_DEVICE_UNAVAILABLE}, + {"device-unknown", NM_META_COLOR_DEVICE_UNKNOWN}, + {"disabled", NM_META_COLOR_DISABLED}, + {"enabled", NM_META_COLOR_ENABLED}, + {"manager-running", NM_META_COLOR_MANAGER_RUNNING}, + {"manager-starting", NM_META_COLOR_MANAGER_STARTING}, + {"manager-stopped", NM_META_COLOR_MANAGER_STOPPED}, + {"permission-auth", NM_META_COLOR_PERMISSION_AUTH}, + {"permission-no", NM_META_COLOR_PERMISSION_NO}, + {"permission-unknown", NM_META_COLOR_PERMISSION_UNKNOWN}, + {"permission-yes", NM_META_COLOR_PERMISSION_YES}, + {"prompt", NM_META_COLOR_PROMPT}, + {"state-asleep", NM_META_COLOR_STATE_ASLEEP}, + {"state-connected-global", NM_META_COLOR_STATE_CONNECTED_GLOBAL}, + {"state-connected-local", NM_META_COLOR_STATE_CONNECTED_LOCAL}, + {"state-connected-site", NM_META_COLOR_STATE_CONNECTED_SITE}, + {"state-connecting", NM_META_COLOR_STATE_CONNECTING}, + {"state-disconnected", NM_META_COLOR_STATE_DISCONNECTED}, + {"state-disconnecting", NM_META_COLOR_STATE_DISCONNECTING}, + {"state-unknown", NM_META_COLOR_STATE_UNKNOWN}, + {"wifi-signal-excellent", NM_META_COLOR_WIFI_SIGNAL_EXCELLENT}, + {"wifi-signal-fair", NM_META_COLOR_WIFI_SIGNAL_FAIR}, + {"wifi-signal-good", NM_META_COLOR_WIFI_SIGNAL_GOOD}, + {"wifi-signal-poor", NM_META_COLOR_WIFI_SIGNAL_POOR}, + {"wifi-signal-unknown", NM_META_COLOR_WIFI_SIGNAL_UNKNOWN}, ); static gboolean -parse_color_scheme(char * palette_buffer, - const char **palette /* _NM_META_COLOR_NUM elements */, - GError ** error) +parse_color_scheme(char *palette_buffer, NmcColorPalette *out_palette, GError **error) { - char * p = palette_buffer; - const char * name; - const char * color; - const char * tmp_palette[_NM_META_COLOR_NUM] = {DEFAULT_PALETTE_INIT}; - static const char *const map[_NM_META_COLOR_NUM] = { - [NM_META_COLOR_NONE] = NULL, - [NM_META_COLOR_CONNECTION_ACTIVATED] = "connection-activated", - [NM_META_COLOR_CONNECTION_ACTIVATING] = "connection-activating", - [NM_META_COLOR_CONNECTION_DISCONNECTING] = "connection-disconnecting", - [NM_META_COLOR_CONNECTION_INVISIBLE] = "connection-invisible", - [NM_META_COLOR_CONNECTION_EXTERNAL] = "connection-external", - [NM_META_COLOR_CONNECTION_UNKNOWN] = "connection-unknown", - [NM_META_COLOR_CONNECTIVITY_FULL] = "connectivity-full", - [NM_META_COLOR_CONNECTIVITY_LIMITED] = "connectivity-limited", - [NM_META_COLOR_CONNECTIVITY_NONE] = "connectivity-none", - [NM_META_COLOR_CONNECTIVITY_PORTAL] = "connectivity-portal", - [NM_META_COLOR_CONNECTIVITY_UNKNOWN] = "connectivity-unknown", - [NM_META_COLOR_DEVICE_ACTIVATED] = "device-activated", - [NM_META_COLOR_DEVICE_ACTIVATING] = "device-activating", - [NM_META_COLOR_DEVICE_DISCONNECTED] = "device-disconnected", - [NM_META_COLOR_DEVICE_FIRMWARE_MISSING] = "device-firmware-missing", - [NM_META_COLOR_DEVICE_PLUGIN_MISSING] = "device-plugin-missing", - [NM_META_COLOR_DEVICE_UNAVAILABLE] = "device-unavailable", - [NM_META_COLOR_DEVICE_DISABLED] = "device-disabled", - [NM_META_COLOR_DEVICE_EXTERNAL] = "device-external", - [NM_META_COLOR_DEVICE_UNKNOWN] = "device-unknown", - [NM_META_COLOR_MANAGER_RUNNING] = "manager-running", - [NM_META_COLOR_MANAGER_STARTING] = "manager-starting", - [NM_META_COLOR_MANAGER_STOPPED] = "manager-stopped", - [NM_META_COLOR_PERMISSION_AUTH] = "permission-auth", - [NM_META_COLOR_PERMISSION_NO] = "permission-no", - [NM_META_COLOR_PERMISSION_UNKNOWN] = "permission-unknown", - [NM_META_COLOR_PERMISSION_YES] = "permission-yes", - [NM_META_COLOR_PROMPT] = "prompt", - [NM_META_COLOR_STATE_ASLEEP] = "state-asleep", - [NM_META_COLOR_STATE_CONNECTED_GLOBAL] = "state-connected-global", - [NM_META_COLOR_STATE_CONNECTED_LOCAL] = "state-connected-local", - [NM_META_COLOR_STATE_CONNECTED_SITE] = "state-connected-site", - [NM_META_COLOR_STATE_CONNECTING] = "state-connecting", - [NM_META_COLOR_STATE_DISCONNECTED] = "state-disconnected", - [NM_META_COLOR_STATE_DISCONNECTING] = "state-disconnecting", - [NM_META_COLOR_STATE_UNKNOWN] = "state-unknown", - [NM_META_COLOR_WIFI_SIGNAL_EXCELLENT] = "wifi-signal-excellent", - [NM_META_COLOR_WIFI_SIGNAL_FAIR] = "wifi-signal-fair", - [NM_META_COLOR_WIFI_SIGNAL_GOOD] = "wifi-signal-good", - [NM_META_COLOR_WIFI_SIGNAL_POOR] = "wifi-signal-poor", - [NM_META_COLOR_WIFI_SIGNAL_UNKNOWN] = "wifi-signal-unknown", - [NM_META_COLOR_DISABLED] = "disabled", - [NM_META_COLOR_ENABLED] = "enabled", - }; - int i; + char *p = palette_buffer; + + nm_assert(out_palette); + + *out_palette = (NmcColorPalette) _NMC_COLOR_PALETTE_INIT(); /* This reads through the raw color scheme file contents, identifying the * color names and sequences, putting in terminating NULs in place, so that * pointers into the buffer can readily be used as strings in the palette. */ while (1) { + NMMetaColor name_idx; + const char *name; + const char *color; + /* Leading whitespace. */ while (nm_utils_is_separator(*p) || *p == '\n') p++; @@ -638,42 +664,51 @@ parse_color_scheme(char * palette_buffer, p++; } - /* All good, set the palette entry. */ - for (i = NM_META_COLOR_NONE + 1; i < _NM_META_COLOR_NUM; i++) { - if (strcmp(map[i], name) == 0) { - tmp_palette[i] = resolve_color_alias(color); - break; - } - } - if (i == _NM_META_COLOR_NUM) + name_idx = _nm_meta_color_from_name(name); + if (name_idx == NM_META_COLOR_NONE) { g_debug("Ignoring an unrecognized color: '%s'\n", name); + continue; + } + + out_palette->ansi_seq[name_idx] = _resolve_color_alias(color) ?: color; } - memcpy(palette, tmp_palette, sizeof(tmp_palette)); return TRUE; } static void -set_colors(NmcColorOption color_option, - bool * out_use_colors, - char ** out_palette_buffer, - const char ** palette /* _NM_META_COLOR_NUM elements */) +set_colors(NmcColorOption color_option, + bool * out_use_colors, + char ** out_palette_buffer, + NmcColorPalette *out_palette) { gs_free char *palette_str = NULL; gboolean use_colors; + gboolean palette_set = FALSE; + + nm_assert(out_use_colors); + nm_assert(out_palette); + nm_assert(out_palette_buffer && !*out_palette_buffer); use_colors = check_colors(color_option, &palette_str); *out_use_colors = use_colors; + if (use_colors && palette_str) { - GError *error = NULL; + gs_free_error GError *error = NULL; + NmcColorPalette palette; - if (!parse_color_scheme(palette_str, palette, &error)) { + if (!parse_color_scheme(palette_str, &palette, &error)) g_debug("Error parsing color scheme: %s", error->message); - g_error_free(error); - } else + else { *out_palette_buffer = g_steal_pointer(&palette_str); + *out_palette = palette; + palette_set = TRUE; + } } + + if (!palette_set) + *out_palette = (NmcColorPalette) _NMC_COLOR_PALETTE_INIT(); } /*************************************************************************************/ @@ -872,7 +907,7 @@ process_command_line(NmCli *nmc, int argc, char **argv_orig) set_colors(colors, &nmc->nmc_config_mutable.use_colors, &nmc->palette_buffer, - nmc->nmc_config_mutable.palette); + &nmc->nmc_config_mutable.palette); /* Now run the requested command */ nmc_do_cmd(nmc, nmcli_cmds, *argv, argc, argv); diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index 1cd2e2a7..718d777f 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2018 Red Hat, Inc. */ @@ -73,6 +73,10 @@ typedef enum { NMC_OF_FLAG_MAIN_HEADER_ONLY = 0x00000008, /* Print main header only */ } NmcOfFlags; +typedef struct { + const char *ansi_seq[_NM_META_COLOR_NUM]; +} NmcColorPalette; + extern const NMMetaType nmc_meta_type_generic_info; typedef struct _NmcOutputField NmcOutputField; @@ -96,8 +100,8 @@ typedef struct _NmcConfig { bool in_editor; /* Whether running the editor - nmcli con edit' */ bool show_secrets; /* Whether to display secrets (both input and output): option '--show-secrets' */ - bool overview; /* Overview mode (hide default values) */ - const char *palette[_NM_META_COLOR_NUM]; /* Color palette */ + bool overview; /* Overview mode (hide default values) */ + NmcColorPalette palette; } NmcConfig; typedef struct { diff --git a/clients/cli/polkit-agent.c b/clients/cli/polkit-agent.c index e2f103d7..2f07a275 100644 --- a/clients/cli/polkit-agent.c +++ b/clients/cli/polkit-agent.c @@ -1,9 +1,9 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2014 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "polkit-agent.h" diff --git a/clients/cli/polkit-agent.h b/clients/cli/polkit-agent.h index ccc89a4d..776d0aa0 100644 --- a/clients/cli/polkit-agent.h +++ b/clients/cli/polkit-agent.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2014 Red Hat, Inc. */ diff --git a/clients/cli/settings.c b/clients/cli/settings.c index e190357a..2c1037f2 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -1,9 +1,9 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2015 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "settings.h" diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 6ca94de0..f103b8fd 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2014 Red Hat, Inc. */ @@ -6,7 +6,6 @@ #ifndef NMC_SETTINGS_H #define NMC_SETTINGS_H -#include "nm-meta-setting.h" #include "nm-meta-setting-desc.h" #include "nmcli.h" diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 2e7b22ce..0a62c35c 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -1,10 +1,10 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 Lennart Poettering * Copyright (C) 2010 - 2018 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "utils.h" @@ -374,23 +374,21 @@ nmc_terminal_show_progress(const char *str) char * nmc_colorize(const NmcConfig *nmc_config, NMMetaColor color, const char *fmt, ...) { - va_list args; - char * str, *colored; - const char *ansi_seq = NULL; + va_list args; + gs_free char *str = NULL; + const char * ansi_seq = NULL; va_start(args, fmt); str = g_strdup_vprintf(fmt, args); va_end(args); if (nmc_config->use_colors) - ansi_seq = nmc_config->palette[color]; + ansi_seq = nmc_config->palette.ansi_seq[color]; - if (ansi_seq == NULL) - return str; + if (!ansi_seq) + return g_steal_pointer(&str); - colored = g_strdup_printf("\33[%sm%s\33[0m", ansi_seq, str); - g_free(str); - return colored; + return g_strdup_printf("\33[%sm%s\33[0m", ansi_seq, str); } /* diff --git a/clients/cli/utils.h b/clients/cli/utils.h index c31b31cb..17605d39 100644 --- a/clients/cli/utils.h +++ b/clients/cli/utils.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 - 2018 Red Hat, Inc. */ -- cgit 1.3.0-6-gf8a5