mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-04 15:21:12 +00:00
device: allow modifying Managed property
https://bugzilla.redhat.com/show_bug.cgi?id=1114685 https://bugzilla.gnome.org/show_bug.cgi?id=746566 Related: https://bugzilla.gnome.org/show_bug.cgi?id=680909 Related: https://bugzilla.gnome.org/show_bug.cgi?id=731014 Based-on-patch-by: Lubomir Rintel <lkundrak@v3.sk>
This commit is contained in:
parent
69315953eb
commit
0eebf580c1
|
@ -96,9 +96,13 @@
|
|||
NM_DEVICE_STATE_ACTIVATED state.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
<property name="Managed" type="b" access="read">
|
||||
<property name="Managed" type="b" access="readwrite">
|
||||
<tp:docstring>
|
||||
Whether or not this device is managed by NetworkManager.
|
||||
Whether or not this device is managed by NetworkManager. Setting this
|
||||
property has a similar effect to configuring the device as unmanaged
|
||||
via the keyfile.unmanaged-devices setting in NetworkManager.conf.
|
||||
Changes to this value are not persistent and lost after NetworkManager
|
||||
restart.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
<property name="Autoconnect" type="b" access="readwrite">
|
||||
|
|
|
@ -215,6 +215,7 @@ typedef struct {
|
|||
char * physical_port_id;
|
||||
guint dev_id;
|
||||
|
||||
gboolean managed_touched_by_user;
|
||||
NMUnmanagedFlags unmanaged_flags;
|
||||
gboolean is_nm_owned; /* whether the device is a device owned and created by NM */
|
||||
DeleteOnDeactivateData *delete_on_deactivate_data; /* data for scheduled cleanup when deleting link (g_idle_add) */
|
||||
|
@ -7768,6 +7769,9 @@ nm_device_set_unmanaged_by_device_spec (NMDevice *self, const GSList *unmanaged_
|
|||
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
if (priv->managed_touched_by_user)
|
||||
return;
|
||||
|
||||
unmanaged = nm_device_spec_match_list (self, unmanaged_specs);
|
||||
nm_device_set_unmanaged (self,
|
||||
NM_UNMANAGED_USER,
|
||||
|
@ -9362,6 +9366,7 @@ set_property (GObject *object, guint prop_id,
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
const char *hw_addr, *p;
|
||||
guint count;
|
||||
gboolean val_bool;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_UDI:
|
||||
|
@ -9399,6 +9404,14 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_IP4_ADDRESS:
|
||||
priv->ip4_address = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MANAGED:
|
||||
val_bool = g_value_get_boolean (value);
|
||||
priv->managed_touched_by_user = TRUE;
|
||||
nm_device_set_unmanaged (self,
|
||||
NM_UNMANAGED_USER | (val_bool ? NM_UNMANAGED_DEFAULT : NM_UNMANAGED_NONE),
|
||||
!val_bool,
|
||||
NM_DEVICE_STATE_REASON_USER_REQUESTED);
|
||||
break;
|
||||
case PROP_AUTOCONNECT:
|
||||
nm_device_set_autoconnect (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
@ -9750,7 +9763,7 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
(object_class, PROP_MANAGED,
|
||||
g_param_spec_boolean (NM_DEVICE_MANAGED, "", "",
|
||||
FALSE,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
|
|
|
@ -60,6 +60,7 @@ typedef struct {
|
|||
#define NM_AUDIT_OP_DEVICE_AUTOCONNECT "device-autoconnect"
|
||||
#define NM_AUDIT_OP_DEVICE_DISCONNECT "device-disconnect"
|
||||
#define NM_AUDIT_OP_DEVICE_DELETE "device-delete"
|
||||
#define NM_AUDIT_OP_DEVICE_MANAGED "device-managed"
|
||||
|
||||
GType nm_audit_manager_get_type (void);
|
||||
NMAuditManager *nm_audit_manager_get (void);
|
||||
|
|
|
@ -4578,6 +4578,10 @@ prop_filter (GDBusConnection *connection,
|
|||
glib_propname = NM_DEVICE_AUTOCONNECT;
|
||||
permission = NM_AUTH_PERMISSION_NETWORK_CONTROL;
|
||||
audit_op = NM_AUDIT_OP_DEVICE_AUTOCONNECT;
|
||||
} else if (!strcmp (propname, "Managed")) {
|
||||
glib_propname = NM_DEVICE_MANAGED;
|
||||
permission = NM_AUTH_PERMISSION_NETWORK_CONTROL;
|
||||
audit_op = NM_AUDIT_OP_DEVICE_MANAGED;
|
||||
} else
|
||||
return message;
|
||||
interface_type = NMDBUS_TYPE_DEVICE_SKELETON;
|
||||
|
|
Loading…
Reference in a new issue