mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-09 06:10:29 +01:00
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
This commit is contained in:
commit
3a68039232
15 changed files with 275 additions and 27 deletions
|
|
@ -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"
|
||||
|
|
@ -332,6 +333,19 @@ usage_device_delete (void)
|
|||
"command.\n\n"));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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 ();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -1213,6 +1218,35 @@ nm_device_get_managed (NMDevice *device)
|
|||
return NM_DEVICE_GET_PRIVATE (device)->managed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -1094,6 +1099,30 @@ nm_device_get_managed (NMDevice *device)
|
|||
return NM_DEVICE_GET_PRIVATE (device)->managed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue