summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-09-18 13:19:53 +0200
committerThomas Haller <thaller@redhat.com>2015-09-18 13:19:53 +0200
commit3a680392323f314f368807ff279618e69ac49623 (patch)
tree17e3dcfa1aca055ccc7846d6efca866fe3894e06
parent69315953eb366706a6ebf1e8af14d486f7a94149 (diff)
parentaeaf31b7a803de528019dc551e6d7513432eb937 (diff)
downloadNetworkManager-3a680392323f314f368807ff279618e69ac49623.tar.gz
all: merge branch 'lr/default-unmanaged-bgo746566'
Make the "managed" property of devices mutable via D-Bus. Also, add a `nmcli device set` command. https://bugzilla.gnome.org/show_bug.cgi?id=746566
-rw-r--r--clients/cli/devices.c139
-rw-r--r--clients/cli/nmcli-completion15
-rw-r--r--introspection/nm-device.xml8
-rw-r--r--libnm-glib/libnm-glib.ver1
-rw-r--r--libnm-glib/nm-device.c34
-rw-r--r--libnm-glib/nm-device.h2
-rw-r--r--libnm/libnm.ver1
-rw-r--r--libnm/nm-device.c29
-rw-r--r--libnm/nm-device.h2
-rw-r--r--man/nmcli.1.in7
-rw-r--r--src/devices/nm-device-generic.c2
-rw-r--r--src/devices/nm-device.c41
-rw-r--r--src/devices/nm-device.h8
-rw-r--r--src/nm-audit-manager.h1
-rw-r--r--src/nm-manager.c12
15 files changed, 275 insertions, 27 deletions
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index 81609d1c9d..b8b4a23fdf 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -259,6 +259,7 @@ usage (void)
"COMMAND := { status | show | connect | disconnect | delete | wifi }\n\n"
" status\n\n"
" show [<ifname>]\n\n"
+ " set [ifname] <ifname> [autoconnect yes|no] [managed yes|no]\n\n"
" connect <ifname>\n\n"
" disconnect <ifname> ...\n\n"
" delete <ifname> ...\n\n"
@@ -333,6 +334,19 @@ usage_device_delete (void)
}
static void
+usage_device_set (void)
+{
+ g_printerr (_("Usage: nmcli device set { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := DEVICE { PROPERTY [ PROPERTY ... ] }\n"
+ "DEVICE := [ifname] <ifname> \n"
+ "PROPERTY := { autoconnect { yes | no } |\n"
+ " { managed { yes | no }\n"
+ "\n"
+ "Modify device properties.\n\n"));
+}
+
+static void
usage_device_wifi (void)
{
g_printerr (_("Usage: nmcli device wifi { ARGUMENTS | help }\n"
@@ -1895,6 +1909,124 @@ error:
return nmc->return_value;
}
+static NMCResultCode
+do_device_set (NmCli *nmc, int argc, char **argv)
+{
+#define DEV_SET_AUTOCONNECT 0
+#define DEV_SET_MANAGED 1
+ NMDevice **devices;
+ NMDevice *device = NULL;
+ const char *ifname = NULL;
+ int i;
+ struct {
+ int idx;
+ gboolean value;
+ } values[2] = {
+ [DEV_SET_AUTOCONNECT] = { -1 },
+ [DEV_SET_MANAGED] = { -1 },
+ };
+
+ if (argc >= 1 && g_strcmp0 (*argv, "ifname") == 0) {
+ argc--;
+ argv++;
+ }
+
+ if (argc == 0) {
+ g_string_printf (nmc->return_text, _("Error: No interface specified."));
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ } else
+ ifname = *argv;
+
+ if (!ifname) {
+ g_string_printf (nmc->return_text, _("Error: No interface specified."));
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ }
+
+ devices = get_devices_sorted (nmc->client);
+ for (i = 0; devices[i]; i++) {
+ NMDevice *candidate = devices[i];
+ const char *dev_iface = nm_device_get_iface (candidate);
+
+ if (!g_strcmp0 (dev_iface, ifname))
+ device = candidate;
+ }
+ g_free (devices);
+
+ if (!device) {
+ g_string_printf (nmc->return_text, _("Error: Device '%s' not found."), ifname);
+ nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND;
+ goto error;
+ }
+
+ if (argc == 1) {
+ g_string_printf (nmc->return_text, _("Error: No property specified."));
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ }
+
+ i = 0;
+ while (next_arg (&argc, &argv) == 0) {
+ gboolean flag;
+ gs_free_error GError *tmp_err = NULL;
+
+ if (matches (*argv, "managed") == 0) {
+ if (next_arg (&argc, &argv) != 0) {
+ g_string_printf (nmc->return_text, _("Error: Agrument missing."));
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ }
+ if (!nmc_string_to_bool (*argv, &flag, &tmp_err)) {
+ g_string_printf (nmc->return_text, _("Error: 'managed': %s."),
+ tmp_err->message);
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ }
+ values[DEV_SET_MANAGED].idx = ++i;
+ values[DEV_SET_MANAGED].value = flag;
+ }
+ else if (matches (*argv, "autoconnect") == 0) {
+ if (next_arg (&argc, &argv) != 0) {
+ g_string_printf (nmc->return_text, _("Error: Agrument missing."));
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ }
+ if (!nmc_string_to_bool (*argv, &flag, &tmp_err)) {
+ g_string_printf (nmc->return_text, _("Error: 'autoconnect': %s."),
+ tmp_err->message);
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ }
+ values[DEV_SET_AUTOCONNECT].idx = ++i;
+ values[DEV_SET_AUTOCONNECT].value = flag;
+ }
+ else {
+ usage_device_set ();
+ g_string_printf (nmc->return_text, _("Error: property '%s' is not known."), *argv);
+ nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ goto error;
+ }
+ }
+
+ /* when multiple properties are specified, set them in the order as they
+ * are specified on the command line. */
+ if ( values[DEV_SET_AUTOCONNECT].idx >= 0
+ && values[DEV_SET_MANAGED].idx >= 0
+ && values[DEV_SET_MANAGED].idx < values[DEV_SET_AUTOCONNECT].idx) {
+ nm_device_set_managed (device, values[DEV_SET_MANAGED].value);
+ values[DEV_SET_MANAGED].idx = -1;
+ }
+ if (values[DEV_SET_AUTOCONNECT].idx >= 0)
+ nm_device_set_autoconnect (device, values[DEV_SET_AUTOCONNECT].value);
+ if (values[DEV_SET_MANAGED].idx >= 0)
+ nm_device_set_autoconnect (device, values[DEV_SET_MANAGED].value);
+
+error:
+ quit ();
+ return nmc->return_value;
+}
+
static void
show_access_point_info (NMDevice *device, NmCli *nmc)
{
@@ -2813,6 +2945,13 @@ do_devices (NmCli *nmc, int argc, char **argv)
}
nmc->return_value = do_device_delete (nmc, argc-1, argv+1);
}
+ else if (matches (*argv, "set") == 0) {
+ if (nmc_arg_is_help (*(argv+1))) {
+ usage_device_set ();
+ goto usage_exit;
+ }
+ nmc->return_value = do_device_set (nmc, argc-1, argv+1);
+ }
else if (matches (*argv, "wifi") == 0) {
if (nmc_arg_is_help (*(argv+1))) {
usage_device_wifi ();
diff --git a/clients/cli/nmcli-completion b/clients/cli/nmcli-completion
index b58efde36d..909c00e299 100644
--- a/clients/cli/nmcli-completion
+++ b/clients/cli/nmcli-completion
@@ -491,6 +491,7 @@ _nmcli_compl_ARGS()
return 0
fi
;;
+ managed| \
autoconnect| \
stp| \
hairpin| \
@@ -595,6 +596,7 @@ _nmcli_compl_ARGS()
# some commands expect a connection as parameter. This connection can either be given
# as id|uuid|path|apath. Parse that connection parameter.
+# Actually, it can also ask for a device name, like `nmcli device set [ifname] <ifname>`
_nmcli_compl_ARGS_CONNECTION()
{
if ! _nmcli_array_has_value OPTIONS "${words[0]}"; then
@@ -1251,7 +1253,7 @@ _nmcli()
;;
d|de|dev|devi|devic|device)
if [[ ${#words[@]} -eq 2 ]]; then
- _nmcli_compl_COMMAND "$command" status show connect disconnect delete wifi
+ _nmcli_compl_COMMAND "$command" status show connect disconnect delete wifi set
elif [[ ${#words[@]} -gt 2 ]]; then
case "$command" in
s|st|sta|stat|statu|status)
@@ -1271,6 +1273,17 @@ _nmcli()
_nmcli_compl_COMMAND_nl "${words[2]}" "$(_nmcli_dev_status DEVICE)"
fi
;;
+ se|set)
+ if [[ ${#words[@]} -eq 3 ]]; then
+ _nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "ifname\n%s" "$(_nmcli_con_show NAME)")"
+ else
+ _nmcli_array_delete_at words 0 1
+ OPTIONS=(ifname)
+ _nmcli_compl_ARGS_CONNECTION && return 0
+ OPTIONS=(autoconnect managed)
+ _nmcli_compl_ARGS
+ fi
+ ;;
w|wi|wif|wifi)
if [[ ${#words[@]} -eq 3 ]]; then
_nmcli_compl_COMMAND "${words[2]}" list connect rescan
diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml
index ba1a8fa69b..909254002f 100644
--- a/introspection/nm-device.xml
+++ b/introspection/nm-device.xml
@@ -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">
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index dc982e566b..fc0c0b95c2 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -173,6 +173,7 @@ global:
nm_device_olpc_mesh_get_type;
nm_device_olpc_mesh_new;
nm_device_set_autoconnect;
+ nm_device_set_managed;
nm_device_team_error_get_type;
nm_device_team_error_quark;
nm_device_team_get_carrier;
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
index ccb1c1f2cb..460f079409 100644
--- a/libnm-glib/nm-device.c
+++ b/libnm-glib/nm-device.c
@@ -515,6 +515,11 @@ set_property (GObject *object,
/* Construct only */
priv->device_type = g_value_get_uint (value);
break;
+ case PROP_MANAGED:
+ b = g_value_get_boolean (value);
+ if (priv->managed != b)
+ nm_device_set_managed (NM_DEVICE (object), b);
+ break;
case PROP_AUTOCONNECT:
b = g_value_get_boolean (value);
if (priv->autoconnect != b)
@@ -1214,6 +1219,35 @@ nm_device_get_managed (NMDevice *device)
}
/**
+ * nm_device_set_managed:
+ * @device: a #NMDevice
+ * @managed: %TRUE to make the device managed by NetworkManager.
+ *
+ * Enables or disables management of #NMDevice by NetworkManager.
+ *
+ * Since: 1.2
+ **/
+void
+nm_device_set_managed (NMDevice *device, gboolean managed)
+{
+ GValue value = G_VALUE_INIT;
+
+ g_return_if_fail (NM_IS_DEVICE (device));
+
+ managed = !!managed;
+
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, managed);
+
+ NM_DEVICE_GET_PRIVATE (device)->managed = managed;
+
+ _nm_object_set_property (NM_OBJECT (device),
+ NM_DBUS_INTERFACE_DEVICE,
+ "Managed",
+ &value);
+}
+
+/**
* nm_device_get_autoconnect:
* @device: a #NMDevice
*
diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h
index 707fddf82a..3d0abde1ca 100644
--- a/libnm-glib/nm-device.h
+++ b/libnm-glib/nm-device.h
@@ -127,6 +127,8 @@ NM_AVAILABLE_IN_0_9_10
const char * nm_device_get_hw_address (NMDevice *device);
NMDeviceCapabilities nm_device_get_capabilities (NMDevice *device);
gboolean nm_device_get_managed (NMDevice *device);
+NM_AVAILABLE_IN_1_2
+void nm_device_set_managed (NMDevice *device, gboolean managed);
gboolean nm_device_get_autoconnect (NMDevice *device);
void nm_device_set_autoconnect (NMDevice *device, gboolean autoconnect);
gboolean nm_device_get_firmware_missing (NMDevice *device);
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index d87664ed1b..efe182daeb 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -860,6 +860,7 @@ global:
nm_access_point_get_last_seen;
nm_device_get_metered;
nm_device_get_nm_plugin_missing;
+ nm_device_set_managed;
nm_device_wifi_request_scan_options;
nm_device_wifi_request_scan_options_async;
nm_metered_get_type;
diff --git a/libnm/nm-device.c b/libnm/nm-device.c
index a792d0954a..725762de61 100644
--- a/libnm/nm-device.c
+++ b/libnm/nm-device.c
@@ -482,6 +482,11 @@ set_property (GObject *object,
/* Construct only */
priv->device_type = g_value_get_enum (value);
break;
+ case PROP_MANAGED:
+ b = g_value_get_boolean (value);
+ if (priv->managed != b)
+ nm_device_set_managed (NM_DEVICE (object), b);
+ break;
case PROP_AUTOCONNECT:
b = g_value_get_boolean (value);
if (priv->autoconnect != b)
@@ -1095,6 +1100,30 @@ nm_device_get_managed (NMDevice *device)
}
/**
+ * nm_device_set_managed:
+ * @device: a #NMDevice
+ * @managed: %TRUE to make the device managed by NetworkManager.
+ *
+ * Enables or disables management of #NMDevice by NetworkManager.
+ *
+ * Since: 1.2
+ **/
+void
+nm_device_set_managed (NMDevice *device, gboolean managed)
+{
+ g_return_if_fail (NM_IS_DEVICE (device));
+
+ managed = !!managed;
+
+ NM_DEVICE_GET_PRIVATE (device)->managed = managed;
+
+ _nm_object_set_property (NM_OBJECT (device),
+ NM_DBUS_INTERFACE_DEVICE,
+ "Managed",
+ "b", managed);
+}
+
+/**
* nm_device_get_autoconnect:
* @device: a #NMDevice
*
diff --git a/libnm/nm-device.h b/libnm/nm-device.h
index 66e1d5780c..4453bfeb2c 100644
--- a/libnm/nm-device.h
+++ b/libnm/nm-device.h
@@ -103,6 +103,8 @@ const char * nm_device_get_type_description (NMDevice *device);
const char * nm_device_get_hw_address (NMDevice *device);
NMDeviceCapabilities nm_device_get_capabilities (NMDevice *device);
gboolean nm_device_get_managed (NMDevice *device);
+NM_AVAILABLE_IN_1_2
+void nm_device_set_managed (NMDevice *device, gboolean managed);
gboolean nm_device_get_autoconnect (NMDevice *device);
void nm_device_set_autoconnect (NMDevice *device, gboolean autoconnect);
gboolean nm_device_get_firmware_missing (NMDevice *device);
diff --git a/man/nmcli.1.in b/man/nmcli.1.in
index 57848c1f07..15781c4964 100644
--- a/man/nmcli.1.in
+++ b/man/nmcli.1.in
@@ -757,7 +757,7 @@ of its latest state.
.B device - show and manage network interfaces
.br
.TP
-.SS \fICOMMAND\fP := { status | show | connect | disconnect | delete | wifi }
+.SS \fICOMMAND\fP := { status | show | set | connect | disconnect | delete | wifi }
.sp
.RS
.TP
@@ -773,6 +773,11 @@ Show detailed information about devices. Without an argument, all devices are
examined. To get information for a specific device, the interface name has
to be provided.
.TP
+.TP
+.B set [ifname] <ifname> [autoconnect yes|no] [managed yes|no]
+.br
+Set device properties.
+.TP
.B connect <ifname>
.br
Connect the device. NetworkManager will try to find a suitable connection that
diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c
index 168301ba02..37eae35bdc 100644
--- a/src/devices/nm-device-generic.c
+++ b/src/devices/nm-device-generic.c
@@ -138,7 +138,7 @@ constructor (GType type,
n_construct_params,
construct_params);
- nm_device_set_initial_unmanaged_flag (NM_DEVICE (object), NM_UNMANAGED_DEFAULT, TRUE);
+ nm_device_set_unmanaged_initial (NM_DEVICE (object), NM_UNMANAGED_DEFAULT, TRUE);
return object;
}
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 83e7c4cbf8..4226725059 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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) */
@@ -1117,7 +1118,7 @@ nm_device_finish_init (NMDevice *self)
if ( NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self)
&& !nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex)
&& priv->ifindex > 0)
- nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN, TRUE);
+ nm_device_set_unmanaged_initial (self, NM_UNMANAGED_EXTERNAL_DOWN, TRUE);
if (priv->master)
nm_device_enslave_slave (priv->master, self, NULL);
@@ -1127,19 +1128,19 @@ nm_device_finish_init (NMDevice *self)
/* Unmanaged the loopback device with an explicit NM_UNMANAGED_LOOPBACK flag.
* Later we might want to manage 'lo' too. Currently that doesn't work because
* NetworkManager might down the interface or remove the 127.0.0.1 address. */
- nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_LOOPBACK, TRUE);
+ nm_device_set_unmanaged_initial (self, NM_UNMANAGED_LOOPBACK, TRUE);
} else if (priv->platform_link_initialized || (priv->is_nm_owned && nm_device_is_software (self))) {
gboolean platform_unmanaged = FALSE;
if (nm_platform_link_get_unmanaged (NM_PLATFORM_GET, priv->ifindex, &platform_unmanaged))
- nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_DEFAULT, platform_unmanaged);
+ nm_device_set_unmanaged_initial (self, NM_UNMANAGED_DEFAULT, platform_unmanaged);
} else {
/* Hardware and externally-created software links stay unmanaged
* until they are fully initialized by the platform. NM created
* links must be available for activation immediately and thus
* do not get the PLATFORM_INIT unmanaged flag set.
*/
- nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_PLATFORM_INIT, TRUE);
+ nm_device_set_unmanaged_initial (self, NM_UNMANAGED_PLATFORM_INIT, TRUE);
}
}
@@ -1426,7 +1427,7 @@ device_link_changed (NMDevice *self)
/* Manage externally-created software interfaces only when they are IFF_UP */
g_assert (priv->ifindex > 0);
if (NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self)) {
- gboolean external_down = nm_device_get_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN);
+ gboolean external_down = nm_device_get_unmanaged (self, NM_UNMANAGED_EXTERNAL_DOWN);
if (external_down && NM_FLAGS_HAS (info.flags, IFF_UP)) {
if (nm_device_get_state (self) < NM_DEVICE_STATE_DISCONNECTED) {
@@ -7677,13 +7678,13 @@ nm_device_get_managed (NMDevice *self)
}
/**
- * nm_device_get_unmanaged_flag():
+ * nm_device_get_unmanaged():
* @self: the #NMDevice
*
* Returns: %TRUE if the device is unmanaged for @flag.
*/
gboolean
-nm_device_get_unmanaged_flag (NMDevice *self, NMUnmanagedFlags flag)
+nm_device_get_unmanaged (NMDevice *self, NMUnmanagedFlags flag)
{
return NM_FLAGS_ANY (NM_DEVICE_GET_PRIVATE (self)->unmanaged_flags, flag);
}
@@ -7697,7 +7698,7 @@ nm_device_get_unmanaged_flag (NMDevice *self, NMUnmanagedFlags flag)
static gboolean
nm_device_get_default_unmanaged (NMDevice *self)
{
- return nm_device_get_unmanaged_flag (self, NM_UNMANAGED_DEFAULT);
+ return nm_device_get_unmanaged (self, NM_UNMANAGED_DEFAULT);
}
static void
@@ -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,
@@ -7793,7 +7797,7 @@ nm_device_set_unmanaged_quitting (NMDevice *self)
}
/**
- * nm_device_set_initial_unmanaged_flag():
+ * nm_device_set_unmanaged_initial():
* @self: the #NMDevice
* @flag: an #NMUnmanagedFlag
* @unmanaged: %TRUE or %FALSE to set or clear @flag
@@ -7803,9 +7807,9 @@ nm_device_set_unmanaged_quitting (NMDevice *self)
* Should only be used when initializing a device.
*/
void
-nm_device_set_initial_unmanaged_flag (NMDevice *self,
- NMUnmanagedFlags flag,
- gboolean unmanaged)
+nm_device_set_unmanaged_initial (NMDevice *self,
+ NMUnmanagedFlags flag,
+ gboolean unmanaged)
{
NMDevicePrivate *priv;
@@ -7920,7 +7924,7 @@ nm_device_check_connection_available (NMDevice *self,
if (state < NM_DEVICE_STATE_UNMANAGED)
return FALSE;
if ( state < NM_DEVICE_STATE_UNAVAILABLE
- && nm_device_get_unmanaged_flag (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT))
+ && nm_device_get_unmanaged (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT))
return FALSE;
if ( state < NM_DEVICE_STATE_DISCONNECTED
&& ( ( !NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER)
@@ -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
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 50ac8b0d38..f70dca2049 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -431,16 +431,16 @@ typedef enum {
} NMUnmanagedFlags;
gboolean nm_device_get_managed (NMDevice *device);
-gboolean nm_device_get_unmanaged_flag (NMDevice *device, NMUnmanagedFlags flag);
+gboolean nm_device_get_unmanaged (NMDevice *device, NMUnmanagedFlags flag);
void nm_device_set_unmanaged (NMDevice *device,
NMUnmanagedFlags flag,
gboolean unmanaged,
NMDeviceStateReason reason);
void nm_device_set_unmanaged_by_device_spec (NMDevice *self, const GSList *unmanaged_specs);
void nm_device_set_unmanaged_quitting (NMDevice *device);
-void nm_device_set_initial_unmanaged_flag (NMDevice *device,
- NMUnmanagedFlags flag,
- gboolean unmanaged);
+void nm_device_set_unmanaged_initial (NMDevice *device,
+ NMUnmanagedFlags flag,
+ gboolean unmanaged);
gboolean nm_device_get_is_nm_owned (NMDevice *device);
void nm_device_set_nm_owned (NMDevice *device);
diff --git a/src/nm-audit-manager.h b/src/nm-audit-manager.h
index 83d969c864..0a74dc063c 100644
--- a/src/nm-audit-manager.h
+++ b/src/nm-audit-manager.h
@@ -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);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 0e13f3b1e3..b56345eb63 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1584,7 +1584,7 @@ recheck_assume_connection (NMDevice *device, gpointer user_data)
if (manager_sleeping (self))
return FALSE;
- if (nm_device_get_unmanaged_flag (device, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT))
+ if (nm_device_get_unmanaged (device, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT))
return FALSE;
state = nm_device_get_state (device);
@@ -1613,7 +1613,7 @@ recheck_assume_connection (NMDevice *device, gpointer user_data)
NM_DEVICE_STATE_REASON_CONFIG_FAILED);
/* Return default-unmanaged devices to their original state */
- if (nm_device_get_unmanaged_flag (device, NM_UNMANAGED_DEFAULT)) {
+ if (nm_device_get_unmanaged (device, NM_UNMANAGED_DEFAULT)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_UNMANAGED,
NM_DEVICE_STATE_REASON_CONFIG_FAILED);
@@ -1769,10 +1769,10 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume)
unmanaged_specs = nm_settings_get_unmanaged_specs (priv->settings);
user_unmanaged = nm_device_spec_match_list (device, unmanaged_specs);
- nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_USER, user_unmanaged);
+ nm_device_set_unmanaged_initial (device, NM_UNMANAGED_USER, user_unmanaged);
sleeping = manager_sleeping (self);
- nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_INTERNAL, sleeping);
+ nm_device_set_unmanaged_initial (device, NM_UNMANAGED_INTERNAL, sleeping);
dbus_path = nm_exported_object_export (NM_EXPORTED_OBJECT (device));
nm_log_dbg (LOGD_DEVICE, "(%s): exported as %s", nm_device_get_iface (device), dbus_path);
@@ -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;