mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 07:20:11 +01:00
cli: check IP configuration when setting connection.master in editor
If IPv4 and/or IPv6 are present on setting connection.master, offer their removal.
This commit is contained in:
parent
afde052445
commit
d31c456033
3 changed files with 43 additions and 1 deletions
|
|
@ -7688,6 +7688,8 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection)
|
|||
|
||||
/* Initialize new connection according to its type using sensible defaults. */
|
||||
|
||||
nmc_setting_connection_connect_handlers (s_con, connection);
|
||||
|
||||
if (g_strcmp0 (con_type, "bond-slave") == 0)
|
||||
slave_type = NM_SETTING_BOND_SETTING_NAME;
|
||||
if (g_strcmp0 (con_type, "team-slave") == 0)
|
||||
|
|
@ -7790,10 +7792,12 @@ editor_init_existing_connection (NMConnection *connection)
|
|||
NMSettingIP4Config *s_ip4;
|
||||
NMSettingIP6Config *s_ip6;
|
||||
NMSettingWireless *s_wireless;
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
s_wireless = nm_connection_get_setting_wireless (connection);
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
|
||||
if (s_ip4)
|
||||
nmc_setting_ip4_connect_handlers (s_ip4);
|
||||
|
|
@ -7801,6 +7805,8 @@ editor_init_existing_connection (NMConnection *connection)
|
|||
nmc_setting_ip6_connect_handlers (s_ip6);
|
||||
if (s_wireless)
|
||||
nmc_setting_wireless_connect_handlers (s_wireless);
|
||||
if (s_con)
|
||||
nmc_setting_connection_connect_handlers (s_con, connection);
|
||||
}
|
||||
|
||||
static NMCResultCode
|
||||
|
|
|
|||
|
|
@ -1848,6 +1848,32 @@ wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer u
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_master_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NMSettingConnection *s_con = NM_SETTING_CONNECTION (object);
|
||||
NMConnection *connection = NM_CONNECTION (user_data);
|
||||
NMSetting *s_ipv4, *s_ipv6;
|
||||
const char *value, *tmp_str;
|
||||
|
||||
value = nm_setting_connection_get_master (s_con);
|
||||
if (value) {
|
||||
s_ipv4 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
s_ipv6 = nm_connection_get_setting_by_name (connection, NM_SETTING_IP6_CONFIG_SETTING_NAME);
|
||||
if (s_ipv4 || s_ipv6) {
|
||||
g_print (_("Warning: setting %s.%s requires removing ipv4 and ipv6 settings\n"),
|
||||
nm_setting_get_name (NM_SETTING (s_con)), g_param_spec_get_name (pspec));
|
||||
tmp_str = nmc_get_user_input (_("Do you want to remove them? [yes] "));
|
||||
if (!tmp_str || matches (tmp_str, "yes") == 0) {
|
||||
if (s_ipv4)
|
||||
nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv4));
|
||||
if (s_ipv6)
|
||||
nm_connection_remove_setting (connection, G_OBJECT_TYPE (s_ipv6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nmc_setting_ip4_connect_handlers (NMSettingIP4Config *setting)
|
||||
{
|
||||
|
|
@ -1881,6 +1907,15 @@ nmc_setting_wireless_connect_handlers (NMSettingWireless *setting)
|
|||
G_CALLBACK (wireless_band_channel_changed_cb), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
|
||||
|
||||
g_signal_connect (setting, "notify::" NM_SETTING_CONNECTION_MASTER,
|
||||
G_CALLBACK (connection_master_changed_cb), connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Customize some properties of the setting so that the setting has sensible
|
||||
* values.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2010 - 2013 Red Hat, Inc.
|
||||
* Copyright 2010 - 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NMC_SETTINGS_H
|
||||
|
|
@ -33,6 +33,7 @@ void nmc_setting_custom_init (NMSetting *setting);
|
|||
void nmc_setting_ip4_connect_handlers (NMSettingIP4Config *setting);
|
||||
void nmc_setting_ip6_connect_handlers (NMSettingIP6Config *setting);
|
||||
void nmc_setting_wireless_connect_handlers (NMSettingWireless *setting);
|
||||
void nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection);
|
||||
|
||||
char **nmc_setting_get_valid_properties (NMSetting *setting);
|
||||
char *nmc_setting_get_property_desc (NMSetting *setting, const char *prop);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue