From 73cfc4097a82db44a06d0d0251412f99c13adc1b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 2 May 2021 14:55:46 +0200 Subject: [PATCH] libnm,glib-aux: add and use nm_uuid_generate_random_str*() helpers --- src/core/NetworkManagerUtils.c | 2 +- src/core/devices/bluetooth/nm-bluez-manager.c | 2 +- src/core/devices/nm-device.c | 2 +- src/core/devices/wifi/nm-iwd-manager.c | 2 +- .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 116 +++++++++--------- src/libnm-core-impl/nm-connection.c | 2 +- src/libnm-core-impl/nm-utils.c | 19 +-- src/libnm-core-impl/tests/test-setting.c | 2 +- src/libnm-core-intern/nm-core-internal.h | 8 -- src/libnm-glib-aux/nm-uuid.c | 11 ++ src/libnm-glib-aux/nm-uuid.h | 16 +++ src/nm-initrd-generator/nmi-cmdline-reader.c | 2 +- 12 files changed, 93 insertions(+), 91 deletions(-) diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c index 481672968b..700acf37d9 100644 --- a/src/core/NetworkManagerUtils.c +++ b/src/core/NetworkManagerUtils.c @@ -254,7 +254,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); } diff --git a/src/core/devices/bluetooth/nm-bluez-manager.c b/src/core/devices/bluetooth/nm-bluez-manager.c index a16a22a096..123591e1a1 100644 --- a/src/core/devices/bluetooth/nm-bluez-manager.c +++ b/src/core/devices/bluetooth/nm-bluez-manager.c @@ -1321,7 +1321,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(); diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index d91b27ec91..b8819a4bbd 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -7238,7 +7238,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, diff --git a/src/core/devices/wifi/nm-iwd-manager.c b/src/core/devices/wifi/nm-iwd-manager.c index c7ba20eaa6..9ede0311c0 100644 --- a/src/core/devices/wifi/nm-iwd-manager.c +++ b/src/core/devices/wifi/nm-iwd-manager.c @@ -774,7 +774,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); diff --git a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 797c31649b..e0a265bed9 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -2519,7 +2519,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 +3977,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 +4062,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 +4122,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 +4305,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 +4363,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 +4676,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 +4831,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 +4999,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 +5111,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 +5169,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 +5315,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 +5432,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 +5587,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 +5711,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 +5813,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 +5983,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 +6110,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 +6187,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 +6273,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 +6347,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 +6445,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 +6539,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 +6634,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 +6732,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 +6833,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 +6931,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 +7037,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 +7142,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 +7252,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 +7379,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 +7515,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 +7630,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 +7747,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 +7872,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 +7969,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 +8043,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 +8118,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 +8187,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 +8273,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 +8334,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 +8392,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 +8510,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 +8639,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 +9023,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 +9078,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 +9202,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 +9302,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 +9389,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 +9478,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 +9636,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 +9882,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 +10000,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 +10092,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 +10151,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 +10341,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 +11031,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 +11166,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, diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index e9880ef49b..960a34fcc0 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -710,7 +710,7 @@ _normalize_connection_uuid(NMConnection *self) if (nm_setting_connection_get_uuid(s_con)) return FALSE; - g_object_set(s_con, NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_buf(uuid), NULL); + g_object_set(s_con, NM_SETTING_CONNECTION_UUID, nm_uuid_generate_random_str_arr(uuid), NULL); return TRUE; } diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index 75e06e9127..5bb43c8d00 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -3043,23 +3043,6 @@ _nm_utils_sriov_vf_from_strparts(const char *index, /*****************************************************************************/ -/** - * 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_uuid_generate_random(&uuid); - return nm_uuid_unparse(&uuid, buf); -} - /** * nm_utils_uuid_generate: * @@ -3069,7 +3052,7 @@ nm_utils_uuid_generate_buf_(char *buf) char * nm_utils_uuid_generate(void) { - return nm_utils_uuid_generate_buf_(g_malloc(37)); + return nm_uuid_generate_random_str_malloc(); } /** diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index 4516c472dc..b64bf79612 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -2219,7 +2219,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, diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index db10c572a4..f4edcedefb 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -370,14 +370,6 @@ nm_utils_uuid_generate_from_string(const char *s, gssize slen, int uuid_type, gp 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; diff --git a/src/libnm-glib-aux/nm-uuid.c b/src/libnm-glib-aux/nm-uuid.c index 3d94c4e337..d4ccca52a6 100644 --- a/src/libnm-glib-aux/nm-uuid.c +++ b/src/libnm-glib-aux/nm-uuid.c @@ -142,3 +142,14 @@ nm_uuid_is_null(const NMUuid *uuid) } 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); +} diff --git a/src/libnm-glib-aux/nm-uuid.h b/src/libnm-glib-aux/nm-uuid.h index 5b3a1a44e5..a4be9536c3 100644 --- a/src/libnm-glib-aux/nm-uuid.h +++ b/src/libnm-glib-aux/nm-uuid.h @@ -31,4 +31,20 @@ NMUuid *nm_uuid_generate_random(NMUuid *out_uuid); gboolean nm_uuid_is_null(const NMUuid *uuid); +/*****************************************************************************/ + +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))) + +/*****************************************************************************/ + #endif /* __NM_UUID_H__ */ diff --git a/src/nm-initrd-generator/nmi-cmdline-reader.c b/src/nm-initrd-generator/nmi-cmdline-reader.c index 2353e2ea0e..eaaed73143 100644 --- a/src/nm-initrd-generator/nmi-cmdline-reader.c +++ b/src/nm-initrd-generator/nmi-cmdline-reader.c @@ -141,7 +141,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,