mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-24 03:34:40 +00:00
all: merge branch 'th/uuid'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/835
This commit is contained in:
commit
8232c3473f
|
@ -444,6 +444,8 @@ src_libnm_glib_aux_libnm_glib_aux_la_SOURCES = \
|
|||
src/libnm-glib-aux/nm-test-utils.h \
|
||||
src/libnm-glib-aux/nm-time-utils.c \
|
||||
src/libnm-glib-aux/nm-time-utils.h \
|
||||
src/libnm-glib-aux/nm-uuid.c \
|
||||
src/libnm-glib-aux/nm-uuid.h \
|
||||
src/libnm-glib-aux/nm-value-type.h \
|
||||
$(NULL)
|
||||
|
||||
|
@ -1392,7 +1394,6 @@ nodist_src_libnm_core_impl_libnm_core_impl_la_SOURCES = \
|
|||
|
||||
src_libnm_core_impl_libnm_core_impl_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(UUID_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
src_libnm_core_impl_libnm_core_impl_la_LDFLAGS = \
|
||||
|
@ -1760,7 +1761,6 @@ src_libnm_client_impl_libnm_client_impl_la_LIBADD = \
|
|||
src/c-siphash/libc-siphash.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(DL_LIBS) \
|
||||
$(UUID_LIBS) \
|
||||
$(LIBUDEV_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
|
3
NEWS
3
NEWS
|
@ -13,6 +13,9 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
|
|||
mode).
|
||||
* nmcli: fix setting property aliases to empty value to reset the
|
||||
default value.
|
||||
* Enforce valid "connection.uuid" by normalizing the string to lower
|
||||
case. This changes the UUID of existing profiles that had an invalid,
|
||||
non-normalized value.
|
||||
|
||||
=============================================
|
||||
NetworkManager-1.30
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "libnm-glib-aux/nm-c-list.h"
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-base/nm-net-aux.h"
|
||||
#include "libnm-core-aux-intern/nm-common-macros.h"
|
||||
#include "nm-utils.h"
|
||||
|
@ -254,7 +255,7 @@ nm_utils_complete_generic(NMPlatform * platform,
|
|||
|
||||
g_object_set(G_OBJECT(s_con),
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_buf(uuid),
|
||||
nm_uuid_generate_random_str_arr(uuid),
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <gmodule.h>
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-dbus-aux.h"
|
||||
#include "libnm-glib-aux/nm-c-list.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
@ -1321,7 +1322,7 @@ _conn_create_panu_connection(NMBluezManager *self, BzDBusObj *bzobj)
|
|||
char uuid[37];
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
nm_utils_uuid_generate_buf(uuid);
|
||||
nm_uuid_generate_random_str_arr(uuid);
|
||||
id = g_strdup_printf(_("%s Network"), bzobj->d_device.name);
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <libudev.h>
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-act-request.h"
|
||||
#include "nm-ip4-config.h"
|
||||
|
@ -1718,11 +1719,11 @@ new_default_connection(NMDevice *self)
|
|||
|
||||
/* Create a stable UUID. The UUID is also the Network_ID for stable-privacy addr-gen-mode,
|
||||
* thus when it changes we will also generate different IPv6 addresses. */
|
||||
uuid = _nm_utils_uuid_generate_from_strings("default-wired",
|
||||
nm_utils_machine_id_str(),
|
||||
defname,
|
||||
perm_hw_addr ?: iface,
|
||||
NULL);
|
||||
uuid = nm_uuid_generate_from_strings("default-wired",
|
||||
nm_utils_machine_id_str(),
|
||||
defname,
|
||||
perm_hw_addr ?: iface,
|
||||
NULL);
|
||||
|
||||
g_object_set(setting,
|
||||
NM_SETTING_CONNECTION_ID,
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-std-aux/unaligned.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-dedup-multi.h"
|
||||
#include "libnm-glib-aux/nm-random-utils.h"
|
||||
#include "libnm-systemd-shared/nm-sd-utils-shared.h"
|
||||
|
@ -7238,7 +7239,7 @@ nm_device_generate_connection(NMDevice *self,
|
|||
|
||||
g_object_set(s_con,
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_buf(uuid),
|
||||
nm_uuid_generate_random_str_arr(uuid),
|
||||
NM_SETTING_CONNECTION_ID,
|
||||
ifname,
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "nm-manager.h"
|
||||
#include "nm-device-iwd.h"
|
||||
#include "nm-wifi-utils.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-random-utils.h"
|
||||
#include "libnm-glib-aux/nm-io-utils.h"
|
||||
#include "settings/nm-settings.h"
|
||||
|
@ -774,7 +775,7 @@ mirror_connection(NMIwdManager * self,
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
id->name,
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_buf(uuid),
|
||||
nm_uuid_generate_random_str_arr(uuid),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
autoconnectable,
|
||||
NULL);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <net/if_arp.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-platform/nmp-base.h"
|
||||
#include "libnm-std-aux/unaligned.h"
|
||||
#include "libnm-glib-aux/nm-random-utils.h"
|
||||
|
@ -2402,7 +2403,7 @@ _uuid_data_init(UuidData *uuid_data, gboolean packed, gboolean is_fake, const NM
|
|||
nm_utils_bin2hexstr_full(uuid, sizeof(*uuid), '\0', FALSE, uuid_data->str);
|
||||
} else {
|
||||
G_STATIC_ASSERT_EXPR(sizeof(uuid_data->str) >= 37);
|
||||
_nm_utils_uuid_unparse(uuid, uuid_data->str);
|
||||
nm_uuid_unparse(uuid, uuid_data->str);
|
||||
}
|
||||
return uuid_data;
|
||||
}
|
||||
|
@ -2455,7 +2456,7 @@ again:
|
|||
(guint8 *) &uuid,
|
||||
sizeof(uuid),
|
||||
NULL)) {
|
||||
if (!nm_utils_uuid_is_null(&uuid)) {
|
||||
if (!nm_uuid_is_null(&uuid)) {
|
||||
/* an all-zero machine-id is not valid. */
|
||||
is_fake = FALSE;
|
||||
}
|
||||
|
@ -2500,11 +2501,11 @@ again:
|
|||
|
||||
/* the fake machine-id is based on secret-key/boot-id, but we hash it
|
||||
* again, so that they are not literally the same. */
|
||||
nm_utils_uuid_generate_from_string_bin(&uuid,
|
||||
(const char *) seed_bin,
|
||||
seed_len,
|
||||
NM_UTILS_UUID_TYPE_VERSION5,
|
||||
(gpointer) hash_seed);
|
||||
nm_uuid_generate_from_string(&uuid,
|
||||
(const char *) seed_bin,
|
||||
seed_len,
|
||||
NM_UUID_TYPE_VERSION5,
|
||||
(gpointer) hash_seed);
|
||||
}
|
||||
|
||||
if (!g_once_init_enter(&lock))
|
||||
|
@ -2854,10 +2855,10 @@ again:
|
|||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!contents || !_nm_utils_uuid_parse(nm_strstrip(contents), &uuid)) {
|
||||
if (!contents || !nm_uuid_parse(nm_strstrip(contents), &uuid)) {
|
||||
/* generate a random UUID instead. */
|
||||
is_fake = TRUE;
|
||||
_nm_utils_uuid_generate_random(&uuid);
|
||||
nm_uuid_generate_random(&uuid);
|
||||
}
|
||||
|
||||
if (!g_once_init_enter(&lock))
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <linux/rtnetlink.h>
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-secret-utils.h"
|
||||
#include "nm-connection.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
|
@ -405,11 +406,9 @@ make_connection_setting(const char *file,
|
|||
/* Try for a UUID key before falling back to hashing the file name */
|
||||
uuid = svGetValueStr(ifcfg, "UUID", &uuid_free);
|
||||
if (!uuid) {
|
||||
uuid_free = nm_utils_uuid_generate_from_string(svFileGetName(ifcfg),
|
||||
-1,
|
||||
NM_UTILS_UUID_TYPE_LEGACY,
|
||||
NULL);
|
||||
uuid = uuid_free;
|
||||
uuid_free =
|
||||
nm_uuid_generate_from_string_str(svFileGetName(ifcfg), -1, NM_UUID_TYPE_LEGACY, NULL);
|
||||
uuid = uuid_free;
|
||||
}
|
||||
|
||||
g_object_set(s_con,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <linux/if_ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-json-aux.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-setting-connection.h"
|
||||
|
@ -2519,7 +2520,7 @@ test_write_dns_options(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test DNS options",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -3977,7 +3978,7 @@ test_write_wifi_hidden(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wi-Fi Hidden",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -4062,7 +4063,7 @@ test_write_wifi_mac_random(gconstpointer user_data)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
val,
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -4122,7 +4123,7 @@ test_write_wired_wake_on_lan(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired Wake-on-LAN",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -4305,7 +4306,7 @@ test_write_wifi_band_a(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wi-Fi Band A",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -4363,7 +4364,7 @@ test_write_wifi_ap_mode(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wi-Fi AP Mode",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -4676,7 +4677,7 @@ test_write_wired_static(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired Static",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES,
|
||||
|
@ -4831,7 +4832,7 @@ test_write_wired_static_with_generic(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired Static",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES,
|
||||
|
@ -4999,7 +5000,7 @@ test_write_wired_dhcp(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired DHCP",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5111,7 +5112,7 @@ test_write_routing_rules(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Routing Rules",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5169,7 +5170,7 @@ test_write_wired_match(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired with Match setting",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5315,7 +5316,7 @@ test_write_wired_static_ip6_only(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired Static IP6 Only",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5432,7 +5433,7 @@ test_write_wired_static_ip6_only_gw(gconstpointer user_data)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
id,
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5587,7 +5588,7 @@ test_write_wired_static_routes(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired Static Routes",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5711,7 +5712,7 @@ test_write_wired_dhcp_8021x_peap_mschapv2(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired DHCP 802.1x PEAP MSCHAPv2",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5813,7 +5814,7 @@ test_write_wired_8021x_tls(gconstpointer test_data)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired 802.1x TLS Blobs",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -5983,7 +5984,7 @@ test_write_wired_aliases(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"alias0",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -6110,7 +6111,7 @@ test_write_gateway(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Static Addresses Gateway",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -6187,7 +6188,7 @@ test_write_wifi_open(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi Open",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6273,7 +6274,7 @@ test_write_wifi_open_hex_ssid(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi Open Hex SSID",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6347,7 +6348,7 @@ test_write_wifi_wep(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WEP",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6445,7 +6446,7 @@ test_write_wifi_wep_adhoc(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WEP AdHoc",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6539,7 +6540,7 @@ test_write_wifi_wep_passphrase(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WEP Passphrase",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6634,7 +6635,7 @@ test_write_wifi_wep_40_ascii(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WEP 40 ASCII",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6732,7 +6733,7 @@ test_write_wifi_wep_104_ascii(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WEP 104 ASCII",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6833,7 +6834,7 @@ test_write_wifi_leap(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi LEAP",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -6931,7 +6932,7 @@ test_write_wifi_leap_secret_flags(gconstpointer data)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi LEAP Secret Flags",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -7037,7 +7038,7 @@ test_write_wifi_wpa_psk(gconstpointer test_data)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
args.name,
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -7142,7 +7143,7 @@ test_write_wifi_wpa_psk_adhoc(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WPA PSK",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -7252,7 +7253,7 @@ test_write_wifi_wpa_eap_tls(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WPA EAP-TLS",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -7379,7 +7380,7 @@ test_write_wifi_wpa_eap_ttls_tls(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WPA EAP-TTLS (TLS)",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -7515,7 +7516,7 @@ test_write_wifi_wpa_eap_ttls_mschapv2(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WPA EAP-TTLS (MSCHAPv2)",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -7630,7 +7631,7 @@ test_write_wifi_wpa_then_open(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"random wifi connection",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -7747,7 +7748,7 @@ test_write_wifi_wpa_then_wep_with_perms(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"random wifi connection 2",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_PERMISSIONS,
|
||||
|
@ -7872,7 +7873,7 @@ test_write_wifi_dynamic_wep_leap(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi Dynamic WEP LEAP",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -7969,7 +7970,7 @@ test_write_wired_qeth_dhcp(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired qeth Static",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -8043,7 +8044,7 @@ test_write_wired_ctc_dhcp(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired ctc Static",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -8118,7 +8119,7 @@ test_write_permissions(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Permissions",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -8187,7 +8188,7 @@ test_write_wifi_wep_agent_keys(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wifi WEP Agent Owned",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -8273,7 +8274,7 @@ test_write_wired_pppoe(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Wired PPPoE",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -8334,7 +8335,7 @@ test_write_vpn(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write VPN",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -8392,7 +8393,7 @@ test_write_mobile_broadband(gconstpointer data)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
gsm ? "Test Write GSM" : "Test Write CDMA",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -8510,7 +8511,7 @@ test_write_bridge_main(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Bridge Main",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
|
@ -8639,7 +8640,7 @@ test_write_bridge_component(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Bridge Component",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -9023,7 +9024,7 @@ test_write_vlan_reorder_hdr(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write VLAN reorder_hdr",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
FALSE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -9078,7 +9079,7 @@ test_write_ethernet_missing_ipv6(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Ethernet Without IPv6 Setting",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -9202,7 +9203,7 @@ test_write_bond_main(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Bond Main",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
|
@ -9302,7 +9303,7 @@ test_write_bond_slave(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Bond Slave",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -9389,7 +9390,7 @@ test_write_infiniband(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write InfiniBand",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -9478,7 +9479,7 @@ test_write_bond_slave_ib(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Bond Slave InfiniBand",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -9636,7 +9637,7 @@ test_write_dcb_basic(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"dcb-test",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
|
@ -9882,7 +9883,7 @@ test_write_fcoe_mode(gconstpointer user_data)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"fcoe-test",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
|
@ -10000,7 +10001,7 @@ test_write_team_master(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Team Master",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
"team0",
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
@ -10092,7 +10093,7 @@ test_write_team_port(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Team Port",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_MASTER,
|
||||
|
@ -10151,7 +10152,7 @@ test_write_team_infiniband_port(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Team Infiniband Port",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_INFINIBAND_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_MASTER,
|
||||
|
@ -10341,7 +10342,7 @@ test_write_proxy_basic(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write Proxy Basic",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
|
@ -11031,7 +11032,7 @@ test_sriov_write(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write SR-IOV config",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
|
@ -11166,7 +11167,7 @@ test_tc_write(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test Write TC config",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "settings/nm-settings-plugin.h"
|
||||
|
||||
|
@ -32,14 +33,6 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _str_has_prefix(val, prefix, require_suffix) \
|
||||
({ \
|
||||
const char *_val = (val); \
|
||||
\
|
||||
(strncmp(_val, "" prefix "", NM_STRLEN(prefix)) == 0) \
|
||||
&& (!(require_suffix) || _val[NM_STRLEN(prefix)] != '\0'); \
|
||||
})
|
||||
|
||||
static const char *
|
||||
_ifupdownplugin_guess_connection_type(if_block *block)
|
||||
{
|
||||
|
@ -51,8 +44,7 @@ _ifupdownplugin_guess_connection_type(if_block *block)
|
|||
if_data *ifb;
|
||||
|
||||
c_list_for_each_entry (ifb, &block->data_lst_head, data_lst) {
|
||||
if (_str_has_prefix(ifb->key, "wireless-", FALSE)
|
||||
|| _str_has_prefix(ifb->key, "wpa-", FALSE)) {
|
||||
if (NM_STR_HAS_PREFIX(ifb->key, "wireless-") || NM_STR_HAS_PREFIX(ifb->key, "wpa-")) {
|
||||
ret_type = NM_SETTING_WIRELESS_SETTING_NAME;
|
||||
break;
|
||||
}
|
||||
|
@ -102,7 +94,7 @@ update_wireless_setting_from_if_block(NMConnection *connection, if_block *block)
|
|||
wireless_setting = NM_SETTING_WIRELESS(nm_setting_wireless_new());
|
||||
|
||||
c_list_for_each_entry (curr, &block->data_lst_head, data_lst) {
|
||||
if (_str_has_prefix(curr->key, "wireless-", TRUE)) {
|
||||
if (NM_STR_HAS_PREFIX_WITH_MORE(curr->key, "wireless-")) {
|
||||
const char *newkey = map_by_mapping(mapping, curr->key + NM_STRLEN("wireless-"));
|
||||
|
||||
_LOGI("wireless setting key: %s='%s'", newkey, curr->data);
|
||||
|
@ -137,7 +129,7 @@ update_wireless_setting_from_if_block(NMConnection *connection, if_block *block)
|
|||
} else {
|
||||
g_object_set(wireless_setting, newkey, curr->data, NULL);
|
||||
}
|
||||
} else if (_str_has_prefix(curr->key, "wpa-", TRUE)) {
|
||||
} else if (NM_STR_HAS_PREFIX_WITH_MORE(curr->key, "wpa-")) {
|
||||
const char *newkey = map_by_mapping(mapping, curr->key + NM_STRLEN("wpa-"));
|
||||
|
||||
if (nm_streq0(newkey, "ssid")) {
|
||||
|
@ -304,7 +296,7 @@ update_wireless_security_setting_from_if_block(NMConnection *connection, if_bloc
|
|||
wireless_security_setting = NM_SETTING_WIRELESS_SECURITY(nm_setting_wireless_security_new());
|
||||
|
||||
c_list_for_each_entry (curr, &block->data_lst_head, data_lst) {
|
||||
if (_str_has_prefix(curr->key, "wireless-", TRUE)) {
|
||||
if (NM_STR_HAS_PREFIX_WITH_MORE(curr->key, "wireless-")) {
|
||||
const char * key = curr->key + NM_STRLEN("wireless-");
|
||||
char * property_value = NULL;
|
||||
gpointer typed_property_value = NULL;
|
||||
|
@ -336,7 +328,7 @@ wireless_next:
|
|||
if (typed_property_value && free_func)
|
||||
(*free_func)(typed_property_value);
|
||||
|
||||
} else if (_str_has_prefix(curr->key, "wpa-", TRUE)) {
|
||||
} else if (NM_STR_HAS_PREFIX_WITH_MORE(curr->key, "wpa-")) {
|
||||
const char * key = curr->key + NM_STRLEN("wpa-");
|
||||
char * property_value = NULL;
|
||||
gpointer typed_property_value = NULL;
|
||||
|
@ -644,7 +636,7 @@ ifupdown_new_connection_from_if_block(if_block *block, gboolean autoconnect, GEr
|
|||
type = _ifupdownplugin_guess_connection_type(block);
|
||||
idstr = g_strconcat("Ifupdown (", block->name, ")", NULL);
|
||||
|
||||
uuid = nm_utils_uuid_generate_from_string(idstr, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
|
||||
uuid = nm_uuid_generate_from_string_str(idstr, -1, NM_UUID_TYPE_LEGACY, NULL);
|
||||
g_object_set(s_con,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
type,
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <linux/if_ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
|
||||
#include "settings/plugins/keyfile/nms-keyfile-reader.h"
|
||||
|
@ -2289,7 +2290,7 @@ test_read_missing_id_uuid(void)
|
|||
gs_free char * expected_uuid = NULL;
|
||||
const char * FILENAME = TEST_KEYFILES_DIR "/Test_Missing_ID_UUID";
|
||||
|
||||
expected_uuid = _nm_utils_uuid_generate_from_strings("keyfile", FILENAME, NULL);
|
||||
expected_uuid = nm_uuid_generate_from_strings("keyfile", FILENAME, NULL);
|
||||
|
||||
connection = keyfile_read_connection_from_file(FILENAME);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "nm-sd-utils-core.h"
|
||||
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
|
||||
#include "nm-sd-adapt-core.h"
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
/* need math.h for isinf() and INFINITY. No need to link with -lm */
|
||||
#include <math.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "nm-core-utils.h"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "nm-connection-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
@ -703,14 +704,24 @@ static gboolean
|
|||
_normalize_connection_uuid(NMConnection *self)
|
||||
{
|
||||
NMSettingConnection *s_con = nm_connection_get_setting_connection(self);
|
||||
char uuid[37];
|
||||
char uuid_normalized[37];
|
||||
const char * uuid;
|
||||
|
||||
nm_assert(s_con);
|
||||
|
||||
if (nm_setting_connection_get_uuid(s_con))
|
||||
return FALSE;
|
||||
uuid = nm_setting_connection_get_uuid(s_con);
|
||||
|
||||
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_buf(uuid), NULL);
|
||||
if (uuid) {
|
||||
gboolean uuid_is_normalized;
|
||||
|
||||
if (!nm_uuid_is_valid_nm(uuid, &uuid_is_normalized, uuid_normalized))
|
||||
return nm_assert_unreachable_val(FALSE);
|
||||
if (!uuid_is_normalized)
|
||||
return FALSE;
|
||||
} else
|
||||
nm_uuid_generate_random_str_arr(uuid_normalized);
|
||||
|
||||
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, uuid_normalized, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -914,46 +914,6 @@ nm_crypto_verify_private_key(const char *filename,
|
|||
error);
|
||||
}
|
||||
|
||||
void
|
||||
nm_crypto_md5_hash(const guint8 *salt,
|
||||
gsize salt_len,
|
||||
const guint8 *password,
|
||||
gsize password_len,
|
||||
guint8 * buffer,
|
||||
gsize buflen)
|
||||
{
|
||||
nm_auto_free_checksum GChecksum * ctx = NULL;
|
||||
nm_auto_clear_static_secret_ptr const NMSecretPtr digest =
|
||||
NM_SECRET_PTR_STATIC(NM_UTILS_CHECKSUM_LENGTH_MD5);
|
||||
gsize bufidx = 0;
|
||||
int i;
|
||||
|
||||
g_return_if_fail(password_len == 0 || password);
|
||||
g_return_if_fail(buffer);
|
||||
g_return_if_fail(buflen > 0);
|
||||
g_return_if_fail(salt_len == 0 || salt);
|
||||
|
||||
ctx = g_checksum_new(G_CHECKSUM_MD5);
|
||||
|
||||
for (;;) {
|
||||
if (password_len > 0)
|
||||
g_checksum_update(ctx, (const guchar *) password, password_len);
|
||||
if (salt_len > 0)
|
||||
g_checksum_update(ctx, (const guchar *) salt, salt_len);
|
||||
|
||||
nm_utils_checksum_get_digest_len(ctx, digest.bin, NM_UTILS_CHECKSUM_LENGTH_MD5);
|
||||
|
||||
for (i = 0; i < NM_UTILS_CHECKSUM_LENGTH_MD5; i++) {
|
||||
if (bufidx >= buflen)
|
||||
return;
|
||||
buffer[bufidx++] = digest.bin[i];
|
||||
}
|
||||
|
||||
g_checksum_reset(ctx);
|
||||
g_checksum_update(ctx, digest.ptr, NM_UTILS_CHECKSUM_LENGTH_MD5);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error)
|
||||
{
|
||||
|
|
|
@ -63,13 +63,6 @@ NMCryptoFileFormat nm_crypto_verify_private_key(const char *file,
|
|||
gboolean * out_is_encrypted,
|
||||
GError ** error);
|
||||
|
||||
void nm_crypto_md5_hash(const guint8 *salt,
|
||||
gsize salt_len,
|
||||
const guint8 *password,
|
||||
gsize password_len,
|
||||
guint8 * buffer,
|
||||
gsize buflen);
|
||||
|
||||
gboolean nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <linux/if_ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-str-buf.h"
|
||||
#include "libnm-glib-aux/nm-secret-utils.h"
|
||||
#include "libnm-systemd-shared/nm-sd-utils-shared.h"
|
||||
|
@ -3695,7 +3696,7 @@ nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallback_uuid_
|
|||
if (nm_setting_connection_get_uuid(s_con))
|
||||
return FALSE;
|
||||
|
||||
hashed_uuid = _nm_utils_uuid_generate_from_strings("keyfile", fallback_uuid_seed, NULL);
|
||||
hashed_uuid = nm_uuid_generate_from_strings("keyfile", fallback_uuid_seed, NULL);
|
||||
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, hashed_uuid, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "nm-setting-connection.h"
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-core-aux-intern/nm-common-macros.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
@ -1065,6 +1066,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
const char * normerr_missing_slave_type = NULL;
|
||||
const char * normerr_missing_slave_type_port = NULL;
|
||||
gboolean normerr_base_setting = FALSE;
|
||||
gboolean uuid_was_normalized = FALSE;
|
||||
|
||||
if (!priv->id) {
|
||||
g_set_error_literal(error,
|
||||
|
@ -1088,7 +1090,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->uuid && !nm_utils_is_uuid(priv->uuid)) {
|
||||
if (priv->uuid && !nm_uuid_is_valid_nm(priv->uuid, &uuid_was_normalized, NULL)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
@ -1460,6 +1462,18 @@ after_interface_name:
|
|||
}
|
||||
}
|
||||
|
||||
if (uuid_was_normalized) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_PROPERTY,
|
||||
_("UUID needs normalization"));
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_CONNECTION_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_UUID);
|
||||
return NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1854,7 +1868,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
|
|||
* The UUID must be in the format "2815492f-7e56-435e-b2e9-246bd7cdc664"
|
||||
* (ie, contains only hexadecimal characters and "-"). A suitable UUID may
|
||||
* be generated by nm_utils_uuid_generate() or
|
||||
* nm_utils_uuid_generate_from_string().
|
||||
* nm_uuid_generate_from_string_str().
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: uuid
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
#include <net/ethernet.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <libintl.h>
|
||||
#include <gmodule.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/pkt_sched.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-json-aux.h"
|
||||
#include "libnm-glib-aux/nm-str-buf.h"
|
||||
#include "libnm-glib-aux/nm-enum-utils.h"
|
||||
|
@ -3044,72 +3044,6 @@ _nm_utils_sriov_vf_from_strparts(const char *index,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMUuid *
|
||||
_nm_utils_uuid_parse(const char *str, NMUuid *out_uuid)
|
||||
{
|
||||
nm_assert(str);
|
||||
nm_assert(out_uuid);
|
||||
|
||||
if (uuid_parse(str, out_uuid->uuid) != 0)
|
||||
return NULL;
|
||||
return out_uuid;
|
||||
}
|
||||
|
||||
char *
|
||||
_nm_utils_uuid_unparse(const NMUuid *uuid, char *out_str /*[37]*/)
|
||||
{
|
||||
nm_assert(uuid);
|
||||
|
||||
if (!out_str) {
|
||||
/* for convenience, allow %NULL to indicate that a new
|
||||
* string should be allocated. */
|
||||
out_str = g_malloc(37);
|
||||
}
|
||||
uuid_unparse_lower(uuid->uuid, out_str);
|
||||
return out_str;
|
||||
}
|
||||
|
||||
NMUuid *
|
||||
_nm_utils_uuid_generate_random(NMUuid *out_uuid)
|
||||
{
|
||||
nm_assert(out_uuid);
|
||||
|
||||
uuid_generate_random(out_uuid->uuid);
|
||||
return out_uuid;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_uuid_is_null(const NMUuid *uuid)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!uuid)
|
||||
return TRUE;
|
||||
|
||||
for (i = 0; i < (int) G_N_ELEMENTS(uuid->uuid); i++) {
|
||||
if (uuid->uuid[i])
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_uuid_generate_buf_:
|
||||
* @buf: input buffer, must contain at least 37 bytes
|
||||
*
|
||||
* Returns: generates a new random UUID, writes it to @buf and returns @buf.
|
||||
**/
|
||||
char *
|
||||
nm_utils_uuid_generate_buf_(char *buf)
|
||||
{
|
||||
NMUuid uuid;
|
||||
|
||||
nm_assert(buf);
|
||||
|
||||
_nm_utils_uuid_generate_random(&uuid);
|
||||
return _nm_utils_uuid_unparse(&uuid, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_uuid_generate:
|
||||
*
|
||||
|
@ -3119,152 +3053,7 @@ nm_utils_uuid_generate_buf_(char *buf)
|
|||
char *
|
||||
nm_utils_uuid_generate(void)
|
||||
{
|
||||
return nm_utils_uuid_generate_buf_(g_malloc(37));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_uuid_generate_from_string_bin:
|
||||
* @uuid: the UUID to update inplace. This function cannot
|
||||
* fail to succeed.
|
||||
* @s: a string to use as the seed for the UUID
|
||||
* @slen: if negative, treat @s as zero terminated C string.
|
||||
* Otherwise, assume the length as given (and allow @s to be
|
||||
* non-null terminated or contain '\0').
|
||||
* @uuid_type: a type identifier which UUID format to generate.
|
||||
* @type_args: additional arguments, depending on the uuid_type
|
||||
*
|
||||
* For a given @s, this function will always return the same UUID.
|
||||
*
|
||||
* Returns: the input @uuid. This function cannot fail.
|
||||
**/
|
||||
NMUuid *
|
||||
nm_utils_uuid_generate_from_string_bin(NMUuid * uuid,
|
||||
const char *s,
|
||||
gssize slen,
|
||||
int uuid_type,
|
||||
gpointer type_args)
|
||||
{
|
||||
g_return_val_if_fail(uuid, FALSE);
|
||||
g_return_val_if_fail(slen == 0 || s, FALSE);
|
||||
|
||||
if (slen < 0)
|
||||
slen = s ? strlen(s) : 0;
|
||||
|
||||
switch (uuid_type) {
|
||||
case NM_UTILS_UUID_TYPE_LEGACY:
|
||||
g_return_val_if_fail(!type_args, NULL);
|
||||
nm_crypto_md5_hash(NULL, 0, (guint8 *) s, slen, (guint8 *) uuid, sizeof(*uuid));
|
||||
break;
|
||||
case NM_UTILS_UUID_TYPE_VERSION3:
|
||||
case NM_UTILS_UUID_TYPE_VERSION5:
|
||||
{
|
||||
NMUuid ns_uuid = {};
|
||||
|
||||
if (type_args) {
|
||||
/* type_args can be a name space UUID. Interpret it as (char *) */
|
||||
if (!_nm_utils_uuid_parse(type_args, &ns_uuid))
|
||||
g_return_val_if_reached(NULL);
|
||||
}
|
||||
|
||||
if (uuid_type == NM_UTILS_UUID_TYPE_VERSION3) {
|
||||
nm_crypto_md5_hash((guint8 *) s,
|
||||
slen,
|
||||
(guint8 *) &ns_uuid,
|
||||
sizeof(ns_uuid),
|
||||
(guint8 *) uuid,
|
||||
sizeof(*uuid));
|
||||
} else {
|
||||
nm_auto_free_checksum GChecksum *sum = NULL;
|
||||
union {
|
||||
guint8 sha1[NM_UTILS_CHECKSUM_LENGTH_SHA1];
|
||||
NMUuid uuid;
|
||||
} digest;
|
||||
|
||||
sum = g_checksum_new(G_CHECKSUM_SHA1);
|
||||
g_checksum_update(sum, (guchar *) &ns_uuid, sizeof(ns_uuid));
|
||||
g_checksum_update(sum, (guchar *) s, slen);
|
||||
nm_utils_checksum_get_digest(sum, digest.sha1);
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(digest.sha1) > sizeof(digest.uuid));
|
||||
*uuid = digest.uuid;
|
||||
}
|
||||
|
||||
uuid->uuid[6] = (uuid->uuid[6] & 0x0F) | (uuid_type << 4);
|
||||
uuid->uuid[8] = (uuid->uuid[8] & 0x3F) | 0x80;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
g_return_val_if_reached(NULL);
|
||||
}
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_uuid_generate_from_string:
|
||||
* @s: a string to use as the seed for the UUID
|
||||
* @slen: if negative, treat @s as zero terminated C string.
|
||||
* Otherwise, assume the length as given (and allow @s to be
|
||||
* non-null terminated or contain '\0').
|
||||
* @uuid_type: a type identifier which UUID format to generate.
|
||||
* @type_args: additional arguments, depending on the uuid_type
|
||||
*
|
||||
* For a given @s, this function will always return the same UUID.
|
||||
*
|
||||
* Returns: a newly allocated UUID suitable for use as the #NMSettingConnection
|
||||
* object's #NMSettingConnection:id: property
|
||||
**/
|
||||
char *
|
||||
nm_utils_uuid_generate_from_string(const char *s, gssize slen, int uuid_type, gpointer type_args)
|
||||
{
|
||||
NMUuid uuid;
|
||||
|
||||
nm_utils_uuid_generate_from_string_bin(&uuid, s, slen, uuid_type, type_args);
|
||||
return _nm_utils_uuid_unparse(&uuid, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* _nm_utils_uuid_generate_from_strings:
|
||||
* @string1: a variadic list of strings. Must be NULL terminated.
|
||||
*
|
||||
* Returns a variant3 UUID based on the concatenated C strings.
|
||||
* It does not simply concatenate them, but also includes the
|
||||
* terminating '\0' character. For example "a", "b", gives
|
||||
* "a\0b\0".
|
||||
*
|
||||
* This has the advantage, that the following invocations
|
||||
* all give different UUIDs: (NULL), (""), ("",""), ("","a"), ("a",""),
|
||||
* ("aa"), ("aa", ""), ("", "aa"), ...
|
||||
*/
|
||||
char *
|
||||
_nm_utils_uuid_generate_from_strings(const char *string1, ...)
|
||||
{
|
||||
if (!string1)
|
||||
return nm_utils_uuid_generate_from_string(NULL,
|
||||
0,
|
||||
NM_UTILS_UUID_TYPE_VERSION3,
|
||||
NM_UTILS_UUID_NS);
|
||||
|
||||
{
|
||||
nm_auto_str_buf NMStrBuf str = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE);
|
||||
va_list args;
|
||||
const char * s;
|
||||
|
||||
nm_str_buf_append_len(&str, string1, strlen(string1) + 1u);
|
||||
|
||||
va_start(args, string1);
|
||||
s = va_arg(args, const char *);
|
||||
while (s) {
|
||||
nm_str_buf_append_len(&str, s, strlen(s) + 1u);
|
||||
s = va_arg(args, const char *);
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
return nm_utils_uuid_generate_from_string(nm_str_buf_get_str_unsafe(&str),
|
||||
str.len,
|
||||
NM_UTILS_UUID_TYPE_VERSION3,
|
||||
NM_UTILS_UUID_NS);
|
||||
}
|
||||
return nm_uuid_generate_random_str_malloc();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4649,28 +4438,7 @@ nm_utils_iface_valid_name(const char *name)
|
|||
gboolean
|
||||
nm_utils_is_uuid(const char *str)
|
||||
{
|
||||
const char *p = str;
|
||||
int num_dashes = 0;
|
||||
|
||||
if (!p)
|
||||
return FALSE;
|
||||
|
||||
while (*p) {
|
||||
if (*p == '-')
|
||||
num_dashes++;
|
||||
else if (!g_ascii_isxdigit(*p))
|
||||
return FALSE;
|
||||
p++;
|
||||
}
|
||||
|
||||
if ((num_dashes == 4) && (p - str == 36))
|
||||
return TRUE;
|
||||
|
||||
/* Backwards compat for older configurations */
|
||||
if ((num_dashes == 0) && (p - str == 40))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
return nm_uuid_is_valid_nmlegacy(str);
|
||||
}
|
||||
|
||||
static _nm_thread_local char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN];
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-std-aux/c-list-util.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-enum-utils.h"
|
||||
#include "libnm-glib-aux/nm-str-buf.h"
|
||||
#include "libnm-glib-aux/nm-json-aux.h"
|
||||
|
@ -7219,7 +7220,7 @@ _uuid(const char *str)
|
|||
static NMUuid u;
|
||||
|
||||
g_assert(str);
|
||||
g_assert(_nm_utils_uuid_parse(str, &u));
|
||||
g_assert(nm_uuid_parse(str, &u));
|
||||
return &u;
|
||||
}
|
||||
|
||||
|
@ -7232,7 +7233,7 @@ _test_uuid(int uuid_type,
|
|||
{
|
||||
gs_free char *uuid_test = NULL;
|
||||
|
||||
uuid_test = nm_utils_uuid_generate_from_string(str, slen, uuid_type, type_args);
|
||||
uuid_test = nm_uuid_generate_from_string_str(str, slen, uuid_type, type_args);
|
||||
|
||||
g_assert(uuid_test);
|
||||
g_assert(nm_utils_is_uuid(uuid_test));
|
||||
|
@ -7242,7 +7243,7 @@ _test_uuid(int uuid_type,
|
|||
uuid_type,
|
||||
str,
|
||||
(long long) slen,
|
||||
NM_IN_SET(uuid_type, NM_UTILS_UUID_TYPE_VERSION3, NM_UTILS_UUID_TYPE_VERSION5)
|
||||
NM_IN_SET(uuid_type, NM_UUID_TYPE_VERSION3, NM_UUID_TYPE_VERSION5)
|
||||
? (((const char *) type_args) ?: "(all-zero)")
|
||||
: (type_args ? "(unknown)" : "(null)"),
|
||||
uuid_test,
|
||||
|
@ -7257,8 +7258,7 @@ _test_uuid(int uuid_type,
|
|||
_test_uuid(uuid_type, expected_uuid, NULL, 0, type_args);
|
||||
}
|
||||
|
||||
if (NM_IN_SET(uuid_type, NM_UTILS_UUID_TYPE_VERSION3, NM_UTILS_UUID_TYPE_VERSION5)
|
||||
&& !type_args) {
|
||||
if (NM_IN_SET(uuid_type, NM_UUID_TYPE_VERSION3, NM_UUID_TYPE_VERSION5) && !type_args) {
|
||||
/* For version3 and version5, a missing @type_args is equal to UUID_NS_ZERO */
|
||||
_test_uuid(uuid_type, expected_uuid, str, slen, UUID_NS_ZERO);
|
||||
}
|
||||
|
@ -7679,76 +7679,44 @@ test_nm_utils_uuid_generate_from_string(void)
|
|||
char i_str[30];
|
||||
guint i;
|
||||
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_LEGACY, "d41d8cd9-8f00-b204-e980-0998ecf8427e", "", -1, NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_LEGACY, "0cc175b9-c0f1-b6a8-31c3-99e269772661", "a", -1, NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_LEGACY, "098f6bcd-4621-d373-cade-4e832627b4f6", "test", -1, NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_LEGACY, "70350f60-27bc-e371-3f6b-76473084309b", "a\0b", 3, NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_LEGACY,
|
||||
_test_uuid(NM_UUID_TYPE_LEGACY, "d41d8cd9-8f00-b204-e980-0998ecf8427e", "", -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_LEGACY, "0cc175b9-c0f1-b6a8-31c3-99e269772661", "a", -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_LEGACY, "098f6bcd-4621-d373-cade-4e832627b4f6", "test", -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_LEGACY, "70350f60-27bc-e371-3f6b-76473084309b", "a\0b", 3, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_LEGACY,
|
||||
"59c0547b-7fe2-1c15-2cce-e328e8bf6742",
|
||||
"/etc/NetworkManager/system-connections/em1",
|
||||
-1,
|
||||
NULL);
|
||||
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3, "4ae71336-e44b-39bf-b9d2-752e234818a5", "", -1, NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3, "0531103a-d8fc-3dd4-b972-d98e4750994e", "a", -1, NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
"96e17d7a-ac89-38cf-95e1-bf5098da34e1",
|
||||
"test",
|
||||
-1,
|
||||
NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
"8156568e-4ae6-3f34-a93e-18e2c6cbbf78",
|
||||
"a\0b",
|
||||
3,
|
||||
NULL);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, "4ae71336-e44b-39bf-b9d2-752e234818a5", "", -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, "0531103a-d8fc-3dd4-b972-d98e4750994e", "a", -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, "96e17d7a-ac89-38cf-95e1-bf5098da34e1", "test", -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, "8156568e-4ae6-3f34-a93e-18e2c6cbbf78", "a\0b", 3, NULL);
|
||||
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
"c87ee674-4ddc-3efe-a74e-dfe25da5d7b3",
|
||||
"",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
"4c104dd0-4821-30d5-9ce3-0e7a1f8b7c0d",
|
||||
"a",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, "c87ee674-4ddc-3efe-a74e-dfe25da5d7b3", "", -1, UUID_NS_DNS);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, "4c104dd0-4821-30d5-9ce3-0e7a1f8b7c0d", "a", -1, UUID_NS_DNS);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3,
|
||||
"45a113ac-c7f2-30b0-90a5-a399ab912716",
|
||||
"test",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3,
|
||||
"002a0ada-f547-375a-bab5-896a11d1927e",
|
||||
"a\0b",
|
||||
3,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3,
|
||||
"9a75f5f2-195e-31a9-9d07-8c18b5d3b285",
|
||||
"test123",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
"ec794efe-a384-3b11-a0b6-ec8995bc6acc",
|
||||
"x",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, "ec794efe-a384-3b11-a0b6-ec8995bc6acc", "x", -1, UUID_NS_DNS);
|
||||
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
"a7650b9f-f19f-5300-8a13-91160ea8de2c",
|
||||
"a\0b",
|
||||
3,
|
||||
NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
"4f3f2898-69e3-5a0d-820a-c4e87987dbce",
|
||||
"a",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
"05b16a01-46c6-56dd-bd6e-c6dfb4a1427a",
|
||||
"x",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5, "a7650b9f-f19f-5300-8a13-91160ea8de2c", "a\0b", 3, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5, "4f3f2898-69e3-5a0d-820a-c4e87987dbce", "a", -1, UUID_NS_DNS);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5, "05b16a01-46c6-56dd-bd6e-c6dfb4a1427a", "x", -1, UUID_NS_DNS);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5,
|
||||
"c9ed566a-6b79-5d3a-b2b7-96a936b48cf3",
|
||||
"test123",
|
||||
-1,
|
||||
|
@ -7756,58 +7724,58 @@ test_nm_utils_uuid_generate_from_string(void)
|
|||
|
||||
for (i = 0; i < G_N_ELEMENTS(zero_uuids); i++) {
|
||||
nm_sprintf_buf(i_str, "%u", i),
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3, zero_uuids[i].uuid3, i_str, -1, NULL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5, zero_uuids[i].uuid5, i_str, -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, zero_uuids[i].uuid3, i_str, -1, NULL);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5, zero_uuids[i].uuid5, i_str, -1, NULL);
|
||||
}
|
||||
for (i = 0; i < G_N_ELEMENTS(dns_uuids); i++) {
|
||||
nm_sprintf_buf(i_str, "%u", i),
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3, dns_uuids[i].uuid3, i_str, -1, UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5, dns_uuids[i].uuid5, i_str, -1, UUID_NS_DNS);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3, dns_uuids[i].uuid3, i_str, -1, UUID_NS_DNS);
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5, dns_uuids[i].uuid5, i_str, -1, UUID_NS_DNS);
|
||||
}
|
||||
|
||||
/* examples from cpython unit tests: */
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3,
|
||||
"6fa459ea-ee8a-3ca4-894e-db77e160355e",
|
||||
"python.org",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5,
|
||||
"886313e1-3b8a-5372-9b90-0c9aee199e5d",
|
||||
"python.org",
|
||||
-1,
|
||||
UUID_NS_DNS);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3,
|
||||
"9fe8e8c4-aaa8-32a9-a55c-4535a88b748d",
|
||||
"http://python.org/",
|
||||
-1,
|
||||
UUID_NS_URL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5,
|
||||
"4c565f0d-3f5a-5890-b41b-20cf47701c5e",
|
||||
"http://python.org/",
|
||||
-1,
|
||||
UUID_NS_URL);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3,
|
||||
"dd1a1cef-13d5-368a-ad82-eca71acd4cd1",
|
||||
"1.3.6.1",
|
||||
-1,
|
||||
UUID_NS_OID);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5,
|
||||
"1447fa61-5277-5fef-a9b3-fbc6e44f4af3",
|
||||
"1.3.6.1",
|
||||
-1,
|
||||
UUID_NS_OID);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION3,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION3,
|
||||
"658d3002-db6b-3040-a1d1-8ddd7d189a4d",
|
||||
"c=ca",
|
||||
-1,
|
||||
UUID_NS_X500);
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5,
|
||||
"cc957dd1-a972-5349-98cd-874190002798",
|
||||
"c=ca",
|
||||
-1,
|
||||
UUID_NS_X500);
|
||||
|
||||
_test_uuid(NM_UTILS_UUID_TYPE_VERSION5,
|
||||
_test_uuid(NM_UUID_TYPE_VERSION5,
|
||||
"74738ff5-5367-5958-9aee-98fffdcd1876",
|
||||
"www.example.org",
|
||||
-1,
|
||||
|
@ -7831,10 +7799,7 @@ __test_uuid(const char *expected_uuid, const char *str, gssize slen, char *uuid_
|
|||
}
|
||||
g_free(uuid_test);
|
||||
|
||||
uuid_test = nm_utils_uuid_generate_from_string(str,
|
||||
slen,
|
||||
NM_UTILS_UUID_TYPE_VERSION3,
|
||||
NM_UTILS_UUID_NS);
|
||||
uuid_test = nm_uuid_generate_from_string_str(str, slen, NM_UUID_TYPE_VERSION3, NM_UUID_NS1);
|
||||
|
||||
g_assert(uuid_test);
|
||||
g_assert(nm_utils_is_uuid(uuid_test));
|
||||
|
@ -7850,7 +7815,7 @@ __test_uuid(const char *expected_uuid, const char *str, gssize slen, char *uuid_
|
|||
}
|
||||
|
||||
#define _test_uuid(expected_uuid, str, strlen, ...) \
|
||||
__test_uuid(expected_uuid, str, strlen, _nm_utils_uuid_generate_from_strings(__VA_ARGS__, NULL))
|
||||
__test_uuid(expected_uuid, str, strlen, nm_uuid_generate_from_strings(__VA_ARGS__, NULL))
|
||||
|
||||
static void
|
||||
test_nm_utils_uuid_generate_from_strings(void)
|
||||
|
@ -7859,10 +7824,10 @@ test_nm_utils_uuid_generate_from_strings(void)
|
|||
|
||||
g_assert_cmpmem(&uuid0, sizeof(uuid0), _uuid("00000000-0000-0000-0000-000000000000"), 16);
|
||||
|
||||
g_assert(nm_utils_uuid_is_null(NULL));
|
||||
g_assert(nm_utils_uuid_is_null(&uuid0));
|
||||
g_assert(nm_utils_uuid_is_null(_uuid("00000000-0000-0000-0000-000000000000")));
|
||||
g_assert(!nm_utils_uuid_is_null(_uuid("10000000-0000-0000-0000-000000000000")));
|
||||
g_assert(nm_uuid_is_null(NULL));
|
||||
g_assert(nm_uuid_is_null(&uuid0));
|
||||
g_assert(nm_uuid_is_null(_uuid("00000000-0000-0000-0000-000000000000")));
|
||||
g_assert(!nm_uuid_is_null(_uuid("10000000-0000-0000-0000-000000000000")));
|
||||
|
||||
_test_uuid("b07c334a-399b-32de-8d50-58e4e08f98e3", "", 0, NULL);
|
||||
_test_uuid("b8a426cb-bcb5-30a3-bd8f-6786fea72df9", "\0", 1, "");
|
||||
|
@ -10828,7 +10793,7 @@ main(int argc, char **argv)
|
|||
g_test_add_func("/core/general/nm_strquote", test_nm_strquote);
|
||||
g_test_add_func("/core/general/test_nm_utils_uuid_generate_from_string",
|
||||
test_nm_utils_uuid_generate_from_string);
|
||||
g_test_add_func("/core/general/_nm_utils_uuid_generate_from_strings",
|
||||
g_test_add_func("/core/general/nm_uuid_generate_from_strings",
|
||||
test_nm_utils_uuid_generate_from_strings);
|
||||
|
||||
g_test_add_func("/core/general/_nm_utils_ascii_str_to_int64", test_nm_utils_ascii_str_to_int64);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/pkt_sched.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-json-aux.h"
|
||||
#include "libnm-base/nm-ethtool-utils-base.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
|
@ -229,6 +230,125 @@ test_private_key_import(const char *path, const char *password, NMSetting8021xCK
|
|||
g_object_unref(s_8021x);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_do_test_connection_uuid(NMConnection *con, const char *uuid, const char *expected_uuid)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
gs_free char * uuid_old = NULL;
|
||||
gboolean success;
|
||||
gboolean is_normalized;
|
||||
char uuid_normalized[37];
|
||||
|
||||
nmtst_assert_connection_verifies_without_normalization(con);
|
||||
|
||||
s_con = NM_SETTING_CONNECTION(nm_connection_get_setting(con, NM_TYPE_SETTING_CONNECTION));
|
||||
g_assert(NM_IS_SETTING_CONNECTION(s_con));
|
||||
|
||||
g_assert(uuid);
|
||||
|
||||
uuid_old = g_strdup(nm_setting_connection_get_uuid(s_con));
|
||||
|
||||
g_assert(nm_utils_is_uuid(uuid_old));
|
||||
|
||||
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
|
||||
|
||||
g_assert_cmpstr(uuid, ==, nm_setting_connection_get_uuid(s_con));
|
||||
|
||||
if (nm_streq0(uuid, expected_uuid)) {
|
||||
nmtst_assert_connection_verifies_without_normalization(con);
|
||||
g_assert(nm_utils_is_uuid(uuid));
|
||||
g_assert(nm_uuid_is_valid(uuid));
|
||||
g_assert(nm_uuid_is_valid_nm(uuid, &is_normalized, NULL));
|
||||
g_assert(!is_normalized);
|
||||
} else if (!expected_uuid) {
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
success = nm_connection_verify(con, &error);
|
||||
nmtst_assert_no_success(success, error);
|
||||
g_assert_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
|
||||
|
||||
g_assert(!nm_utils_is_uuid(uuid));
|
||||
g_assert(!nm_uuid_is_valid(uuid));
|
||||
g_assert(!nm_uuid_is_valid_nmlegacy(uuid));
|
||||
g_assert(!nm_uuid_is_valid_nm(uuid, NULL, NULL));
|
||||
} else {
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
nmtst_assert_connection_verifies_and_normalizable(con);
|
||||
|
||||
success = nm_connection_verify(con, &error);
|
||||
nmtst_assert_success(success, error);
|
||||
|
||||
if (!nmtst_connection_normalize(con))
|
||||
g_assert_not_reached();
|
||||
|
||||
g_assert_cmpstr(expected_uuid, ==, nm_setting_connection_get_uuid(s_con));
|
||||
g_assert(nm_uuid_is_valid(expected_uuid));
|
||||
|
||||
g_assert(nm_utils_is_uuid(uuid));
|
||||
g_assert(nm_uuid_is_valid_nmlegacy(uuid));
|
||||
g_assert(nm_uuid_is_valid_nm(uuid, &is_normalized, uuid_normalized));
|
||||
|
||||
g_assert_cmpstr(expected_uuid, ==, uuid_normalized);
|
||||
}
|
||||
|
||||
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, uuid_old, NULL);
|
||||
nmtst_assert_connection_verifies_without_normalization(con);
|
||||
|
||||
if (expected_uuid && !nm_streq(expected_uuid, uuid))
|
||||
_do_test_connection_uuid(con, expected_uuid, expected_uuid);
|
||||
}
|
||||
|
||||
static void
|
||||
test_connection_uuid(void)
|
||||
{
|
||||
gs_unref_object NMConnection *con = NULL;
|
||||
|
||||
con = nmtst_create_minimal_connection("test-uuid", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL);
|
||||
|
||||
nmtst_connection_normalize(con);
|
||||
|
||||
#define _do_test_connection_uuid_bad(con, uuid) _do_test_connection_uuid((con), "" uuid "", NULL)
|
||||
|
||||
#define _do_test_connection_uuid_good(con, uuid) \
|
||||
_do_test_connection_uuid((con), "" uuid "", "" uuid "")
|
||||
|
||||
#define _do_test_connection_uuid_norm(con, uuid, expected_uuid) \
|
||||
_do_test_connection_uuid((con), "" uuid "", "" expected_uuid "")
|
||||
|
||||
_do_test_connection_uuid_bad(con, "x1e775e3-a316-4eb2-b4d8-4b0f2bcaea53");
|
||||
_do_test_connection_uuid_bad(con, "1e775e3aa3164eb2b4d84b0f2bcaea53abcdabc");
|
||||
_do_test_connection_uuid_bad(con, "1e775e3aa3164eb2b4d84b0f2bcaea53abcdabcdd");
|
||||
|
||||
_do_test_connection_uuid_good(con, "a1e775e3-a316-4eb2-b4d8-4b0f2bcaea53");
|
||||
|
||||
_do_test_connection_uuid_norm(con,
|
||||
"A1E775e3-a316-4eb2-b4d8-4b0f2bcaea53",
|
||||
"a1e775e3-a316-4eb2-b4d8-4b0f2bcaea53");
|
||||
_do_test_connection_uuid_norm(con,
|
||||
"A1E775E3-A316-4EB2-B4D8-4B0F2BCAEA53",
|
||||
"a1e775e3-a316-4eb2-b4d8-4b0f2bcaea53");
|
||||
_do_test_connection_uuid_norm(con,
|
||||
"-1e775e3aa316-4eb2-b4d8-4b0f2bcaea53",
|
||||
"bdd73688-5c87-5454-917d-f5c3faed39c0");
|
||||
_do_test_connection_uuid_norm(con,
|
||||
"----1e775e3aa3164eb2b4d84b0f2bcaea53",
|
||||
"8a232814-c6cf-54c9-9384-71a60011d0b2");
|
||||
_do_test_connection_uuid_norm(con,
|
||||
"1e775e3aa3164eb2b4d84b0f2bcaea53abcdabcd",
|
||||
"ae35a4a8-4029-5770-9fa4-d79a672874c3");
|
||||
_do_test_connection_uuid_norm(con,
|
||||
"1e775e3Aa3164eb2b4d84b0f2bcaea53abcdabcd",
|
||||
"ae35a4a8-4029-5770-9fa4-d79a672874c3");
|
||||
_do_test_connection_uuid_norm(con,
|
||||
"1E775E3AA3164EB2B4D84B0F2BCAEA53ABCDABCD",
|
||||
"ae35a4a8-4029-5770-9fa4-d79a672874c3");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_phase2_private_key_import(const char * path,
|
||||
const char * password,
|
||||
|
@ -2146,7 +2266,7 @@ test_sriov_setting(void)
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
"Test SR-IOV connection",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
TRUE,
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
|
@ -4258,6 +4378,8 @@ main(int argc, char **argv)
|
|||
{
|
||||
nmtst_init(&argc, &argv, TRUE);
|
||||
|
||||
g_test_add_func("/libnm/test_connection_uuid", test_connection_uuid);
|
||||
|
||||
g_test_add_data_func("/libnm/setting-8021x/key-and-cert",
|
||||
"test_key_and_cert.pem, test",
|
||||
test_8021x);
|
||||
|
|
|
@ -351,42 +351,6 @@ gboolean _nm_utils_check_module_file(const char * name,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _NMUuid {
|
||||
guchar uuid[16];
|
||||
} NMUuid;
|
||||
|
||||
NMUuid *_nm_utils_uuid_parse(const char *str, NMUuid *uuid);
|
||||
char * _nm_utils_uuid_unparse(const NMUuid *uuid, char *out_str /*[37]*/);
|
||||
NMUuid *_nm_utils_uuid_generate_random(NMUuid *out_uuid);
|
||||
|
||||
gboolean nm_utils_uuid_is_null(const NMUuid *uuid);
|
||||
|
||||
#define NM_UTILS_UUID_TYPE_LEGACY 0
|
||||
#define NM_UTILS_UUID_TYPE_VERSION3 3
|
||||
#define NM_UTILS_UUID_TYPE_VERSION5 5
|
||||
|
||||
NMUuid *nm_utils_uuid_generate_from_string_bin(NMUuid * uuid,
|
||||
const char *s,
|
||||
gssize slen,
|
||||
int uuid_type,
|
||||
gpointer type_args);
|
||||
|
||||
char *
|
||||
nm_utils_uuid_generate_from_string(const char *s, gssize slen, int uuid_type, gpointer type_args);
|
||||
|
||||
/* arbitrarily chosen namespace UUID for _nm_utils_uuid_generate_from_strings() */
|
||||
#define NM_UTILS_UUID_NS "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
|
||||
|
||||
char *_nm_utils_uuid_generate_from_strings(const char *string1, ...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
char *nm_utils_uuid_generate_buf_(char *buf);
|
||||
#define nm_utils_uuid_generate_buf(buf) \
|
||||
({ \
|
||||
G_STATIC_ASSERT(sizeof(buf) == G_N_ELEMENTS(buf) && sizeof(buf) >= 37); \
|
||||
nm_utils_uuid_generate_buf_(buf); \
|
||||
})
|
||||
#define nm_utils_uuid_generate_a() (nm_utils_uuid_generate_buf_(g_alloca(37)))
|
||||
|
||||
void _nm_dbus_errors_init(void);
|
||||
|
||||
extern gboolean _nm_utils_is_manager_process;
|
||||
|
|
|
@ -17,6 +17,7 @@ libnm_glib_aux = static_library(
|
|||
'nm-secret-utils.c',
|
||||
'nm-shared-utils.c',
|
||||
'nm-time-utils.c',
|
||||
'nm-uuid.c',
|
||||
),
|
||||
include_directories: [
|
||||
src_inc,
|
||||
|
|
|
@ -6199,3 +6199,45 @@ NM_ASSERT_VALID_PATH_COMPONENT(const char *name)
|
|||
NM_PRINT_FMT_QUOTED(name, "\"", name, "\"", "(null)"));
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_crypto_md5_hash(const guint8 *salt,
|
||||
gsize salt_len,
|
||||
const guint8 *password,
|
||||
gsize password_len,
|
||||
guint8 * buffer,
|
||||
gsize buflen)
|
||||
{
|
||||
nm_auto_free_checksum GChecksum * ctx = NULL;
|
||||
nm_auto_clear_static_secret_ptr const NMSecretPtr digest =
|
||||
NM_SECRET_PTR_STATIC(NM_UTILS_CHECKSUM_LENGTH_MD5);
|
||||
gsize bufidx = 0;
|
||||
int i;
|
||||
|
||||
g_return_if_fail(password_len == 0 || password);
|
||||
g_return_if_fail(buffer);
|
||||
g_return_if_fail(buflen > 0);
|
||||
g_return_if_fail(salt_len == 0 || salt);
|
||||
|
||||
ctx = g_checksum_new(G_CHECKSUM_MD5);
|
||||
|
||||
for (;;) {
|
||||
if (password_len > 0)
|
||||
g_checksum_update(ctx, (const guchar *) password, password_len);
|
||||
if (salt_len > 0)
|
||||
g_checksum_update(ctx, (const guchar *) salt, salt_len);
|
||||
|
||||
nm_utils_checksum_get_digest_len(ctx, digest.bin, NM_UTILS_CHECKSUM_LENGTH_MD5);
|
||||
|
||||
for (i = 0; i < NM_UTILS_CHECKSUM_LENGTH_MD5; i++) {
|
||||
if (bufidx >= buflen)
|
||||
return;
|
||||
buffer[bufidx++] = digest.bin[i];
|
||||
}
|
||||
|
||||
g_checksum_reset(ctx);
|
||||
g_checksum_update(ctx, digest.ptr, NM_UTILS_CHECKSUM_LENGTH_MD5);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2786,4 +2786,13 @@ gboolean nm_utils_sysctl_ip_conf_is_path(int addr_family,
|
|||
const char *ifname,
|
||||
const char *property);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void nm_crypto_md5_hash(const guint8 *salt,
|
||||
gsize salt_len,
|
||||
const guint8 *password,
|
||||
gsize password_len,
|
||||
guint8 * buffer,
|
||||
gsize buflen);
|
||||
|
||||
#endif /* __NM_SHARED_UTILS_H__ */
|
||||
|
|
409
src/libnm-glib-aux/nm-uuid.c
Normal file
409
src/libnm-glib-aux/nm-uuid.c
Normal file
|
@ -0,0 +1,409 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "libnm-glib-aux/nm-default-glib.h"
|
||||
|
||||
#include "nm-uuid.h"
|
||||
|
||||
#include "libnm-glib-aux/nm-random-utils.h"
|
||||
#include "libnm-glib-aux/nm-str-buf.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char *
|
||||
nm_uuid_unparse_case(const NMUuid *uuid, char out_str[static 37], gboolean upper_case)
|
||||
{
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
nm_assert(uuid);
|
||||
nm_assert(out_str);
|
||||
|
||||
s = out_str;
|
||||
for (i = 0; i < 16; i++) {
|
||||
const guint8 c = uuid->uuid[i];
|
||||
|
||||
if (NM_IN_SET(i, 4, 6, 8, 10))
|
||||
*(s++) = '-';
|
||||
*(s++) = nm_hexchar(c >> 4, upper_case);
|
||||
*(s++) = nm_hexchar(c, upper_case);
|
||||
}
|
||||
*s = '\0';
|
||||
|
||||
return out_str;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_uuid_parse_full(const char *str, NMUuid *out_uuid, gboolean *out_is_normalized)
|
||||
{
|
||||
NMUuid uuid;
|
||||
guint8 * p;
|
||||
int i;
|
||||
gboolean is_normalized = TRUE;
|
||||
|
||||
nm_assert(str);
|
||||
|
||||
p = uuid.uuid;
|
||||
|
||||
for (i = 0; TRUE;) {
|
||||
int v0;
|
||||
int v1;
|
||||
|
||||
if (NM_IN_SET(i, 8, 13, 18, 23)) {
|
||||
if (str[i] != '-')
|
||||
return FALSE;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == 36) {
|
||||
if (str[i] != '\0')
|
||||
return FALSE;
|
||||
|
||||
NM_SET_OUT(out_is_normalized, is_normalized);
|
||||
NM_SET_OUT(out_uuid, uuid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define _hexchar(ch, out_is_normalized2) \
|
||||
({ \
|
||||
const char _ch = (ch); \
|
||||
int _result = -1; \
|
||||
\
|
||||
if (_ch >= '0') { \
|
||||
if (_ch <= '9') \
|
||||
_result = (_ch - '0'); \
|
||||
else if (_ch >= 'A') { \
|
||||
if (_ch <= 'F') { \
|
||||
*(out_is_normalized2) = FALSE; \
|
||||
_result = ((int) _ch) + (10 - (int) 'A'); \
|
||||
} else if (_ch >= 'a' && _ch <= 'f') \
|
||||
_result = ((int) _ch) + (10 - (int) 'a'); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
_result; \
|
||||
})
|
||||
|
||||
v0 = _hexchar(str[i++], &is_normalized);
|
||||
if (v0 < 0)
|
||||
return FALSE;
|
||||
v1 = _hexchar(str[i++], &is_normalized);
|
||||
if (v1 < 0)
|
||||
return FALSE;
|
||||
|
||||
*(p++) = (v0 << 4) + v1;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMUuid *
|
||||
nm_uuid_generate_random(NMUuid *out_uuid)
|
||||
{
|
||||
nm_assert(out_uuid);
|
||||
|
||||
/* https://tools.ietf.org/html/rfc4122#section-4.4 */
|
||||
|
||||
/* See also, systemd's id128_make_v4_uuid() */
|
||||
|
||||
/* nm_utils_random_bytes() is supposed to try hard to give good
|
||||
* randomness. If it fails, it still makes an effort to fill
|
||||
* random data into the buffer. There is not much we can do about
|
||||
* that case, except making sure that it does not happen in the
|
||||
* first place. */
|
||||
nm_utils_random_bytes(out_uuid, sizeof(*out_uuid));
|
||||
|
||||
/* Set the four most significant bits (bits 12 through 15) of the
|
||||
* time_hi_and_version field to the 4-bit version number from
|
||||
* Section 4.1.3. */
|
||||
out_uuid->uuid[6] = (out_uuid->uuid[6] & 0x0Fu) | 0x40u;
|
||||
|
||||
/* Set the two most significant bits (bits 6 and 7) of the
|
||||
* clock_seq_hi_and_reserved to zero and one, respectively. */
|
||||
out_uuid->uuid[8] = (out_uuid->uuid[8] & 0x3Fu) | 0x80u;
|
||||
|
||||
return out_uuid;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_uuid_is_valid_nmlegacy()
|
||||
* @str: the string to check whether it's a valid UUID.
|
||||
*
|
||||
* Note that this does not perform a strict check.
|
||||
* Instead, it checks a more relaxed format (including
|
||||
* non valid UUID strings). This is for backward compatibility,
|
||||
* where older code did not perform a strict check.
|
||||
*
|
||||
* Returns: %TRUE, if the string is a valid legacy format.
|
||||
* This may not be a valid UUID!
|
||||
*/
|
||||
gboolean
|
||||
nm_uuid_is_valid_nmlegacy(const char *str)
|
||||
{
|
||||
const char *p = str;
|
||||
int num_dashes = 0;
|
||||
|
||||
if (!p)
|
||||
return FALSE;
|
||||
|
||||
while (*p) {
|
||||
if (*p == '-')
|
||||
num_dashes++;
|
||||
else if (!g_ascii_isxdigit(*p))
|
||||
return FALSE;
|
||||
p++;
|
||||
}
|
||||
|
||||
/* While we accept here bogus strings as UUIDs, they must contain only
|
||||
* hexdigits and '-', and they must be eithr 36 or 40 chars long. */
|
||||
|
||||
if ((num_dashes == 4) && (p - str == 36))
|
||||
return TRUE;
|
||||
|
||||
/* Backwards compat for older configurations */
|
||||
if ((num_dashes == 0) && (p - str == 40))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_uuid_is_valid_nm(const char *str,
|
||||
gboolean * out_normalized,
|
||||
char * out_normalized_str /* [static 37] */)
|
||||
{
|
||||
NMUuid uuid;
|
||||
gboolean is_normalized;
|
||||
|
||||
if (!str)
|
||||
return FALSE;
|
||||
|
||||
if (nm_uuid_parse_full(str, &uuid, &is_normalized)) {
|
||||
if (is_normalized) {
|
||||
/* @str is a normalized (lower-case), valid UUID. Nothing to normalize,
|
||||
* and return success. */
|
||||
NM_SET_OUT(out_normalized, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* @str is a valid UUID, but not normalized. That means that it's
|
||||
* upper case. Normalize the UUID. */
|
||||
NM_SET_OUT(out_normalized, TRUE);
|
||||
if (out_normalized_str)
|
||||
nm_uuid_unparse(&uuid, out_normalized_str);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (nm_uuid_is_valid_nmlegacy(str)) {
|
||||
/* This is not a valid UUID, but something that we used to
|
||||
* accept according to nm_uuid_is_valid_nmlegacy().
|
||||
*
|
||||
* Normalize it by sha1 hashing the string. Upper case characters
|
||||
* are made lower case first. */
|
||||
NM_SET_OUT(out_normalized, TRUE);
|
||||
if (out_normalized_str) {
|
||||
char str_lower[40 + 1];
|
||||
int i;
|
||||
|
||||
nm_assert(strlen(str) < G_N_ELEMENTS(str_lower));
|
||||
|
||||
/* normalize first to lower-case. */
|
||||
g_strlcpy(str_lower, str, sizeof(str_lower));
|
||||
for (i = 0; str_lower[i]; i++)
|
||||
str_lower[i] = g_ascii_tolower(str_lower[i]);
|
||||
|
||||
/* The namespace UUID is chosen randomly. */
|
||||
nm_uuid_generate_from_string(&uuid,
|
||||
str_lower,
|
||||
-1,
|
||||
NM_UUID_TYPE_VERSION5,
|
||||
"4e72f709-ca95-4405-9053-1f43294a618c");
|
||||
nm_uuid_unparse(&uuid, out_normalized_str);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* UUID is not valid. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_uuid_is_null(const NMUuid *uuid)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!uuid)
|
||||
return TRUE;
|
||||
|
||||
for (i = 0; i < (int) G_N_ELEMENTS(uuid->uuid); i++) {
|
||||
if (uuid->uuid[i])
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *
|
||||
nm_uuid_generate_random_str(char buf[static 37])
|
||||
{
|
||||
NMUuid uuid;
|
||||
|
||||
nm_assert(buf);
|
||||
|
||||
nm_uuid_generate_random(&uuid);
|
||||
return nm_uuid_unparse(&uuid, buf);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_uuid_generate_from_string:
|
||||
* @uuid: the UUID to update inplace. This function cannot
|
||||
* fail to succeed.
|
||||
* @s: a string to use as the seed for the UUID
|
||||
* @slen: if negative, treat @s as zero terminated C string.
|
||||
* Otherwise, assume the length as given (and allow @s to be
|
||||
* non-null terminated or contain '\0').
|
||||
* @uuid_type: a type identifier which UUID format to generate.
|
||||
* @type_args: additional arguments, depending on the uuid_type
|
||||
*
|
||||
* For a given @s, this function will always return the same UUID.
|
||||
*
|
||||
* Returns: the input @uuid. This function cannot fail.
|
||||
**/
|
||||
NMUuid *
|
||||
nm_uuid_generate_from_string(NMUuid * uuid,
|
||||
const char *s,
|
||||
gssize slen,
|
||||
NMUuidType uuid_type,
|
||||
gpointer type_args)
|
||||
{
|
||||
g_return_val_if_fail(uuid, FALSE);
|
||||
g_return_val_if_fail(slen == 0 || s, FALSE);
|
||||
|
||||
if (slen < 0)
|
||||
slen = s ? strlen(s) : 0;
|
||||
|
||||
switch (uuid_type) {
|
||||
case NM_UUID_TYPE_LEGACY:
|
||||
g_return_val_if_fail(!type_args, NULL);
|
||||
nm_crypto_md5_hash(NULL, 0, (guint8 *) s, slen, (guint8 *) uuid, sizeof(*uuid));
|
||||
break;
|
||||
case NM_UUID_TYPE_VERSION3:
|
||||
case NM_UUID_TYPE_VERSION5:
|
||||
{
|
||||
NMUuid ns_uuid = {};
|
||||
|
||||
if (type_args) {
|
||||
/* type_args can be a name space UUID. Interpret it as (char *) */
|
||||
if (!nm_uuid_parse(type_args, &ns_uuid))
|
||||
g_return_val_if_reached(NULL);
|
||||
}
|
||||
|
||||
if (uuid_type == NM_UUID_TYPE_VERSION3) {
|
||||
nm_crypto_md5_hash((guint8 *) s,
|
||||
slen,
|
||||
(guint8 *) &ns_uuid,
|
||||
sizeof(ns_uuid),
|
||||
(guint8 *) uuid,
|
||||
sizeof(*uuid));
|
||||
} else {
|
||||
nm_auto_free_checksum GChecksum *sum = NULL;
|
||||
union {
|
||||
guint8 sha1[NM_UTILS_CHECKSUM_LENGTH_SHA1];
|
||||
NMUuid uuid;
|
||||
} digest;
|
||||
|
||||
sum = g_checksum_new(G_CHECKSUM_SHA1);
|
||||
g_checksum_update(sum, (guchar *) &ns_uuid, sizeof(ns_uuid));
|
||||
g_checksum_update(sum, (guchar *) s, slen);
|
||||
nm_utils_checksum_get_digest(sum, digest.sha1);
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(digest.sha1) > sizeof(digest.uuid));
|
||||
*uuid = digest.uuid;
|
||||
}
|
||||
|
||||
uuid->uuid[6] = (uuid->uuid[6] & 0x0F) | (uuid_type << 4);
|
||||
uuid->uuid[8] = (uuid->uuid[8] & 0x3F) | 0x80;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
g_return_val_if_reached(NULL);
|
||||
}
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_uuid_generate_from_string_str:
|
||||
* @s: a string to use as the seed for the UUID
|
||||
* @slen: if negative, treat @s as zero terminated C string.
|
||||
* Otherwise, assume the length as given (and allow @s to be
|
||||
* non-null terminated or contain '\0').
|
||||
* @uuid_type: a type identifier which UUID format to generate.
|
||||
* @type_args: additional arguments, depending on the uuid_type
|
||||
*
|
||||
* For a given @s, this function will always return the same UUID.
|
||||
*
|
||||
* Returns: a newly allocated UUID suitable for use as the #NMSettingConnection
|
||||
* object's #NMSettingConnection:id: property
|
||||
**/
|
||||
char *
|
||||
nm_uuid_generate_from_string_str(const char *s,
|
||||
gssize slen,
|
||||
NMUuidType uuid_type,
|
||||
gpointer type_args)
|
||||
{
|
||||
NMUuid uuid;
|
||||
|
||||
nm_uuid_generate_from_string(&uuid, s, slen, uuid_type, type_args);
|
||||
return nm_uuid_unparse(&uuid, g_new(char, 37));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_uuid_generate_from_strings:
|
||||
* @string1: a variadic list of strings. Must be NULL terminated.
|
||||
*
|
||||
* Returns a variant3 UUID based on the concatenated C strings.
|
||||
* It does not simply concatenate them, but also includes the
|
||||
* terminating '\0' character. For example "a", "b", gives
|
||||
* "a\0b\0".
|
||||
*
|
||||
* This has the advantage, that the following invocations
|
||||
* all give different UUIDs: (NULL), (""), ("",""), ("","a"), ("a",""),
|
||||
* ("aa"), ("aa", ""), ("", "aa"), ...
|
||||
*/
|
||||
char *
|
||||
nm_uuid_generate_from_strings(const char *string1, ...)
|
||||
{
|
||||
if (!string1)
|
||||
return nm_uuid_generate_from_string_str(NULL, 0, NM_UUID_TYPE_VERSION3, NM_UUID_NS1);
|
||||
|
||||
{
|
||||
nm_auto_str_buf NMStrBuf str = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE);
|
||||
va_list args;
|
||||
const char * s;
|
||||
|
||||
nm_str_buf_append_len(&str, string1, strlen(string1) + 1u);
|
||||
|
||||
va_start(args, string1);
|
||||
s = va_arg(args, const char *);
|
||||
while (s) {
|
||||
nm_str_buf_append_len(&str, s, strlen(s) + 1u);
|
||||
s = va_arg(args, const char *);
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
return nm_uuid_generate_from_string_str(nm_str_buf_get_str_unsafe(&str),
|
||||
str.len,
|
||||
NM_UUID_TYPE_VERSION3,
|
||||
NM_UUID_NS1);
|
||||
}
|
||||
}
|
90
src/libnm-glib-aux/nm-uuid.h
Normal file
90
src/libnm-glib-aux/nm-uuid.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#ifndef __NM_UUID_H__
|
||||
#define __NM_UUID_H__
|
||||
|
||||
typedef struct _NMUuid {
|
||||
guint8 uuid[16];
|
||||
} NMUuid;
|
||||
|
||||
char *nm_uuid_unparse_case(const NMUuid *uuid, char out_str[static 37], gboolean upper_case);
|
||||
|
||||
static inline char *
|
||||
nm_uuid_unparse(const NMUuid *uuid, char out_str[static 37])
|
||||
{
|
||||
return nm_uuid_unparse_case(uuid, out_str, FALSE);
|
||||
}
|
||||
|
||||
gboolean nm_uuid_parse_full(const char *str, NMUuid *out_uuid, gboolean *out_is_normalized);
|
||||
|
||||
static inline NMUuid *
|
||||
nm_uuid_parse(const char *str, NMUuid *out_uuid)
|
||||
{
|
||||
nm_assert(out_uuid);
|
||||
|
||||
if (!nm_uuid_parse_full(str, out_uuid, NULL))
|
||||
return NULL;
|
||||
return out_uuid;
|
||||
}
|
||||
|
||||
NMUuid *nm_uuid_generate_random(NMUuid *out_uuid);
|
||||
|
||||
gboolean nm_uuid_is_null(const NMUuid *uuid);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
nm_uuid_is_valid(const char *str)
|
||||
{
|
||||
return str && nm_uuid_parse_full(str, NULL, NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_uuid_is_valid_nmlegacy(const char *str);
|
||||
|
||||
gboolean nm_uuid_is_valid_nm(const char *str,
|
||||
gboolean * out_normalized,
|
||||
char * out_normalized_str /* [static 37] */);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char *nm_uuid_generate_random_str(char buf[static 37]);
|
||||
|
||||
#define nm_uuid_generate_random_str_arr(buf) \
|
||||
({ \
|
||||
G_STATIC_ASSERT(sizeof(buf) == G_N_ELEMENTS(buf) && sizeof(buf) >= 37); \
|
||||
nm_uuid_generate_random_str(buf); \
|
||||
})
|
||||
|
||||
#define nm_uuid_generate_random_str_a() (nm_uuid_generate_random_str(g_alloca(37)))
|
||||
|
||||
#define nm_uuid_generate_random_str_malloc() (nm_uuid_generate_random_str(g_new(char, 37)))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
NM_UUID_TYPE_LEGACY = 0,
|
||||
NM_UUID_TYPE_VERSION3 = 3,
|
||||
NM_UUID_TYPE_VERSION5 = 5,
|
||||
} NMUuidType;
|
||||
|
||||
NMUuid *nm_uuid_generate_from_string(NMUuid * uuid,
|
||||
const char *s,
|
||||
gssize slen,
|
||||
NMUuidType uuid_type,
|
||||
gpointer type_args);
|
||||
|
||||
char *nm_uuid_generate_from_string_str(const char *s,
|
||||
gssize slen,
|
||||
NMUuidType uuid_type,
|
||||
gpointer type_args);
|
||||
|
||||
/* arbitrarily chosen namespace UUID for nm_uuid_generate_from_strings() */
|
||||
#define NM_UUID_NS1 "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
|
||||
|
||||
char *nm_uuid_generate_from_strings(const char *string1, ...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* __NM_UUID_H__ */
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/if_ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-log-core/nm-logging.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "nm-initrd-generator.h"
|
||||
|
@ -141,7 +142,7 @@ reader_create_connection(Reader * reader,
|
|||
NM_SETTING_CONNECTION_ID,
|
||||
id,
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_utils_uuid_generate_a(),
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME,
|
||||
ifname,
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <unistd.h>
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-log-core/nm-logging.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "libnm-platform/nm-platform-utils.h"
|
||||
|
@ -304,13 +305,13 @@ connection_setting_add(GHashTable * nic,
|
|||
s_index ? " " : "",
|
||||
s_index ? s_index : "");
|
||||
|
||||
uuid = _nm_utils_uuid_generate_from_strings("ibft",
|
||||
s_hwaddr,
|
||||
s_vlanid ? "V" : "v",
|
||||
s_vlanid ? s_vlanid : "",
|
||||
s_ipaddr ? "A" : "DHCP",
|
||||
s_ipaddr ? s_ipaddr : "",
|
||||
NULL);
|
||||
uuid = nm_uuid_generate_from_strings("ibft",
|
||||
s_hwaddr,
|
||||
s_vlanid ? "V" : "v",
|
||||
s_vlanid ? s_vlanid : "",
|
||||
s_ipaddr ? "A" : "DHCP",
|
||||
s_ipaddr ? s_ipaddr : "",
|
||||
NULL);
|
||||
|
||||
s_con = (NMSetting *) nm_connection_get_setting_connection(connection);
|
||||
if (!s_con) {
|
||||
|
|
Loading…
Reference in a new issue