Merge remote branch 'origin/master' into rm-userset

This commit is contained in:
Dan Williams
2010-10-18 19:02:27 -05:00
49 changed files with 6071 additions and 3016 deletions

View File

@@ -657,9 +657,10 @@ check_ethernet_compatible (NMDeviceEthernet *device, NMConnection *connection, G
if (s_wired) {
const GByteArray *mac;
const char *device_mac_str;
struct ether_addr *device_mac;
struct ether_addr *device_mac = NULL;
device_mac_str = nm_device_ethernet_get_permanent_hw_address (device);
if (device_mac_str)
device_mac = ether_aton (device_mac_str);
if (!device_mac) {
g_set_error (error, 0, 0, "Invalid device MAC address.");
@@ -706,9 +707,10 @@ check_wifi_compatible (NMDeviceWifi *device, NMConnection *connection, GError **
if (s_wireless) {
const GByteArray *mac;
const char *device_mac_str;
struct ether_addr *device_mac;
struct ether_addr *device_mac = NULL;
device_mac_str = nm_device_wifi_get_permanent_hw_address (device);
if (device_mac_str)
device_mac = ether_aton (device_mac_str);
if (!device_mac) {
g_set_error (error, 0, 0, "Invalid device MAC address.");

View File

@@ -84,7 +84,7 @@ dnl Make sha1.c happy on big endian systems
dnl
AC_C_BIGENDIAN
AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo, mandriva or pardus]))
AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo, mandriva, pardus or linexa]))
if test "z$with_distro" = "z"; then
AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
@@ -96,6 +96,7 @@ if test "z$with_distro" = "z"; then
AC_CHECK_FILE(/etc/frugalware-release,with_distro="frugalware")
AC_CHECK_FILE(/etc/mandriva-release,with_distro="mandriva")
AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
AC_CHECK_FILE(/etc/linexa-release,with_distro="linexa")
if test "z$with_distro" = "z"; then
with_distro=`lsb_release -is`
fi
@@ -107,7 +108,7 @@ if test "z$with_distro" = "z"; then
exit 1
else
case $with_distro in
redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus) ;;
redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa) ;;
*)
echo "Your distribution (${with_distro}) is not yet supported! (patches welcome)"
exit 1
@@ -165,6 +166,11 @@ if test x"$with_distro" = xpardus; then
AC_DEFINE(TARGET_PARDUS, 1, [Define if you have Pardus])
fi
AM_CONDITIONAL(TARGET_LINEXA, test x"$with_distro" = xlinexa)
if test x"$with_distro" = xlinexa; then
AC_DEFINE(TARGET_LINEXA, 1, [Define if you have linexa])
fi
dnl
dnl Distribution version string
dnl
@@ -543,6 +549,8 @@ initscript/paldo/Makefile
initscript/paldo/NetworkManager
initscript/Mandriva/Makefile
initscript/Mandriva/networkmanager
initscript/linexa/Makefile
initscript/linexa/networkmanager
introspection/Makefile
man/Makefile
man/NetworkManager.8
@@ -560,6 +568,7 @@ docs/libnm-util/Makefile
NetworkManager.pc
examples/Makefile
examples/python/Makefile
examples/C/Makefile
])
AC_OUTPUT

View File

@@ -1,7 +1,7 @@
SUBDIRS = libnm-glib libnm-util
if WITH_DOCS
SUBDIRS = libnm-glib libnm-util
INCLUDES = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/libnm-util

2
examples/C/Makefile.am Normal file
View File

@@ -0,0 +1,2 @@
EXTRA_DIST = \
add-connection-glib.c

View File

@@ -0,0 +1,112 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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 Red Hat, Inc.
*/
/*
* The example shows how to call AddConnection() D-Bus method to add
* a connection to system settings service. It uses dbus-glib and libnm-util
* libraries.
*
* Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` add-connection-glib.c -o add-connection-glib
*/
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <nm-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-ip4-config.h>
#include <NetworkManager.h>
#include <nm-utils.h>
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
void add_connection (DBusGProxy *proxy, const char *con_name)
{
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
NMSettingIP4Config *s_ip4;
char *uuid;
GHashTable *hash;
GError *error = NULL;
/* Create a new connection object */
connection = (NMConnection *) nm_connection_new ();
/* Build up the 'connection' Setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
uuid = nm_utils_uuid_generate ();
g_object_set (G_OBJECT (s_con),
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_ID, con_name,
NM_SETTING_CONNECTION_TYPE, "802-3-ethernet",
NULL);
g_free (uuid);
nm_connection_add_setting (connection, NM_SETTING (s_con));
/* Build up the 'wired' Setting */
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wired));
/* Build up the 'ipv4' Setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
g_object_set (G_OBJECT (s_ip4),
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
NULL);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
hash = nm_connection_to_hash (connection);
/* Call AddConnection with the hash as argument */
dbus_g_proxy_call (proxy, "AddConnection", &error,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
G_TYPE_INVALID);
g_hash_table_destroy (hash);
g_object_unref (connection);
}
int main (int argc, char *argv[])
{
DBusGConnection *bus;
DBusGProxy *proxy;
/* Initialize GType system */
g_type_init ();
/* Get system bus */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
/* Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h */
proxy = dbus_g_proxy_new_for_name (bus,
NM_DBUS_SERVICE_SYSTEM_SETTINGS,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
/* Add a connection */
add_connection (proxy, "__Test connection__");
g_object_unref (proxy);
dbus_g_connection_unref (bus);
return 0;
}

View File

@@ -1 +1,3 @@
SUBDIRS=python
SUBDIRS= \
python \
C

View File

@@ -23,3 +23,6 @@ endif
if TARGET_MANDRIVA
SUBDIRS += Mandriva
endif
if TARGET_LINEXA
SUBDIRS += linexa
endif

View File

@@ -0,0 +1,6 @@
EXTRA_DIST = networkmanager
DISTCLEANFILES = networkmanager
initddir = $(sysconfdir)/rc.d/init.d
initd_SCRIPTS = networkmanager

View File

@@ -0,0 +1,59 @@
#!/bin/bash
# Start the networkmanager daemon
#
# Author: Elias <elias@linexa.de>
# [2010-08-20]
# Information about the daemon
title="networkmanager" # No spaces allowed in here
start_after="dbus" # dependencies for start-up
stop_after="xinetd" # dependencies for stop
runlevel="2" # start/stop in this runlevel
sequence="25" # "checkinstall networkmanager enable"
# will create links to:
# /etc/rc.d/rc${runlevel}.d/S${sequence}${title}
# /etc/rc.d/rc${runlevel}.d/S$((100 - ${sequence}))${title}
# check whether daemon is running
# returns 0 if running, >0 if not
check() {
[ -f /var/run/NetworkManager.pid ]
}
# start procedure
start() {
if check ; then
warning "${title} is already running. Type 'service restart ${title}'" # Issue a warning
else
/usr/sbin/NetworkManager &
evaluate_retval "Starting ${title}. " # Print [ done ] or [ failed ] depending on outcome
fi
}
# stop procedure
stop() {
if check ; then # daemon is running
kill $(cat /var/run/NetworkManager.pid)
evaluate_retval "Stopping ${title}." # Print [ done ] or [ failed ] depending on outcome
else # daemon not running
warning "${title} is not running." # Issue a warning
fi
}
# restart procedure
restart() {
stop
sleep 1
start
}
# reload action
reload() {
if check ; then # daemon is running
kill -HUP $(cat /var/run/NetworkManager.pid) &>/dev/null
evaluate_retval "Reloading ${title}." # Print [ done ] or [ failed ] depending on outcome
else # daemon not running
warning "${title} is not running." # Issue a warning
fi
}

View File

@@ -117,7 +117,7 @@ libnm_glib_la_LIBADD = \
$(GUDEV_LIBS)
libnm_glib_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib.ver \
-version-info "6:1:4"
-version-info "6:2:4"
noinst_PROGRAMS = libnm-glib-test

View File

@@ -527,12 +527,17 @@ _nm_object_set_property (NMObject *object,
g_return_if_fail (prop_name != NULL);
g_return_if_fail (G_IS_VALUE (value));
dbus_g_proxy_call_no_reply (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
"Set",
if (!dbus_g_proxy_call_with_timeout (NM_OBJECT_GET_PRIVATE (object)->properties_proxy,
"Set", 2000, NULL,
G_TYPE_STRING, interface,
G_TYPE_STRING, prop_name,
G_TYPE_VALUE, value,
G_TYPE_INVALID);
G_TYPE_INVALID)) {
/* Ignore errors. dbus_g_proxy_call_with_timeout() is called instead of
* dbus_g_proxy_call_no_reply() to give NM chance to authenticate the caller.
*/
}
}
char *

View File

@@ -23,6 +23,7 @@
#include <glib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <stdlib.h>
#include <glib/gi18n.h>

View File

@@ -19,10 +19,11 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include <config.h>
#include <string.h>
#include <ctype.h>
#include <dbus/dbus-glib.h>

View File

@@ -24,6 +24,7 @@
*/
#include <string.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <dbus/dbus-glib.h>

2161
po/bg.po

File diff suppressed because it is too large Load Diff

175
po/es.po
View File

@@ -1,5 +1,5 @@
# translation of es.po to Spanish
# translation of NetworkManager.HEAD.po to
# translation of NetworkManager.master.po to
# Traducción de NetworkManager al español.
# Copyright (C) Spanish translation for NetworkManager
# This file is distributed under the same license as the NetworkManager package.
@@ -12,11 +12,11 @@
#
msgid ""
msgstr ""
"Project-Id-Version: es\n"
"Project-Id-Version: NetworkManager.master\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?"
"product=NetworkManager&component=general\n"
"POT-Creation-Date: 2010-09-17 15:25+0000\n"
"PO-Revision-Date: 2010-09-18 11:01+0200\n"
"POT-Creation-Date: 2010-09-21 03:25+0000\n"
"PO-Revision-Date: 2010-09-25 11:36+0200\n"
"Last-Translator: Jorge González <jorgegonz@svn.gnome.org>\n"
"Language-Team: Español <gnome-es-list@gnome.org>\n"
"MIME-Version: 1.0\n"
@@ -94,7 +94,12 @@ msgstr "AUTOCONECTAR"
msgid "READONLY"
msgstr "SÓLOLECTURA"
#: ../cli/src/connections.c:158
#. 7
#: ../cli/src/connections.c:83
msgid "DBUS-PATH"
msgstr "RUTA-DBUS"
#: ../cli/src/connections.c:159
#, c-format
msgid ""
"Usage: nmcli con { COMMAND | help }\n"
@@ -115,37 +120,37 @@ msgstr ""
"<timeout>]\n"
" down id <id> | uuid <id>\n"
#: ../cli/src/connections.c:198 ../cli/src/connections.c:537
#: ../cli/src/connections.c:199 ../cli/src/connections.c:540
#, c-format
msgid "Error: 'con list': %s"
msgstr "Error: «con list»: %s"
#: ../cli/src/connections.c:200 ../cli/src/connections.c:539
#: ../cli/src/connections.c:201 ../cli/src/connections.c:542
#, c-format
msgid "Error: 'con list': %s; allowed fields: %s"
msgstr "Error: «con list»: %s; campos permitidos: %s"
#: ../cli/src/connections.c:208
#: ../cli/src/connections.c:209
msgid "Connection details"
msgstr "Detalles de conexiones"
#: ../cli/src/connections.c:382 ../cli/src/connections.c:602
#: ../cli/src/connections.c:384 ../cli/src/connections.c:605
msgid "system"
msgstr "sistema"
#: ../cli/src/connections.c:382 ../cli/src/connections.c:602
#: ../cli/src/connections.c:384 ../cli/src/connections.c:605
msgid "user"
msgstr "usuario"
#: ../cli/src/connections.c:384
#: ../cli/src/connections.c:386
msgid "never"
msgstr "nunca"
#. "CAPABILITIES"
#. Print header
#. "WIFI-PROPERTIES"
#: ../cli/src/connections.c:385 ../cli/src/connections.c:386
#: ../cli/src/connections.c:603 ../cli/src/connections.c:606
#: ../cli/src/connections.c:387 ../cli/src/connections.c:388
#: ../cli/src/connections.c:606 ../cli/src/connections.c:609
#: ../cli/src/devices.c:432 ../cli/src/devices.c:557 ../cli/src/devices.c:583
#: ../cli/src/devices.c:584 ../cli/src/devices.c:585 ../cli/src/devices.c:586
#: ../cli/src/devices.c:587 ../cli/src/settings.c:508
@@ -164,8 +169,8 @@ msgstr "nunca"
msgid "yes"
msgstr "sí"
#: ../cli/src/connections.c:385 ../cli/src/connections.c:386
#: ../cli/src/connections.c:603 ../cli/src/connections.c:606
#: ../cli/src/connections.c:387 ../cli/src/connections.c:388
#: ../cli/src/connections.c:606 ../cli/src/connections.c:609
#: ../cli/src/devices.c:432 ../cli/src/devices.c:557 ../cli/src/devices.c:583
#: ../cli/src/devices.c:584 ../cli/src/devices.c:585 ../cli/src/devices.c:586
#: ../cli/src/devices.c:587 ../cli/src/settings.c:508
@@ -184,272 +189,272 @@ msgstr "sí"
msgid "no"
msgstr "no"
#: ../cli/src/connections.c:458 ../cli/src/connections.c:501
#: ../cli/src/connections.c:461 ../cli/src/connections.c:504
msgid "System connections"
msgstr "Conexiones de sistema"
#: ../cli/src/connections.c:463 ../cli/src/connections.c:514
#: ../cli/src/connections.c:466 ../cli/src/connections.c:517
msgid "User connections"
msgstr "Conexiones de usuario"
#: ../cli/src/connections.c:475 ../cli/src/connections.c:1335
#: ../cli/src/connections.c:1351 ../cli/src/connections.c:1360
#: ../cli/src/connections.c:1371 ../cli/src/connections.c:1456
#: ../cli/src/connections.c:478 ../cli/src/connections.c:1338
#: ../cli/src/connections.c:1354 ../cli/src/connections.c:1363
#: ../cli/src/connections.c:1374 ../cli/src/connections.c:1459
#: ../cli/src/devices.c:962 ../cli/src/devices.c:972 ../cli/src/devices.c:1074
#: ../cli/src/devices.c:1081
#, c-format
msgid "Error: %s argument is missing."
msgstr "Error: falta el argumento %s."
#: ../cli/src/connections.c:488
#: ../cli/src/connections.c:491
#, c-format
msgid "Error: %s - no such connection."
msgstr "Error: %s - no hay tal conexión."
#: ../cli/src/connections.c:520 ../cli/src/connections.c:1384
#: ../cli/src/connections.c:1474 ../cli/src/devices.c:785
#: ../cli/src/connections.c:523 ../cli/src/connections.c:1387
#: ../cli/src/connections.c:1477 ../cli/src/devices.c:785
#: ../cli/src/devices.c:852 ../cli/src/devices.c:986 ../cli/src/devices.c:1087
#, c-format
msgid "Unknown parameter: %s\n"
msgstr "Parámetro desconocido: %s\n"
#: ../cli/src/connections.c:529
#: ../cli/src/connections.c:532
#, c-format
msgid "Error: no valid parameter specified."
msgstr "Error: no se especificó un parámetro válido."
#: ../cli/src/connections.c:544 ../cli/src/connections.c:1577
#: ../cli/src/connections.c:547 ../cli/src/connections.c:1580
#: ../cli/src/devices.c:1293 ../cli/src/network-manager.c:359
#, c-format
msgid "Error: %s."
msgstr "Error: %s."
#: ../cli/src/connections.c:650
#: ../cli/src/connections.c:653
#, c-format
msgid "Error: 'con status': %s"
msgstr "Error: «con status»: %s"
#: ../cli/src/connections.c:652
#: ../cli/src/connections.c:655
#, c-format
msgid "Error: 'con status': %s; allowed fields: %s"
msgstr "Error: «con status»: %s; campos permitidos: %s"
#: ../cli/src/connections.c:659
#: ../cli/src/connections.c:662
msgid "Active connections"
msgstr "Conexiones activas"
#: ../cli/src/connections.c:1027
#: ../cli/src/connections.c:1030
#, c-format
msgid "no active connection on device '%s'"
msgstr "conexión no activa en el dispositivo «%s»"
#: ../cli/src/connections.c:1035
#: ../cli/src/connections.c:1038
#, c-format
msgid "no active connection or device"
msgstr "conexión o dispositivo no activo"
#: ../cli/src/connections.c:1085
#: ../cli/src/connections.c:1088
#, c-format
msgid "device '%s' not compatible with connection '%s'"
msgstr "dispositivo «%s» incompatible con conexión «%s»"
#: ../cli/src/connections.c:1087
#: ../cli/src/connections.c:1090
#, c-format
msgid "no device found for connection '%s'"
msgstr "no se encontró dispositivo para conexión «%s»"
#: ../cli/src/connections.c:1098
#: ../cli/src/connections.c:1101
msgid "activating"
msgstr "activando"
#: ../cli/src/connections.c:1100
#: ../cli/src/connections.c:1103
msgid "activated"
msgstr "activada"
#: ../cli/src/connections.c:1103 ../cli/src/connections.c:1126
#: ../cli/src/connections.c:1159 ../cli/src/devices.c:246
#: ../cli/src/connections.c:1106 ../cli/src/connections.c:1129
#: ../cli/src/connections.c:1162 ../cli/src/devices.c:246
#: ../cli/src/devices.c:558 ../cli/src/network-manager.c:94
#: ../cli/src/network-manager.c:149 ../cli/src/settings.c:473
msgid "unknown"
msgstr "desconocido"
#: ../cli/src/connections.c:1112
#: ../cli/src/connections.c:1115
msgid "VPN connecting (prepare)"
msgstr "Conectando VPN (preparar)"
#: ../cli/src/connections.c:1114
#: ../cli/src/connections.c:1117
msgid "VPN connecting (need authentication)"
msgstr "Conectando VPN (necesita autenticación)"
#: ../cli/src/connections.c:1116
#: ../cli/src/connections.c:1119
msgid "VPN connecting"
msgstr "Conectando VPN"
#: ../cli/src/connections.c:1118
#: ../cli/src/connections.c:1121
msgid "VPN connecting (getting IP configuration)"
msgstr "Conectando VPN (obteniendo configuración IP)"
#: ../cli/src/connections.c:1120
#: ../cli/src/connections.c:1123
msgid "VPN connected"
msgstr "VPN conectada"
#: ../cli/src/connections.c:1122
#: ../cli/src/connections.c:1125
msgid "VPN connection failed"
msgstr "Falló la conexión VPN"
#: ../cli/src/connections.c:1124
#: ../cli/src/connections.c:1127
msgid "VPN disconnected"
msgstr "VPN desconectada"
#: ../cli/src/connections.c:1135
#: ../cli/src/connections.c:1138
msgid "unknown reason"
msgstr "razón desconocida"
#: ../cli/src/connections.c:1137
#: ../cli/src/connections.c:1140
msgid "none"
msgstr "ninguna"
#: ../cli/src/connections.c:1139
#: ../cli/src/connections.c:1142
msgid "the user was disconnected"
msgstr "el usuario estaba desconectado"
#: ../cli/src/connections.c:1141
#: ../cli/src/connections.c:1144
msgid "the base network connection was interrupted"
msgstr "se interrumpió la conexión de red de base"
#: ../cli/src/connections.c:1143
#: ../cli/src/connections.c:1146
msgid "the VPN service stopped unexpectedly"
msgstr "el servicio VPN se detuvo inesperadamente"
#: ../cli/src/connections.c:1145
#: ../cli/src/connections.c:1148
msgid "the VPN service returned invalid configuration"
msgstr "el servicio VPN retornó una configuración no válida"
#: ../cli/src/connections.c:1147
#: ../cli/src/connections.c:1150
msgid "the connection attempt timed out"
msgstr "se agotaron los intentos de conexión"
#: ../cli/src/connections.c:1149
#: ../cli/src/connections.c:1152
msgid "the VPN service did not start in time"
msgstr "el servicio VPN no inició a tiempo"
#: ../cli/src/connections.c:1151
#: ../cli/src/connections.c:1154
msgid "the VPN service failed to start"
msgstr "el servicio VPN falló en el inicio"
#: ../cli/src/connections.c:1153
#: ../cli/src/connections.c:1156
msgid "no valid VPN secrets"
msgstr "secretos VPN inválidos"
#: ../cli/src/connections.c:1155
#: ../cli/src/connections.c:1158
msgid "invalid VPN secrets"
msgstr "secretos VPN válidos"
#: ../cli/src/connections.c:1157
#: ../cli/src/connections.c:1160
msgid "the connection was removed"
msgstr "se eliminó la conexión"
#: ../cli/src/connections.c:1171
#: ../cli/src/connections.c:1174
#, c-format
msgid "state: %s\n"
msgstr "estado: %s\n"
#: ../cli/src/connections.c:1174 ../cli/src/connections.c:1200
#: ../cli/src/connections.c:1177 ../cli/src/connections.c:1203
#, c-format
msgid "Connection activated\n"
msgstr "Conexión activada\n"
#: ../cli/src/connections.c:1177
#: ../cli/src/connections.c:1180
#, c-format
msgid "Error: Connection activation failed."
msgstr "Error: falló la activación de la conexión."
#: ../cli/src/connections.c:1196
#: ../cli/src/connections.c:1199
#, c-format
msgid "state: %s (%d)\n"
msgstr "estado: %s (%d)\n"
#: ../cli/src/connections.c:1206
#: ../cli/src/connections.c:1209
#, c-format
msgid "Error: Connection activation failed: %s."
msgstr "Error: falló la activación de la conexión: %s."
#: ../cli/src/connections.c:1223 ../cli/src/devices.c:909
#: ../cli/src/connections.c:1226 ../cli/src/devices.c:909
#, c-format
msgid "Error: Timeout %d sec expired."
msgstr "Error: expiró la pausa de %d segundos."
#: ../cli/src/connections.c:1266
#: ../cli/src/connections.c:1269
#, c-format
msgid "Error: Connection activation failed: %s"
msgstr "Error: falló la activación de la conexión: %s"
#: ../cli/src/connections.c:1280
#: ../cli/src/connections.c:1283
#, c-format
msgid "Error: Obtaining active connection for '%s' failed."
msgstr "Error: falló la obtención de conexión activa para «%s»."
#: ../cli/src/connections.c:1289
#: ../cli/src/connections.c:1292
#, c-format
msgid "Active connection state: %s\n"
msgstr "Estado de la conexión activa: %s\n"
#: ../cli/src/connections.c:1290
#: ../cli/src/connections.c:1293
#, c-format
msgid "Active connection path: %s\n"
msgstr "Ruta de la conexión activa: %s\n"
#: ../cli/src/connections.c:1344 ../cli/src/connections.c:1465
#: ../cli/src/connections.c:1347 ../cli/src/connections.c:1468
#, c-format
msgid "Error: Unknown connection: %s."
msgstr "Error: conexión desconocida: %s."
#: ../cli/src/connections.c:1379 ../cli/src/devices.c:980
#: ../cli/src/connections.c:1382 ../cli/src/devices.c:980
#, c-format
msgid "Error: timeout value '%s' is not valid."
msgstr "Error: valor de pausa «%s» inválido."
#: ../cli/src/connections.c:1392 ../cli/src/connections.c:1482
#: ../cli/src/connections.c:1395 ../cli/src/connections.c:1485
#, c-format
msgid "Error: id or uuid has to be specified."
msgstr "Error: se debe especificar un id o uuid."
#: ../cli/src/connections.c:1412
#: ../cli/src/connections.c:1415
#, c-format
msgid "Error: No suitable device found: %s."
msgstr "Error: no se encontró un dispositivo apropiado: %s."
#: ../cli/src/connections.c:1414
#: ../cli/src/connections.c:1417
#, c-format
msgid "Error: No suitable device found."
msgstr "Error: no se encontró un dispositivo apropiado."
#: ../cli/src/connections.c:1509
#: ../cli/src/connections.c:1512
#, c-format
msgid "Warning: Connection not active\n"
msgstr "Advertencia: conexión inactiva\n"
#: ../cli/src/connections.c:1566
#: ../cli/src/connections.c:1569
#, c-format
msgid "Error: 'con' command '%s' is not valid."
msgstr "Error: comando «con» «%s» no es válido."
#: ../cli/src/connections.c:1602
#: ../cli/src/connections.c:1605
#, c-format
msgid "Error: could not connect to D-Bus."
msgstr "Error: no se pudo conectar con D-Bus."
#: ../cli/src/connections.c:1609
#: ../cli/src/connections.c:1612
#, c-format
msgid "Error: Could not get system settings."
msgstr "Error: no se pudo obtener configuración de sistema."
#: ../cli/src/connections.c:1617
#: ../cli/src/connections.c:1620
#, c-format
msgid "Error: Could not get user settings."
msgstr "Error: No se pudo obtener configuración de usuario."
#: ../cli/src/connections.c:1627
#: ../cli/src/connections.c:1630
#, c-format
msgid "Error: Can't obtain connections: settings services are not running."
msgstr ""
@@ -891,17 +896,6 @@ msgstr "WWAN"
#: ../cli/src/network-manager.c:64
#, c-format
#| msgid ""
#| "Usage: nmcli nm { COMMAND | help }\n"
#| "\n"
#| " COMMAND := { status | sleep | wakeup | wifi | wwan }\n"
#| "\n"
#| " status\n"
#| " sleep\n"
#| " wakeup\n"
#| " wifi [on|off]\n"
#| " wwan [on|off]\n"
#| "\n"
msgid ""
"Usage: nmcli nm { COMMAND | help }\n"
"\n"
@@ -973,19 +967,16 @@ msgstr "no ejecutando"
#: ../cli/src/network-manager.c:175
#, c-format
#| msgid "Error: could not connect to D-Bus."
msgid "Error: Couldn't connect to system bus: %s"
msgstr "Error: no se pudo conectar con el bus del sistema: %s"
#: ../cli/src/network-manager.c:186
#, c-format
#| msgid "Error: could not connect to D-Bus."
msgid "Error: Couldn't create D-Bus object proxy."
msgstr "Error: no se pudo crear un objeto proxy en D-Bus."
#: ../cli/src/network-manager.c:192
#, c-format
#| msgid "Error: 'con list': %s"
msgid "Error in sleep: %s"
msgstr "Error al dormir: %s"
@@ -996,25 +987,21 @@ msgid "Error: '--fields' value '%s' is not valid here; allowed fields: %s"
msgstr "Error: «--fields» valor «%s» no es válido aquí; campos permitidos: %s"
#: ../cli/src/network-manager.c:245
#| msgid "WiFi enabled"
msgid "Networking enabled"
msgstr "Red activada"
#: ../cli/src/network-manager.c:256
#, c-format
#| msgid "Error: invalid 'wwan' parameter: '%s'."
msgid "Error: invalid 'enable' parameter: '%s'; use 'true' or 'false'."
msgstr "Error: parámetro «enable» inválido: «%s»; use «true» o «false»."
#: ../cli/src/network-manager.c:265
#, c-format
#| msgid "Error: Could not connect to NetworkManager."
msgid "Error: Sleeping status is not exported by NetworkManager."
msgstr "Error: NetworkManager no exporta el estado para dormir."
#: ../cli/src/network-manager.c:273
#, c-format
#| msgid "Error: invalid 'wifi' parameter: '%s'."
msgid "Error: invalid 'sleep' parameter: '%s'; use 'true' or 'false'."
msgstr "Error: parámetro «wifi» inválido: «%s»."

1543
po/hu.po

File diff suppressed because it is too large Load Diff

1857
po/pl.po

File diff suppressed because it is too large Load Diff

View File

@@ -57,6 +57,18 @@
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
send_member="SetLogging"/>
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
send_member="Sleep"/>
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
send_member="sleep"/>
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
send_member="wake"/>
</policy>
<policy context="default">
<deny own="org.freedesktop.NetworkManager"/>
@@ -76,7 +88,19 @@
send_interface="org.freedesktop.NetworkManager"
send_member="SetLogging"/>
<!-- The org.freedesktop.NetworkManager.Settings.Connection.Secrets
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
send_member="Sleep"/>
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
send_member="sleep"/>
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
send_member="wake"/>
<!-- The org.freedesktop.NetworkManagerSettings.Connection.Secrets
interface is secured via PolicyKit.
-->
</policy>

View File

@@ -53,6 +53,10 @@ if TARGET_PARDUS
libnmbackend_la_SOURCES += NetworkManagerPardus.c
endif
if TARGET_LINEXA
libnmbackend_la_SOURCES += NetworkManagerLinexa.c
endif
libnmbackend_la_LIBADD += \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \

View File

@@ -0,0 +1,66 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* Matthew Garrett <mjg59@srcf.ucam.org>
*
* Heavily based on NetworkManagerRedhat.c by Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 Tom Parker
* (C) Copyright 2004 Matthew Garrett
* (C) Copyright 2004 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "NetworkManagerGeneric.h"
#include "nm-system.h"
#include "NetworkManagerUtils.h"
#include "nm-logging.h"
/*
* nm_system_enable_loopback
*
* Bring up the loopback interface
*
*/
void nm_system_enable_loopback (void)
{
nm_generic_enable_loopback ();
}
/*
* 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");
}
}

View File

@@ -17,6 +17,7 @@
*
*/
#include <config.h>
#include <glib.h>
#include <string.h>
#include <sys/types.h>

View File

@@ -512,6 +512,8 @@ dhclient_start (NMDHCPClient *client,
uuid = nm_dhcp_client_get_uuid (client);
ipv6 = nm_dhcp_client_get_ipv6 (client);
log_domain = ipv6 ? LOGD_DHCP6 : LOGD_DHCP4;
#if defined(DHCLIENT_V3)
if (ipv6) {
nm_log_warn (log_domain, "(%s): ISC dhcp3 does not support IPv6", iface);
@@ -521,8 +523,6 @@ dhclient_start (NMDHCPClient *client,
g_return_val_if_fail (ip_opt != NULL, -1);
#endif
log_domain = ipv6 ? LOGD_DHCP6 : LOGD_DHCP4;
priv->pid_file = g_strdup_printf (LOCALSTATEDIR "/run/dhclient%s-%s.pid",
ipv6 ? "6" : "",
iface);

View File

@@ -18,6 +18,7 @@
*
*/
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

View File

@@ -18,6 +18,7 @@
*
*/
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

View File

@@ -572,7 +572,7 @@ update_dns (NMDnsManager *self,
priv = NM_DNS_MANAGER_GET_PRIVATE (self);
if (iface) {
if (iface && (iface != priv->last_iface)) {
g_free (priv->last_iface);
priv->last_iface = g_strdup (iface);
}

View File

@@ -17,6 +17,7 @@
*
*/
#include <config.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
@@ -106,7 +107,7 @@ kill_existing (const char *progname, const char *pidfile, const char *kill_match
goto out;
if (strstr (cmdline_contents, kill_match)) {
if (kill (pid, 0)) {
if (kill (pid, 0) == 0) {
nm_log_dbg (LOGD_DNS, "Killing stale %s child process %ld", progname, pid);
kill (pid, SIGKILL);
}

View File

@@ -18,6 +18,7 @@
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*/
#include <config.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
@@ -385,7 +386,7 @@ kill_existing_for_iface (const char *iface, const char *pidfile)
goto out;
if (strstr (cmdline_contents, "bin/dnsmasq")) {
if (kill (pid, 0)) {
if (kill (pid, 0) == 0) {
nm_log_dbg (LOGD_SHARING, "Killing stale dnsmasq process %ld", pid);
kill (pid, SIGKILL);
}

View File

@@ -78,30 +78,17 @@ typedef enum
#define NM_ETHERNET_ERROR (nm_ethernet_error_quark ())
#define NM_TYPE_ETHERNET_ERROR (nm_ethernet_error_get_type ())
typedef struct SupplicantStateTask {
NMDeviceEthernet *self;
guint32 new_state;
guint32 old_state;
gboolean mgr_task;
guint source_id;
} SupplicantStateTask;
typedef struct Supplicant {
NMSupplicantManager *mgr;
NMSupplicantInterface *iface;
/* signal handler ids */
guint mgr_state_id;
guint iface_error_id;
guint iface_state_id;
guint iface_con_state_id;
/* Timeouts and idles */
guint iface_con_error_cb_id;
guint con_timeout_id;
GSList *iface_tasks;
GSList *mgr_tasks;
} Supplicant;
typedef struct {
@@ -996,30 +983,6 @@ remove_supplicant_timeouts (NMDeviceEthernet *self)
}
}
static void
finish_supplicant_task (SupplicantStateTask *task, gboolean remove_source)
{
NMDeviceEthernet *self = task->self;
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
/* idle/timeout handlers should pass FALSE for remove_source, since they
* will tell glib to remove their source from the mainloop by returning
* FALSE when they exit. When called from this NMDevice's dispose handler,
* remove_source should be TRUE to cancel all outstanding idle/timeout
* handlers asynchronously.
*/
if (task->source_id && remove_source)
g_source_remove (task->source_id);
if (task->mgr_task)
priv->supplicant.mgr_tasks = g_slist_remove (priv->supplicant.mgr_tasks, task);
else
priv->supplicant.iface_tasks = g_slist_remove (priv->supplicant.iface_tasks, task);
memset (task, 0, sizeof (SupplicantStateTask));
g_slice_free (SupplicantStateTask, task);
}
static void
remove_supplicant_interface_error_handler (NMDeviceEthernet *self)
{
@@ -1044,28 +1007,14 @@ supplicant_interface_release (NMDeviceEthernet *self)
remove_supplicant_timeouts (self);
remove_supplicant_interface_error_handler (self);
/* Clean up all pending supplicant interface state idle tasks */
while (priv->supplicant.iface_tasks)
finish_supplicant_task ((SupplicantStateTask *) priv->supplicant.iface_tasks->data, TRUE);
if (priv->supplicant.iface_con_state_id) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_con_state_id);
priv->supplicant.iface_con_state_id = 0;
}
if (priv->supplicant.iface_state_id > 0) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_state_id);
priv->supplicant.iface_state_id = 0;
}
if (priv->supplicant.mgr_state_id) {
g_signal_handler_disconnect (priv->supplicant.mgr, priv->supplicant.mgr_state_id);
priv->supplicant.mgr_state_id = 0;
}
if (priv->supplicant.iface) {
nm_supplicant_interface_disconnect (priv->supplicant.iface);
nm_supplicant_manager_release_iface (priv->supplicant.mgr, priv->supplicant.iface);
nm_supplicant_manager_iface_release (priv->supplicant.mgr, priv->supplicant.iface);
priv->supplicant.iface = NULL;
}
}
@@ -1127,77 +1076,6 @@ time_out:
return FALSE;
}
static gboolean
schedule_state_handler (NMDeviceEthernet *self,
GSourceFunc handler,
guint32 new_state,
guint32 old_state,
gboolean mgr_task)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
SupplicantStateTask *task;
if (new_state == old_state)
return TRUE;
task = g_slice_new0 (SupplicantStateTask);
if (!task) {
nm_log_err (LOGD_DEVICE, "Not enough memory to process supplicant manager state change.");
return FALSE;
}
task->self = self;
task->new_state = new_state;
task->old_state = old_state;
task->mgr_task = mgr_task;
task->source_id = g_idle_add (handler, task);
if (mgr_task)
priv->supplicant.mgr_tasks = g_slist_append (priv->supplicant.mgr_tasks, task);
else
priv->supplicant.iface_tasks = g_slist_append (priv->supplicant.iface_tasks, task);
return TRUE;
}
static gboolean
supplicant_mgr_state_cb_handler (gpointer user_data)
{
SupplicantStateTask *task = (SupplicantStateTask *) user_data;
NMDevice *device = NM_DEVICE (task->self);
/* If the supplicant went away, release the supplicant interface */
if (task->new_state == NM_SUPPLICANT_MANAGER_STATE_DOWN) {
supplicant_interface_release (task->self);
if (nm_device_get_state (device) > NM_DEVICE_STATE_UNAVAILABLE) {
nm_device_state_changed (device, NM_DEVICE_STATE_UNAVAILABLE,
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
}
}
finish_supplicant_task (task, FALSE);
return FALSE;
}
static void
supplicant_mgr_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
gpointer user_data)
{
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"(%s): supplicant manager state: %s -> %s",
nm_device_get_iface (NM_DEVICE (user_data)),
nm_supplicant_manager_state_to_string (old_state),
nm_supplicant_manager_state_to_string (new_state));
schedule_state_handler (NM_DEVICE_ETHERNET (user_data),
supplicant_mgr_state_cb_handler,
new_state,
old_state,
TRUE);
}
static NMSupplicantConfig *
build_supplicant_config (NMDeviceEthernet *self)
{
@@ -1224,20 +1102,33 @@ build_supplicant_config (NMDeviceEthernet *self)
return config;
}
static gboolean
supplicant_iface_state_cb_handler (gpointer user_data)
static void
supplicant_iface_state_cb (NMSupplicantInterface *iface,
guint32 new_state,
guint32 old_state,
gpointer user_data)
{
SupplicantStateTask *task = (SupplicantStateTask *) user_data;
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (task->self);
NMDevice *device = NM_DEVICE (task->self);
if (task->new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) {
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMDevice *device = NM_DEVICE (self);
NMSupplicantConfig *config;
const char *iface;
gboolean success = FALSE;
NMDeviceState devstate;
iface = nm_device_get_iface (device);
config = build_supplicant_config (task->self);
if (new_state == old_state)
return;
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"(%s): supplicant interface state: %s -> %s",
nm_device_get_iface (device),
nm_supplicant_interface_state_to_string (old_state),
nm_supplicant_interface_state_to_string (new_state));
devstate = nm_device_get_state (device);
switch (new_state) {
case NM_SUPPLICANT_INTERFACE_STATE_READY:
config = build_supplicant_config (self);
if (config) {
success = nm_supplicant_interface_set_config (priv->supplicant.iface, config);
g_object_unref (config);
@@ -1246,99 +1137,54 @@ supplicant_iface_state_cb_handler (gpointer user_data)
nm_log_err (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): couldn't send security "
"configuration to the supplicant.",
iface);
nm_device_get_iface (device));
}
} else {
nm_log_warn (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): couldn't build security configuration.",
iface);
nm_device_get_iface (device));
}
if (!success)
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED);
} else if (task->new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) {
NMDeviceState state = nm_device_get_state (device);
supplicant_interface_release (task->self);
if (nm_device_is_activating (device) || state == NM_DEVICE_STATE_ACTIVATED)
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
if (!success) {
nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED);
}
finish_supplicant_task (task, FALSE);
return FALSE;
}
static void
supplicant_iface_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
gpointer user_data)
{
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"(%s): supplicant interface state: %s -> %s",
nm_device_get_iface (NM_DEVICE (user_data)),
nm_supplicant_interface_state_to_string (old_state),
nm_supplicant_interface_state_to_string (new_state));
schedule_state_handler (NM_DEVICE_ETHERNET (user_data),
supplicant_iface_state_cb_handler,
new_state,
old_state,
FALSE);
}
static gboolean
supplicant_iface_connection_state_cb_handler (gpointer user_data)
{
SupplicantStateTask *task = (SupplicantStateTask *) user_data;
NMDevice *dev = NM_DEVICE (task->self);
if (task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED) {
remove_supplicant_interface_error_handler (task->self);
remove_supplicant_timeouts (task->self);
break;
case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED:
remove_supplicant_interface_error_handler (self);
remove_supplicant_timeouts (self);
/* If this is the initial association during device activation,
* schedule the next activation stage.
*/
if (nm_device_get_state (dev) == NM_DEVICE_STATE_CONFIG) {
if (devstate == NM_DEVICE_STATE_CONFIG) {
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired) Stage 2 of 5 (Device Configure) successful.",
nm_device_get_iface (dev));
nm_device_activate_schedule_stage3_ip_config_start (dev);
nm_device_get_iface (device));
nm_device_activate_schedule_stage3_ip_config_start (device);
}
} else if (task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED) {
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED || nm_device_is_activating (dev)) {
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (task->self);
break;
case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED:
if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) {
/* Start the link timeout so we allow some time for reauthentication */
if (!priv->supplicant_timeout_id)
priv->supplicant_timeout_id = g_timeout_add_seconds (15, link_timeout_cb, dev);
priv->supplicant_timeout_id = g_timeout_add_seconds (15, link_timeout_cb, device);
}
break;
case NM_SUPPLICANT_INTERFACE_STATE_DOWN:
supplicant_interface_release (self);
remove_supplicant_timeouts (self);
if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
}
break;
default:
break;
}
finish_supplicant_task (task, FALSE);
return FALSE;
}
static void
supplicant_iface_connection_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
gpointer user_data)
{
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"(%s) supplicant connection state: %s -> %s",
nm_device_get_iface (NM_DEVICE (user_data)),
nm_supplicant_interface_connection_state_to_string (old_state),
nm_supplicant_interface_connection_state_to_string (new_state));
schedule_state_handler (NM_DEVICE_ETHERNET (user_data),
supplicant_iface_connection_state_cb_handler,
new_state,
old_state,
FALSE);
}
static gboolean
@@ -1456,13 +1302,12 @@ supplicant_interface_init (NMDeviceEthernet *self)
iface = nm_device_get_iface (NM_DEVICE (self));
/* Create supplicant interface */
priv->supplicant.iface = nm_supplicant_manager_get_iface (priv->supplicant.mgr, iface, FALSE);
priv->supplicant.iface = nm_supplicant_manager_iface_get (priv->supplicant.mgr, iface, FALSE);
if (!priv->supplicant.iface) {
nm_log_err (LOGD_DEVICE | LOGD_ETHER,
"Couldn't initialize supplicant interface for %s.",
iface);
supplicant_interface_release (self);
return FALSE;
}
@@ -1478,17 +1323,6 @@ supplicant_interface_init (NMDeviceEthernet *self)
G_CALLBACK (supplicant_iface_connection_error_cb),
self);
priv->supplicant.iface_con_state_id = g_signal_connect (priv->supplicant.iface,
"connection-state",
G_CALLBACK (supplicant_iface_connection_state_cb),
self);
/* Listen for supplicant manager state changes */
priv->supplicant.mgr_state_id = g_signal_connect (priv->supplicant.mgr,
"state",
G_CALLBACK (supplicant_mgr_state_cb),
self);
/* Set up a timeout on the connection attempt to fail it after 25 seconds */
priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self);
@@ -2047,12 +1881,6 @@ dispose (GObject *object)
priv->disposed = TRUE;
/* Clean up all pending supplicant tasks */
while (priv->supplicant.iface_tasks)
finish_supplicant_task ((SupplicantStateTask *) priv->supplicant.iface_tasks->data, TRUE);
while (priv->supplicant.mgr_tasks)
finish_supplicant_task ((SupplicantStateTask *) priv->supplicant.mgr_tasks->data, TRUE);
if (priv->link_connected_id) {
g_signal_handler_disconnect (priv->monitor, priv->link_connected_id);
priv->link_connected_id = 0;

View File

@@ -113,34 +113,18 @@ typedef enum {
#define NM_WIFI_ERROR (nm_wifi_error_quark ())
#define NM_TYPE_WIFI_ERROR (nm_wifi_error_get_type ())
typedef struct SupplicantStateTask {
NMDeviceWifi *self;
guint32 new_state;
guint32 old_state;
gboolean mgr_task;
guint source_id;
} SupplicantStateTask;
#define SUP_SIG_ID_LEN 5
typedef struct Supplicant {
NMSupplicantManager *mgr;
NMSupplicantInterface *iface;
/* signal handler ids */
guint mgr_state_id;
guint sig_ids[SUP_SIG_ID_LEN];
guint iface_error_id;
guint iface_state_id;
guint iface_scanned_ap_id;
guint iface_scan_request_result_id;
guint iface_scan_results_id;
guint iface_con_state_id;
guint iface_notify_scanning_id;
/* Timeouts and idles */
guint iface_con_error_cb_id;
guint con_timeout_id;
GSList *mgr_tasks;
GSList *iface_tasks;
} Supplicant;
struct _NMDeviceWifiPrivate {
@@ -199,15 +183,10 @@ static void cleanup_association_attempt (NMDeviceWifi * self,
static void remove_supplicant_timeouts (NMDeviceWifi *self);
static void supplicant_iface_state_cb (NMSupplicantInterface * iface,
static void supplicant_iface_state_cb (NMSupplicantInterface *iface,
guint32 new_state,
guint32 old_state,
NMDeviceWifi *self);
static void supplicant_iface_connection_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
NMDeviceWifi *self);
gpointer user_data);
static void supplicant_iface_scanned_ap_cb (NMSupplicantInterface * iface,
GHashTable *properties,
@@ -221,11 +200,6 @@ static void supplicant_iface_scan_results_cb (NMSupplicantInterface * iface,
guint32 num_bssids,
NMDeviceWifi * self);
static void supplicant_mgr_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
NMDeviceWifi *self);
static void supplicant_iface_notify_scanning_cb (NMSupplicantInterface * iface,
GParamSpec * pspec,
NMDeviceWifi * self);
@@ -625,10 +599,7 @@ constructor (GType type,
/* Connect to the supplicant manager */
priv->supplicant.mgr = nm_supplicant_manager_get ();
priv->supplicant.mgr_state_id = g_signal_connect (priv->supplicant.mgr,
"state",
G_CALLBACK (supplicant_mgr_state_cb),
self);
g_assert (priv->supplicant.mgr);
/* The ipw2x00 drivers don't integrate with the kernel rfkill subsystem until
* 2.6.33. Thus all our nice libgudev magic is useless. So we get to poll.
@@ -657,17 +628,13 @@ static gboolean
supplicant_interface_acquire (NMDeviceWifi *self)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
guint id, mgr_state;
guint id, i = 0;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (priv->supplicant.mgr != NULL, FALSE);
/* interface already acquired? */
g_return_val_if_fail (priv->supplicant.iface == NULL, TRUE);
mgr_state = nm_supplicant_manager_get_state (priv->supplicant.mgr);
g_return_val_if_fail (mgr_state == NM_SUPPLICANT_MANAGER_STATE_IDLE, FALSE);
priv->supplicant.iface = nm_supplicant_manager_get_iface (priv->supplicant.mgr,
priv->supplicant.iface = nm_supplicant_manager_iface_get (priv->supplicant.mgr,
nm_device_get_iface (NM_DEVICE (self)),
TRUE);
if (priv->supplicant.iface == NULL) {
@@ -676,69 +643,41 @@ supplicant_interface_acquire (NMDeviceWifi *self)
return FALSE;
}
memset (priv->supplicant.sig_ids, 0, sizeof (priv->supplicant.sig_ids));
id = g_signal_connect (priv->supplicant.iface,
"state",
G_CALLBACK (supplicant_iface_state_cb),
self);
priv->supplicant.iface_state_id = id;
priv->supplicant.sig_ids[i++] = id;
id = g_signal_connect (priv->supplicant.iface,
"scanned-ap",
G_CALLBACK (supplicant_iface_scanned_ap_cb),
self);
priv->supplicant.iface_scanned_ap_id = id;
priv->supplicant.sig_ids[i++] = id;
id = g_signal_connect (priv->supplicant.iface,
"scan-req-result",
G_CALLBACK (supplicant_iface_scan_request_result_cb),
self);
priv->supplicant.iface_scan_request_result_id = id;
priv->supplicant.sig_ids[i++] = id;
id = g_signal_connect (priv->supplicant.iface,
"scan-results",
G_CALLBACK (supplicant_iface_scan_results_cb),
self);
priv->supplicant.iface_scan_results_id = id;
id = g_signal_connect (priv->supplicant.iface,
"connection-state",
G_CALLBACK (supplicant_iface_connection_state_cb),
self);
priv->supplicant.iface_con_state_id = id;
priv->supplicant.sig_ids[i++] = id;
id = g_signal_connect (priv->supplicant.iface,
"notify::scanning",
G_CALLBACK (supplicant_iface_notify_scanning_cb),
self);
priv->supplicant.iface_notify_scanning_id = id;
priv->supplicant.sig_ids[i++] = id;
return TRUE;
}
static void
finish_supplicant_task (SupplicantStateTask *task, gboolean remove_source)
{
NMDeviceWifi *self = task->self;
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
/* idle/timeout handlers should pass FALSE for remove_source, since they
* will tell glib to remove their source from the mainloop by returning
* FALSE when they exit. When called from this NMDevice's dispose handler,
* remove_source should be TRUE to cancel all outstanding idle/timeout
* handlers asynchronously.
*/
if (task->source_id && remove_source)
g_source_remove (task->source_id);
if (task->mgr_task)
priv->supplicant.mgr_tasks = g_slist_remove (priv->supplicant.mgr_tasks, task);
else
priv->supplicant.iface_tasks = g_slist_remove (priv->supplicant.iface_tasks, task);
memset (task, 0, sizeof (SupplicantStateTask));
g_slice_free (SupplicantStateTask, task);
}
static void
remove_supplicant_interface_error_handler (NMDeviceWifi *self)
{
@@ -762,6 +701,7 @@ static void
supplicant_interface_release (NMDeviceWifi *self)
{
NMDeviceWifiPrivate *priv;
guint i;
g_return_if_fail (self != NULL);
@@ -776,45 +716,18 @@ supplicant_interface_release (NMDeviceWifi *self)
remove_supplicant_interface_error_handler (self);
/* Clean up all pending supplicant interface state idle tasks */
while (priv->supplicant.iface_tasks)
finish_supplicant_task ((SupplicantStateTask *) priv->supplicant.iface_tasks->data, TRUE);
if (priv->supplicant.iface_state_id > 0) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_state_id);
priv->supplicant.iface_state_id = 0;
}
if (priv->supplicant.iface_scanned_ap_id > 0) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_scanned_ap_id);
priv->supplicant.iface_scanned_ap_id = 0;
}
if (priv->supplicant.iface_scan_request_result_id > 0) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_scan_request_result_id);
priv->supplicant.iface_scan_request_result_id = 0;
}
if (priv->supplicant.iface_scan_results_id > 0) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_scan_results_id);
priv->supplicant.iface_scan_results_id = 0;
}
if (priv->supplicant.iface_con_state_id > 0) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_con_state_id);
priv->supplicant.iface_con_state_id = 0;
}
if (priv->supplicant.iface_notify_scanning_id > 0) {
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.iface_notify_scanning_id);
priv->supplicant.iface_notify_scanning_id = 0;
/* Clear supplicant interface signal handlers */
for (i = 0; i < SUP_SIG_ID_LEN; i++) {
if (priv->supplicant.sig_ids[i] > 0)
g_signal_handler_disconnect (priv->supplicant.iface, priv->supplicant.sig_ids[i]);
}
memset (priv->supplicant.sig_ids, 0, sizeof (priv->supplicant.sig_ids));
if (priv->supplicant.iface) {
/* Tell the supplicant to disconnect from the current AP */
nm_supplicant_interface_disconnect (priv->supplicant.iface);
nm_supplicant_manager_release_iface (priv->supplicant.mgr, priv->supplicant.iface);
nm_supplicant_manager_iface_release (priv->supplicant.mgr, priv->supplicant.iface);
priv->supplicant.iface = NULL;
}
}
@@ -1837,11 +1750,11 @@ scanning_allowed (NMDeviceWifi *self)
}
/* Don't scan if the supplicant is busy */
sup_state = nm_supplicant_interface_get_connection_state (priv->supplicant.iface);
if ( sup_state == NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATING
|| sup_state == NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATED
|| sup_state == NM_SUPPLICANT_INTERFACE_CON_STATE_4WAY_HANDSHAKE
|| sup_state == NM_SUPPLICANT_INTERFACE_CON_STATE_GROUP_HANDSHAKE
sup_state = nm_supplicant_interface_get_state (priv->supplicant.iface);
if ( sup_state == NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING
|| sup_state == NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED
|| sup_state == NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE
|| sup_state == NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE
|| nm_supplicant_interface_get_scanning (priv->supplicant.iface))
return FALSE;
@@ -2441,148 +2354,72 @@ time_out:
return FALSE;
}
static gboolean
schedule_state_handler (NMDeviceWifi *self,
GSourceFunc handler,
static void
supplicant_iface_state_cb (NMSupplicantInterface *iface,
guint32 new_state,
guint32 old_state,
gboolean mgr_task)
gpointer user_data)
{
NMDeviceWifiPrivate *priv;
SupplicantStateTask *task;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (handler != NULL, FALSE);
NMDeviceWifi *self = NM_DEVICE_WIFI (user_data);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMDevice *device = NM_DEVICE (self);
NMDeviceState devstate;
gboolean scanning;
if (new_state == old_state)
return TRUE;
return;
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
nm_log_info (LOGD_DEVICE | LOGD_WIFI,
"(%s): supplicant interface state: %s -> %s",
nm_device_get_iface (device),
nm_supplicant_interface_state_to_string (old_state),
nm_supplicant_interface_state_to_string (new_state));
task = g_slice_new0 (SupplicantStateTask);
if (!task) {
nm_log_err (LOGD_WIFI, "Not enough memory to process supplicant manager state change.");
return FALSE;
}
devstate = nm_device_get_state (device);
scanning = nm_supplicant_interface_get_scanning (iface);
task->self = self;
task->new_state = new_state;
task->old_state = old_state;
task->mgr_task = mgr_task;
task->source_id = g_idle_add (handler, task);
if (mgr_task)
priv->supplicant.mgr_tasks = g_slist_append (priv->supplicant.mgr_tasks, task);
else
priv->supplicant.iface_tasks = g_slist_append (priv->supplicant.iface_tasks, task);
return TRUE;
}
static gboolean
supplicant_iface_state_cb_handler (gpointer user_data)
{
SupplicantStateTask *task = (SupplicantStateTask *) user_data;
NMDeviceWifi *self;
NMDeviceWifiPrivate *priv;
g_return_val_if_fail (task != NULL, FALSE);
self = task->self;
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
nm_log_info (LOGD_WIFI, "(%s): supplicant interface state: %s -> %s",
nm_device_get_iface (NM_DEVICE (self)),
nm_supplicant_interface_state_to_string (task->old_state),
nm_supplicant_interface_state_to_string (task->new_state));
if (task->new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) {
switch (new_state) {
case NM_SUPPLICANT_INTERFACE_STATE_READY:
priv->scan_interval = SCAN_INTERVAL_MIN;
/* If the interface can now be activated because the supplicant is now
* available, transition to DISCONNECTED.
*/
if ( (nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_UNAVAILABLE)
&& nm_device_is_available (NM_DEVICE (self))) {
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED,
if ((devstate == NM_DEVICE_STATE_UNAVAILABLE) && nm_device_is_available (device)) {
nm_device_state_changed (device,
NM_DEVICE_STATE_DISCONNECTED,
NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE);
}
nm_log_dbg (LOGD_WIFI_SCAN, "(%s): supplicant ready, requesting initial scan",
nm_device_get_iface (NM_DEVICE (self)));
nm_log_dbg (LOGD_WIFI_SCAN,
"(%s): supplicant ready, requesting initial scan",
nm_device_get_iface (device));
/* Request a scan to get latest results */
cancel_pending_scan (self);
request_wireless_scan (self);
} else if (task->new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) {
cleanup_association_attempt (self, FALSE);
supplicant_interface_release (self);
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_UNAVAILABLE,
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
}
finish_supplicant_task (task, FALSE);
return FALSE;
}
static void
supplicant_iface_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
NMDeviceWifi *self)
{
g_return_if_fail (self != NULL);
schedule_state_handler (self,
supplicant_iface_state_cb_handler,
new_state,
old_state,
FALSE);
}
static gboolean
supplicant_iface_connection_state_cb_handler (gpointer user_data)
{
SupplicantStateTask *task = (SupplicantStateTask *) user_data;
NMDeviceWifi *self = task->self;
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMDevice *dev = NM_DEVICE (self);
gboolean scanning;
if (!nm_device_get_act_request (dev)) {
/* The device is not activating or already activated; do nothing. */
goto out;
}
nm_log_info (LOGD_WIFI, "(%s): supplicant connection state: %s -> %s",
nm_device_get_iface (dev),
nm_supplicant_interface_connection_state_to_string (task->old_state),
nm_supplicant_interface_connection_state_to_string (task->new_state));
scanning = nm_supplicant_interface_get_scanning (priv->supplicant.iface);
if (task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED) {
break;
case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED:
remove_supplicant_interface_error_handler (self);
remove_supplicant_timeouts (self);
/* If this is the initial association during device activation,
* schedule the next activation stage.
*/
if (nm_device_get_state (dev) == NM_DEVICE_STATE_CONFIG) {
if (devstate == NM_DEVICE_STATE_CONFIG) {
NMAccessPoint *ap = nm_device_wifi_get_activation_ap (self);
const GByteArray * ssid = nm_ap_get_ssid (ap);
const GByteArray *ssid = nm_ap_get_ssid (ap);
nm_log_info (LOGD_DEVICE | LOGD_WIFI,
"Activation (%s/wireless) Stage 2 of 5 (Device Configure) "
"successful. Connected to wireless network '%s'.",
nm_device_get_iface (dev),
nm_device_get_iface (device),
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
nm_device_activate_schedule_stage3_ip_config_start (dev);
nm_device_activate_schedule_stage3_ip_config_start (device);
}
} else if (task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED) {
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED || nm_device_is_activating (dev)) {
break;
case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED:
if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) {
/* Start the link timeout so we allow some time for reauthentication,
* use a longer timeout if we are scanning since some cards take a
* while to scan.
@@ -2592,102 +2429,22 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
link_timeout_cb, self);
}
}
}
out:
/* Signal scanning state changes */
if ( task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING
|| task->old_state == NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING)
g_object_notify (G_OBJECT (self), "scanning");
finish_supplicant_task (task, FALSE);
return FALSE;
}
static void
supplicant_iface_connection_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
NMDeviceWifi *self)
{
g_return_if_fail (self != NULL);
schedule_state_handler (self,
supplicant_iface_connection_state_cb_handler,
new_state,
old_state,
FALSE);
}
static gboolean
supplicant_mgr_state_cb_handler (gpointer user_data)
{
SupplicantStateTask *task = (SupplicantStateTask *) user_data;
NMDeviceWifi *self;
NMDeviceWifiPrivate *priv;
NMDevice *dev;
NMDeviceState dev_state;
g_return_val_if_fail (task != NULL, FALSE);
self = task->self;
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
dev = NM_DEVICE (self);
nm_log_info (LOGD_WIFI, "(%s): supplicant manager state: %s -> %s",
nm_device_get_iface (NM_DEVICE (self)),
nm_supplicant_manager_state_to_string (task->old_state),
nm_supplicant_manager_state_to_string (task->new_state));
/* If the supplicant went away, release the supplicant interface */
if (task->new_state == NM_SUPPLICANT_MANAGER_STATE_DOWN) {
if (priv->supplicant.iface) {
break;
case NM_SUPPLICANT_INTERFACE_STATE_DOWN:
cleanup_association_attempt (self, FALSE);
supplicant_interface_release (self);
}
if (nm_device_get_state (dev) > NM_DEVICE_STATE_UNAVAILABLE) {
nm_device_state_changed (dev, NM_DEVICE_STATE_UNAVAILABLE,
nm_device_state_changed (device,
NM_DEVICE_STATE_UNAVAILABLE,
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
}
} else if (task->new_state == NM_SUPPLICANT_MANAGER_STATE_IDLE) {
dev_state = nm_device_get_state (dev);
if ( priv->enabled
&& !priv->supplicant.iface
&& (dev_state >= NM_DEVICE_STATE_UNAVAILABLE)
&& (nm_device_get_firmware_missing (NM_DEVICE (self)) == FALSE)) {
/* request a supplicant interface from the supplicant manager */
supplicant_interface_acquire (self);
/* if wireless is enabled and we have a supplicant interface,
* we can transition to the DISCONNECTED state.
*/
if (priv->supplicant.iface) {
nm_device_state_changed (dev, NM_DEVICE_STATE_DISCONNECTED,
NM_DEVICE_STATE_REASON_NONE);
}
}
break;
default:
break;
}
finish_supplicant_task (task, FALSE);
return FALSE;
}
static void
supplicant_mgr_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
NMDeviceWifi *self)
{
g_return_if_fail (self != NULL);
schedule_state_handler (self,
supplicant_mgr_state_cb_handler,
new_state,
old_state,
TRUE);
/* Signal scanning state changes */
if ( new_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING
|| old_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING)
g_object_notify (G_OBJECT (self), "scanning");
}
struct iface_con_error_cb_data {
@@ -3845,20 +3602,9 @@ dispose (GObject *object)
priv->periodic_source_id = 0;
}
/* Clean up all pending supplicant tasks */
while (priv->supplicant.iface_tasks)
finish_supplicant_task ((SupplicantStateTask *) priv->supplicant.iface_tasks->data, TRUE);
while (priv->supplicant.mgr_tasks)
finish_supplicant_task ((SupplicantStateTask *) priv->supplicant.mgr_tasks->data, TRUE);
cleanup_association_attempt (self, TRUE);
supplicant_interface_release (self);
if (priv->supplicant.mgr_state_id) {
g_signal_handler_disconnect (priv->supplicant.mgr, priv->supplicant.mgr_state_id);
priv->supplicant.mgr_state_id = 0;
}
if (priv->supplicant.mgr) {
g_object_unref (priv->supplicant.mgr);
priv->supplicant.mgr = NULL;

View File

@@ -19,6 +19,7 @@
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
#include <config.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>

View File

@@ -2472,6 +2472,7 @@ _internal_sleep (NMManager *self, gboolean do_sleep)
g_object_notify (G_OBJECT (self), NM_MANAGER_SLEEPING);
}
#if 0
static void
sleep_auth_done_cb (NMAuthChain *chain,
GError *error,
@@ -2510,6 +2511,7 @@ sleep_auth_done_cb (NMAuthChain *chain,
nm_auth_chain_unref (chain);
}
#endif
static void
impl_manager_sleep (NMManager *self,
@@ -2517,10 +2519,12 @@ impl_manager_sleep (NMManager *self,
DBusGMethodInvocation *context)
{
NMManagerPrivate *priv;
NMAuthChain *chain;
GError *error = NULL;
#if 0
NMAuthChain *chain;
gulong sender_uid = G_MAXULONG;
const char *error_desc = NULL;
#endif
g_return_if_fail (NM_IS_MANAGER (self));
@@ -2535,6 +2539,19 @@ impl_manager_sleep (NMManager *self,
return;
}
/* Unconditionally allow the request. Previously it was polkit protected
* but unfortunately that doesn't work for short-lived processes like
* pm-utils. It uses dbus-send without --print-reply, which quits
* immediately after sending the request, and NM is unable to obtain the
* sender's UID as dbus-send has already dropped off the bus. Thus NM
* fails the request. Instead, don't validate the request, but rely on
* D-Bus permissions to restrict the call to root.
*/
_internal_sleep (self, do_sleep);
dbus_g_method_return (context);
return;
#if 0
if (!nm_auth_get_caller_uid (context, priv->dbus_mgr, &sender_uid, &error_desc)) {
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_PERMISSION_DENIED,
@@ -2560,6 +2577,7 @@ impl_manager_sleep (NMManager *self,
nm_auth_chain_set_data (chain, "sleep", GUINT_TO_POINTER (do_sleep), NULL);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SLEEP_WAKE, TRUE);
#endif
}
static void

View File

@@ -217,7 +217,7 @@ nm_policy_set_system_hostname (const char *new_hostname,
char old_hostname[HOST_NAME_MAX + 1];
int ret = 0;
const char *name;
gboolean set_hostname = TRUE, changed = FALSE;
gboolean set_hostname = TRUE, changed = FALSE, old_valid = TRUE;
if (new_hostname)
g_warn_if_fail (strlen (new_hostname));
@@ -230,11 +230,15 @@ nm_policy_set_system_hostname (const char *new_hostname,
if (ret != 0) {
nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
errno, strerror (errno));
old_valid = FALSE;
} 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)))
set_hostname = FALSE;
if (old_hostname[0] == '\0')
old_valid = FALSE;
}
if (set_hostname) {
@@ -255,6 +259,7 @@ nm_policy_set_system_hostname (const char *new_hostname,
* /etc/hosts at all.
*/
if (!nm_policy_hosts_update_etc_hosts (name,
old_valid ? old_hostname : NULL,
FALLBACK_HOSTNAME4,
FALLBACK_HOSTNAME6,
ip4_addr,

View File

@@ -18,6 +18,7 @@
* Copyright (C) 2004 - 2010 Red Hat, Inc.
*/
#include <config.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
@@ -28,6 +29,9 @@
#include "nm-policy-hosts.h"
#include "nm-logging.h"
#define IP4_LH "127.0.0.1"
#define IP6_LH "::1"
gboolean
nm_policy_hosts_find_token (const char *line, const char *token)
{
@@ -56,13 +60,28 @@ nm_policy_hosts_find_token (const char *line, const char *token)
static gboolean
is_local_mapping (const char *str, gboolean ip6, const char *hostname)
{
const char *addr = ip6 ? "::1" : "127.0.0.1";
const char *addr = ip6 ? IP6_LH : IP4_LH;
const char *fallback = ip6 ? "localhost6" : "localhost";
return ( !strncmp (str, addr, strlen (addr))
&& nm_policy_hosts_find_token (str, hostname ? hostname : fallback));
}
static gboolean
is_ip4_addr (const char *str)
{
struct in_addr found;
char buf[INET_ADDRSTRLEN + 2];
const char *p = str;
guint32 i = 0;
memset (buf, 0, sizeof (buf));
while (*p && !isblank (*p) && (i < sizeof (buf)))
buf[i++] = *p++;
return inet_pton (AF_INET, buf, &found) == 1 ? TRUE : FALSE;
}
static gboolean
ip4_addr_matches (const char *str, const char *ip4_addr)
{
@@ -85,6 +104,21 @@ ip4_addr_matches (const char *str, const char *ip4_addr)
return memcmp (&found, &given, sizeof (found)) == 0;
}
static gboolean
is_ip6_addr (const char *str)
{
struct in6_addr found;
char buf[INET6_ADDRSTRLEN + 2];
const char *p = str;
guint32 i = 0;
memset (buf, 0, sizeof (buf));
while (*p && !isblank (*p) && (i < sizeof (buf)))
buf[i++] = *p++;
return inet_pton (AF_INET6, buf, &found) == 1 ? TRUE : FALSE;
}
static gboolean
ip6_addr_matches (const char *str, const char *ip6_addr)
{
@@ -107,12 +141,77 @@ ip6_addr_matches (const char *str, const char *ip6_addr)
return memcmp (&found, &given, sizeof (found)) == 0;
}
static char *
get_custom_hostnames (const char *line,
const char *hostname,
const char *old_hostname,
const char *short_hostname,
const char *fallback_hostname)
{
char **items = NULL, **iter;
guint start = 0;
GString *str = NULL;
char *custom = NULL;
g_return_val_if_fail (line != NULL, NULL);
if (!strncmp (line, IP4_LH, strlen (IP4_LH)))
start = strlen (IP4_LH);
else if (!strncmp (line, IP6_LH, strlen (IP6_LH)))
start = strlen (IP6_LH);
g_return_val_if_fail (start > 0, NULL);
/* Split the line into tokens */
items = g_strsplit_set (line + start, " \t", -1);
if (!items)
return NULL;
str = g_string_sized_new (50);
/* Ignore current & old hostnames, and localhost-anything */
for (iter = items; iter && *iter; iter++) {
if (*iter[0] == '\0')
continue;
if (hostname && !strcmp (*iter, hostname))
continue;
if (old_hostname && !strcmp (*iter, old_hostname))
continue;
if (short_hostname && !strcmp (*iter, short_hostname))
continue;
if (fallback_hostname && !strcmp (*iter, fallback_hostname))
continue;
if (!strcmp (*iter, "localhost"))
continue;
if (!strcmp (*iter, "localhost6"))
continue;
if (!strcmp (*iter, "localhost.localdomain"))
continue;
if (!strcmp (*iter, "localhost4.localdomain4"))
continue;
if (!strcmp (*iter, "localhost6.localdomain6"))
continue;
/* Found a custom hostname */
g_string_append_c (str, '\t');
g_string_append (str, *iter);
}
if (str->len)
custom = g_string_free (str, FALSE);
else
g_string_free (str, TRUE);
g_strfreev (items);
return custom;
}
#define ADDED_TAG "# Added by NetworkManager"
GString *
nm_policy_get_etc_hosts (const char **lines,
gsize existing_len,
const char *hostname,
const char *old_hostname,
const char *fallback_hostname4,
const char *fallback_hostname6,
const char *ip4_addr,
@@ -133,7 +232,10 @@ nm_policy_get_etc_hosts (const char **lines,
gboolean hostname6_is_fallback;
gboolean host4_before = FALSE;
gboolean host6_before = FALSE;
gboolean no_stale = TRUE;
char *short_hostname = NULL;
char *custom4 = NULL;
char *custom6 = NULL;
g_return_val_if_fail (lines != NULL, FALSE);
g_return_val_if_fail (hostname != NULL, FALSE);
@@ -141,72 +243,6 @@ nm_policy_get_etc_hosts (const char **lines,
hostname4_is_fallback = !strcmp (hostname, fallback_hostname4);
hostname6_is_fallback = !strcmp (hostname, fallback_hostname6);
/* We need the following in /etc/hosts:
*
* 1) current hostname mapped to current IPv4 addresses if IPv4 is active
* 2) current hostname mapped to current IPv6 addresses if IPv6 is active
* 3) 'localhost' mapped to 127.0.0.1
* 4) 'localhost6' mapped to ::1
*
* If all these things exist we don't need to bother updating the file.
*/
if (!ip4_addr) {
found_host4 = TRUE;
host4_before = TRUE;
}
if (!ip6_addr) {
found_host6 = TRUE;
host6_before = TRUE;
}
/* Look for the four cases from above */
for (line = lines; lines && *line; line++) {
if (!strlen (*line) || (*line[0] == '#'))
continue;
if (nm_policy_hosts_find_token (*line, hostname)) {
/* Found the current hostname on this line */
if (ip4_addr && ip4_addr_matches (*line, ip4_addr)) {
found_host4 = TRUE;
if (strstr (*line, ADDED_TAG)) {
if (!host4_before)
host4_before = !found_localhost4;
} else {
found_user_host4 = TRUE;
host4_before = TRUE; /* Ignore if user added mapping manually */
}
}
if (ip6_addr && ip6_addr_matches (*line, ip6_addr)) {
found_host6 = TRUE;
if (strstr (*line, ADDED_TAG)) {
if (!host6_before)
host6_before = !found_localhost6;
} else {
found_user_host6 = TRUE;
host6_before = TRUE; /* Ignore if user added mapping manually */
}
}
}
if (is_local_mapping (*line, FALSE, "localhost")) {
/* a 127.0.0.1 line containing 'localhost' */
found_localhost4 = TRUE;
} else if (is_local_mapping (*line, TRUE, "localhost6")) {
/* a ::1 line containing 'localhost6' */
found_localhost6 = TRUE;
}
if (found_localhost4 && found_host4 && found_localhost6 && found_host6 && host4_before && host6_before)
return NULL; /* No update required */
}
contents = g_string_sized_new (existing_len ? existing_len + 100 : 200);
if (!contents) {
g_set_error_literal (error, 0, 0, "not enough memory");
return NULL;
}
/* Find the short hostname, like 'foo' from 'foo.bar.baz'; we want to
* make sure that the entries we add for this host also include the short
* hostname too so that if the resolver does not answer queries for the
@@ -225,6 +261,112 @@ nm_policy_get_etc_hosts (const char **lines,
}
}
/* We need the following in /etc/hosts:
*
* 1) current hostname mapped to current IPv4 addresses if IPv4 is active
* 2) current hostname mapped to current IPv6 addresses if IPv6 is active
* 3) 'localhost' mapped to 127.0.0.1
* 4) 'localhost6' mapped to ::1
*
* If all these things exist we don't need to bother updating the file.
*/
if (!ip4_addr)
host4_before = TRUE;
if (!ip6_addr)
host6_before = TRUE;
/* Look for the four cases from above */
for (line = lines; lines && *line; line++) {
gboolean found_hostname = FALSE;
if ((*line[0] == '\0') || (*line[0] == '#'))
continue;
found_hostname = nm_policy_hosts_find_token (*line, hostname);
if (found_hostname) {
/* Found the current hostname on this line */
if (ip4_addr && ip4_addr_matches (*line, ip4_addr)) {
found_host4 = TRUE;
if (strstr (*line, ADDED_TAG)) {
if (!host4_before)
host4_before = !found_localhost4;
} else {
found_user_host4 = TRUE;
host4_before = TRUE; /* Ignore if user added mapping manually */
}
} else if (!ip4_addr && strstr (*line, ADDED_TAG)) {
/* If this is a stale NM-added IPv4 entry we need to remove it,
* so make sure we update /etc/hosts.
*/
if (is_ip4_addr (*line))
no_stale = FALSE;
}
if (ip6_addr && ip6_addr_matches (*line, ip6_addr)) {
found_host6 = TRUE;
if (strstr (*line, ADDED_TAG)) {
if (!host6_before)
host6_before = !found_localhost6;
} else {
found_user_host6 = TRUE;
host6_before = TRUE; /* Ignore if user added mapping manually */
}
} else if (!ip6_addr && strstr (*line, ADDED_TAG)) {
/* If this is a stale NM-added IPv6 entry we need to remove it,
* so make sure we update /etc/hosts.
*/
if (is_ip6_addr (*line))
no_stale = FALSE;
}
}
if (is_local_mapping (*line, FALSE, "localhost")) {
/* a 127.0.0.1 line containing 'localhost' */
found_localhost4 = TRUE;
custom4 = get_custom_hostnames (*line, hostname, old_hostname, short_hostname, fallback_hostname4);
if (!ip4_addr) {
/* If there's no IP-specific mapping for the current hostname
* but that hostname is present on in the local mapping line,
* we've found our IPv4 hostname mapping. If the hostname is
* the fallback *IPv6* hostname it's not going to show up in
* the IPv4 local mapping though, so fake it.
*/
if (hostname6_is_fallback || found_hostname)
found_host4 = TRUE;
}
} else if (is_local_mapping (*line, TRUE, "localhost6")) {
/* a ::1 line containing 'localhost6' */
found_localhost6 = TRUE;
custom6 = get_custom_hostnames (*line, hostname, old_hostname, short_hostname, fallback_hostname6);
if (!ip6_addr) {
/* If there's no IP-specific mapping for the current hostname
* but that hostname is present on in the local mapping line,
* we've found our IPv6 hostname mapping. If the hostname is
* the fallback *IPv4* hostname it's not going to show up in
* the IPv6 local mapping though, so fake it.
*/
if (hostname4_is_fallback || found_hostname)
found_host6 = TRUE;
}
}
if ( found_localhost4
&& found_host4
&& found_localhost6
&& found_host6
&& host4_before
&& host6_before
&& no_stale)
goto out; /* No update required */
}
contents = g_string_sized_new (existing_len ? existing_len + 100 : 200);
if (!contents) {
g_set_error_literal (error, 0, 0, "not enough memory");
goto out;
}
/* Construct the new hosts file; replace any 127.0.0.1/::1 entry that is
* at the beginning of the file or right after initial comments and contains
* the string 'localhost' (for IPv4) or 'localhost6' (for IPv6). If there
@@ -234,8 +376,6 @@ nm_policy_get_etc_hosts (const char **lines,
* 'localhost6'.
*/
for (line = lines, initial_comments = TRUE; lines && *line; line++) {
gboolean add_line = TRUE;
/* This is the first line after the initial comments */
if (strlen (*line) && initial_comments && (*line[0] != '#')) {
initial_comments = FALSE;
@@ -268,7 +408,10 @@ nm_policy_get_etc_hosts (const char **lines,
if (short_hostname)
g_string_append_printf (contents, "\t%s", short_hostname);
}
g_string_append_printf (contents, "\t%s\tlocalhost\n", fallback_hostname4);
g_string_append_printf (contents, "\t%s\tlocalhost", fallback_hostname4);
if (custom4)
g_string_append (contents, custom4);
g_string_append_c (contents, '\n');
/* IPv6 localhost line */
g_string_append (contents, "::1");
@@ -277,26 +420,23 @@ nm_policy_get_etc_hosts (const char **lines,
if (short_hostname)
g_string_append_printf (contents, "\t%s", short_hostname);
}
g_string_append_printf (contents, "\t%s\tlocalhost6\n", fallback_hostname6);
g_string_append_printf (contents, "\t%s\tlocalhost6", fallback_hostname6);
if (custom6)
g_string_append (contents, custom6);
g_string_append_c (contents, '\n');
added = TRUE;
}
/* Don't add the original line if it is a localhost mapping */
if (is_local_mapping (*line, FALSE, "localhost"))
add_line = FALSE;
else if (is_local_mapping (*line, FALSE, fallback_hostname4))
add_line = FALSE;
else if (is_local_mapping (*line, FALSE, hostname))
add_line = FALSE;
else if (is_local_mapping (*line, TRUE, "localhost6"))
add_line = FALSE;
else if (is_local_mapping (*line, TRUE, fallback_hostname6))
add_line = FALSE;
else if (is_local_mapping (*line, TRUE, hostname))
add_line = FALSE;
if ( !is_local_mapping (*line, FALSE, "localhost")
&& !is_local_mapping (*line, FALSE, fallback_hostname4)
&& !is_local_mapping (*line, FALSE, hostname)
&& !is_local_mapping (*line, TRUE, "localhost6")
&& !is_local_mapping (*line, TRUE, fallback_hostname6)
&& !is_local_mapping (*line, TRUE, hostname)
&& !strstr (*line, ADDED_TAG)) {
if (add_line && !strstr (*line, ADDED_TAG)) {
g_string_append (contents, *line);
/* Only append the new line if this isn't the last line in the file */
if (*(line+1))
@@ -327,12 +467,16 @@ nm_policy_get_etc_hosts (const char **lines,
g_string_append_printf (contents, "::1\t%s\tlocalhost6\n", fallback_hostname6);
}
out:
g_free (custom4);
g_free (custom6);
g_free (short_hostname);
return contents;
}
gboolean
nm_policy_hosts_update_etc_hosts (const char *hostname,
const char *old_hostname,
const char *fallback_hostname4,
const char *fallback_hostname6,
const char *ip4_addr,
@@ -362,6 +506,7 @@ nm_policy_hosts_update_etc_hosts (const char *hostname,
new_contents = nm_policy_get_etc_hosts ((const char **) lines,
contents_len,
hostname,
old_hostname,
fallback_hostname4,
fallback_hostname6,
ip4_addr,

View File

@@ -24,6 +24,7 @@
#include <glib.h>
gboolean nm_policy_hosts_update_etc_hosts (const char *hostname,
const char *old_hostname,
const char *fallback_hostname4,
const char *fallback_hostname6,
const char *ip4_addr,
@@ -36,6 +37,7 @@ gboolean nm_policy_hosts_find_token (const char *line, const char *token);
GString *nm_policy_get_etc_hosts (const char **lines,
gsize existing_len,
const char *hostname,
const char *old_hostname,
const char *fallback_hostname4,
const char *fallback_hostname6,
const char *ip4_addr,

View File

@@ -19,6 +19,7 @@
* Copyright (C) 2007 - 2008 Novell, Inc.
*/
#include <config.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
@@ -1226,6 +1227,15 @@ nm_policy_destroy (NMPolicy *policy)
}
g_slist_free (policy->dev_signal_ids);
/* Rewrite /etc/hosts on exit to ensure we don't leave stale IP addresses
* lying around. FIXME: this will take out a valid IP address of an
* ethernet device we're leaving active (ie, a connection we can "assume"
* when NM starts again).
*/
policy->default_device4 = NULL;
policy->default_device6 = NULL;
update_system_hostname (policy, NULL, NULL);
g_free (policy->orig_hostname);
g_free (policy->cur_hostname);

View File

@@ -1254,11 +1254,11 @@ dump_route (struct rtnl_route *route)
memset (buf4, 0, sizeof (buf4));
nl = rtnl_route_get_dst (route);
if (nl) {
if (rtnl_route_get_family (route) == AF_INET) {
if (nl_addr_get_family (nl) == AF_INET) {
addr4 = nl_addr_get_binary_addr (nl);
if (addr4)
inet_ntop (AF_INET, addr4, &buf4[0], sizeof (buf4));
} else if (rtnl_route_get_family (route) == AF_INET6) {
} else if (nl_addr_get_family (nl) == AF_INET6) {
addr6 = nl_addr_get_binary_addr (nl);
if (addr6)
inet_ntop (AF_INET6, addr6, &buf6[0], sizeof (buf6));

View File

@@ -19,6 +19,7 @@
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*/
#include <config.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2006 - 2008 Red Hat, Inc.
* Copyright (C) 2006 - 2010 Red Hat, Inc.
* Copyright (C) 2007 - 2008 Novell, Inc.
*/
@@ -26,47 +26,26 @@
#include <dbus/dbus.h>
#include "nm-supplicant-types.h"
G_BEGIN_DECLS
/*
* Supplicant interface states
* The states are linear, ie INIT -> READY -> DOWN and state may only be
* changed in one direction. If an interface reaches the DOWN state, it
* cannot be re-initialized; it must be torn down and a new one created.
*
* INIT: interface has been created, but cannot be used yet; it is waiting
* for pending requests of the supplicant to complete.
* READY: interface is ready for use
* DOWN: interface has been removed or has otherwise been made invalid; it
* must be torn down.
*
* Note: LAST is an invalid state and only used for boundary checking.
* A mix of wpa_supplicant interface states and internal states.
*/
enum {
NM_SUPPLICANT_INTERFACE_STATE_INIT = 0,
NM_SUPPLICANT_INTERFACE_STATE_STARTING,
NM_SUPPLICANT_INTERFACE_STATE_READY,
NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED,
NM_SUPPLICANT_INTERFACE_STATE_INACTIVE,
NM_SUPPLICANT_INTERFACE_STATE_SCANNING,
NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATING,
NM_SUPPLICANT_INTERFACE_STATE_ASSOCIATED,
NM_SUPPLICANT_INTERFACE_STATE_4WAY_HANDSHAKE,
NM_SUPPLICANT_INTERFACE_STATE_GROUP_HANDSHAKE,
NM_SUPPLICANT_INTERFACE_STATE_COMPLETED,
NM_SUPPLICANT_INTERFACE_STATE_DOWN,
NM_SUPPLICANT_INTERFACE_STATE_LAST
};
/*
* Supplicant interface connection states
* The wpa_supplicant state for the connection.
*/
enum {
NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED = 0,
NM_SUPPLICANT_INTERFACE_CON_STATE_INACTIVE,
NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING,
NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATING,
NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATED,
NM_SUPPLICANT_INTERFACE_CON_STATE_4WAY_HANDSHAKE,
NM_SUPPLICANT_INTERFACE_CON_STATE_GROUP_HANDSHAKE,
NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED,
NM_SUPPLICANT_INTERFACE_CON_STATE_LAST
};
#define NM_TYPE_SUPPLICANT_INTERFACE (nm_supplicant_interface_get_type ())
#define NM_SUPPLICANT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterface))
#define NM_SUPPLICANT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterfaceClass))
@@ -103,11 +82,6 @@ typedef struct {
void (*scan_results) (NMSupplicantInterface * iface,
guint num_bssids);
/* link state of the device's connection */
void (*connection_state) (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state);
/* an error occurred during a connection request */
void (*connection_error) (NMSupplicantInterface * iface,
const char * name,
@@ -119,7 +93,8 @@ GType nm_supplicant_interface_get_type (void);
NMSupplicantInterface * nm_supplicant_interface_new (NMSupplicantManager * smgr,
const char *ifname,
gboolean is_wireless);
gboolean is_wireless,
gboolean start_now);
gboolean nm_supplicant_interface_set_config (NMSupplicantInterface * iface,
NMSupplicantConfig * cfg);
@@ -128,18 +103,16 @@ void nm_supplicant_interface_disconnect (NMSupplicantInterface * iface);
const char * nm_supplicant_interface_get_device (NMSupplicantInterface * iface);
const char *nm_supplicant_interface_get_object_path (NMSupplicantInterface * iface);
gboolean nm_supplicant_interface_request_scan (NMSupplicantInterface * self);
guint32 nm_supplicant_interface_get_state (NMSupplicantInterface * self);
guint32 nm_supplicant_interface_get_connection_state (NMSupplicantInterface * self);
const char *nm_supplicant_interface_state_to_string (guint32 state);
const char *nm_supplicant_interface_connection_state_to_string (guint32 state);
gboolean nm_supplicant_interface_get_scanning (NMSupplicantInterface *self);
G_END_DECLS
const char *nm_supplicant_interface_get_ifname (NMSupplicantInterface *self);
#endif /* NM_SUPPLICANT_INTERFACE_H */

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2006 - 2008 Red Hat, Inc.
* Copyright (C) 2006 - 2010 Red Hat, Inc.
* Copyright (C) 2007 - 2008 Novell, Inc.
*/
@@ -26,19 +26,7 @@
#include "nm-supplicant-manager.h"
#include "nm-supplicant-interface.h"
#include "nm-dbus-manager.h"
#include "nm-marshal.h"
#include "nm-logging.h"
#include "nm-glib-compat.h"
#define SUPPLICANT_POKE_INTERVAL 120
typedef struct {
NMDBusManager * dbus_mgr;
guint32 state;
GSList * ifaces;
gboolean dispose_has_run;
guint poke_id;
} NMSupplicantManagerPrivate;
#define NM_SUPPLICANT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
NM_TYPE_SUPPLICANT_MANAGER, \
@@ -46,252 +34,59 @@ typedef struct {
G_DEFINE_TYPE (NMSupplicantManager, nm_supplicant_manager, G_TYPE_OBJECT)
static void nm_supplicant_manager_name_owner_changed (NMDBusManager *dbus_mgr,
const char *name,
const char *old,
const char *new,
gpointer user_data);
static void nm_supplicant_manager_set_state (NMSupplicantManager * self,
guint32 new_state);
static gboolean nm_supplicant_manager_startup (NMSupplicantManager * self);
/* Signals */
/* Properties */
enum {
STATE, /* change in the manager's state */
LAST_SIGNAL
PROP_0 = 0,
PROP_AVAILABLE,
LAST_PROP
};
static guint nm_supplicant_manager_signals[LAST_SIGNAL] = { 0 };
NMSupplicantManager *
nm_supplicant_manager_get (void)
{
static NMSupplicantManager * singleton = NULL;
if (!singleton) {
singleton = NM_SUPPLICANT_MANAGER (g_object_new (NM_TYPE_SUPPLICANT_MANAGER, NULL));
} else {
g_object_ref (singleton);
}
g_assert (singleton);
return singleton;
}
static gboolean
poke_supplicant_cb (gpointer user_data)
{
NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data);
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
DBusGConnection *g_connection;
DBusGProxy *proxy;
const char *tmp = "ignoreme";
g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
proxy = dbus_g_proxy_new_for_name (g_connection,
WPAS_DBUS_SERVICE,
WPAS_DBUS_PATH,
WPAS_DBUS_INTERFACE);
if (!proxy) {
nm_log_warn (LOGD_SUPPLICANT, "Error: could not init wpa_supplicant proxy");
goto out;
}
nm_log_info (LOGD_SUPPLICANT, "Trying to start the supplicant...");
dbus_g_proxy_call_no_reply (proxy, "getInterface", G_TYPE_STRING, tmp, G_TYPE_INVALID);
g_object_unref (proxy);
out:
/* Reschedule the poke */
priv->poke_id = g_timeout_add_seconds (SUPPLICANT_POKE_INTERVAL,
poke_supplicant_cb,
(gpointer) self);
return FALSE;
}
static void
nm_supplicant_manager_init (NMSupplicantManager * self)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
typedef struct {
NMDBusManager * dbus_mgr;
guint name_owner_id;
DBusGProxy * proxy;
gboolean running;
GHashTable * ifaces;
guint die_count_reset_id;
guint die_count;
gboolean disposed;
} NMSupplicantManagerPrivate;
priv->dispose_has_run = FALSE;
priv->state = NM_SUPPLICANT_MANAGER_STATE_DOWN;
priv->dbus_mgr = nm_dbus_manager_get ();
priv->poke_id = 0;
/********************************************************************/
running = nm_supplicant_manager_startup (self);
g_signal_connect (priv->dbus_mgr,
"name-owner-changed",
G_CALLBACK (nm_supplicant_manager_name_owner_changed),
self);
if (!running) {
/* Try to activate the supplicant */
priv->poke_id = g_idle_add (poke_supplicant_cb, (gpointer) self);
}
}
static void
nm_supplicant_manager_dispose (GObject *object)
static inline gboolean
die_count_exceeded (guint32 count)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (object);
if (priv->dispose_has_run) {
G_OBJECT_CLASS (nm_supplicant_manager_parent_class)->dispose (object);
return;
}
priv->dispose_has_run = TRUE;
if (priv->poke_id) {
g_source_remove (priv->poke_id);
priv->poke_id = 0;
}
if (priv->dbus_mgr) {
g_object_unref (G_OBJECT (priv->dbus_mgr));
priv->dbus_mgr = NULL;
}
/* Chain up to the parent class */
G_OBJECT_CLASS (nm_supplicant_manager_parent_class)->dispose (object);
}
static void
nm_supplicant_manager_class_init (NMSupplicantManagerClass *klass)
{
GObjectClass * object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (NMSupplicantManagerPrivate));
object_class->dispose = nm_supplicant_manager_dispose;
/* Signals */
nm_supplicant_manager_signals[STATE] =
g_signal_new ("state",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NMSupplicantManagerClass, state),
NULL, NULL,
_nm_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
}
static void
nm_supplicant_manager_name_owner_changed (NMDBusManager *dbus_mgr,
const char *name,
const char *old_owner,
const char *new_owner,
gpointer user_data)
{
NMSupplicantManager * self = (NMSupplicantManager *) user_data;
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
gboolean old_owner_good = (old_owner && strlen (old_owner));
gboolean new_owner_good = (new_owner && strlen (new_owner));
/* Can't handle the signal if its not from the supplicant service */
if (strcmp (WPAS_DBUS_SERVICE, name) != 0)
return;
if (!old_owner_good && new_owner_good) {
gboolean running;
running = nm_supplicant_manager_startup (self);
if (running && priv->poke_id) {
g_source_remove (priv->poke_id);
priv->poke_id = 0;
}
} else if (old_owner_good && !new_owner_good) {
nm_supplicant_manager_set_state (self, NM_SUPPLICANT_MANAGER_STATE_DOWN);
if (priv->poke_id)
g_source_remove (priv->poke_id);
/* Poke the supplicant so that it gets activated by dbus system bus
* activation.
*/
priv->poke_id = g_idle_add (poke_supplicant_cb, (gpointer) self);
}
}
guint32
nm_supplicant_manager_get_state (NMSupplicantManager * self)
{
g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), FALSE);
return NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->state;
}
static void
nm_supplicant_manager_set_state (NMSupplicantManager * self, guint32 new_state)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
guint32 old_state;
if (new_state == priv->state)
return;
old_state = priv->state;
priv->state = new_state;
g_signal_emit (self,
nm_supplicant_manager_signals[STATE],
0,
priv->state,
old_state);
}
static gboolean
nm_supplicant_manager_startup (NMSupplicantManager * self)
{
gboolean running;
/* FIXME: convert to pending call */
running = nm_dbus_manager_name_has_owner (NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->dbus_mgr,
WPAS_DBUS_SERVICE);
if (running)
nm_supplicant_manager_set_state (self, NM_SUPPLICANT_MANAGER_STATE_IDLE);
return running;
return count > 2;
}
NMSupplicantInterface *
nm_supplicant_manager_get_iface (NMSupplicantManager * self,
nm_supplicant_manager_iface_get (NMSupplicantManager * self,
const char *ifname,
gboolean is_wireless)
{
NMSupplicantManagerPrivate *priv;
NMSupplicantInterface * iface = NULL;
GSList * elt;
NMSupplicantInterface *iface = NULL;
gboolean start_now;
g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL);
g_return_val_if_fail (ifname != NULL, NULL);
priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
/* Ensure we don't already have this interface */
for (elt = priv->ifaces; elt; elt = g_slist_next (elt)) {
NMSupplicantInterface * if_tmp = (NMSupplicantInterface *) elt->data;
if (!strcmp (ifname, nm_supplicant_interface_get_device (if_tmp))) {
iface = if_tmp;
break;
}
}
iface = g_hash_table_lookup (priv->ifaces, ifname);
if (!iface) {
/* If we're making the supplicant take a time out for a bit, don't
* let the supplicant interface start immediately, just let it hang
* around in INIT state until we're ready to talk to the supplicant
* again.
*/
start_now = !die_count_exceeded (priv->die_count);
nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname);
iface = nm_supplicant_interface_new (self, ifname, is_wireless);
iface = nm_supplicant_interface_new (self, ifname, is_wireless, start_now);
if (iface)
priv->ifaces = g_slist_append (priv->ifaces, iface);
g_hash_table_insert (priv->ifaces, g_strdup (ifname), iface);
} else {
nm_log_dbg (LOGD_SUPPLICANT, "(%s): returning existing supplicant interface", ifname);
}
@@ -300,44 +95,222 @@ nm_supplicant_manager_get_iface (NMSupplicantManager * self,
}
void
nm_supplicant_manager_release_iface (NMSupplicantManager * self,
NMSupplicantInterface * iface)
nm_supplicant_manager_iface_release (NMSupplicantManager *self,
NMSupplicantInterface *iface)
{
NMSupplicantManagerPrivate *priv;
GSList * elt;
const char *ifname, *op;
g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self));
g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (iface));
ifname = nm_supplicant_interface_get_ifname (iface);
g_assert (ifname);
priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
for (elt = priv->ifaces; elt; elt = g_slist_next (elt)) {
NMSupplicantInterface * if_tmp = (NMSupplicantInterface *) elt->data;
g_return_if_fail (g_hash_table_lookup (priv->ifaces, ifname) == iface);
if (if_tmp == iface) {
/* Remove the iface from the supplicant manager's list and
* dereference to match additional reference in get_iface.
*/
priv->ifaces = g_slist_remove_link (priv->ifaces, elt);
g_slist_free_1 (elt);
g_object_unref (iface);
break;
}
/* Ask wpa_supplicant to remove this interface */
op = nm_supplicant_interface_get_object_path (iface);
if (priv->running && priv->proxy && op) {
dbus_g_proxy_call_no_reply (priv->proxy, "removeInterface",
DBUS_TYPE_G_OBJECT_PATH, op,
G_TYPE_INVALID);
}
g_hash_table_remove (priv->ifaces, ifname);
}
const char *
nm_supplicant_manager_state_to_string (guint32 state)
gboolean
nm_supplicant_manager_available (NMSupplicantManager *self)
{
switch (state) {
case NM_SUPPLICANT_MANAGER_STATE_DOWN:
return "down";
case NM_SUPPLICANT_MANAGER_STATE_IDLE:
return "idle";
default:
break;
}
return "unknown";
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), FALSE);
if (die_count_exceeded (NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->die_count))
return FALSE;
return NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->running;
}
static void
set_running (NMSupplicantManager *self, gboolean now_running)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
gboolean old_available = nm_supplicant_manager_available (self);
priv->running = now_running;
if (old_available != nm_supplicant_manager_available (self))
g_object_notify (G_OBJECT (self), NM_SUPPLICANT_MANAGER_AVAILABLE);
}
static void
set_die_count (NMSupplicantManager *self, guint new_die_count)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
gboolean old_available = nm_supplicant_manager_available (self);
priv->die_count = new_die_count;
if (old_available != nm_supplicant_manager_available (self))
g_object_notify (G_OBJECT (self), NM_SUPPLICANT_MANAGER_AVAILABLE);
}
static gboolean
wpas_die_count_reset_cb (gpointer user_data)
{
NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data);
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
/* Reset the die count back to zero, which allows use of the supplicant again */
priv->die_count_reset_id = 0;
set_die_count (self, 0);
nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant die count reset");
return FALSE;
}
static void
name_owner_changed (NMDBusManager *dbus_mgr,
const char *name,
const char *old_owner,
const char *new_owner,
gpointer user_data)
{
NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data);
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
gboolean old_owner_good = (old_owner && strlen (old_owner));
gboolean new_owner_good = (new_owner && strlen (new_owner));
/* We only care about the supplicant here */
if (strcmp (WPAS_DBUS_SERVICE, name) != 0)
return;
if (!old_owner_good && new_owner_good) {
nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant started");
set_running (self, TRUE);
} else if (old_owner_good && !new_owner_good) {
nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant stopped");
/* Reschedule the die count reset timeout. Every time the supplicant
* dies we wait 10 seconds before resetting the counter. If the
* supplicant died more than twice before the timer is reset, then
* we don't try to talk to the supplicant for a while.
*/
if (priv->die_count_reset_id)
g_source_remove (priv->die_count_reset_id);
priv->die_count_reset_id = g_timeout_add_seconds (10, wpas_die_count_reset_cb, self);
set_die_count (self, priv->die_count + 1);
if (die_count_exceeded (priv->die_count)) {
nm_log_info (LOGD_SUPPLICANT,
"wpa_supplicant die count %d; ignoring for 10 seconds",
priv->die_count);
}
set_running (self, FALSE);
}
}
/*******************************************************************/
NMSupplicantManager *
nm_supplicant_manager_get (void)
{
static NMSupplicantManager *singleton = NULL;
if (!singleton)
singleton = NM_SUPPLICANT_MANAGER (g_object_new (NM_TYPE_SUPPLICANT_MANAGER, NULL));
else
g_object_ref (singleton);
g_assert (singleton);
return singleton;
}
static void
nm_supplicant_manager_init (NMSupplicantManager * self)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
DBusGConnection *bus;
priv->dbus_mgr = nm_dbus_manager_get ();
priv->name_owner_id = g_signal_connect (priv->dbus_mgr,
"name-owner-changed",
G_CALLBACK (name_owner_changed),
self);
priv->running = nm_dbus_manager_name_has_owner (priv->dbus_mgr, WPAS_DBUS_SERVICE);
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
priv->proxy = dbus_g_proxy_new_for_name (bus,
WPAS_DBUS_SERVICE,
WPAS_DBUS_PATH,
WPAS_DBUS_INTERFACE);
priv->ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
}
static void
set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static void
get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
case PROP_AVAILABLE:
g_value_set_boolean (value, nm_supplicant_manager_available (NM_SUPPLICANT_MANAGER (object)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
dispose (GObject *object)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (object);
if (priv->disposed)
goto out;
priv->disposed = TRUE;
if (priv->die_count_reset_id)
g_source_remove (priv->die_count_reset_id);
if (priv->dbus_mgr) {
if (priv->name_owner_id)
g_signal_handler_disconnect (priv->dbus_mgr, priv->name_owner_id);
g_object_unref (G_OBJECT (priv->dbus_mgr));
}
g_hash_table_destroy (priv->ifaces);
if (priv->proxy)
g_object_unref (priv->proxy);
out:
/* Chain up to the parent class */
G_OBJECT_CLASS (nm_supplicant_manager_parent_class)->dispose (object);
}
static void
nm_supplicant_manager_class_init (NMSupplicantManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (NMSupplicantManagerPrivate));
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->dispose = dispose;
g_object_class_install_property (object_class, PROP_AVAILABLE,
g_param_spec_boolean (NM_SUPPLICANT_MANAGER_AVAILABLE,
"Available",
"Available",
FALSE,
G_PARAM_READABLE));
}

View File

@@ -33,23 +33,6 @@
G_BEGIN_DECLS
/*
* Supplicant manager states
* Either state may transition to the other state at any time.
*
* DOWN: supplicant manager has been created, but cannot be used; the supplicant
* is either not running or has not yet been fully initialized.
* IDLE: supplicant manager is ready for use
*
* Note: LAST is an invalid state and only used for boundary checking.
*/
enum {
NM_SUPPLICANT_MANAGER_STATE_DOWN = 0,
NM_SUPPLICANT_MANAGER_STATE_IDLE,
NM_SUPPLICANT_MANAGER_STATE_LAST
};
#define NM_TYPE_SUPPLICANT_MANAGER (nm_supplicant_manager_get_type ())
#define NM_SUPPLICANT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManager))
#define NM_SUPPLICANT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManagerClass))
@@ -57,6 +40,8 @@ enum {
#define NM_IS_SUPPLICANT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_MANAGER))
#define NM_SUPPLICANT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_MANAGER, NMSupplicantManagerClass))
#define NM_SUPPLICANT_MANAGER_AVAILABLE "available"
struct _NMSupplicantManager
{
GObject parent;
@@ -65,24 +50,19 @@ struct _NMSupplicantManager
typedef struct
{
GObjectClass parent;
/* class members */
void (* state) (NMSupplicantManager * mgr, guint32 new_state, guint32 old_state);
} NMSupplicantManagerClass;
GType nm_supplicant_manager_get_type (void);
NMSupplicantManager * nm_supplicant_manager_get (void);
NMSupplicantManager *nm_supplicant_manager_get (void);
guint32 nm_supplicant_manager_get_state (NMSupplicantManager * mgr);
NMSupplicantInterface * nm_supplicant_manager_get_iface (NMSupplicantManager * mgr,
NMSupplicantInterface *nm_supplicant_manager_iface_get (NMSupplicantManager *mgr,
const char *ifname,
gboolean is_wireless);
void nm_supplicant_manager_release_iface (NMSupplicantManager * mgr,
NMSupplicantInterface * iface);
void nm_supplicant_manager_iface_release (NMSupplicantManager *mgr,
NMSupplicantInterface *iface);
const char *nm_supplicant_manager_state_to_string (guint32 state);
gboolean nm_supplicant_manager_available (NMSupplicantManager *mgr);
#endif /* NM_SUPPLICANT_MANAGER_H */

View File

@@ -123,6 +123,7 @@ static const struct Opt opt_table[] = {
{ "engine_id", TYPE_BYTES, 0, 0, FALSE, NULL },
{ "key_id", TYPE_BYTES, 0, 0, FALSE, NULL },
{ "fragment_size", TYPE_INT, 1, 2000, FALSE, NULL },
{ "proactive_key_caching", TYPE_INT, 0, 1, FALSE, NULL },
};

View File

@@ -149,6 +149,7 @@ constructor (GType type,
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_READ_ONLY, priv->read_only,
NM_SETTING_CONNECTION_TIMESTAMP, time (NULL),
NULL);
g_free (id);

View File

@@ -26,6 +26,8 @@
#define FALLBACK_HOSTNAME4 "localhost.localdomain"
#define FALLBACK_HOSTNAME6 "localhost6.localdomain6"
#define DEBUG 0
static void
test_generic (const char *before,
const char *after,
@@ -43,6 +45,7 @@ test_generic (const char *before,
newc = nm_policy_get_etc_hosts ((const char **) lines,
strlen (before),
hostname,
NULL,
FALLBACK_HOSTNAME4,
FALLBACK_HOSTNAME6,
ip4_addr,
@@ -56,11 +59,11 @@ test_generic (const char *before,
g_clear_error (&error);
} else if (after == NULL) {
/* No change to /etc/hosts required */
#if 0
#if DEBUG
if (newc != NULL) {
g_message ("\n- NEW ---------------------------------\n"
"%s"
"- EXPECTED NONE -------------------------\n",
"+ EXPECTED NONE +++++++++++++++++++++++++\n",
newc->str);
}
#endif
@@ -70,10 +73,10 @@ test_generic (const char *before,
g_assert (newc != NULL);
g_assert (error == NULL);
#if 0
#if DEBUG
g_message ("\n- NEW ---------------------------------\n"
"%s"
"- EXPECTED ------------------------------\n"
"+ EXPECTED ++++++++++++++++++++++++++++++\n"
"%s"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
newc->str, after);
@@ -167,10 +170,17 @@ static const char *named_generic_before = \
"::1 localhost6.localdomain6 localhost6\n"
"127.0.0.1 lcmd.us.intellitxt.com\n";
static const char *named_generic_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 playboy localhost.localdomain localhost\n"
"::1 playboy localhost6.localdomain6 localhost6\n"
"127.0.0.1 lcmd.us.intellitxt.com\n";
static void
test_hosts_named_generic (void)
{
test_generic (named_generic_before, NULL, "playboy", NULL, NULL, FALSE);
test_generic (named_generic_before, named_generic_after, "playboy", NULL, NULL, FALSE);
}
/*******************************************/
@@ -609,24 +619,178 @@ static const char *long_before = \
"127.0.0.1 ad.doubleclick.net\n"
"127.0.0.1 oascentral.movietickets.com\n"
"127.0.0.1 view.atdmt.com\n"
"127.0.0.1 ads.chumcity.com\n"
"127.0.0.1 ads.as4x.tmcs.net\n"
"127.0.0.1 n4403ad.doubleclick.net\n"
"127.0.0.1 www.assoc-amazon.com\n"
"127.0.0.1 s25.sitemeter.com\n"
"127.0.0.1 adlog.com.com\n"
"127.0.0.1 ahs.laptopmag.com\n"
"127.0.0.1 altfarm.mediaplex.com\n"
"127.0.0.1 ads.addynamix.com\n"
"127.0.0.1 srx.main.ebayrtm.com\n"
"127.0.0.1 cdn5.tribalfusion.com\n"
"127.0.0.1 a.tribalfusion.com\n";
"127.0.0.1 ads.chumcity.com\n";
static const char *long_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost\n"
"::1 comet localhost6.localdomain6 localhost6\n"
"\n"
"127.0.0.1 lcmd.us.intellitxt.com\n"
"127.0.0.1 adserver.adtech.de\n"
"127.0.0.1 a.as-us.falkag.net\n"
"127.0.0.1 a.as-eu.falkag.net\n"
"127.0.0.1 ads.doubleclick.com\n"
"\n"
"# random comment\n"
"127.0.0.1 m1.2mdn.net\n"
"127.0.0.1 ds.serving-sys.com\n"
"127.0.0.1 pagead2.googlesyndication.com\n"
"127.0.0.1 ad.doubleclick.com\n"
"127.0.0.1 ad.doubleclick.net\n"
"127.0.0.1 oascentral.movietickets.com\n"
"127.0.0.1 view.atdmt.com\n"
"127.0.0.1 ads.chumcity.com\n";
static void
test_hosts_long (void)
{
test_generic (long_before, NULL, "comet", NULL, NULL, FALSE);
test_generic (long_before, long_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
static const char *custom4_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 localhost.localdomain localhost pintglass\n"
"::1 localhost6.localdomain6 localhost6\n";
static const char *custom4_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost pintglass\n"
"::1 comet localhost6.localdomain6 localhost6\n";
static void
test_hosts_custom4 (void)
{
test_generic (custom4_before, custom4_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
static const char *custom6_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 localhost.localdomain localhost\n"
"::1 localhost6.localdomain6 localhost6 pintglass\n";
static const char *custom6_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost\n"
"::1 comet localhost6.localdomain6 localhost6 pintglass\n";
static void
test_hosts_custom6 (void)
{
test_generic (custom6_before, custom6_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
static const char *custom46_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 localhost.localdomain localhost shotglass\n"
"::1 localhost6.localdomain6 localhost6 pintglass\n";
static const char *custom46_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost shotglass\n"
"::1 comet localhost6.localdomain6 localhost6 pintglass\n";
static void
test_hosts_custom46 (void)
{
test_generic (custom46_before, custom46_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
static const char *custom46_mixed_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 localhost.localdomain localhost shotglass\n"
"::1 localhost6.localdomain6 localhost6 pintglass\n";
static const char *custom46_mixed_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost shotglass\n"
"::1 comet localhost6.localdomain6 localhost6 pintglass\n";
static void
test_hosts_custom46_mixed (void)
{
test_generic (custom46_mixed_before, custom46_mixed_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
static const char *stale4_removed_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"1.2.3.4 comet # Added by NetworkManager\n"
"127.0.0.1 localhost.localdomain localhost\n"
"::1 comet localhost6.localdomain6 localhost6\n";
static const char *stale4_removed_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost\n"
"::1 comet localhost6.localdomain6 localhost6\n";
static void
test_hosts_stale4_removed (void)
{
test_generic (stale4_removed_before, stale4_removed_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
static const char *stale6_removed_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"3001:abba::3234 comet # Added by NetworkManager\n"
"127.0.0.1 comet localhost.localdomain localhost\n"
"::1 localhost6.localdomain6 localhost6\n";
static const char *stale6_removed_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost\n"
"::1 comet localhost6.localdomain6 localhost6\n";
static void
test_hosts_stale6_removed (void)
{
test_generic (stale6_removed_before, stale6_removed_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
static const char *stale46_removed_before = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"1.2.3.4 comet # Added by NetworkManager\n"
"3001:abba::3234 comet # Added by NetworkManager\n"
"127.0.0.1 localhost.localdomain localhost\n"
"::1 localhost6.localdomain6 localhost6\n";
static const char *stale46_removed_after = \
"# Do not remove the following line, or various programs\n"
"# that require network functionality will fail.\n"
"127.0.0.1 comet localhost.localdomain localhost\n"
"::1 comet localhost6.localdomain6 localhost6\n";
static void
test_hosts_stale46_removed (void)
{
test_generic (stale46_removed_before, stale46_removed_after, "comet", NULL, NULL, FALSE);
}
/*******************************************/
@@ -712,6 +876,13 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_hosts_no_host4, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_no_host6, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_long, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_custom4, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_custom6, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_custom46, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_custom46_mixed, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_stale4_removed, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_stale6_removed, NULL));
g_test_suite_add (suite, TESTCASE (test_hosts_stale46_removed, NULL));
return g_test_run ();
}

View File

@@ -19,6 +19,7 @@
* Copyright (C) 2005 - 2008 Novell, Inc.
*/
#include <config.h>
#include <glib.h>
#include <string.h>
#include <dbus/dbus.h>

View File

@@ -18,6 +18,7 @@
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

View File

@@ -1021,6 +1021,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
guint32 i, num;
GString *searches;
gboolean success = FALSE;
gboolean fake_ip4 = FALSE;
const char *method = NULL;
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
@@ -1058,15 +1059,19 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
return TRUE;
}
value = nm_setting_ip4_config_get_method (s_ip4);
g_assert (value);
if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
/* Temporarily create fake IP4 setting if missing; method set to DHCP above */
if (!s_ip4) {
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
fake_ip4 = TRUE;
}
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
svSetValue (ifcfg, "BOOTPROTO", "dhcp", FALSE);
else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
svSetValue (ifcfg, "BOOTPROTO", "none", FALSE);
else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
svSetValue (ifcfg, "BOOTPROTO", "autoip", FALSE);
else if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
svSetValue (ifcfg, "BOOTPROTO", "shared", FALSE);
num = nm_setting_ip4_config_get_num_addresses (s_ip4);
@@ -1156,7 +1161,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
svSetValue (ifcfg, "PEERROUTES", NULL, FALSE);
svSetValue (ifcfg, "DHCP_HOSTNAME", NULL, FALSE);
svSetValue (ifcfg, "DHCP_CLIENT_ID", NULL, FALSE);
if (!strcmp (value, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
svSetValue (ifcfg, "PEERDNS",
nm_setting_ip4_config_get_ignore_auto_dns (s_ip4) ? "no" : "yes",
FALSE);
@@ -1264,6 +1269,9 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
success = TRUE;
out:
if (fake_ip4)
g_object_unref (s_ip4);
return success;
}

View File

@@ -19,6 +19,7 @@
* Copyright (C) 1999-2010 Gentoo Foundation, Inc.
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>