static void udev_device_added (SettingsPluginIfupdown *self, GUdevDevice *device) { SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); const char *iface, *path; NMIfupdownConnection *exported; iface = g_udev_device_get_name (device); path = g_udev_device_get_sysfs_path (device); if (!iface || !path) return; nm_log_info (LOGD_SETTINGS, "devices added (path: %s, iface: %s)", path, iface); /* if we have a configured connection for this particular iface * we want to either unmanage the device or lock it */ exported = g_hash_table_lookup (priv->connections, iface); if (!exported && !g_hash_table_lookup (priv->eni_ifaces, iface)) { nm_log_info (LOGD_SETTINGS, "device added (path: %s, iface: %s): no ifupdown configuration found.", path, iface); return; } g_hash_table_insert (priv->kernel_ifaces, g_strdup (iface), g_object_ref (device)); if (exported) bind_device_to_connection (self, device, exported); if (ALWAYS_UNMANAGE || priv->unmanage_well_known) g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); }
static void daemon_watch_cb (GPid pid, gint status, gpointer user_data) { NMDHCPClient *self = NM_DHCP_CLIENT (user_data); NMDHCPClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self); NMDHCPState new_state; if (priv->ipv6) { nm_log_info (LOGD_DHCP6, "(%s): DHCPv6 client pid %d exited with status %d", priv->iface, pid, WIFEXITED (status) ? WEXITSTATUS (status) : -1); } else { nm_log_info (LOGD_DHCP4, "(%s): DHCPv4 client pid %d exited with status %d", priv->iface, pid, WIFEXITED (status) ? WEXITSTATUS (status) : -1); } if (!WIFEXITED (status)) { new_state = DHC_ABEND; nm_log_warn (LOGD_DHCP, "DHCP client died abnormally"); } else new_state = DHC_END; watch_cleanup (self); timeout_cleanup (self); priv->dead = TRUE; dhcp_client_set_state (self, new_state, TRUE, FALSE); }
static NMActStageReturn real_act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (dev); gboolean scanning; /* disconnect companion device, if it is connected */ if (nm_device_get_act_request (NM_DEVICE (priv->companion))) { nm_log_info (LOGD_OLPC_MESH, "(%s): disconnecting companion device %s", nm_device_get_iface (dev), nm_device_get_iface (priv->companion)); /* FIXME: VPN stuff here is a bug; but we can't really change API now... */ nm_device_state_changed (NM_DEVICE (priv->companion), NM_DEVICE_STATE_DISCONNECTED, NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED); nm_log_info (LOGD_OLPC_MESH, "(%s): companion %s disconnected", nm_device_get_iface (dev), nm_device_get_iface (priv->companion)); } /* wait with continuing configuration untill the companion device is done scanning */ g_object_get (priv->companion, "scanning", &scanning, NULL); if (scanning) { priv->stage1_waiting = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; } return NM_ACT_STAGE_RETURN_SUCCESS; }
static void _name_owner_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { NMVpnService *service = NM_VPN_SERVICE (user_data); NMVpnServicePrivate *priv = NM_VPN_SERVICE_GET_PRIVATE (service); gboolean success; char *owner; owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object)); /* Service changed, no need to wait for the timeout any longer */ if (priv->start_timeout) { g_source_remove (priv->start_timeout); priv->start_timeout = 0; } if (owner && !priv->service_running) { /* service appeared */ priv->service_running = TRUE; nm_log_info (LOGD_VPN, "VPN service '%s' appeared; activating connections", nm_vpn_plugin_info_get_name (priv->plugin_info)); /* Expect success because the VPN service has already appeared */ success = start_active_vpn (service, NULL); g_warn_if_fail (success); } else if (!owner && priv->service_running) { /* service went away */ priv->service_running = FALSE; nm_log_info (LOGD_VPN, "VPN service '%s' disappeared", nm_vpn_plugin_info_get_name (priv->plugin_info)); nm_vpn_service_stop_connections (service, FALSE, NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED); } g_free (owner); }
static void bluez_property_changed (DBusGProxy *proxy, const char *property, GValue *value, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); NMDeviceBt *self = NM_DEVICE_BT (user_data); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self); gboolean connected; NMDeviceState state; const char *prop_str = "(unknown)"; if (G_VALUE_HOLDS_STRING (value)) prop_str = g_value_get_string (value); else if (G_VALUE_HOLDS_BOOLEAN (value)) prop_str = g_value_get_boolean (value) ? "true" : "false"; nm_log_dbg (LOGD_BT, "(%s): bluez property '%s' changed to '%s'", nm_device_get_iface (device), property, prop_str); if (strcmp (property, "Connected")) return; state = nm_device_get_state (device); connected = g_value_get_boolean (value); if (connected) { if (state == NM_DEVICE_STATE_CONFIG) { nm_log_dbg (LOGD_BT, "(%s): connected to the device", nm_device_get_iface (device)); priv->connected = TRUE; check_connect_continue (self); } } else { gboolean fail = FALSE; /* Bluez says we're disconnected from the device. Suck. */ if (nm_device_is_activating (device)) { nm_log_info (LOGD_BT, "Activation (%s/bluetooth): bluetooth link disconnected.", nm_device_get_iface (device)); fail = TRUE; } else if (state == NM_DEVICE_STATE_ACTIVATED) { nm_log_info (LOGD_BT, "(%s): bluetooth link disconnected.", nm_device_get_iface (device)); fail = TRUE; } if (fail) { nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CARRIER); priv->connected = FALSE; } } }
void nm_dhcp_client_new_options (NMDHCPClient *self, GHashTable *options, const char *reason) { NMDHCPClientPrivate *priv; guint32 old_state; guint32 new_state; g_return_if_fail (self != NULL); g_return_if_fail (NM_IS_DHCP_CLIENT (self)); g_return_if_fail (options != NULL); g_return_if_fail (reason != NULL); priv = NM_DHCP_CLIENT_GET_PRIVATE (self); old_state = priv->state; new_state = string_to_state (reason); /* Clear old and save new DHCP options */ g_hash_table_remove_all (priv->options); g_hash_table_foreach (options, copy_option, priv->options); if (old_state == new_state) { /* dhclient will stay in the same state (or, really, provide the same * reason) for operations like RENEW and REBIND. We need to ensure * that triggers various DHCP lease change code, so we need to pass * along same-state transitions for these states. */ if ( new_state != DHC_BOUND4 && new_state != DHC_RENEW4 && new_state != DHC_REBIND4 && new_state != DHC_BOUND6 && new_state != DHC_RENEW6 && new_state != DHC_REBIND6) return; } /* Handle changed device state */ if (state_is_bound (new_state)) { /* Cancel the timeout if the DHCP client is now bound */ timeout_cleanup (self); } if (priv->ipv6) { nm_log_info (LOGD_DHCP6, "(%s): DHCPv6 state changed %s -> %s", priv->iface, state_to_string (old_state), state_to_string (new_state)); } else { nm_log_info (LOGD_DHCP4, "(%s): DHCPv4 state changed %s -> %s", priv->iface, state_to_string (old_state), state_to_string (new_state)); } dhcp_client_set_state (self, new_state, TRUE, FALSE); }
static void process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4_config) { const char *str; char **searches, **s; str = g_hash_table_lookup (options, "static_routes"); if (!str) return; searches = g_strsplit (str, " ", 0); if ((g_strv_length (searches) % 2)) { nm_log_info (LOGD_DHCP, " static routes provided, but invalid"); goto out; } for (s = searches; *s; s += 2) { NMPlatformIP4Route route; guint32 rt_addr, rt_route; if (inet_pton (AF_INET, *s, &rt_addr) <= 0) { nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route address: '%s'", *s); continue; } if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) { nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route gateway: '%s'", *(s + 1)); continue; } // FIXME: ensure the IP address and route are sane memset (&route, 0, sizeof (route)); route.network = rt_addr; /* RFC 2132, updated by RFC 3442: The Static Routes option (option 33) does not provide a subnet mask for each route - it is assumed that the subnet mask is implicit in whatever network number is specified in each route entry */ route.plen = nm_utils_ip4_get_default_prefix (rt_addr); if (rt_addr & ~nm_utils_ip4_prefix_to_netmask (route.plen)) { /* RFC 943: target not "this network"; using host routing */ route.plen = 32; } route.gateway = rt_route; route.source = NM_IP_CONFIG_SOURCE_DHCP; route.metric = priority; nm_ip4_config_add_route (ip4_config, &route); nm_log_info (LOGD_DHCP, " static route %s", nm_platform_ip4_route_to_string (&route, NULL, 0)); } out: g_strfreev (searches); }
static void nm_connectivity_check_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) { GSimpleAsyncResult *simple = user_data; NMConnectivity *self; NMConnectivityPrivate *priv; NMConnectivityState new_state; const char *nm_header; self = NM_CONNECTIVITY (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); g_object_unref (self); priv = NM_CONNECTIVITY_GET_PRIVATE (self); if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) { nm_log_info (LOGD_CONCHECK, "Connectivity check for uri '%s' failed with '%s'.", priv->uri, msg->reason_phrase); new_state = NM_CONNECTIVITY_LIMITED; goto done; } /* Check headers; if we find the NM-specific one we're done */ nm_header = soup_message_headers_get_one (msg->response_headers, "X-NetworkManager-Status"); if (g_strcmp0 (nm_header, "online") == 0) { nm_log_dbg (LOGD_CONCHECK, "Connectivity check for uri '%s' with Status header successful.", priv->uri); new_state = NM_CONNECTIVITY_FULL; } else if (msg->status_code == SOUP_STATUS_OK) { /* check response */ if (msg->response_body->data && (g_str_has_prefix (msg->response_body->data, priv->response))) { nm_log_dbg (LOGD_CONCHECK, "Connectivity check for uri '%s' successful.", priv->uri); new_state = NM_CONNECTIVITY_FULL; } else { nm_log_info (LOGD_CONCHECK, "Connectivity check for uri '%s' did not match expected response '%s'; assuming captive portal.", priv->uri, priv->response); new_state = NM_CONNECTIVITY_PORTAL; } } else { nm_log_info (LOGD_CONCHECK, "Connectivity check for uri '%s' returned status '%d %s'; assuming captive portal.", priv->uri, msg->status_code, msg->reason_phrase); new_state = NM_CONNECTIVITY_PORTAL; } done: g_simple_async_result_set_op_res_gssize (simple, new_state); g_simple_async_result_complete (simple); update_state (self, new_state); }
gboolean nm_policy_set_system_hostname (const char *new_hostname, const char *msg) { char old_hostname[HOST_NAME_MAX + 1]; const char *name; int ret; if (new_hostname) g_warn_if_fail (strlen (new_hostname)); old_hostname[HOST_NAME_MAX] = '\0'; errno = 0; ret = gethostname (old_hostname, HOST_NAME_MAX); if (ret != 0) { nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s", errno, strerror (errno)); } else { /* Don't set the hostname if it isn't actually changing */ if ( (new_hostname && !strcmp (old_hostname, new_hostname)) || (!new_hostname && !strcmp (old_hostname, FALLBACK_HOSTNAME4))) return FALSE; } name = (new_hostname && strlen (new_hostname)) ? new_hostname : FALLBACK_HOSTNAME4; nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg); ret = sethostname (name, strlen (name)); if (ret != 0) { nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s", name, errno, strerror (errno)); } return (ret == 0); }
/* Connection type is determined here */ static void init_block_by_line (gchar * buf) { gchar **key_value; gchar *pos; gchar *data; gchar *tmp; GHashTable *conn; key_value = g_strsplit (buf, "=", 2); if (g_strv_length (key_value) != 2) { nm_log_warn (LOGD_SETTINGS, "Can't handle this line: %s\n", buf); g_strfreev (key_value); return; } pos = g_strrstr (key_value[0], "_"); if (pos == NULL || is_global_setting (key_value[0])) { /* global data */ data = g_strdup (key_value[1]); tmp = strip_string (data, '"'); strip_string (tmp, '\''); nm_log_info (LOGD_SETTINGS, "global:%s-%s\n", key_value[0], tmp); g_hash_table_insert (global_settings_table, g_strdup (key_value[0]), g_strdup (tmp)); g_strfreev (key_value); g_free (data); return; } *pos++ = '\0'; if ((conn = get_connection_config (pos)) == NULL) { if (g_ascii_strncasecmp (pos, "eth", 3) == 0 && strlen (pos) == 4) /* wired connection */ conn = add_new_connection_config ("wired", pos); else if (g_ascii_strncasecmp (pos, "ppp", 3) == 0 && strlen (pos) == 4) /* pppoe connection */ conn = add_new_connection_config ("ppp", pos); else if (ignore_connection_name (pos)) { /* ignored connection */ conn = add_new_connection_config ("ignore", pos); } else { int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, pos); if (ifindex && nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) != NM_LINK_TYPE_WIFI) /* wired connection */ conn = add_new_connection_config ("wired", pos); else /* wireless connection */ conn = add_new_connection_config ("wireless", pos); } } data = g_strdup (key_value[1]); tmp = strip_string (data, '"'); strip_string (tmp, '\''); if (conn) g_hash_table_insert (conn, strip_string (g_strdup (key_value[0]), ' '), g_strdup (tmp)); g_free (data); g_strfreev (key_value); }
static gboolean release_slave (NMDevice *device, NMDevice *slave) { gboolean success, no_firmware = FALSE; success = nm_platform_link_release (nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); nm_log_info (LOGD_BOND, "(%s): released bond slave %s (success %d)", nm_device_get_ip_iface (device), nm_device_get_ip_iface (slave), success); g_object_notify (G_OBJECT (device), "slaves"); /* Kernel bonding code "closes" the slave when releasing it, (which clears * IFF_UP), so we must bring it back up here to ensure carrier changes and * other state is noticed by the now-released slave. */ if (!nm_device_bring_up (slave, TRUE, &no_firmware)) { nm_log_warn (LOGD_BOND, "(%s): released bond slave could not be brought up.", nm_device_get_iface (slave)); } return success; }
static gboolean enslave_slave (NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure) { gboolean success = TRUE, no_firmware = FALSE; const char *iface = nm_device_get_ip_iface (device); const char *slave_iface = nm_device_get_ip_iface (slave); nm_device_master_check_slave_physical_port (device, slave, LOGD_BOND); if (configure) { nm_device_take_down (slave, TRUE); success = nm_platform_link_enslave (nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); nm_device_bring_up (slave, TRUE, &no_firmware); } if (success) { nm_log_info (LOGD_BOND, "(%s): enslaved bond slave %s", iface, slave_iface); g_object_notify (G_OBJECT (device), "slaves"); } return success; }
static void try_add_service (NMVpnManager *self, const char *namefile) { NMVpnManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); NMVpnService *service = NULL; GHashTableIter iter; GError *error = NULL; const char *service_name; g_return_if_fail (g_path_is_absolute (namefile)); /* Make sure we don't add dupes */ g_hash_table_iter_init (&iter, priv->services); while (g_hash_table_iter_next (&iter, NULL, (gpointer) &service)) { if (g_strcmp0 (namefile, nm_vpn_service_get_name_file (service)) == 0) return; } /* New service */ service = nm_vpn_service_new (namefile, &error); if (service) { service_name = nm_vpn_service_get_dbus_service (service); g_hash_table_insert (priv->services, (char *) service_name, service); nm_log_info (LOGD_VPN, "VPN: loaded %s", service_name); } else { nm_log_warn (LOGD_VPN, "failed to load VPN service file %s: (%d) %s", namefile, error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); } }
static gboolean finish_addrconf (gpointer user_data) { CallbackInfo *info = user_data; NMIP6Device *device = info->device; NMIP6Manager *manager = device->manager; int ifindex; device->finish_addrconf_id = 0; device->addrconf_complete = TRUE; ifindex = device->ifindex; /* We're done, stop polling IPv6 flags */ if (device->ip6flags_poll_id) { g_source_remove (device->ip6flags_poll_id); device->ip6flags_poll_id = 0; } /* And tell listeners that addrconf is complete */ if (info->success) { g_signal_emit (manager, signals[ADDRCONF_COMPLETE], 0, ifindex, info->dhcp_opts, TRUE); } else { nm_log_info (LOGD_IP6, "(%s): IP6 addrconf timed out or failed.", device->iface); nm_ip6_manager_cancel_addrconf (manager, ifindex); g_signal_emit (manager, signals[ADDRCONF_COMPLETE], 0, ifindex, info->dhcp_opts, FALSE); } return FALSE; }
static void set_ap_scan_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) { NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; gs_unref_variant GVariant *reply = NULL; gs_free_error GError *error = NULL; reply = g_dbus_proxy_call_finish (proxy, result, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; self = NM_SUPPLICANT_INTERFACE (user_data); priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); if (!reply) { g_dbus_error_strip_remote_error (error); nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.", error->message); emit_error_helper (self, error); return; } nm_log_info (LOGD_SUPPLICANT, "Config: set interface ap_scan to %d", nm_supplicant_config_get_ap_scan (priv->cfg)); g_dbus_proxy_call (priv->iface_proxy, "AddNetwork", g_variant_new ("(@a{sv})", nm_supplicant_config_to_variant (priv->cfg)), G_DBUS_CALL_FLAGS_NONE, -1, priv->assoc_cancellable, (GAsyncReadyCallback) add_network_cb, self); }
void nm_dhcp_client_stop (NMDHCPClient *self, gboolean release) { NMDHCPClientPrivate *priv; g_return_if_fail (self != NULL); g_return_if_fail (NM_IS_DHCP_CLIENT (self)); priv = NM_DHCP_CLIENT_GET_PRIVATE (self); /* Kill the DHCP client */ if (!priv->dead) { NM_DHCP_CLIENT_GET_CLASS (self)->stop (self, release); priv->dead = TRUE; nm_log_info (LOGD_DHCP, "(%s): canceled DHCP transaction, DHCP client pid %d", priv->iface, priv->pid); } /* And clean stuff up */ priv->pid = -1; dhcp_client_set_state (self, DHC_END, FALSE, TRUE); g_hash_table_remove_all (priv->options); timeout_cleanup (self); watch_cleanup (self); }
gboolean wpa_add_security (const char *ssid) { if (wpa_has_security (ssid)) return TRUE; else { GHashTable *security = g_hash_table_new (g_str_hash, g_str_equal); gchar *ssid_i; nm_log_info (LOGD_SETTINGS, "Adding security for %s", ssid); if (g_str_has_prefix (ssid, "0x")) { /* hex ssid */ ssid_i = g_strdup (ssid + 2); } else { /* ascii ssid requires quotes */ ssid_i = g_strdup_printf ("\"%s\"", ssid); } g_hash_table_insert (security, strdup ("ssid"), ssid_i); g_hash_table_insert (security, strdup ("priority"), strdup ("1")); g_hash_table_insert (wsec_table, g_strdup (ssid), security); wpa_parser_data_changed = TRUE; return TRUE; } }
static gboolean supports_secrets (NMSettingsConnection *connection, const char *setting_name) { nm_log_info (LOGD_SETTINGS, "supports_secrets() for setting_name: '%s'", setting_name); return (strcmp (setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) == 0); }
static void _ifparser_source (const char *path, const char *en_dir, int quiet) { char *abs_path; wordexp_t we; uint i; if (g_path_is_absolute (path)) abs_path = g_strdup (path); else abs_path = g_build_filename (en_dir, path, NULL); if (!quiet) nm_log_info (LOGD_SETTINGS, " interface-parser: source line includes interfaces file(s) %s\n", abs_path); /* ifupdown uses WRDE_NOCMD for wordexp. */ if (wordexp (abs_path, &we, WRDE_NOCMD)) { if (!quiet) nm_log_warn (LOGD_SETTINGS, "word expansion for %s failed\n", abs_path); } else { for (i = 0; i < we.we_wordc; i++) _recursive_ifparser (we.we_wordv[i], quiet); wordfree (&we); } g_free (abs_path); }
static void modem_added_cb (NMModemManager *manager, NMModem *modem, gpointer user_data) { NMWwanFactory *self = NM_WWAN_FACTORY (user_data); NMDevice *device; const char *driver, *port; /* Do nothing if the modem was consumed by some other plugin */ if (nm_device_factory_emit_component_added (NM_DEVICE_FACTORY (self), G_OBJECT (modem))) return; driver = nm_modem_get_driver (modem); /* If it was a Bluetooth modem and no bluetooth device claimed it, ignore * it. The rfcomm port (and thus the modem) gets created automatically * by the Bluetooth code during the connection process. */ if (driver && strstr (driver, "bluetooth")) { port = nm_modem_get_data_port (modem); if (!port) port = nm_modem_get_control_port (modem); nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)", port); return; } /* Make the new modem device */ device = nm_device_modem_new (modem); g_assert (device); g_signal_emit_by_name (self, NM_DEVICE_FACTORY_DEVICE_ADDED, device); g_object_unref (device); }
static void modem_manager_appeared (NMModemManager *self, gboolean enumerate_devices) { NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (self); if (priv->poke_id) { g_source_remove (priv->poke_id); priv->poke_id = 0; } nm_log_info (LOGD_MB, "modem-manager is now available"); priv->proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr), MM_DBUS_SERVICE, MM_DBUS_PATH, MM_DBUS_INTERFACE); dbus_g_proxy_add_signal (priv->proxy, "DeviceAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "DeviceAdded", G_CALLBACK (modem_added), self, NULL); dbus_g_proxy_add_signal (priv->proxy, "DeviceRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "DeviceRemoved", G_CALLBACK (modem_removed), self, NULL); if (enumerate_devices) dbus_g_proxy_begin_call (priv->proxy, "EnumerateDevices", enumerate_devices_done, self, NULL, G_TYPE_INVALID); }
/* * nm_system_update_dns * * Invalidate the nscd host cache, if it exists, since * we changed resolv.conf. * */ void nm_system_update_dns (void) { if (g_file_test ("/usr/sbin/nscd", G_FILE_TEST_IS_EXECUTABLE)) { nm_log_info (LOGD_DNS, "Clearing nscd hosts cache."); nm_spawn_process ("/usr/sbin/nscd -i hosts"); } }
gboolean nm_dhcp_client_start_ip6 (NMDHCPClient *self, NMSettingIP6Config *s_ip6, guint8 *dhcp_anycast_addr, const char *hostname, gboolean info_only) { NMDHCPClientPrivate *priv; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE); priv = NM_DHCP_CLIENT_GET_PRIVATE (self); g_return_val_if_fail (priv->pid == -1, FALSE); g_return_val_if_fail (priv->ipv6 == TRUE, FALSE); g_return_val_if_fail (priv->uuid != NULL, FALSE); priv->info_only = info_only; nm_log_info (LOGD_DHCP, "Activation (%s) Beginning DHCPv6 transaction (timeout in %d seconds)", priv->iface, priv->timeout); priv->pid = NM_DHCP_CLIENT_GET_CLASS (self)->ip6_start (self, s_ip6, dhcp_anycast_addr, hostname, info_only); if (priv->pid > 0) start_monitor (self); return priv->pid ? TRUE : FALSE; }
static void read_connections (SettingsPluginIbft *self) { SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); GSList *blocks = NULL, *iter; GError *error = NULL; NMIbftConnection *connection; if (!read_ibft_blocks ("/sbin/iscsiadm", &blocks, &error)) { nm_log_dbg (LOGD_SETTINGS, "ibft: failed to read iscsiadm records: %s", error->message); g_error_free (error); return; } for (iter = blocks; iter; iter = iter->next) { connection = nm_ibft_connection_new (iter->data, &error); if (connection) { nm_log_info (LOGD_SETTINGS, "ibft: read connection '%s'", nm_connection_get_id (NM_CONNECTION (connection))); g_hash_table_insert (priv->connections, g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), connection); } else { nm_log_warn (LOGD_SETTINGS, "ibft: failed to read iscsiadm record: %s", error->message); g_clear_error (&error); } } g_slist_free_full (blocks, (GDestroyNotify) g_ptr_array_unref); }
static void parse_capabilities (NMSupplicantInterface *self, GVariant *capabilities) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); gboolean have_active = FALSE, have_ssid = FALSE; gint32 max_scan_ssids = -1; const char **array; g_return_if_fail (capabilities && g_variant_is_of_type (capabilities, G_VARIANT_TYPE_VARDICT)); if (g_variant_lookup (capabilities, "Scan", "^a&s", &array)) { if (_nm_utils_string_in_list ("active", array)) have_active = TRUE; if (_nm_utils_string_in_list ("ssid", array)) have_ssid = TRUE; g_free (array); } if (g_variant_lookup (capabilities, "MaxScanSSID", "i", &max_scan_ssids)) { /* We need active scan and SSID probe capabilities to care about MaxScanSSIDs */ if (max_scan_ssids > 0 && have_active && have_ssid) { /* wpa_supplicant's WPAS_MAX_SCAN_SSIDS value is 16, but for speed * and to ensure we don't disclose too many SSIDs from the hidden * list, we'll limit to 5. */ priv->max_scan_ssids = CLAMP (max_scan_ssids, 0, 5); nm_log_info (LOGD_SUPPLICANT, "(%s) supports %d scan SSIDs", priv->dev, priv->max_scan_ssids); } } }
static void manager_configure_quit (NMManager *manager, gpointer user_data) { nm_log_info (LOGD_CORE, "quitting now that startup is complete"); g_main_loop_quit (main_loop); configure_and_quit = TRUE; }
static void try_add_service (NMVPNManager *self, const char *namefile) { NMVPNManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self); NMVPNService *service = NULL; GError *error = NULL; const char *service_name; char *tmp; g_return_if_fail (g_path_is_absolute (namefile)); /* Make sure we don't add dupes */ tmp = service_name_from_file (namefile); if (tmp) service = g_hash_table_lookup (priv->services, tmp); g_free (tmp); if (service) return; /* New service, add it */ service = nm_vpn_service_new (namefile, &error); if (!service) { nm_log_warn (LOGD_VPN, "failed to load VPN service file %s: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); return; } service_name = nm_vpn_service_get_dbus_service (service); g_hash_table_insert (priv->services, (char *) service_name, service); nm_log_info (LOGD_VPN, "VPN: loaded %s", service_name, service); }
static void set_ap_scan_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) { NMSupplicantInfo *info = (NMSupplicantInfo *) user_data; NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface); GError *err = NULL; DBusGProxyCall *call; GHashTable *config_hash; if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_INVALID)) { nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.", err->message); emit_error_helper (info->interface, err); g_error_free (err); return; } nm_log_info (LOGD_SUPPLICANT, "Config: set interface ap_scan to %d", nm_supplicant_config_get_ap_scan (priv->cfg)); info = nm_supplicant_info_new (info->interface, priv->iface_proxy, info->store); config_hash = nm_supplicant_config_get_hash (priv->cfg); call = dbus_g_proxy_begin_call (priv->iface_proxy, "AddNetwork", add_network_cb, info, nm_supplicant_info_destroy, DBUS_TYPE_G_MAP_OF_VARIANT, config_hash, G_TYPE_INVALID); g_hash_table_destroy (config_hash); nm_supplicant_info_set_call (info, call); }
/* * Return a list of device specifications which NetworkManager should not * manage. Returned list will be freed by the system settings service, and * each element must be allocated using g_malloc() or its variants. */ static GSList* get_unmanaged_specs (NMSettingsPlugin *config) { SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (config); GSList *specs = NULL; GHashTableIter iter; GUdevDevice *device; const char *iface; if (!ALWAYS_UNMANAGE && !priv->unmanage_well_known) return NULL; nm_log_info (LOGD_SETTINGS, "get unmanaged devices count: %d", g_hash_table_size (priv->kernel_ifaces)); g_hash_table_iter_init (&iter, priv->kernel_ifaces); while (g_hash_table_iter_next (&iter, (gpointer) &iface, (gpointer) &device)) { const char *address; address = g_udev_device_get_sysfs_attr (device, "address"); if (address) specs = g_slist_append (specs, g_strdup_printf ("mac:%s", address)); else specs = g_slist_append (specs, g_strdup_printf ("interface-name:%s", iface)); } return specs; }
gboolean nm_vpn_service_activate (NMVPNService *service, NMVPNConnection *vpn, GError **error) { NMVPNServicePrivate *priv; g_return_val_if_fail (NM_IS_VPN_SERVICE (service), FALSE); g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), FALSE); g_return_val_if_fail (error != NULL, FALSE); g_return_val_if_fail (*error == NULL, FALSE); priv = NM_VPN_SERVICE_GET_PRIVATE (service); clear_quit_timeout (service); g_signal_connect (vpn, NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED, G_CALLBACK (connection_vpn_state_changed), service); priv->connections = g_slist_prepend (priv->connections, g_object_ref (vpn)); if (nm_dbus_manager_name_has_owner (priv->dbus_mgr, priv->dbus_service)) nm_vpn_connection_activate (vpn); else if (priv->start_timeout == 0) { nm_log_info (LOGD_VPN, "Starting VPN service '%s'...", priv->name); if (!nm_vpn_service_daemon_exec (service, error)) return FALSE; } return TRUE; }