Merge branch 'master' into cli-output

Conflicts:
	man/Makefile.am
This commit is contained in:
Jiří Klimeš 2010-04-26 10:44:28 +02:00
commit 825d999a05
99 changed files with 7971 additions and 2263 deletions

View file

@ -164,6 +164,14 @@ if test x"$with_distro" = xpardus; then
AC_DEFINE(TARGET_PARDUS, 1, [Define if you have Pardus])
fi
dnl
dnl Distribution version string
dnl
AC_ARG_WITH(dist-version, AS_HELP_STRING([--with-dist-version=<NM-distribution-version>], [Define the NM's distribution version string]), ac_distver=$withval, ac_distver="")
if ! test x"$ac_distver" = x""; then
AC_DEFINE_UNQUOTED(NM_DIST_VERSION, "$ac_distver", [Define the distribution version string])
fi
AC_MSG_CHECKING([Linux Wireless Extensions >= 18])
AC_TRY_COMPILE([#ifndef __user
#define __user
@ -440,6 +448,7 @@ include/Makefile
src/Makefile
src/tests/Makefile
marshallers/Makefile
src/logging/Makefile
src/named-manager/Makefile
src/vpn-manager/Makefile
src/dhcp-manager/Makefile

View file

@ -128,6 +128,7 @@ write_one_setting (FILE *f, SettingNewFunc func)
value_desc = g_param_spec_get_blurb (*iter);
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (*iter));
g_param_value_set_default (*iter, &value);
default_value = g_strdup_value_contents (&value);
if (default_value && !strcmp (default_value, "NULL")) {
g_free (default_value);

View file

@ -34,23 +34,26 @@ IGNORE_HFILES= \
nm-device-private.h \
nm-object-cache.h \
nm-object-private.h \
nm-remote-connection-private.h \
nm-types-private.h \
nm-access-point-bindings.h \
nm-active-connection-bindings.h \
nm-client-bindings.h \
nm-device-bindings.h \
nm-device-bt-bindings.h \
nm-device-ethernet-bindings.h \
nm-device-wifi-bindings.h \
nm-exported-connection-glue.h \
nm-dhcp4-config-bindings.h \
nm-dhcp6-config-bindings.h \
nm-exported-connection-bindings.h \
nm-settings-glue.h \
nm-exported-connection-glue.h \
nm-ip4-config-bindings.h \
nm-ip6-config-bindings.h \
nm-settings-bindings.h \
nm-settings-glue.h \
nm-settings-system-bindings.h \
nm-vpn-connection-bindings.h \
nm-vpn-plugin-glue.h \
nm-active-connection-bindings.h \
nm-ip4-config-bindings.h \
nm-dhcp4-config-bindings.h \
nm-ip4-config-bindings.h
nm-vpn-plugin-glue.h
# Images to copy into HTML directory.
HTML_IMAGES =

View file

@ -5,35 +5,40 @@
<bookinfo>
<title>libnm-glib Reference Manual</title>
<releaseinfo>
for libnm-glib [VERSION]
for libnm-glib 0.8
The latest version of this documentation can be found on-line at
<ulink role="online-location" url="http://[SERVER]/libnm-glib/index.html">http://[SERVER]/libnm-glib/</ulink>.
<ulink role="online-location" url="http://projects.gnome.org/NetworkManager/developers/libnm-glib/08/">http://projects.gnome.org/NetworkManager/developers/libnm-glib/08/</ulink>.
</releaseinfo>
</bookinfo>
<chapter>
<title>[Insert title here]</title>
<xi:include href="xml/nm-access-point.xml"/>
<xi:include href="xml/nm-cdma-device.xml"/>
<title>libnm-glib Objects</title>
<xi:include href="xml/nm-client.xml"/>
<xi:include href="xml/nm-gsm-device.xml"/>
<xi:include href="xml/nm-device.xml"/>
<xi:include href="xml/nm-ip4-config.xml"/>
<xi:include href="xml/nm-ip6-config.xml"/>
<xi:include href="xml/nm-object.xml"/>
<xi:include href="xml/nm-settings.xml"/>
<xi:include href="xml/nm-vpn-connection.xml"/>
<xi:include href="xml/nm-vpn-plugin.xml"/>
<xi:include href="xml/nm-dbus-settings-system.xml"/>
<xi:include href="xml/nm-active-connection.xml"/>
<xi:include href="xml/nm-device.xml"/>
<xi:include href="xml/nm-device-ethernet.xml"/>
<xi:include href="xml/nm-device-wifi.xml"/>
<xi:include href="xml/nm-dbus-connection.xml"/>
<xi:include href="xml/nm-serial-device.xml"/>
<xi:include href="xml/nm-dbus-settings.xml"/>
<xi:include href="xml/nm-gsm-device.xml"/>
<xi:include href="xml/nm-cdma-device.xml"/>
<xi:include href="xml/nm-device-bt.xml"/>
<xi:include href="xml/nm-access-point.xml"/>
<xi:include href="xml/nm-ip4-config.xml"/>
<xi:include href="xml/nm-ip6-config.xml"/>
<xi:include href="xml/nm-dhcp4-config.xml"/>
<xi:include href="xml/nm-vpn-plugin-ui-interface.xml"/>
<xi:include href="xml/libnm_glib.xml"/>
<xi:include href="xml/nm-dhcp6-config.xml"/>
<xi:include href="xml/nm-exported-connection.xml"/>
<xi:include href="xml/nm-object.xml"/>
<xi:include href="xml/nm-remote-connection.xml"/>
<xi:include href="xml/nm-remote-settings.xml"/>
<xi:include href="xml/nm-remote-settings-system.xml"/>
<xi:include href="xml/nm-settings-connection-interface.xml"/>
<xi:include href="xml/nm-settings-interface.xml"/>
<xi:include href="xml/nm-settings-service.xml"/>
<xi:include href="xml/nm-settings-system-interface.xml"/>
<xi:include href="xml/nm-types.xml"/>
<xi:include href="xml/nm-vpn-connection.xml"/>
<xi:include href="xml/nm-vpn-plugin.xml"/>
<xi:include href="xml/nm-vpn-plugin-ui-interface.xml"/>
</chapter>
</book>

View file

@ -8,9 +8,9 @@
<bookinfo>
<title>libnm-util Reference Manual</title>
<releaseinfo>
for libnm-util [VERSION]
for libnm-util 0.8
The latest version of this documentation can be found on-line at
<ulink role="online-location" url="http://[SERVER]/libnm-util/index.html">http://[SERVER]/libnm-util/</ulink>.
<ulink role="online-location" url="http://projects.gnome.org/NetworkManager/developers/libnm-util/08/">http://projects.gnome.org/NetworkManager/developers/libnm-util/08/</ulink>.
</releaseinfo>
</bookinfo>

View file

@ -96,6 +96,28 @@
</arg>
</method>
<method name="SetLogging">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_set_logging"/>
<tp:docstring>
Set logging verbosity and which operations are logged.
</tp:docstring>
<arg name="level" type="s" direction="in">
<tp:docstring>
One of [ERR, WARN, INFO, DEBUG].
</tp:docstring>
</arg>
<arg name="domains" type="s" direction="in">
<tp:docstring>
A combination of logging domains separated by commas (','), or "NONE"
to disable logging. Each domain enables logging for operations
related to that domain. Available domains are: [NONE, HW, RKILL,
ETHER, WIFI, BT, MB, DHCP4, DHCP6, PPP, WIFI_SCAN, IP4, IP6, AUTOIP4,
DNS, VPN, SHARING, SUPPLICANT, USER_SET, SYS_SET, SUSPEND, CORE,
DEVICE, OLPC]
</tp:docstring>
</arg>
</method>
<property name="WirelessEnabled" type="b" access="readwrite">
<tp:docstring>
Indicates if wireless is currently enabled or not.

View file

@ -129,6 +129,7 @@ global:
nm_settings_connection_interface_get_type;
nm_settings_connection_interface_update;
nm_settings_interface_add_connection;
nm_settings_interface_error_get_type;
nm_settings_interface_error_quark;
nm_settings_interface_get_connection_by_path;
nm_settings_interface_get_type;

View file

@ -228,7 +228,9 @@ impl_exported_connection_get_secrets (NMExportedConnection *self,
if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets)
NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets (self, setting_name, hints, request_new, context);
else {
error = g_error_new (0, 0, "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
dbus_g_method_return_error (context, error);
g_error_free (error);
}

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include <string.h>
@ -324,12 +324,14 @@ constructor (GType type,
nm_connection_get_path (NM_CONNECTION (object)),
NM_DBUS_IFACE_SETTINGS_CONNECTION);
g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
priv->secrets_proxy = dbus_g_proxy_new_for_name (priv->bus,
service,
nm_connection_get_path (NM_CONNECTION (object)),
NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS);
g_assert (priv->secrets_proxy);
dbus_g_proxy_set_default_timeout (priv->secrets_proxy, G_MAXINT);
dbus_g_proxy_add_signal (priv->proxy, "Updated", DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Updated", G_CALLBACK (updated_cb), object, NULL);

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <string.h>
@ -280,6 +280,7 @@ constructor (GType type,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS_SYSTEM);
g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <string.h>
@ -414,6 +414,7 @@ constructor (GType type,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
dbus_g_proxy_add_signal (priv->proxy, "NewConnection",
DBUS_TYPE_G_OBJECT_PATH,

View file

@ -12,3 +12,6 @@ EXTRA_DIST = \
nm-system-settings.conf.5.in \
nm-tool.1.in \
nmcli.1.in
CLEANFILES = $(man_MANS)

View file

@ -8,7 +8,7 @@
.SH NAME
NetworkManager \- network management daemon
.SH SYNOPSIS
.B NetworkManager [\-\-no\-daemon] [\-\-pid\-file=<filename>] [\-\-state\-file=<filename>] [\-\-config=<filename>] [\-\-plugins=<plugin1>,plugin2>,...]
.B NetworkManager [\-\-no\-daemon] [\-\-pid\-file=<filename>] [\-\-state\-file=<filename>] [\-\-config=<filename>] [\-\-plugins=<plugin1>,plugin2>,...] [\-\-log\-level=<level>] [\-\-log\-domains=<domain1>,<domain2>,...]
.SH DESCRIPTION
The \fINetworkManager\fP daemon attempts to make networking configuration and
operation as painless and automatic as possible by managing the primary network
@ -55,7 +55,7 @@ The system hostname has been updated. Use gethostname(2) to retrieve it.
.SH OPTIONS
The following options are supported:
.TP
.I "\-\-no-daemon"
.I "\-\-no\-daemon"
Do not daemonize. This is useful for debugging, and directs log output to the
controlling terminal in addition to syslog.
.TP
@ -81,11 +81,23 @@ List plugins used to manage system-wide connection settings. This list has
preference over plugins specified in the configuration file. Currently supported
plugins are: keyfile, ifcfg\-rh, ifcfg\-suse, ifupdown.
See \fBNetworkManager.conf\fP(5) for more information on the plugins.
.TP
.I "\-\-log\-level=<level>
Sets how much information NetworkManager sends to the log destination (usually
syslog's "daemon" facility). By default, only informational, warning, and error
messages are logged. See \fBNetworkManager.conf\fP(5) for more information on
log levels and domains.
.TP
.I "\-\-log\-domains=<domain1>,<domain2>, ...
Sets which operations are logged to the log destination (usually syslog). By
default, most domains are logging-enabled. See \fBNetworkManager.conf\fP(5) for
more information on log levels and domains.
.SH DEBUGGING
The following environment variables are supported to help debugging. When used
in conjunction with the "\-\-no\-daemon" option (thus echoing PPP and DHCP helper
output to stdout) these can quickly help pinpoint the source of connection
issues.
issues. Also see the \-\-log\-level and \-\-log\-domains to enable debug logging inside
NetworkManager itself.
.TP
.I "NM_PPP_DEBUG"
When set to anything, causes NetworkManager to turn on PPP debugging in pppd,

View file

@ -16,8 +16,8 @@ where <SYSCONFDIR> depends on your distribution or build.
.SH DESCRIPTION
.P
.I NetworkManager.conf
is a configuration file for NetworkManager. As the name suggests, it configures
how NetworkManager handles system-wide connection settings. The location of
is a configuration file for NetworkManager. It is used to set up various
aspects of NetworkManager's behavior. The location of
the file may be changed through use of the "\-\-config=" argument for
\fBNetworkManager\fP (8).
@ -81,11 +81,26 @@ plugin is only provided for simple backward compatibility with SUSE and OpenSUSE
Most setups should be using the \fIkeyfile\fP plugin instead. The \fIifcfg\-suse\fP plugin supports
reading wired and WiFi connections, but does not support saving any connection types.
.RE
.TP
.B dhcp=\fIdhclient\fP | \fIdhcpcd\fP
This key sets up what DHCP client NetworkManager will use. Presently
\fIdhclient\fP and \fIdhcpcd\fP are supported. The client configured here should
be available on your system too. If this key is missing, available DHCP clients
are looked for in this order: dhclient, dhcpcd.
.SS [keyfile]
This section contains keyfile-specific options and thus only has effect when using \fIkeyfile\fP plugin.
.TP
.B hostname=\fI<hostname>\fP
Set a persistent hostname when using the \fIkeyfile\fP plugin.
.TP
.B unmanaged-devices=\fImac:<hwaddr>\fP;\fImac:<hwaddr>\fP;...
Set devices that should be ignored by NetworkManager when using the \fIkeyfile\fP
plugin. Devices are specified in the following format: "mac:<hwaddr>", where
<hwaddr> is MAC address of the device to be ignored, in lowercase. Multiple
entries are separated by a semicolon. Example:
.nf
unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1e:65:30:d1:c4
.fi
.SS [ifupdown]
This section contains ifupdown-specific options and thus only has effect when using \fIifupdown\fP plugin.
.TP
@ -97,6 +112,26 @@ ignored by NetworkManager. Remember that NetworkManager controls the default rou
so because the interface is ignored, NetworkManager may assign the default route to
some other interface.
When the option is missing, \fIfalse\fP value is taken as default.
.SS [logging]
This section controls NetworkManager's logging. Any settings here are
overridden by the \-\-log\-level and \-\-log\-domains command-line options.
.TP
.B level=\fI<level>\fP
One of [ERR, WARN, INFO, DEBUG]. The ERR level logs only critical errors. WARN
logs warnings that may reflect operation. INFO logs various informational
messages that are useful for tracking state and operations. DEBUG enables
verbose logging for debugging purposes. Subsequent levels also log all messages
from earlier levels; thus setting the log level to INFO also logs error and
warning messages.
.TP
.B domains=\fI<domain1>,<domain2>, ...\fP
The following log domains are available: [NONE, HW, RKILL, ETHER, WIFI, BT, MB,
DHCP4, DHCP6, PPP, WIFI_SCAN, IP4, IP6, AUTOIP4, DNS, VPN, SHARING, SUPPLICANT,
USER_SET, SYS_SET, SUSPEND, CORE, DEVICE, OLPC]. When "NONE" is given by itself,
logging is disabled. MB = Mobile Broadband, USER_SET = user settings operations
and communication, SYS_SET = system settings service operations, OLPC = OLPC
Mesh device operations, CORE = core daemon operations, DEVICE = activation and
general interface operations.
.SH "SEE ALSO"
.BR http://live.gnome.org/NetworkManager/SystemSettings
.sp

View file

@ -15,6 +15,7 @@ src/main.c
src/dhcp-manager/nm-dhcp-dhclient.c
src/dhcp-manager/nm-dhcp-manager.c
src/ip6-manager/nm-netlink-listener.c
src/logging/nm-logging.c
src/named-manager/nm-named-manager.c
src/system-settings/nm-default-wired-connection.c
system-settings/plugins/ifcfg-rh/reader.c

1525
po/cs.po

File diff suppressed because it is too large Load diff

460
po/es.po

File diff suppressed because it is too large Load diff

1002
po/kn.po

File diff suppressed because it is too large Load diff

1573
po/pa.po

File diff suppressed because it is too large Load diff

996
po/te.po

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
SUBDIRS= \
logging \
named-manager \
vpn-manager \
dhcp-manager \
@ -16,6 +17,7 @@ SUBDIRS= \
INCLUDES = -I${top_srcdir} \
-I${top_srcdir}/include \
-I${top_builddir}/marshallers \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/src/named-manager \
-I${top_srcdir}/src/vpn-manager \
-I${top_srcdir}/src/dhcp-manager \
@ -125,8 +127,6 @@ NetworkManager_SOURCES = \
NetworkManagerUtils.h \
nm-system.c \
nm-system.h \
nm-logging.c \
nm-logging.h \
nm-manager.c \
nm-manager.h \
nm-netlink-monitor.c \
@ -224,6 +224,7 @@ NetworkManager_CPPFLAGS = \
NetworkManager_LDADD = \
$(top_builddir)/marshallers/libmarshallers.la \
./logging/libnm-logging.la \
./named-manager/libnamed-manager.la \
./vpn-manager/libvpn-manager.la \
./dhcp-manager/libdhcp-manager.la \

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) 2004 - 2008 Red Hat, Inc.
* Copyright (C) 2004 - 2010 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
*/
@ -28,6 +28,7 @@
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-device.h"
#include "nm-device-wifi.h"
#include "nm-device-ethernet.h"
@ -85,13 +86,13 @@ nm_spawn_process (const char *args)
g_return_val_if_fail (args != NULL, -1);
if (!g_shell_parse_argv (args, &num_args, &argv, &error)) {
nm_warning ("could not parse arguments for '%s': %s", args, error->message);
nm_log_warn (LOGD_CORE, "could not parse arguments for '%s': %s", args, error->message);
g_error_free (error);
return -1;
}
if (!g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, NULL, NULL, &status, &error)) {
nm_warning ("could not spawn process '%s': %s", args, error->message);
nm_log_warn (LOGD_CORE, "could not spawn process '%s': %s", args, error->message);
g_error_free (error);
}
@ -394,7 +395,7 @@ nm_utils_call_dispatcher (const char *action,
NM_DISPATCHER_DBUS_PATH,
NM_DISPATCHER_DBUS_IFACE);
if (!proxy) {
nm_warning ("Error: could not get dispatcher proxy!");
nm_log_err (LOGD_CORE, "could not get dispatcher proxy!");
g_object_unref (dbus_mgr);
return;
}

View file

@ -1,9 +1,11 @@
INCLUDES = -I${top_srcdir} \
-I${top_srcdir}/include \
-I${top_srcdir}/src \
-I${top_srcdir}/src/vpn-manager \
-I${top_srcdir}/src/named-manager \
-I${top_srcdir}/libnm-util
INCLUDES = \
-I${top_srcdir} \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/include \
-I${top_srcdir}/src \
-I${top_srcdir}/src/vpn-manager \
-I${top_srcdir}/src/named-manager \
-I${top_srcdir}/libnm-util
noinst_LTLIBRARIES = libnmbackend.la
@ -53,7 +55,11 @@ if TARGET_PARDUS
libnmbackend_la_SOURCES += NetworkManagerPardus.c
endif
libnmbackend_la_LIBADD += $(DBUS_LIBS) $(GLIB_LIBS)
libnmbackend_la_LIBADD += \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)
libnmbackend_la_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \

View file

@ -34,7 +34,7 @@
#include "NetworkManagerGeneric.h"
#include "nm-system.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
/*
* nm_system_enable_loopback
@ -57,7 +57,7 @@ void nm_system_enable_loopback (void)
void nm_system_update_dns (void)
{
if (g_file_test ("/usr/sbin/nscd", G_FILE_TEST_IS_EXECUTABLE)) {
nm_info ("Clearing nscd hosts cache.");
nm_log_info (LOGD_DNS, "Clearing nscd hosts cache.");
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}
}

View file

@ -1,3 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* Timothee Lecomte <timothee.lecomte@ens.fr>
@ -36,7 +37,7 @@
#include "nm-system.h"
#include "NetworkManagerUtils.h"
#include "nm-netlink.h"
#include "nm-utils.h"
#include "nm-logging.h"
/* Because of a bug in libnl, rtnl.h should be included before route.h */
#include <netlink/route/rtnl.h>
@ -93,8 +94,9 @@ void nm_generic_enable_loopback (void)
rtnl_addr_set_label (addr, "lo");
if ((err = rtnl_addr_add (nlh, addr, 0)) < 0) {
if (err != -EEXIST)
nm_warning ("error %d returned from rtnl_addr_add():\n%s", err, nl_geterror());
if (err != -EEXIST) {
nm_log_warn (LOGD_CORE, "error %d returned from rtnl_addr_add():\n%s", err, nl_geterror());
}
}
out:
if (addr)

View file

@ -34,7 +34,7 @@
#include "NetworkManagerGeneric.h"
#include "nm-system.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
/*
* nm_system_enable_loopback
@ -59,7 +59,7 @@ void nm_system_enable_loopback (void)
void nm_system_update_dns (void)
{
if (g_file_test ("/usr/sbin/nscd", G_FILE_TEST_IS_EXECUTABLE)) {
nm_info ("Clearing nscd hosts cache.");
nm_log_info (LOGD_DNS, "Clearing nscd hosts cache.");
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}
}

View file

@ -33,7 +33,7 @@
#include "NetworkManagerGeneric.h"
#include "nm-system.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
/*
* nm_system_enable_loopback
@ -55,7 +55,7 @@ void nm_system_enable_loopback (void)
*/
void nm_system_update_dns (void)
{
nm_info ("Clearing nscd hosts cache.");
nm_log_info (LOGD_DNS, "Clearing nscd hosts cache.");
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}

View file

@ -34,7 +34,7 @@
#include "NetworkManagerGeneric.h"
#include "nm-system.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
/*
* nm_system_enable_loopback
@ -56,7 +56,7 @@ void nm_system_enable_loopback (void)
*/
void nm_system_update_dns (void)
{
nm_info ("Clearing nscd hosts cache.");
nm_log_info (LOGD_DNS, "Clearing nscd hosts cache.");
nm_spawn_process ("/usr/sbin/nscd -i hosts");
}

View file

@ -3,6 +3,7 @@ INCLUDES = \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/src \
-I${top_srcdir}/src/logging \
-I${top_builddir}/marshallers \
-I$(top_srcdir)/src/nm-bluez-manager
@ -30,6 +31,7 @@ libbluez_manager_la_CPPFLAGS = \
libbluez_manager_la_LIBADD = \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
$(BLUEZ_LIBS)

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <glib.h>
@ -27,7 +27,7 @@
#include "nm-bluez-device.h"
#include "nm-bluez-common.h"
#include "nm-dbus-glib-types.h"
#include "nm-utils.h"
#include "nm-logging.h"
G_DEFINE_TYPE (NMBluezAdapter, nm_bluez_adapter, G_TYPE_OBJECT)
@ -175,8 +175,8 @@ get_properties_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
if (!dbus_g_proxy_end_call (proxy, call, &err,
DBUS_TYPE_G_MAP_OF_VARIANT, &properties,
G_TYPE_INVALID)) {
nm_warning ("bluez error getting adapter properties: %s",
err && err->message ? err->message : "(unknown)");
nm_log_warn (LOGD_BT, "bluez error getting adapter properties: %s",
err && err->message ? err->message : "(unknown)");
g_error_free (err);
goto done;
}
@ -209,8 +209,8 @@ query_properties (NMBluezAdapter *self)
self,
NULL, G_TYPE_INVALID);
if (!call) {
nm_warning ("failed to request Bluetooth adapter properties for %s.",
priv->path);
nm_log_warn (LOGD_BT, "failed to request Bluetooth adapter properties for %s.",
priv->path);
}
}

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <glib.h>
@ -26,7 +26,7 @@
#include "nm-bluez-device.h"
#include "nm-bluez-common.h"
#include "nm-dbus-glib-types.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-marshal.h"
@ -228,8 +228,8 @@ get_properties_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
if (!dbus_g_proxy_end_call (proxy, call, &err,
DBUS_TYPE_G_MAP_OF_VARIANT, &properties,
G_TYPE_INVALID)) {
nm_warning ("bluez error getting device properties: %s",
err && err->message ? err->message : "(unknown)");
nm_log_warn (LOGD_BT, "bluez error getting device properties: %s",
err && err->message ? err->message : "(unknown)");
g_error_free (err);
g_signal_emit (self, signals[INITIALIZED], 0, FALSE);
return;
@ -270,8 +270,8 @@ query_properties (NMBluezDevice *self)
self,
NULL, G_TYPE_INVALID);
if (!call) {
nm_warning ("failed to request Bluetooth device properties for %s.",
priv->path);
nm_log_warn (LOGD_BT, "failed to request Bluetooth device properties for %s.",
priv->path);
}
}

View file

@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include <signal.h>
@ -24,7 +24,7 @@
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-glib-types.h"
#include "nm-marshal.h"
#include "nm-bluez-manager.h"
@ -181,8 +181,8 @@ default_adapter_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
if (!dbus_g_proxy_end_call (proxy, call, &err,
DBUS_TYPE_G_OBJECT_PATH, &default_adapter,
G_TYPE_INVALID)) {
nm_warning ("bluez error getting default adapter: %s",
err && err->message ? err->message : "(unknown)");
nm_log_warn (LOGD_BT, "bluez error getting default adapter: %s",
err && err->message ? err->message : "(unknown)");
g_error_free (err);
return;
}
@ -201,7 +201,7 @@ query_default_adapter (NMBluezManager *self)
self,
NULL, G_TYPE_INVALID);
if (!call)
nm_warning ("failed to request default Bluetooth adapter.");
nm_log_warn (LOGD_BT, "failed to request default Bluetooth adapter.");
}
static void

View file

@ -2,6 +2,7 @@ INCLUDES = \
-I${top_srcdir} \
-I${top_srcdir}/include \
-I${top_builddir}/marshallers \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/src \
-I${top_srcdir}/src/named-manager
@ -32,6 +33,7 @@ libdhcp_manager_la_CPPFLAGS = \
libdhcp_manager_la_LIBADD = \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)

View file

@ -29,6 +29,7 @@
#include <stdlib.h>
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-glib-types.h"
#include "nm-dhcp-client.h"
@ -159,14 +160,14 @@ stop_process (GPid pid, const char *iface)
if (i <= 0) {
if (iface) {
g_warning ("%s: dhcp client pid %d didn't exit, will kill it.",
iface, pid);
nm_log_warn (LOGD_DHCP, "(%s): DHCP client pid %d didn't exit, will kill it.",
iface, pid);
}
kill (pid, SIGKILL);
g_warning ("waiting for dhcp client pid %d to exit", pid);
nm_log_dbg (LOGD_DHCP, "waiting for DHCP client pid %d to exit", pid);
waitpid (pid, NULL, 0);
g_warning ("dhcp client pid %d cleaned up", pid);
nm_log_dbg (LOGD_DHCP, "DHCP client pid %d cleaned up", pid);
}
}
@ -193,8 +194,11 @@ daemon_timeout (gpointer user_data)
NMDHCPClient *self = NM_DHCP_CLIENT (user_data);
NMDHCPClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
g_message ("(%s): DHCPv%c request timed out.",
priv->iface, priv->ipv6 ? '6' : '4');
if (priv->ipv6) {
nm_log_warn (LOGD_DHCP6, "(%s): DHCPv6 request timed out.", priv->iface);
} else {
nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 request timed out.", priv->iface);
}
g_signal_emit (G_OBJECT (self), signals[TIMEOUT], 0);
return FALSE;
}
@ -207,7 +211,7 @@ daemon_watch_cb (GPid pid, gint status, gpointer user_data)
if (!WIFEXITED (status)) {
priv->state = DHC_ABEND;
g_warning ("dhcp client died abnormally");
nm_log_warn (LOGD_DHCP, "DHCP client died abnormally");
}
priv->pid = 0;
@ -248,8 +252,8 @@ nm_dhcp_client_start_ip4 (NMDHCPClient *self,
g_return_val_if_fail (priv->ipv6 == FALSE, FALSE);
g_return_val_if_fail (priv->uuid != NULL, FALSE);
g_message ("Activation (%s) Beginning DHCPv4 transaction (timeout in %d seconds)",
priv->iface, priv->timeout);
nm_log_info (LOGD_DHCP, "Activation (%s) Beginning DHCPv4 transaction (timeout in %d seconds)",
priv->iface, priv->timeout);
priv->pid = NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, s_ip4, dhcp_anycast_addr);
if (priv->pid)
@ -274,8 +278,8 @@ nm_dhcp_client_start_ip6 (NMDHCPClient *self,
g_return_val_if_fail (priv->ipv6 == TRUE, FALSE);
g_return_val_if_fail (priv->uuid != NULL, FALSE);
g_message ("Activation (%s) Beginning DHCPv6 transaction (timeout in %d seconds)",
priv->iface, priv->timeout);
nm_log_info (LOGD_DHCP, "Activation (%s) Beginning DHCPv6 transaction (timeout in %d seconds)",
priv->iface, priv->timeout);
priv->pid = NM_DHCP_CLIENT_GET_CLASS (self)->ip6_start (self, s_ip6, dhcp_anycast_addr, info_only);
if (priv->pid > 0)
@ -333,9 +337,8 @@ nm_dhcp_client_stop (NMDHCPClient *self)
if (priv->pid > 0) {
NM_DHCP_CLIENT_GET_CLASS (self)->stop (self);
g_message ("(%s): canceled DHCP transaction, dhcp client pid %d",
priv->iface,
priv->pid);
nm_log_info (LOGD_DHCP, "(%s): canceled DHCP transaction, DHCP client pid %d",
priv->iface, priv->pid);
}
/* And clean stuff up */
@ -452,7 +455,7 @@ garray_to_string (GArray *array, const char *key)
converted = str->str;
if (!g_utf8_validate (converted, -1, NULL))
g_warning ("%s: DHCP option '%s' couldn't be converted to UTF-8", __func__, key);
nm_log_warn (LOGD_DHCP, "DHCP option '%s' couldn't be converted to UTF-8", key);
g_string_free (str, FALSE);
return converted;
}
@ -467,9 +470,9 @@ copy_option (gpointer key,
char *str_value = NULL;
if (G_VALUE_TYPE (value) != DBUS_TYPE_G_UCHAR_ARRAY) {
g_warning ("Unexpected key %s value type was not "
"DBUS_TYPE_G_UCHAR_ARRAY",
str_key);
nm_log_warn (LOGD_DHCP, "unexpected key %s value type was not "
"DBUS_TYPE_G_UCHAR_ARRAY",
str_key);
return;
}
@ -510,11 +513,17 @@ nm_dhcp_client_new_options (NMDHCPClient *self,
}
priv->state = new_state;
g_message ("DHCPv%c: device %s state changed %s -> %s",
priv->ipv6 ? '6' : '4',
priv->iface,
state_to_string (old_state),
state_to_string (priv->state));
if (priv->ipv6) {
nm_log_info (LOGD_DHCP6, "(%s): DHCPv6 state changed %s -> %s",
priv->iface,
state_to_string (old_state),
state_to_string (priv->state));
} else {
nm_log_info (LOGD_DHCP4, "(%s): DHCPv4 state changed %s -> %s",
priv->iface,
state_to_string (old_state),
state_to_string (priv->state));
}
g_signal_emit (G_OBJECT (self),
signals[STATE_CHANGED],
@ -575,7 +584,11 @@ nm_dhcp_client_foreach_option (NMDHCPClient *self,
priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
if (!state_is_bound (priv->state)) {
g_warning ("%s: dhclient didn't bind to a lease.", priv->iface);
if (priv->ipv6) {
nm_log_warn (LOGD_DHCP6, "(%s): DHCPv6 client didn't bind to a lease.", priv->iface);
} else {
nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 client didn't bind to a lease.", priv->iface);
}
return FALSE;
}
@ -599,7 +612,7 @@ process_classful_routes (GHashTable *options, NMIP4Config *ip4_config)
searches = g_strsplit (str, " ", 0);
if ((g_strv_length (searches) % 2)) {
g_message (" static routes provided, but invalid");
nm_log_info (LOGD_DHCP, " static routes provided, but invalid");
goto out;
}
@ -609,11 +622,11 @@ process_classful_routes (GHashTable *options, NMIP4Config *ip4_config)
struct in_addr rt_route;
if (inet_pton (AF_INET, *s, &rt_addr) <= 0) {
g_warning ("DHCP provided invalid static route address: '%s'", *s);
nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route address: '%s'", *s);
continue;
}
if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) {
g_warning ("DHCP provided invalid static route gateway: '%s'", *(s + 1));
nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route gateway: '%s'", *(s + 1));
continue;
}
@ -625,7 +638,7 @@ process_classful_routes (GHashTable *options, NMIP4Config *ip4_config)
nm_ip4_route_set_next_hop (route, (guint32) rt_route.s_addr);
nm_ip4_config_take_route (ip4_config, route);
g_message (" static route %s gw %s", *s, *(s + 1));
nm_log_info (LOGD_DHCP, " static route %s gw %s", *s, *(s + 1));
}
out:
@ -654,14 +667,14 @@ process_domain_search (const char *str, GFunc add_func, gpointer user_data)
} while (*p++);
if (strchr (unescaped, '\\')) {
g_message (" invalid domain search: '%s'", unescaped);
nm_log_warn (LOGD_DHCP, " invalid domain search: '%s'", unescaped);
goto out;
}
searches = g_strsplit (unescaped, " ", 0);
for (s = searches; *s; s++) {
if (strlen (*s)) {
g_message (" domain search '%s'", *s);
nm_log_info (LOGD_DHCP, " domain search '%s'", *s);
add_func (*s, user_data);
}
}
@ -697,31 +710,31 @@ ip4_options_to_config (NMDHCPClient *self)
ip4_config = nm_ip4_config_new ();
if (!ip4_config) {
g_warning ("%s: couldn't allocate memory for an IP4Config!", priv->iface);
nm_log_warn (LOGD_DHCP4, "(%s): couldn't allocate memory for an IP4Config!", priv->iface);
return NULL;
}
addr = nm_ip4_address_new ();
if (!addr) {
g_warning ("%s: couldn't allocate memory for an IP4 Address!", priv->iface);
nm_log_warn (LOGD_DHCP4, "(%s): couldn't allocate memory for an IP4 Address!", priv->iface);
goto error;
}
str = g_hash_table_lookup (priv->options, "new_ip_address");
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
nm_ip4_address_set_address (addr, tmp_addr.s_addr);
g_message (" address %s", str);
nm_log_info (LOGD_DHCP4, " address %s", str);
} else
goto error;
str = g_hash_table_lookup (priv->options, "new_subnet_mask");
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
prefix = nm_utils_ip4_netmask_to_prefix (tmp_addr.s_addr);
g_message (" prefix %d (%s)", prefix, str);
nm_log_info (LOGD_DHCP4, " prefix %d (%s)", prefix, str);
} else {
/* Get default netmask for the IP according to appropriate class. */
prefix = nm_utils_ip4_get_default_prefix (nm_ip4_address_get_address (addr));
g_message (" prefix %d (default)", prefix);
nm_log_info (LOGD_DHCP4, " prefix %d (default)", prefix);
}
nm_ip4_address_set_prefix (addr, prefix);
@ -744,7 +757,7 @@ ip4_options_to_config (NMDHCPClient *self)
char buf[INET_ADDRSTRLEN + 1];
inet_ntop (AF_INET, &gwaddr, buf, sizeof (buf));
g_message (" gateway %s", buf);
nm_log_info (LOGD_DHCP4, " gateway %s", buf);
nm_ip4_address_set_gateway (addr, gwaddr);
} else {
/* If the gateway wasn't provided as a classless static route with a
@ -759,10 +772,10 @@ ip4_options_to_config (NMDHCPClient *self)
/* FIXME: how to handle multiple routers? */
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
nm_ip4_address_set_gateway (addr, tmp_addr.s_addr);
g_message (" gateway %s", *s);
nm_log_info (LOGD_DHCP4, " gateway %s", *s);
break;
} else
g_warning ("Ignoring invalid gateway '%s'", *s);
nm_log_warn (LOGD_DHCP4, "ignoring invalid gateway '%s'", *s);
}
g_strfreev (routers);
}
@ -773,7 +786,7 @@ ip4_options_to_config (NMDHCPClient *self)
str = g_hash_table_lookup (priv->options, "new_host_name");
if (str)
g_message (" hostname '%s'", str);
nm_log_info (LOGD_DHCP4, " hostname '%s'", str);
str = g_hash_table_lookup (priv->options, "new_domain_name_servers");
if (str) {
@ -783,9 +796,9 @@ ip4_options_to_config (NMDHCPClient *self)
for (s = searches; *s; s++) {
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
nm_ip4_config_add_nameserver (ip4_config, tmp_addr.s_addr);
g_message (" nameserver '%s'", *s);
nm_log_info (LOGD_DHCP4, " nameserver '%s'", *s);
} else
g_warning ("Ignoring invalid nameserver '%s'", *s);
nm_log_warn (LOGD_DHCP4, "ignoring invalid nameserver '%s'", *s);
}
g_strfreev (searches);
}
@ -796,7 +809,7 @@ ip4_options_to_config (NMDHCPClient *self)
char **s;
for (s = domains; *s; s++) {
g_message (" domain name '%s'", *s);
nm_log_info (LOGD_DHCP4, " domain name '%s'", *s);
nm_ip4_config_add_domain (ip4_config, *s);
}
g_strfreev (domains);
@ -814,9 +827,9 @@ ip4_options_to_config (NMDHCPClient *self)
for (s = searches; *s; s++) {
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
nm_ip4_config_add_wins (ip4_config, tmp_addr.s_addr);
g_message (" wins '%s'", *s);
nm_log_info (LOGD_DHCP4, " wins '%s'", *s);
} else
g_warning ("Ignoring invalid WINS server '%s'", *s);
nm_log_warn (LOGD_DHCP4, "ignoring invalid WINS server '%s'", *s);
}
g_strfreev (searches);
}
@ -854,7 +867,7 @@ nm_dhcp_client_get_ip4_config (NMDHCPClient *self, gboolean test)
priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
if (test && !state_is_bound (priv->state)) {
g_warning ("%s: dhcp client didn't bind to a lease.", priv->iface);
nm_log_warn (LOGD_DHCP4, "(%s): DHCP client didn't bind to a lease.", priv->iface);
return NULL;
}
@ -887,20 +900,20 @@ ip6_options_to_config (NMDHCPClient *self)
ip6_config = nm_ip6_config_new ();
if (!ip6_config) {
g_warning ("%s: couldn't allocate memory for an IP6Config!", priv->iface);
nm_log_warn (LOGD_DHCP6, "(%s): couldn't allocate memory for an IP6Config!", priv->iface);
return NULL;
}
addr = nm_ip6_address_new ();
if (!addr) {
g_warning ("%s: couldn't allocate memory for an IP6 Address!", priv->iface);
nm_log_warn (LOGD_DHCP6, "(%s): couldn't allocate memory for an IP6 Address!", priv->iface);
goto error;
}
str = g_hash_table_lookup (priv->options, "new_ip6_address");
if (str && (inet_pton (AF_INET6, str, &tmp_addr) > 0)) {
nm_ip6_address_set_address (addr, &tmp_addr);
g_message (" address %s", str);
nm_log_info (LOGD_DHCP6, " address %s", str);
} else
goto error;
@ -914,7 +927,7 @@ ip6_options_to_config (NMDHCPClient *self)
goto error;
nm_ip6_address_set_prefix (addr, (guint32) prefix);
g_message (" prefix %lu", prefix);
nm_log_info (LOGD_DHCP6, " prefix %lu", prefix);
}
nm_ip6_config_take_address (ip6_config, addr);
@ -922,7 +935,7 @@ ip6_options_to_config (NMDHCPClient *self)
str = g_hash_table_lookup (priv->options, "new_host_name");
if (str)
g_message (" hostname '%s'", str);
nm_log_info (LOGD_DHCP6, " hostname '%s'", str);
str = g_hash_table_lookup (priv->options, "new_dhcp6_name_servers");
if (str) {
@ -932,9 +945,9 @@ ip6_options_to_config (NMDHCPClient *self)
for (s = searches; *s; s++) {
if (inet_pton (AF_INET6, *s, &tmp_addr) > 0) {
nm_ip6_config_add_nameserver (ip6_config, &tmp_addr);
g_message (" nameserver '%s'", *s);
nm_log_info (LOGD_DHCP6, " nameserver '%s'", *s);
} else
g_warning ("Ignoring invalid nameserver '%s'", *s);
nm_log_warn (LOGD_DHCP6, "ignoring invalid nameserver '%s'", *s);
}
g_strfreev (searches);
}
@ -963,7 +976,7 @@ nm_dhcp_client_get_ip6_config (NMDHCPClient *self, gboolean test)
priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
if (test && !state_is_bound (priv->state)) {
g_warning ("%s: dhcp client didn't bind to a lease.", priv->iface);
nm_log_warn (LOGD_DHCP6, "(%s): dhcp client didn't bind to a lease.", priv->iface);
return NULL;
}

View file

@ -38,6 +38,7 @@
#include "nm-dhcp-dhclient.h"
#include "nm-utils.h"
#include "nm-logging.h"
G_DEFINE_TYPE (NMDHCPDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT)
@ -101,7 +102,7 @@ add_lease_option (GHashTable *hash, char *line)
spc = strchr (line, ' ');
if (!spc) {
g_warning ("%s: line '%s' did not contain a space", __func__, line);
nm_log_warn (LOGD_DHCP, "DHCP lease file line '%s' did not contain a space", line);
return;
}
@ -109,8 +110,8 @@ add_lease_option (GHashTable *hash, char *line)
if (g_str_has_prefix (line, "option ")) {
spc = strchr (spc + 1, ' ');
if (!spc) {
g_warning ("%s: option line '%s' did not contain a second space",
__func__, line);
nm_log_warn (LOGD_DHCP, "DHCP lease file option line '%s' did not contain a second space",
line);
return;
}
}
@ -168,9 +169,9 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid)
} else if (!strcmp (*line, "lease {")) {
/* Beginning of a new lease */
if (hash) {
g_warning ("%s: lease file %s malformed; new lease started "
"without ending previous lease",
__func__, leasefile);
nm_log_warn (LOGD_DHCP, "DHCP lease file %s malformed; new lease started "
"without ending previous lease",
leasefile);
g_hash_table_destroy (hash);
}
@ -182,9 +183,9 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid)
/* Check if the last lease in the file was properly ended */
if (hash) {
g_warning ("%s: lease file %s malformed; new lease started "
"without ending previous lease",
__func__, leasefile);
nm_log_warn (LOGD_DHCP, "DHCP lease file %s malformed; new lease started "
"without ending previous lease",
leasefile);
g_hash_table_destroy (hash);
hash = NULL;
}
@ -211,8 +212,8 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid)
/* Read lease expiration (in UTC) */
if (!strptime (data, "%w %Y/%m/%d %H:%M:%S", &expire)) {
g_warning ("%s: couldn't parse expire time '%s'",
__func__, data);
nm_log_warn (LOGD_DHCP, "couldn't parse DHCP lease file expire time '%s'",
data);
continue;
}
@ -254,7 +255,7 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid)
/* IP4 address */
if (!inet_pton (AF_INET, data, &tmp)) {
g_warning ("%s: couldn't parse IP4 address '%s'", __func__, data);
nm_log_warn (LOGD_DHCP, "couldn't parse DHCP lease file IP4 address '%s'", data);
goto error;
}
nm_ip4_address_set_address (addr, tmp.s_addr);
@ -263,7 +264,7 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid)
data = g_hash_table_lookup (hash, "option subnet-mask");
if (data) {
if (!inet_pton (AF_INET, data, &tmp)) {
g_warning ("%s: couldn't parse IP4 subnet mask '%s'", __func__, data);
nm_log_warn (LOGD_DHCP, "couldn't parse DHCP lease file IP4 subnet mask '%s'", data);
goto error;
}
prefix = nm_utils_ip4_netmask_to_prefix (tmp.s_addr);
@ -277,7 +278,7 @@ nm_dhcp_dhclient_get_lease_config (const char *iface, const char *uuid)
data = g_hash_table_lookup (hash, "option routers");
if (data) {
if (!inet_pton (AF_INET, data, &tmp)) {
g_warning ("%s: couldn't parse IP4 gateway '%s'", __func__, data);
nm_log_warn (LOGD_DHCP, "couldn't parse DHCP lease file IP4 gateway '%s'", data);
goto error;
}
nm_ip4_address_set_gateway (addr, tmp.s_addr);
@ -327,8 +328,8 @@ merge_dhclient_config (const char *iface,
GError *read_error = NULL;
if (!g_file_get_contents (orig_path, &orig_contents, NULL, &read_error)) {
nm_warning ("%s: error reading dhclient configuration %s: %s",
iface, orig_path, read_error->message);
nm_log_warn (LOGD_DHCP, "(%s): error reading dhclient configuration %s: %s",
iface, orig_path, read_error->message);
g_error_free (read_error);
}
}
@ -445,7 +446,7 @@ create_dhclient_config (const char *iface,
#endif
if (!orig) {
nm_warning ("%s: not enough memory for dhclient options.", iface);
nm_log_warn (LOGD_DHCP, "(%s): not enough memory for dhclient options.", iface);
return FALSE;
}
@ -456,8 +457,8 @@ create_dhclient_config (const char *iface,
error = NULL;
success = merge_dhclient_config (iface, conf_file, s_ip4, dhcp_anycast_addr, orig, &error);
if (!success) {
nm_warning ("%s: error creating dhclient configuration: %s",
iface, error->message);
nm_log_warn (LOGD_DHCP, "(%s): error creating dhclient configuration: %s",
iface, error->message);
g_error_free (error);
}
@ -486,6 +487,7 @@ dhclient_start (NMDHCPClient *client,
const char *iface, *uuid;
char *binary_name, *cmd_str;
gboolean ipv6;
guint log_domain;
g_return_val_if_fail (priv->pid_file == NULL, -1);
g_return_val_if_fail (ip_opt != NULL, -1);
@ -494,16 +496,18 @@ 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;
priv->pid_file = g_strdup_printf (LOCALSTATEDIR "/run/dhclient%s-%s.pid",
ipv6 ? "6" : "",
iface);
if (!priv->pid_file) {
nm_warning ("%s: not enough memory for dhcpcd options.", iface);
nm_log_warn (log_domain, "(%s): not enough memory for dhcpcd options.", iface);
return -1;
}
if (!g_file_test (priv->path, G_FILE_TEST_EXISTS)) {
nm_warning ("%s does not exist.", priv->path);
nm_log_warn (log_domain, "%s does not exist.", priv->path);
return -1;
}
@ -514,7 +518,7 @@ dhclient_start (NMDHCPClient *client,
priv->lease_file = get_leasefile_for_iface (iface, uuid, ipv6);
if (!priv->lease_file) {
nm_warning ("%s: not enough memory for dhclient options.", iface);
nm_log_warn (log_domain, "(%s): not enough memory for dhclient options.", iface);
return -1;
}
@ -546,16 +550,16 @@ dhclient_start (NMDHCPClient *client,
g_ptr_array_add (argv, NULL);
cmd_str = g_strjoinv (" ", (gchar **) argv->pdata);
nm_info ("running: %s", cmd_str);
nm_log_dbg (log_domain, "running: %s", cmd_str);
g_free (cmd_str);
if (!g_spawn_async (NULL, (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
&dhclient_child_setup, NULL, &pid, &error)) {
nm_warning ("dhclient failed to start. error: '%s'", error->message);
nm_log_warn (log_domain, "dhclient failed to start: '%s'", error->message);
g_error_free (error);
pid = -1;
} else
nm_info ("dhclient started with pid %d", pid);
nm_log_info (log_domain, "dhclient started with pid %d", pid);
g_ptr_array_free (argv, TRUE);
return pid;
@ -573,7 +577,7 @@ real_ip4_start (NMDHCPClient *client,
priv->conf_file = create_dhclient_config (iface, s_ip4, dhcp_anycast_addr);
if (!priv->conf_file) {
nm_warning ("%s: error creating dhclient configuration file.", iface);
nm_log_warn (LOGD_DHCP4, "(%s): error creating dhclient configuration file.", iface);
return -1;
}
@ -694,7 +698,7 @@ real_ip4_process_classless_routes (NMDHCPClient *client,
o = octets = g_strsplit (str, " ", 0);
if (g_strv_length (octets) < 5) {
nm_warning ("Ignoring invalid classless static routes '%s'", str);
nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes '%s'", str);
goto out;
}
@ -702,7 +706,7 @@ real_ip4_process_classless_routes (NMDHCPClient *client,
route = NULL;
o = (char **) process_rfc3442_route ((const char **) o, &route);
if (!route) {
nm_warning ("Ignoring invalid classless static routes");
nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes");
break;
}
@ -723,8 +727,8 @@ real_ip4_process_classless_routes (NMDHCPClient *client,
inet_ntop (AF_INET, &tmp, addr, sizeof (addr));
tmp.s_addr = nm_ip4_route_get_next_hop (route);
inet_ntop (AF_INET, &tmp, nh, sizeof (nh));
nm_info (" classless static route %s/%d gw %s",
addr, nm_ip4_route_get_prefix (route), nh);
nm_log_info (LOGD_DHCP4, " classless static route %s/%d gw %s",
addr, nm_ip4_route_get_prefix (route), nh);
}
}

View file

@ -34,6 +34,7 @@
#include "nm-dhcp-dhcpcd.h"
#include "nm-utils.h"
#include "nm-logging.h"
G_DEFINE_TYPE (NMDHCPDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_DHCPCD)
@ -103,12 +104,12 @@ real_ip4_start (NMDHCPClient *client,
priv->pid_file = g_strdup_printf (LOCALSTATEDIR "/run/dhcpcd-%s.pid", iface);
if (!priv->pid_file) {
nm_warning ("%s: not enough memory for dhcpcd options.", iface);
nm_log_warn (LOGD_DHCP4, "(%s): not enough memory for dhcpcd options.", iface);
return -1;
}
if (!g_file_test (priv->path, G_FILE_TEST_EXISTS)) {
nm_warning ("%s does not exist.", priv->path);
nm_log_warn (LOGD_DHCP4, "%s does not exist.", priv->path);
return -1;
}
@ -139,15 +140,15 @@ real_ip4_start (NMDHCPClient *client,
g_ptr_array_add (argv, NULL);
cmd_str = g_strjoinv (" ", (gchar **) argv->pdata);
nm_info ("running: %s", cmd_str);
nm_log_dbg (LOGD_DHCP4, "running: %s", cmd_str);
g_free (cmd_str);
if (!g_spawn_async (NULL, (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
&dhcpcd_child_setup, NULL, &pid, &error)) {
nm_warning ("dhcpcd failed to start. error: '%s'", error->message);
nm_log_warn (LOGD_DHCP4, "dhcpcd failed to start. error: '%s'", error->message);
g_error_free (error);
} else
nm_info ("dhcpcd started with pid %d", pid);
nm_log_info (LOGD_DHCP4, "dhcpcd started with pid %d", pid);
g_free (pid_contents);
g_ptr_array_free (argv, TRUE);
@ -160,7 +161,7 @@ real_ip6_start (NMDHCPClient *client,
guint8 *dhcp_anycast_addr,
gboolean info_only)
{
g_warning ("The dhcpcd backend does not support IPv6.");
nm_log_warn (LOGD_DHCP6, "the dhcpcd backend does not support IPv6.");
return -1;
}
@ -202,7 +203,7 @@ real_ip4_process_classless_routes (NMDHCPClient *client,
goto out;
if ((g_strv_length (routes) % 2) != 0) {
nm_info (" classless static routes provided, but invalid");
nm_log_warn (LOGD_DHCP4, " classless static routes provided, but invalid");
goto out;
}
@ -219,16 +220,16 @@ real_ip4_process_classless_routes (NMDHCPClient *client,
errno = 0;
rt_cidr = strtol (slash + 1, NULL, 10);
if ((errno == EINVAL) || (errno == ERANGE)) {
nm_warning ("DHCP provided invalid classless static route cidr: '%s'", slash + 1);
nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route cidr: '%s'", slash + 1);
continue;
}
}
if (inet_pton (AF_INET, *r, &rt_addr) <= 0) {
nm_warning ("DHCP provided invalid classless static route address: '%s'", *r);
nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route address: '%s'", *r);
continue;
}
if (inet_pton (AF_INET, *(r + 1), &rt_route) <= 0) {
nm_warning ("DHCP provided invalid classless static route gateway: '%s'", *(r + 1));
nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route gateway: '%s'", *(r + 1));
continue;
}
@ -244,7 +245,7 @@ real_ip4_process_classless_routes (NMDHCPClient *client,
nm_ip4_config_take_route (ip4_config, route);
nm_info (" classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
nm_log_info (LOGD_DHCP4, " classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
}
}

View file

@ -38,7 +38,7 @@
#include "nm-dhcp-dhclient.h"
#include "nm-dhcp-dhcpcd.h"
#include "nm-marshal.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-manager.h"
#include "nm-hostname-provider.h"
#include "nm-dbus-glib-types.h"
@ -125,7 +125,7 @@ garray_to_string (GArray *array, const char *key)
converted = str->str;
if (!g_utf8_validate (converted, -1, NULL))
nm_warning ("%s: DHCP option '%s' couldn't be converted to UTF-8", __func__, key);
nm_log_warn (LOGD_DHCP, "DHCP option '%s' couldn't be converted to UTF-8", key);
g_string_free (str, FALSE);
return converted;
}
@ -190,9 +190,9 @@ get_option (GHashTable *hash, const char *key)
return NULL;
if (G_VALUE_TYPE (value) != DBUS_TYPE_G_UCHAR_ARRAY) {
g_warning ("Unexpected key %s value type was not "
"DBUS_TYPE_G_UCHAR_ARRAY",
(char *) key);
nm_log_warn (LOGD_DHCP, "unexpected key %s value type was not "
"DBUS_TYPE_G_UCHAR_ARRAY",
(char *) key);
return NULL;
}
@ -217,37 +217,37 @@ nm_dhcp_manager_handle_event (DBusGProxy *proxy,
iface = get_option (options, "interface");
if (iface == NULL) {
nm_warning ("DHCP event didn't have associated interface.");
nm_log_warn (LOGD_DHCP, "DHCP event didn't have associated interface.");
goto out;
}
pid_str = get_option (options, "pid");
if (pid_str == NULL) {
nm_warning ("DHCP event didn't have associated PID.");
nm_log_warn (LOGD_DHCP, "DHCP event didn't have associated PID.");
goto out;
}
temp = strtoul (pid_str, NULL, 10);
if ((temp == ULONG_MAX) && (errno == ERANGE)) {
nm_warning ("Couldn't convert PID");
nm_log_warn (LOGD_DHCP, "couldn't convert PID");
goto out;
}
client = get_client_for_pid (manager, (GPid) temp);
if (client == NULL) {
nm_warning ("Unhandled DHCP event for interface %s", iface);
nm_log_warn (LOGD_DHCP, "unhandled DHCP event for interface %s", iface);
goto out;
}
if (strcmp (iface, nm_dhcp_client_get_iface (client))) {
nm_warning ("Received DHCP event from unexpected interface '%s' (expected '%s')",
iface, nm_dhcp_client_get_iface (client));
nm_log_warn (LOGD_DHCP, "received DHCP event from unexpected interface '%s' (expected '%s')",
iface, nm_dhcp_client_get_iface (client));
goto out;
}
reason = get_option (options, "reason");
if (reason == NULL) {
nm_warning ("DHCP event didn't have a reason");
nm_log_warn (LOGD_DHCP, "DHCP event didn't have a reason");
goto out;
}
@ -573,7 +573,7 @@ nm_dhcp_manager_test_ip4_options_to_config (const char *dhcp_client,
client_type = get_client_type (dhcp_client, &error);
if (!client_type) {
g_warning ("Error: %s", error ? error->message : "(unknown)");
nm_log_err (LOGD_DHCP4, "error: %s", error ? error->message : "(unknown)");
g_clear_error (&error);
return NULL;
}

View file

@ -1,5 +1,6 @@
INCLUDES = \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/src \
-I${top_srcdir}/include
@ -13,4 +14,6 @@ libdnsmasq_manager_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
-DLOCALSTATEDIR=\"$(localstatedir)\"
libdnsmasq_manager_la_LIBADD = $(GLIB_LIBS)
libdnsmasq_manager_la_LIBADD = \
$(top_builddir)/src/logging/libnm-logging.la \
$(GLIB_LIBS)

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) 2008 Red Hat, Inc.
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*/
#include <sys/types.h>
@ -27,7 +27,7 @@
#include <stdlib.h>
#include "nm-dnsmasq-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-glib-compat.h"
typedef struct {
@ -168,13 +168,12 @@ nm_cmd_line_add_string (NMCmdLine *cmd, const char *str)
static inline const char *
nm_find_dnsmasq (void)
{
static const char *dnsmasq_binary_paths[] =
{
"/usr/local/sbin/dnsmasq",
"/usr/sbin/dnsmasq",
"/sbin/dnsmasq",
NULL
};
static const char *dnsmasq_binary_paths[] = {
"/usr/local/sbin/dnsmasq",
"/usr/sbin/dnsmasq",
"/sbin/dnsmasq",
NULL
};
const char **dnsmasq_binary = dnsmasq_binary_paths;
@ -214,7 +213,7 @@ dm_exit_code (guint dm_exit_status)
break;
}
g_warning ("dnsmasq exited with error: %s (%d)", msg, dm_exit_status);
nm_log_warn (LOGD_SHARING, "dnsmasq exited with error: %s (%d)", msg, dm_exit_status);
}
static void
@ -228,12 +227,13 @@ dm_watch_cb (GPid pid, gint status, gpointer user_data)
err = WEXITSTATUS (status);
if (err != 0)
dm_exit_code (err);
} else if (WIFSTOPPED (status))
g_warning ("dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status));
else if (WIFSIGNALED (status))
g_warning ("dnsmasq died with signal %d", WTERMSIG (status));
else
g_warning ("dnsmasq died from an unknown cause");
} else if (WIFSTOPPED (status)) {
nm_log_warn (LOGD_SHARING, "dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status));
} else if (WIFSIGNALED (status)) {
nm_log_warn (LOGD_SHARING, "dnsmasq died with signal %d", WTERMSIG (status));
} else {
nm_log_warn (LOGD_SHARING, "dnsmasq died from an unknown cause");
}
priv->pid = 0;
@ -288,8 +288,8 @@ create_dm_cmd_line (const char *iface,
s = g_string_new ("--listen-address=");
addr.s_addr = nm_ip4_address_get_address (tmp);
if (!inet_ntop (AF_INET, &addr, &localaddr[0], INET_ADDRSTRLEN)) {
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
nm_log_warn (LOGD_SHARING, "error converting IP4 address 0x%X",
ntohl (addr.s_addr));
goto error;
}
g_string_append (s, localaddr);
@ -301,8 +301,8 @@ create_dm_cmd_line (const char *iface,
/* Add start of address range */
addr.s_addr = nm_ip4_address_get_address (tmp) + htonl (9);
if (!inet_ntop (AF_INET, &addr, &buf[0], INET_ADDRSTRLEN)) {
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
nm_log_warn (LOGD_SHARING, "error converting IP4 address 0x%X",
ntohl (addr.s_addr));
goto error;
}
g_string_append (s, buf);
@ -312,8 +312,8 @@ create_dm_cmd_line (const char *iface,
/* Add end of address range */
addr.s_addr = nm_ip4_address_get_address (tmp) + htonl (99);
if (!inet_ntop (AF_INET, &addr, &buf[0], INET_ADDRSTRLEN)) {
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (addr.s_addr));
nm_log_warn (LOGD_SHARING, "error converting IP4 address 0x%X",
ntohl (addr.s_addr));
goto error;
}
g_string_append (s, buf);
@ -370,7 +370,7 @@ kill_existing_for_iface (const char *iface, const char *pidfile)
if (strstr (cmdline_contents, "bin/dnsmasq")) {
if (kill (pid, 0)) {
nm_info ("Killing stale dnsmasq process %ld", pid);
nm_log_dbg (LOGD_SHARING, "Killing stale dnsmasq process %ld", pid);
kill (pid, SIGKILL);
}
unlink (pidfile);
@ -405,10 +405,10 @@ nm_dnsmasq_manager_start (NMDnsMasqManager *manager,
g_ptr_array_add (dm_cmd->array, NULL);
nm_info ("Starting dnsmasq...");
nm_log_info (LOGD_SHARING, "Starting dnsmasq...");
cmd_str = nm_cmd_line_to_str (dm_cmd);
nm_debug ("Command line: %s", cmd_str);
nm_log_dbg (LOGD_SHARING, "Command line: %s", cmd_str);
g_free (cmd_str);
priv->pid = 0;
@ -419,7 +419,7 @@ nm_dnsmasq_manager_start (NMDnsMasqManager *manager,
goto out;
}
nm_debug ("dnsmasq started with pid %d", priv->pid);
nm_log_dbg (LOGD_SHARING, "dnsmasq started with pid %d", priv->pid);
priv->dm_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) dm_watch_cb, manager);
@ -439,9 +439,9 @@ ensure_killed (gpointer data)
kill (pid, SIGKILL);
/* ensure the child is reaped */
nm_debug ("waiting for dnsmasq pid %d to exit", pid);
nm_log_dbg (LOGD_SHARING, "waiting for dnsmasq pid %d to exit", pid);
waitpid (pid, NULL, 0);
nm_debug ("dnsmasq pid %d cleaned up", pid);
nm_log_dbg (LOGD_SHARING, "dnsmasq pid %d cleaned up", pid);
return FALSE;
}
@ -467,9 +467,9 @@ nm_dnsmasq_manager_stop (NMDnsMasqManager *manager)
kill (priv->pid, SIGKILL);
/* ensure the child is reaped */
nm_debug ("waiting for dnsmasq pid %d to exit", priv->pid);
nm_log_dbg (LOGD_SHARING, "waiting for dnsmasq pid %d to exit", priv->pid);
waitpid (priv->pid, NULL, 0);
nm_debug ("dnsmasq pid %d cleaned up", priv->pid);
nm_log_dbg (LOGD_SHARING, "dnsmasq pid %d cleaned up", priv->pid);
}
priv->pid = 0;

View file

@ -3,6 +3,7 @@ INCLUDES = \
-I${top_srcdir}/include \
-I${top_builddir}/marshallers \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/src \
-I${top_srcdir}/src/named-manager
@ -21,6 +22,8 @@ libip6_manager_la_CPPFLAGS = \
-DG_DISABLE_DEPRECATED
libip6_manager_la_LIBADD = \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
$(top_builddir)/marshallers/libmarshallers.la
$(GLIB_LIBS)

View file

@ -28,7 +28,7 @@
#include "nm-netlink-listener.h"
#include "NetworkManagerUtils.h"
#include "nm-marshal.h"
#include "nm-utils.h"
#include "nm-logging.h"
/* Pre-DHCP addrconf timeout, in seconds */
#define NM_IP6_TIMEOUT 10
@ -213,7 +213,7 @@ nm_ip6_manager_new (void)
priv = NM_IP6_MANAGER_GET_PRIVATE (manager);
if (!priv->devices_by_iface || !priv->devices_by_index) {
nm_warning ("Error: not enough memory to initialize IP6 manager tables");
nm_log_err (LOGD_IP6, "not enough memory to initialize IP6 manager tables");
g_object_unref (manager);
manager = NULL;
}
@ -250,8 +250,8 @@ finish_addrconf (gpointer user_data)
g_signal_emit (manager, signals[ADDRCONF_COMPLETE], 0,
device->iface, info->dhcp_opts, TRUE);
} else {
nm_info ("Device '%s' IP6 addrconf timed out or failed.",
device->iface);
nm_log_info (LOGD_IP6, "(%s): IP6 addrconf timed out or failed.",
device->iface);
iface_copy = g_strdup (device->iface);
@ -647,13 +647,13 @@ nm_ip6_device_new (NMIP6Manager *manager, const char *iface)
device = g_slice_new0 (NMIP6Device);
if (!device) {
nm_warning ("%s: Out of memory creating IP6 addrconf object.", iface);
nm_log_err (LOGD_IP6, "(%s): out of memory creating IP6 addrconf object.", iface);
return NULL;
}
device->iface = g_strdup (iface);
if (!device->iface) {
nm_warning ("%s: Out of memory creating IP6 addrconf object "
nm_log_err (LOGD_IP6, "(%s): out of memory creating IP6 addrconf object "
"property 'iface'.",
iface);
goto error;
@ -662,7 +662,7 @@ nm_ip6_device_new (NMIP6Manager *manager, const char *iface)
device->accept_ra_path = g_strdup_printf ("/proc/sys/net/ipv6/conf/%s/accept_ra", iface);
if (!device->accept_ra_path) {
nm_warning ("%s: Out of memory creating IP6 addrconf object "
nm_log_err (LOGD_IP6, "(%s): out of memory creating IP6 addrconf object "
"property 'accept_ra_path'.",
iface);
goto error;
@ -679,10 +679,10 @@ nm_ip6_device_new (NMIP6Manager *manager, const char *iface)
* device is taken down.
*/
if (!g_file_get_contents (device->accept_ra_path, &contents, NULL, &error)) {
nm_warning ("%s: error reading %s: (%d) %s",
iface, device->accept_ra_path,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_IP6, "(%s): error reading %s: (%d) %s",
iface, device->accept_ra_path,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_clear_error (&error);
} else {
long int tmp;
@ -755,7 +755,7 @@ nm_ip6_manager_begin_addrconf (NMIP6Manager *manager,
device = (NMIP6Device *) g_hash_table_lookup (priv->devices_by_iface, iface);
g_return_if_fail (device != NULL);
nm_info ("Activation (%s) Beginning IP6 addrconf.", iface);
nm_log_info (LOGD_IP6, "Activation (%s) Beginning IP6 addrconf.", iface);
device->addrconf_complete = FALSE;
@ -818,13 +818,13 @@ nm_ip6_manager_get_ip6_config (NMIP6Manager *manager,
device = (NMIP6Device *) g_hash_table_lookup (priv->devices_by_iface, iface);
if (!device) {
nm_warning ("Device '%s' addrconf not started.", iface);
nm_log_warn (LOGD_IP6, "(%s): addrconf not started.", iface);
return NULL;
}
config = nm_ip6_config_new ();
if (!config) {
nm_warning ("%s: Out of memory creating IP6 config object.",
nm_log_err (LOGD_IP6, "(%s): out of memory creating IP6 config object.",
iface);
return NULL;
}

View file

@ -45,7 +45,6 @@
#include "NetworkManager.h"
#include "nm-system.h"
#include "nm-netlink-listener.h"
#include "nm-utils.h"
#include "nm-marshal.h"
#include "nm-netlink.h"

14
src/logging/Makefile.am Normal file
View file

@ -0,0 +1,14 @@
noinst_LTLIBRARIES = libnm-logging.la
libnm_logging_la_SOURCES = \
nm-logging.c \
nm-logging.h
libnm_logging_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DG_DISABLE_DEPRECATED
libnm_logging_la_LIBADD = \
$(GLIB_LIBS)

347
src/logging/nm-logging.c Normal file
View file

@ -0,0 +1,347 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
*
* Copyright (C) 2006 - 2010 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
#define _GNU_SOURCE
#include <dlfcn.h>
#include <syslog.h>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <execinfo.h>
#include <strings.h>
#include <string.h>
#include <glib/gi18n.h>
#include "nm-logging.h"
static guint32 log_level = LOGL_INFO | LOGL_WARN | LOGL_ERR;
static guint32 log_domains = \
LOGD_HW | LOGD_RFKILL | LOGD_ETHER | LOGD_WIFI | LOGD_BT | LOGD_MB | \
LOGD_DHCP4 | LOGD_DHCP6 | LOGD_PPP | LOGD_IP4 | LOGD_IP6 | LOGD_AUTOIP4 | \
LOGD_DNS | LOGD_VPN | LOGD_SHARING | LOGD_SUPPLICANT | LOGD_USER_SET | \
LOGD_SYS_SET | LOGD_SUSPEND | LOGD_CORE | LOGD_DEVICE | LOGD_OLPC_MESH;
typedef struct {
guint32 num;
const char *name;
} LogDesc;
static const LogDesc level_descs[] = {
{ LOGL_ERR, "ERR" },
{ LOGL_WARN | LOGL_ERR, "WARN" },
{ LOGL_INFO | LOGL_WARN | LOGL_ERR, "INFO" },
{ LOGL_DEBUG | LOGL_INFO | LOGL_WARN | LOGL_ERR, "DEBUG" },
{ 0, NULL }
};
static const LogDesc domain_descs[] = {
{ LOGD_NONE, "NONE" },
{ LOGD_HW, "HW" },
{ LOGD_RFKILL, "RFKILL" },
{ LOGD_ETHER, "ETHER" },
{ LOGD_WIFI, "WIFI" },
{ LOGD_BT, "BT" },
{ LOGD_MB, "MB" },
{ LOGD_DHCP4, "DHCP4" },
{ LOGD_DHCP6, "DHCP6" },
{ LOGD_PPP, "PPP" },
{ LOGD_WIFI_SCAN, "WIFI_SCAN" },
{ LOGD_IP4, "IP4" },
{ LOGD_IP6, "IP6" },
{ LOGD_AUTOIP4, "AUTOIP4" },
{ LOGD_DNS, "DNS" },
{ LOGD_VPN, "VPN" },
{ LOGD_SHARING, "SHARING" },
{ LOGD_SUPPLICANT,"SUPPLICANT" },
{ LOGD_USER_SET, "USER_SET" },
{ LOGD_SYS_SET, "SYS_SET" },
{ LOGD_SUSPEND, "SUSPEND" },
{ LOGD_CORE, "CORE" },
{ LOGD_DEVICE, "DEVICE" },
{ LOGD_OLPC_MESH, "OLPC" },
{ 0, NULL }
};
/************************************************************************/
enum {
NM_LOGGING_ERROR_UNKNOWN_LEVEL = 0,
NM_LOGGING_ERROR_UNKNOWN_DOMAIN = 1,
};
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
GQuark
nm_logging_error_quark (void)
{
static GQuark ret = 0;
if (ret == 0)
ret = g_quark_from_static_string ("nm_logging_error");
return ret;
}
GType
nm_logging_error_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (NM_LOGGING_ERROR_UNKNOWN_LEVEL, "UnknownLevel"),
ENUM_ENTRY (NM_LOGGING_ERROR_UNKNOWN_DOMAIN, "UnknownDomain"),
{ 0, 0, 0 }
};
etype = g_enum_register_static ("NMLoggingError", values);
}
return etype;
}
/************************************************************************/
gboolean
nm_logging_setup (const char *level, const char *domains, GError **error)
{
char **tmp, **iter;
guint32 new_domains = 0;
/* levels */
if (level && strlen (level)) {
gboolean found = FALSE;
const LogDesc *diter;
for (diter = &level_descs[0]; diter->name; diter++) {
if (!strcasecmp (diter->name, level)) {
log_level = diter->num;
found = TRUE;
break;
}
}
if (!found) {
g_set_error (error, NM_LOGGING_ERROR, NM_LOGGING_ERROR_UNKNOWN_LEVEL,
_("Unknown log level '%s'"), level);
return FALSE;
}
}
/* domains */
if (domains && strlen (domains)) {
tmp = g_strsplit_set (domains, ", ", 0);
for (iter = tmp; iter && *iter; iter++) {
const LogDesc *diter;
gboolean found = FALSE;
if (!strlen (*iter))
continue;
for (diter = &domain_descs[0]; diter->name; diter++) {
if (!strcasecmp (diter->name, *iter)) {
new_domains |= diter->num;
found = TRUE;
break;
}
}
if (!found) {
g_set_error (error, NM_LOGGING_ERROR, NM_LOGGING_ERROR_UNKNOWN_DOMAIN,
_("Unknown log domain '%s'"), *iter);
return FALSE;
}
}
g_strfreev (tmp);
log_domains = new_domains;
}
return TRUE;
}
void _nm_log (const char *loc,
const char *func,
guint32 domain,
guint32 level,
const char *fmt,
...)
{
va_list args;
char *msg;
GTimeVal tv;
if (!(log_level & level) || !(log_domains & domain))
return;
va_start (args, fmt);
msg = g_strdup_vprintf (fmt, args);
va_end (args);
if ((log_level & LOGL_DEBUG) && (level == LOGL_DEBUG)) {
g_get_current_time (&tv);
syslog (LOG_INFO, "<debug> [%ld.%ld] [%s] %s(): %s\n", tv.tv_sec, tv.tv_usec, loc, func, msg);
} else if ((log_level & LOGL_INFO) && (level == LOGL_INFO))
syslog (LOG_INFO, "<info> %s\n", msg);
else if ((log_level & LOGL_WARN) && (level == LOGL_WARN))
syslog (LOG_WARNING, "<warn> %s\n", msg);
else if ((log_level & LOGL_ERR) && (level == LOGL_ERR)) {
g_get_current_time (&tv);
syslog (LOG_ERR, "<error> [%ld.%ld] [%s] %s(): %s\n", tv.tv_sec, tv.tv_usec, loc, func, msg);
}
g_free (msg);
}
/************************************************************************/
static void
fallback_get_backtrace (void)
{
void *frames[64];
Dl_info info;
size_t size;
guint32 i;
const char *name;
size = backtrace (frames, G_N_ELEMENTS (frames));
syslog (LOG_CRIT, "******************* START **********************************");
for (i = 0; i < size; i++) {
dladdr (frames[i], &info);
name = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
if (info.dli_saddr) {
syslog (LOG_CRIT, "Frame %d: %s (%s+0x%lx) [%p]",
i, name,
info.dli_sname,
(gulong)(frames[i] - info.dli_saddr),
frames[i]);
} else {
syslog (LOG_CRIT, "Frame %d: %s (%p+0x%lx) [%p]",
i, name,
info.dli_fbase,
(gulong)(frames[i] - info.dli_saddr),
frames[i]);
}
}
syslog (LOG_CRIT, "******************* END **********************************");
}
static gboolean
crashlogger_get_backtrace (void)
{
gboolean success = FALSE;
int pid;
pid = fork();
if (pid > 0)
{
/* Wait for the child to finish */
int estatus;
if (waitpid (pid, &estatus, 0) != -1)
{
/* Only succeed if the crashlogger succeeded */
if (WIFEXITED (estatus) && (WEXITSTATUS (estatus) == 0))
success = TRUE;
}
}
else if (pid == 0)
{
/* Child process */
execl (LIBEXECDIR"/nm-crash-logger",
LIBEXECDIR"/nm-crash-logger", NULL);
}
return success;
}
void
nm_logging_backtrace (void)
{
struct stat s;
gboolean fallback = TRUE;
/* Try to use gdb via nm-crash-logger if it exists, since
* we get much better information out of it. Otherwise
* fall back to execinfo.
*/
if (stat (LIBEXECDIR"/nm-crash-logger", &s) == 0)
fallback = crashlogger_get_backtrace () ? FALSE : TRUE;
if (fallback)
fallback_get_backtrace ();
}
static void
nm_log_handler (const gchar *log_domain,
GLogLevelFlags level,
const gchar *message,
gpointer ignored)
{
int syslog_priority;
switch (level) {
case G_LOG_LEVEL_ERROR:
syslog_priority = LOG_CRIT;
break;
case G_LOG_LEVEL_CRITICAL:
syslog_priority = LOG_ERR;
break;
case G_LOG_LEVEL_WARNING:
syslog_priority = LOG_WARNING;
break;
case G_LOG_LEVEL_MESSAGE:
syslog_priority = LOG_NOTICE;
break;
case G_LOG_LEVEL_DEBUG:
syslog_priority = LOG_DEBUG;
break;
case G_LOG_LEVEL_INFO:
default:
syslog_priority = LOG_INFO;
break;
}
syslog (syslog_priority, "%s", message);
}
void
nm_logging_start (gboolean become_daemon)
{
if (become_daemon)
openlog (G_LOG_DOMAIN, 0, LOG_DAEMON);
else
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR, LOG_USER);
g_log_set_handler (G_LOG_DOMAIN,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
nm_log_handler,
NULL);
}
void
nm_logging_shutdown (void)
{
closelog ();
}

108
src/logging/nm-logging.h Normal file
View file

@ -0,0 +1,108 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
*
* Copyright (C) 2006 - 2010 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
#ifndef NM_LOGGING_H
#define NM_LOGGING_H
#include <glib.h>
#include <glib-object.h>
/* Log domains */
enum {
LOGD_NONE = 0x00000000,
LOGD_HW = 0x00000001, /* Hardware detection and info */
LOGD_RFKILL = 0x00000002,
LOGD_ETHER = 0x00000004,
LOGD_WIFI = 0x00000008,
LOGD_BT = 0x00000010,
LOGD_MB = 0x00000020, /* mobile broadband */
LOGD_DHCP4 = 0x00000040,
LOGD_DHCP6 = 0x00000080,
LOGD_PPP = 0x00000100,
LOGD_WIFI_SCAN = 0x00000200,
LOGD_IP4 = 0x00000400,
LOGD_IP6 = 0x00000800,
LOGD_AUTOIP4 = 0x00001000,
LOGD_DNS = 0x00002000,
LOGD_VPN = 0x00004000,
LOGD_SHARING = 0x00008000, /* Connection sharing/dnsmasq */
LOGD_SUPPLICANT = 0x00010000, /* WiFi and 802.1x */
LOGD_USER_SET = 0x00020000, /* User settings */
LOGD_SYS_SET = 0x00040000, /* System settings */
LOGD_SUSPEND = 0x00080000, /* Suspend/Resume */
LOGD_CORE = 0x00100000, /* Core daemon and policy stuff */
LOGD_DEVICE = 0x00200000, /* Device state and activation */
LOGD_OLPC_MESH = 0x00400000,
};
#define LOGD_DHCP (LOGD_DHCP4 | LOGD_DHCP6)
/* Log levels */
enum {
LOGL_ERR = 0x00000001,
LOGL_WARN = 0x00000002,
LOGL_INFO = 0x00000004,
LOGL_DEBUG = 0x00000008
};
#define NM_LOGGING_ERROR (nm_logging_error_quark ())
#define NM_TYPE_LOGGING_ERROR (nm_logging_error_get_type ())
GQuark nm_logging_error_quark (void);
GType nm_logging_error_get_type (void);
#define nm_log_err(domain, fmt, args...) \
{ _nm_log (G_STRLOC, G_STRFUNC, domain, LOGL_ERR, fmt, ##args); }
#define nm_log_warn(domain, fmt, args...) \
{ _nm_log (G_STRLOC, G_STRFUNC, domain, LOGL_WARN, fmt, ##args); }
#define nm_log_info(domain, fmt, args...) \
{ _nm_log (G_STRLOC, G_STRFUNC, domain, LOGL_INFO, fmt, ##args); }
#define nm_log_dbg(domain, fmt, args...) \
{ _nm_log (G_STRLOC, G_STRFUNC, domain, LOGL_DEBUG, fmt, ##args); }
#define nm_log(domain, level, fmt, args...) \
{ _nm_log (G_STRLOC, G_STRFUNC, domain, level, fmt, ##args); }
void _nm_log (const char *loc, const char *func,
guint32 domain, guint32 level,
const char *fmt, ...);
/* Undefine the nm-utils.h logging stuff to ensure errors */
#undef nm_print_backtrace
#undef nm_get_timestamp
#undef nm_info
#undef nm_info_str
#undef nm_debug
#undef nm_debug_str
#undef nm_warning
#undef nm_warning_str
#undef nm_error
#undef nm_error_str
gboolean nm_logging_setup (const char *level, const char *domains, GError **error);
void nm_logging_start (gboolean become_daemon);
void nm_logging_backtrace (void);
void nm_logging_shutdown (void);
#endif /* NM_LOGGING_H */

View file

@ -40,7 +40,6 @@
#include <string.h>
#include "NetworkManager.h"
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-manager.h"
#include "nm-policy.h"
@ -54,6 +53,10 @@
#include "nm-vpn-manager.h"
#include "nm-logging.h"
#if !defined(NM_DIST_VERSION)
# define NM_DIST_VERSION VERSION
#endif
#define NM_DEFAULT_PID_FILE LOCALSTATEDIR"/run/NetworkManager.pid"
#define NM_DEFAULT_SYSTEM_CONF_FILE SYSCONFDIR"/NetworkManager/NetworkManager.conf"
#define NM_OLD_SYSTEM_CONF_FILE SYSCONFDIR"/NetworkManager/nm-system-settings.conf"
@ -75,7 +78,7 @@ typedef struct {
static gboolean
detach_monitor (gpointer data)
{
nm_info ("Detaching netlink event monitor");
nm_log_warn (LOGD_HW, "detaching netlink event monitor");
nm_netlink_monitor_detach (NM_NETLINK_MONITOR (data));
return FALSE;
}
@ -90,10 +93,11 @@ nm_error_monitoring_device_link_state (NMNetlinkMonitor *monitor,
now = time (NULL);
if (info->domain != error->domain || info->code != error->code || (info->time && now > info->time + 10)) {
if ( (info->domain != error->domain)
|| (info->code != error->code)
|| (info->time && now > info->time + 10)) {
/* FIXME: Try to handle the error instead of just printing it. */
nm_warning ("error monitoring device for netlink events: %s\n",
error->message);
nm_log_warn (LOGD_HW, "error monitoring device for netlink events: %s\n", error->message);
info->time = now;
info->domain = error->domain;
@ -106,26 +110,20 @@ nm_error_monitoring_device_link_state (NMNetlinkMonitor *monitor,
/* Broken drivers will sometimes cause a flood of netlink errors.
* rh #459205, novell #443429, lp #284507
*/
nm_warning ("Excessive netlink errors ocurred, disabling netlink monitor.");
nm_warning ("Link change events will not be processed.");
nm_log_warn (LOGD_HW, "excessive netlink errors ocurred, disabling netlink monitor.");
nm_log_warn (LOGD_HW, "link change events will not be processed.");
g_idle_add_full (G_PRIORITY_HIGH, detach_monitor, monitor, NULL);
}
}
static gboolean
nm_monitor_setup (void)
nm_monitor_setup (GError **error)
{
GError *error = NULL;
NMNetlinkMonitor *monitor;
MonitorInfo *info;
monitor = nm_netlink_monitor_get ();
nm_netlink_monitor_open_connection (monitor, &error);
if (error != NULL)
{
nm_warning ("could not monitor wired ethernet devices: %s",
error->message);
g_error_free (error);
if (!nm_netlink_monitor_open_connection (monitor, error)) {
g_object_unref (monitor);
return FALSE;
}
@ -136,7 +134,6 @@ nm_monitor_setup (void)
info,
(GClosureNotify) g_free,
0);
nm_netlink_monitor_attach (monitor);
/* Request initial status of cards */
@ -163,7 +160,7 @@ nm_signal_handler (int signo)
case SIGBUS:
case SIGILL:
case SIGABRT:
nm_warning ("Caught signal %d. Generating backtrace...", signo);
nm_log_warn (LOGD_CORE, "caught signal %d. Generating backtrace...", signo);
nm_logging_backtrace ();
exit (1);
break;
@ -173,7 +170,7 @@ nm_signal_handler (int signo)
/* let the fatal signals interrupt us */
--in_fatal;
nm_warning ("Caught signal %d, shutting down abnormally. Generating backtrace...", signo);
nm_log_warn (LOGD_CORE, "caught signal %d, shutting down abnormally. Generating backtrace...", signo);
nm_logging_backtrace ();
g_main_loop_quit (main_loop);
break;
@ -183,7 +180,7 @@ nm_signal_handler (int signo)
/* let the fatal signals interrupt us */
--in_fatal;
nm_warning ("Caught signal %d, shutting down normally.", signo);
nm_log_info (LOGD_CORE, "caught signal %d, shutting down normally.", signo);
quit_early = TRUE;
g_main_loop_quit (main_loop);
break;
@ -237,18 +234,18 @@ write_pidfile (const char *pidfile)
gboolean success = FALSE;
if ((fd = open (pidfile, O_CREAT|O_WRONLY|O_TRUNC, 00644)) < 0) {
nm_warning ("Opening %s failed: %s", pidfile, strerror (errno));
fprintf (stderr, "Opening %s failed: %s\n", pidfile, strerror (errno));
return FALSE;
}
snprintf (pid, sizeof (pid), "%d", getpid ());
if (write (fd, pid, strlen (pid)) < 0)
nm_warning ("Writing to %s failed: %s", pidfile, strerror (errno));
fprintf (stderr, "Writing to %s failed: %s\n", pidfile, strerror (errno));
else
success = TRUE;
if (close (fd))
nm_warning ("Closing %s failed: %s", pidfile, strerror (errno));
fprintf (stderr, "Closing %s failed: %s\n", pidfile, strerror (errno));
return success;
}
@ -291,7 +288,7 @@ check_pidfile (const char *pidfile)
if (strcmp (process_name, "NetworkManager") == 0) {
/* Check that the process exists */
if (kill (pid, 0) == 0) {
g_warning ("NetworkManager is already running (pid %ld)", pid);
fprintf (stderr, "NetworkManager is already running (pid %ld)\n", pid);
nm_running = TRUE;
}
}
@ -306,6 +303,8 @@ static gboolean
parse_config_file (const char *filename,
char **plugins,
char **dhcp_client,
char **log_level,
char **log_domains,
GError **error)
{
GKeyFile *config;
@ -327,6 +326,9 @@ parse_config_file (const char *filename,
*dhcp_client = g_key_file_get_value (config, "main", "dhcp", NULL);
*log_level = g_key_file_get_value (config, "logging", "level", NULL);
*log_domains = g_key_file_get_value (config, "logging", "domains", NULL);
g_key_file_free (config);
return TRUE;
}
@ -442,6 +444,7 @@ main (int argc, char *argv[])
gboolean g_fatal_warnings = FALSE;
char *pidfile = NULL, *state_file = NULL, *dhcp = NULL;
char *config = NULL, *plugins = NULL, *conf_plugins = NULL;
char *log_level = NULL, *log_domains = NULL;
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE;
gboolean success;
NMPolicy *policy = NULL;
@ -452,6 +455,7 @@ main (int argc, char *argv[])
NMDHCPManager *dhcp_mgr = NULL;
GError *error = NULL;
gboolean wrote_pidfile = FALSE;
char *cfg_log_level = NULL, *cfg_log_domains = NULL;
GOptionEntry options[] = {
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL },
@ -459,17 +463,21 @@ main (int argc, char *argv[])
{ "pid-file", 0, 0, G_OPTION_ARG_FILENAME, &pidfile, "Specify the location of a PID file", "filename" },
{ "state-file", 0, 0, G_OPTION_ARG_FILENAME, &state_file, "State file location", "/path/to/state.file" },
{ "config", 0, 0, G_OPTION_ARG_FILENAME, &config, "Config file location", "/path/to/config.file" },
{ "plugins", 0, 0, G_OPTION_ARG_STRING, &plugins, "List of plugins separated by ,", "plugin1,plugin2" },
{ "plugins", 0, 0, G_OPTION_ARG_STRING, &plugins, "List of plugins separated by ','", "plugin1,plugin2" },
{ "log-level", 0, 0, G_OPTION_ARG_STRING, &log_level, "Log level: one of [ERR, WARN, INFO, DEBUG]", "INFO" },
{ "log-domains", 0, 0, G_OPTION_ARG_STRING, &log_domains,
"Log domains separated by ',': any combination of [NONE,HW,RKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,USER_SET,SYS_SET,SUSPEND,CORE,DEVICE,OLPC]",
"HW,RFKILL,WIFI" },
{NULL}
};
if (getuid () != 0) {
g_printerr ("You must be root to run NetworkManager!\n");
fprintf (stderr, "You must be root to run NetworkManager!\n");
exit (1);
}
if (!g_module_supported ()) {
g_printerr ("GModules are not supported on your platform!");
fprintf (stderr, "GModules are not supported on your platform!\n");
exit (1);
}
@ -504,11 +512,11 @@ main (int argc, char *argv[])
/* Parse the config file */
if (config) {
if (!parse_config_file (config, &conf_plugins, &dhcp, &error)) {
g_warning ("Config file %s invalid: (%d) %s.",
config,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
if (!parse_config_file (config, &conf_plugins, &dhcp, &cfg_log_level, &cfg_log_domains, &error)) {
fprintf (stderr, "Config file %s invalid: (%d) %s\n",
config,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
exit (1);
}
} else {
@ -517,12 +525,12 @@ main (int argc, char *argv[])
/* Try NetworkManager.conf first */
if (g_file_test (NM_DEFAULT_SYSTEM_CONF_FILE, G_FILE_TEST_EXISTS)) {
config = g_strdup (NM_DEFAULT_SYSTEM_CONF_FILE);
parsed = parse_config_file (config, &conf_plugins, &dhcp, &error);
parsed = parse_config_file (config, &conf_plugins, &dhcp, &cfg_log_level, &cfg_log_domains, &error);
if (!parsed) {
g_warning ("Default config file %s invalid: (%d) %s.",
config,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
fprintf (stderr, "Default config file %s invalid: (%d) %s\n",
config,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
g_free (config);
config = NULL;
g_clear_error (&error);
@ -533,11 +541,11 @@ main (int argc, char *argv[])
/* Try old nm-system-settings.conf next */
if (!parsed) {
config = g_strdup (NM_OLD_SYSTEM_CONF_FILE);
if (!parse_config_file (config, &conf_plugins, &dhcp, &error)) {
g_warning ("Default config file %s invalid: (%d) %s.",
config,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
if (!parse_config_file (config, &conf_plugins, &dhcp, &cfg_log_level, &cfg_log_domains, &error)) {
fprintf (stderr, "Default config file %s invalid: (%d) %s\n",
config,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
g_free (config);
config = NULL;
g_clear_error (&error);
@ -546,16 +554,26 @@ main (int argc, char *argv[])
}
}
/* Logging setup */
if (!nm_logging_setup (log_level ? log_level : cfg_log_level,
log_domains ? log_domains : cfg_log_domains,
&error)) {
fprintf (stderr,
_("%s. Please use --help to see a list of valid options.\n"),
error->message);
exit (1);
}
/* Plugins specified with '--plugins' override those of config file */
plugins = plugins ? plugins : g_strdup (conf_plugins);
g_free (conf_plugins);
/* Parse the state file */
if (!parse_state_file (state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &error)) {
g_warning ("State file %s parsing failed: (%d) %s.",
state_file,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
fprintf (stderr, "State file %s parsing failed: (%d) %s\n",
state_file,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
/* Not a hard failure */
}
g_clear_error (&error);
@ -569,9 +587,9 @@ main (int argc, char *argv[])
int saved_errno;
saved_errno = errno;
nm_error ("Could not daemonize: %s [error %u]",
g_strerror (saved_errno),
saved_errno);
fprintf (stderr, "Could not daemonize: %s [error %u]\n",
g_strerror (saved_errno),
saved_errno);
exit (1);
}
if (write_pidfile (pidfile))
@ -600,29 +618,32 @@ main (int argc, char *argv[])
setup_signals ();
nm_logging_setup (become_daemon);
nm_logging_start (become_daemon);
nm_info ("starting...");
nm_log_info (LOGD_CORE, "NetworkManager (version " NM_DIST_VERSION ") is starting...");
success = FALSE;
main_loop = g_main_loop_new (NULL, FALSE);
/* Create watch functions that monitor cards for link status. */
if (!nm_monitor_setup ())
if (!nm_monitor_setup (&error)) {
nm_log_err (LOGD_CORE, "failed to start monitoring devices: %s.",
error && error->message ? error->message : "(unknown)");
goto done;
}
/* Initialize our DBus service & connection */
dbus_mgr = nm_dbus_manager_get ();
vpn_manager = nm_vpn_manager_get ();
if (!vpn_manager) {
nm_warning ("Failed to start the VPN manager.");
nm_log_err (LOGD_CORE, "failed to start the VPN manager.");
goto done;
}
named_mgr = nm_named_manager_get ();
if (!named_mgr) {
nm_warning ("Failed to start the named manager.");
nm_log_err (LOGD_CORE, "failed to start the named manager.");
goto done;
}
@ -634,28 +655,28 @@ main (int argc, char *argv[])
wwan_enabled,
&error);
if (manager == NULL) {
nm_error ("Failed to initialize the network manager: %s",
nm_log_err (LOGD_CORE, "failed to initialize the network manager: %s",
error && error->message ? error->message : "(unknown)");
goto done;
}
policy = nm_policy_new (manager, vpn_manager);
if (policy == NULL) {
nm_error ("Failed to initialize the policy.");
nm_log_err (LOGD_CORE, "failed to initialize the policy.");
goto done;
}
/* Initialize the supplicant manager */
sup_mgr = nm_supplicant_manager_get ();
if (!sup_mgr) {
nm_error ("Failed to initialize the supplicant manager.");
nm_log_err (LOGD_CORE, "failed to initialize the supplicant manager.");
goto done;
}
/* Initialize DHCP manager */
dhcp_mgr = nm_dhcp_manager_new (dhcp, &error);
if (!dhcp_mgr) {
nm_warning ("Failed to start the DHCP manager: %s.", error->message);
nm_log_err (LOGD_CORE, "failed to start the DHCP manager: %s.", error->message);
goto done;
}
@ -663,7 +684,7 @@ main (int argc, char *argv[])
/* Start our DBus service */
if (!nm_dbus_manager_start_service (dbus_mgr)) {
nm_warning ("Failed to start the dbus service.");
nm_log_err (LOGD_CORE, "failed to start the dbus service.");
goto done;
}
@ -713,7 +734,11 @@ done:
g_free (config);
g_free (plugins);
g_free (dhcp);
g_free (log_level);
g_free (log_domains);
g_free (cfg_log_level);
g_free (cfg_log_domains);
nm_info ("exiting (%s)", success ? "success" : "error");
nm_log_info (LOGD_CORE, "exiting (%s)", success ? "success" : "error");
exit (success ? 0 : 1);
}

View file

@ -1,5 +1,6 @@
INCLUDES = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_builddir}/marshallers
@ -22,6 +23,7 @@ libmodem_manager_la_CPPFLAGS = \
libmodem_manager_la_LIBADD = \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS)
nm-serial-device-glue.h: $(top_srcdir)/introspection/nm-device-serial.xml

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
*/
@ -28,8 +28,8 @@
#include "nm-dbus-manager.h"
#include "nm-setting-connection.h"
#include "nm-setting-cdma.h"
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-logging.h"
G_DEFINE_TYPE (NMModemCdma, nm_modem_cdma, NM_TYPE_MODEM)
@ -119,9 +119,9 @@ stage1_prepare_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data
if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID))
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, TRUE, NM_DEVICE_STATE_REASON_NONE);
else {
nm_warning ("CDMA connection failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB, "CDMA connection failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_error_free (error);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_NONE);
}
@ -150,9 +150,9 @@ stage1_enable_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_da
if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID))
do_connect (self);
else {
nm_warning ("CDMA modem enable failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB, "CDMA modem enable failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_error_free (error);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
}

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
*/
@ -26,7 +26,7 @@
#include "nm-setting-connection.h"
#include "nm-setting-gsm.h"
#include "nm-modem-types.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "NetworkManagerUtils.h"
typedef enum {
@ -207,9 +207,9 @@ stage1_prepare_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data
else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_WRONG))
ask_for_pin (self, TRUE);
else {
nm_warning ("GSM connection failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB, "GSM connection failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, translate_mm_error (error));
}
@ -260,9 +260,9 @@ stage1_pin_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
/* Success; go back and try the enable again */
do_enable (self);
} else {
nm_warning ("GSM PIN unlock failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB, "GSM PIN unlock failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_error_free (error);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
@ -303,9 +303,9 @@ stage1_enable_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_da
if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID))
do_connect (self);
else {
nm_warning ("GSM modem enable failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB, "GSM modem enable failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN))
handle_enable_pin_required (self);

View file

@ -15,18 +15,18 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
* Copyright (C) 2009 Canonical Ltd.
*/
#include <string.h>
#include "nm-modem-manager.h"
#include "nm-logging.h"
#include "nm-modem.h"
#include "nm-modem-gsm.h"
#include "nm-modem-cdma.h"
#include "nm-dbus-manager.h"
#include "nm-utils.h"
#include "nm-modem-types.h"
#include "nm-marshal.h"
@ -95,7 +95,7 @@ get_modem_properties (DBusGConnection *connection,
*type = g_value_get_uint (&value);
g_value_unset (&value);
} else {
g_warning ("Could not get device type: %s", err->message);
nm_log_warn (LOGD_MB, "could not get device type: %s", err->message);
goto out;
}
@ -108,7 +108,7 @@ get_modem_properties (DBusGConnection *connection,
*device = g_value_dup_string (&value);
g_value_unset (&value);
} else {
g_warning ("Could not get device: %s", err->message);
nm_log_warn (LOGD_MB, "could not get device: %s", err->message);
goto out;
}
@ -121,7 +121,7 @@ get_modem_properties (DBusGConnection *connection,
*ip_method = g_value_get_uint (&value);
g_value_unset (&value);
} else {
g_warning ("Could not get IP method: %s", err->message);
nm_log_warn (LOGD_MB, "could not get IP method: %s", err->message);
goto out;
}
@ -134,7 +134,7 @@ get_modem_properties (DBusGConnection *connection,
*data_device = g_value_dup_string (&value);
g_value_unset (&value);
} else {
g_warning ("Could not get modem data device: %s", err->message);
nm_log_warn (LOGD_MB, "could not get modem data device: %s", err->message);
goto out;
}
@ -147,7 +147,7 @@ get_modem_properties (DBusGConnection *connection,
*driver = g_value_dup_string (&value);
g_value_unset (&value);
} else {
g_warning ("Could not get modem driver: %s", err->message);
nm_log_warn (LOGD_MB, "could not get modem driver: %s", err->message);
goto out;
}
@ -164,13 +164,13 @@ static void
create_modem (NMModemManager *manager, const char *path)
{
NMModemManagerPrivate *priv = NM_MODEM_MANAGER_GET_PRIVATE (manager);
NMModem *modem;
NMModem *modem = NULL;
char *data_device = NULL, *driver = NULL, *master_device = NULL;
uint modem_type = MM_MODEM_TYPE_UNKNOWN;
uint ip_method = MM_MODEM_IP_METHOD_PPP;
if (g_hash_table_lookup (priv->modems, path)) {
nm_warning ("Modem with path %s already exists, ignoring", path);
nm_log_warn (LOGD_MB, "modem with path %s already exists, ignoring", path);
return;
}
@ -180,22 +180,22 @@ create_modem (NMModemManager *manager, const char *path)
return;
if (modem_type == MM_MODEM_TYPE_UNKNOWN) {
nm_warning ("Modem with path %s has unknown type, ignoring", path);
nm_log_warn (LOGD_MB, "modem with path %s has unknown type, ignoring", path);
return;
}
if (!master_device || !strlen (master_device)) {
nm_warning ("Modem with path %s has unknown device, ignoring", path);
nm_log_warn (LOGD_MB, "modem with path %s has unknown device, ignoring", path);
return;
}
if (!driver || !strlen (driver)) {
nm_warning ("Modem with path %s has unknown driver, ignoring", path);
nm_log_warn (LOGD_MB, "modem with path %s has unknown driver, ignoring", path);
return;
}
if (!data_device || !strlen (data_device)) {
nm_warning ("Modem with path %s has unknown data device, ignoring", path);
nm_log_warn (LOGD_MB, "modem with path %s has unknown data device, ignoring", path);
return;
}
@ -204,7 +204,7 @@ create_modem (NMModemManager *manager, const char *path)
else if (modem_type == MM_MODEM_TYPE_CDMA)
modem = nm_modem_cdma_new (path, master_device, data_device, ip_method);
else
g_error ("Invalid modem type");
nm_log_warn (LOGD_MB, "unknown modem type '%d'", modem_type);
g_free (data_device);
@ -265,7 +265,7 @@ enumerate_devices_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer dat
if (!dbus_g_proxy_end_call (proxy, call_id, &error,
dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), &modems,
G_TYPE_INVALID)) {
nm_warning ("Could not get modem list: %s", error->message);
nm_log_warn (LOGD_MB, "could not get modem list: %s", error->message);
g_error_free (error);
} else {
int i;
@ -291,7 +291,7 @@ modem_manager_appeared (NMModemManager *self, gboolean enumerate_devices)
priv->poke_id = 0;
}
nm_info ("modem-manager is now available");
nm_log_info (LOGD_MB, "modem-manager is now available");
priv->proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
MM_DBUS_SERVICE, MM_DBUS_PATH, MM_DBUS_INTERFACE);
@ -331,7 +331,7 @@ modem_manager_disappeared (NMModemManager *self)
}
/* Try to activate the modem-manager */
nm_info ("Trying to start the modem-manager...");
nm_log_info (LOGD_MB, "trying to start the modem manager...");
poke_modem_cb (self);
priv->poke_id = g_timeout_add_seconds (MODEM_POKE_INTERVAL, poke_modem_cb, self);
}
@ -356,7 +356,7 @@ nm_modem_manager_name_owner_changed (NMDBusManager *dbus_mgr,
if (!old_owner_good && new_owner_good) {
modem_manager_appeared (NM_MODEM_MANAGER (user_data), FALSE);
} else if (old_owner_good && !new_owner_good) {
nm_info ("modem manager disappeared");
nm_log_info (LOGD_MB, "the modem manager disappeared");
modem_manager_disappeared (NM_MODEM_MANAGER (user_data));
}
}

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
*/
@ -27,7 +27,7 @@
#include "nm-marshal.h"
#include "nm-properties-changed-signal.h"
#include "nm-modem-types.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "NetworkManagerUtils.h"
#include "nm-device-private.h"
#include "nm-device-interface.h"
@ -203,6 +203,7 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
}
if (!num || dns_workaround) {
nm_log_warn (LOGD_PPP, "compensating for invalid PPP-provided nameservers");
nm_ip4_config_reset_nameservers (config);
nm_ip4_config_add_nameserver (config, good_dns1);
nm_ip4_config_add_nameserver (config, good_dns2);
@ -267,8 +268,7 @@ ppp_stage3_ip4_config_start (NMModem *self,
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else {
nm_warning ("%s: error starting PPP: (%d) %s",
__func__,
nm_log_err (LOGD_PPP, "error starting PPP: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_error_free (error);
@ -398,6 +398,7 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
NMDeviceClass *device_class,
NMDeviceStateReason *reason)
{
NMModemPrivate *priv;
NMActRequest *req;
NMActStageReturn ret;
@ -412,7 +413,8 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
req = nm_device_get_act_request (device);
g_assert (req);
switch (NM_MODEM_GET_PRIVATE (self)->ip_method) {
priv = NM_MODEM_GET_PRIVATE (self);
switch (priv->ip_method) {
case MM_MODEM_IP_METHOD_PPP:
ret = ppp_stage3_ip4_config_start (self, req, reason);
break;
@ -423,7 +425,7 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
ret = device_class->act_stage3_ip4_config_start (device, reason);
break;
default:
g_warning ("Invalid IP method");
nm_log_err (LOGD_MB, "unknown IP method %d", priv->ip_method);
ret = NM_ACT_STAGE_RETURN_FAILURE;
break;
}
@ -438,6 +440,7 @@ nm_modem_stage4_get_ip4_config (NMModem *self,
NMIP4Config **config,
NMDeviceStateReason *reason)
{
NMModemPrivate *priv;
NMActRequest *req;
NMActStageReturn ret;
@ -452,7 +455,8 @@ nm_modem_stage4_get_ip4_config (NMModem *self,
req = nm_device_get_act_request (device);
g_assert (req);
switch (NM_MODEM_GET_PRIVATE (self)->ip_method) {
priv = NM_MODEM_GET_PRIVATE (self);
switch (priv->ip_method) {
case MM_MODEM_IP_METHOD_PPP:
ret = ppp_stage4 (self, req, config, reason);
break;
@ -463,7 +467,7 @@ nm_modem_stage4_get_ip4_config (NMModem *self,
ret = device_class->act_stage4_get_ip4_config (device, config, reason);
break;
default:
g_warning ("Invalid IP method");
nm_log_err (LOGD_MB, "unknown IP method %d", priv->ip_method);
ret = NM_ACT_STAGE_RETURN_FAILURE;
break;
}
@ -526,7 +530,7 @@ nm_modem_connection_secrets_updated (NMModem *self,
if (!strcmp (candidate_setting_name, setting_name))
found = TRUE;
else {
nm_warning ("Ignoring updated secrets for setting '%s'.",
nm_log_warn (LOGD_MB, "ignoring updated secrets for setting '%s'.",
candidate_setting_name);
}
}
@ -662,7 +666,7 @@ real_deactivate_quickly (NMModem *self, NMDevice *device)
nm_system_device_set_up_down_with_iface (iface, FALSE, NULL);
break;
default:
g_warning ("Invalid IP method");
nm_log_err (LOGD_MB, "unknown IP method %d", priv->ip_method);
break;
}
}
@ -679,10 +683,9 @@ disconnect_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
GError *error = NULL;
if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
g_warning ("%s: disconnect failed: (%d) %s",
__func__,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_info (LOGD_MB, "disconnect failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
}
}
@ -786,10 +789,9 @@ get_mm_enabled_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_d
if (!dbus_g_proxy_end_call (proxy, call_id, &error,
G_TYPE_VALUE, &value,
G_TYPE_INVALID)) {
g_warning ("%s: failed get modem enabled state: (%d) %s",
__func__,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB, "failed get modem enabled state: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
return;
}
@ -797,7 +799,7 @@ get_mm_enabled_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_d
NM_MODEM_GET_PRIVATE (self)->mm_enabled = g_value_get_boolean (&value);
g_object_notify (G_OBJECT (self), NM_MODEM_ENABLED);
} else
g_warning ("%s: failed get modem enabled state: unexpected reply type", __func__);
nm_log_warn (LOGD_MB, "failed get modem enabled state: unexpected reply type");
g_value_unset (&value);
}
@ -819,10 +821,9 @@ set_mm_enabled_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_d
GError *error = NULL;
if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
g_warning ("%s: failed to enable/disable modem: (%d) %s",
__func__,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB, "failed to enable/disable modem: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
}
/* Update enabled/disabled state again */
@ -904,17 +905,17 @@ constructor (GType type,
priv = NM_MODEM_GET_PRIVATE (object);
if (!priv->device) {
g_warning ("Modem parent device not provided");
nm_log_err (LOGD_HW, "modem parent device not provided");
goto err;
}
if (!priv->device) {
g_warning ("Modem command interface not provided");
nm_log_err (LOGD_HW, "modem command interface not provided");
goto err;
}
if (!priv->path) {
g_warning ("DBus path not provided");
nm_log_err (LOGD_HW, "D-Bus path not provided");
goto err;
}

View file

@ -1,4 +1,8 @@
INCLUDES = -I${top_srcdir}/libnm-util -I${top_srcdir}/src -I${top_srcdir}/include
INCLUDES = \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/src \
-I${top_srcdir}/include
noinst_LTLIBRARIES = libnamed-manager.la
@ -10,4 +14,8 @@ libnamed_manager_la_CPPFLAGS = \
-DNM_PKGDATADIR=\"$(pkgdatadir)\" \
-DNM_LOCALSTATEDIR=\"$(localstatedir)\"
libnamed_manager_la_LIBADD = $(DBUS_LIBS) $(GLIB_LIBS)
libnamed_manager_la_LIBADD = \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)

View file

@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2004 - 2005 Colin Walters <walters@redhat.com>
* Copyright (C) 2004 - 2008 Red Hat, Inc.
* Copyright (C) 2004 - 2010 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
* and others
*/
@ -38,7 +38,7 @@
#include "nm-named-manager.h"
#include "nm-ip4-config.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-system.h"
#include "NetworkManagerUtils.h"
@ -60,9 +60,9 @@ G_DEFINE_TYPE(NMNamedManager, nm_named_manager, G_TYPE_OBJECT)
struct NMNamedManagerPrivate {
NMIP4Config * vpn_config;
NMIP4Config * device_config;
GSList * configs;
NMIP4Config *vpn_config;
NMIP4Config *device_config;
GSList *configs;
};
@ -71,11 +71,10 @@ nm_named_manager_get (void)
{
static NMNamedManager * singleton = NULL;
if (!singleton) {
if (!singleton)
singleton = NM_NAMED_MANAGER (g_object_new (NM_TYPE_NAMED_MANAGER, NULL));
} else {
else
g_object_ref (singleton);
}
g_assert (singleton);
return singleton;
@ -185,7 +184,7 @@ run_netconfig (GError **error, gint *stdin_fd)
argv[4] = NULL;
tmp = g_strjoinv (" ", argv);
nm_debug ("Spawning '%s'", tmp);
nm_log_debug (LOGD_DNS, "spawning '%s'", tmp);
g_free (tmp);
if (!g_spawn_async_with_pipes (NULL, argv, NULL, 0, netconfig_child_setup,
@ -202,7 +201,7 @@ write_to_netconfig (gint fd, const char *key, const char *value)
int x;
str = g_strdup_printf ("%s='%s'\n", key, value);
nm_debug ("Writing to netconfig: %s", str);
nm_log_debug (LOGD_DNS, "writing to netconfig: %s", str);
x = write (fd, str, strlen (str));
g_free (str);
}
@ -327,7 +326,7 @@ write_resolv_conf (FILE *f, const char *domain,
}
if (fprintf (f, "%s%s%s",
domain_str ? domain_str : "",
domain_str ? domain_str : "",
searches_str ? searches_str : "",
nameservers_str ? nameservers_str : "") != -1)
retval = TRUE;
@ -356,7 +355,7 @@ dispatch_resolvconf (const char *domain,
if (domain || searches || nameservers) {
cmd = g_strconcat (RESOLVCONF_PATH, " -a ", "NetworkManager", NULL);
nm_info ("(%s): writing resolv.conf to %s", iface, RESOLVCONF_PATH);
nm_log_info (LOGD_DNS, "(%s): writing resolv.conf to %s", iface, RESOLVCONF_PATH);
if ((f = popen (cmd, "w")) == NULL)
g_set_error (error,
NM_NAMED_MANAGER_ERROR,
@ -370,7 +369,7 @@ dispatch_resolvconf (const char *domain,
}
} else {
cmd = g_strconcat (RESOLVCONF_PATH, " -d ", "NetworkManager", NULL);
nm_info ("(%s): removing resolv.conf from %s", iface, RESOLVCONF_PATH);
nm_log_info (LOGD_DNS, "(%s): removing resolv.conf from %s", iface, RESOLVCONF_PATH);
if (nm_spawn_process (cmd) == 0)
retval = TRUE;
}
@ -587,7 +586,7 @@ nm_named_manager_add_ip4_config (NMNamedManager *mgr,
priv->configs = g_slist_append (priv->configs, g_object_ref (config));
if (!rewrite_resolv_conf (mgr, iface, &error)) {
nm_warning ("Could not commit DNS changes. Error: '%s'", error ? error->message : "(none)");
nm_log_warn (LOGD_DNS, "could not commit DNS changes: '%s'", error ? error->message : "(none)");
g_error_free (error);
}
@ -623,7 +622,7 @@ nm_named_manager_remove_ip4_config (NMNamedManager *mgr,
g_object_unref (config);
if (!rewrite_resolv_conf (mgr, iface, &error)) {
nm_warning ("Could not commit DNS changes. Error: '%s'", error ? error->message : "(none)");
nm_log_warn (LOGD_DNS, "could not commit DNS changes: '%s'", error ? error->message : "(none)");
if (error)
g_error_free (error);
}
@ -653,7 +652,7 @@ nm_named_manager_add_ip6_config (NMNamedManager *mgr,
priv->configs = g_slist_append (priv->configs, g_object_ref (config));
if (!rewrite_resolv_conf (mgr, iface, &error)) {
nm_warning ("Could not commit DNS changes. Error: '%s'", error ? error->message : "(none)");
nm_log_warn (LOGD_DNS, "could not commit DNS changes: '%s'", error ? error->message : "(none)");
g_error_free (error);
}
@ -683,7 +682,7 @@ nm_named_manager_remove_ip6_config (NMNamedManager *mgr,
g_object_unref (config);
if (!rewrite_resolv_conf (mgr, iface, &error)) {
nm_warning ("Could not commit DNS changes. Error: '%s'", error ? error->message : "(none)");
nm_log_warn (LOGD_DNS, "could not commit DNS changes: '%s'", error ? error->message : "(none)");
if (error)
g_error_free (error);
}

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) 2005 - 2008 Red Hat, Inc.
* Copyright (C) 2005 - 2010 Red Hat, Inc.
* Copyright (C) 2007 - 2008 Novell, Inc.
*/
@ -27,7 +27,7 @@
#include "nm-activation-request.h"
#include "nm-marshal.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-setting-wireless-security.h"
#include "nm-setting-8021x.h"
#include "nm-dbus-manager.h"
@ -418,9 +418,9 @@ secrets_update_setting (NMSecretsProviderInterface *interface,
nm_connection_add_setting (priv->connection, setting);
else {
if (!nm_connection_update_secrets (priv->connection, setting_name, new, &error)) {
nm_warning ("Failed to update connection secrets: %d %s",
error ? error->code : -1,
error && error->message ? error->message : "(none)");
nm_log_warn (LOGD_DEVICE, "Failed to update connection secrets: %d %s",
error ? error->code : -1,
error && error->message ? error->message : "(none)");
g_clear_error (&error);
}
}
@ -591,15 +591,17 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared)
int status;
GError *error = NULL;
nm_info ("Executing: %s", cmd);
nm_log_info (LOGD_SHARING, "Executing: %s", cmd);
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
share_child_setup, NULL, NULL, NULL, &status, &error)) {
nm_info ("Error executing command: (%d) %s",
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
nm_log_warn (LOGD_SHARING, "Error executing command: (%d) %s",
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
} else if (WEXITSTATUS (status))
nm_info ("** Command returned exit status %d.", WEXITSTATUS (status));
} else if (WEXITSTATUS (status)) {
nm_log_warn (LOGD_SHARING, "** Command returned exit status %d.",
WEXITSTATUS (status));
}
}
g_free (cmd);
if (argv)

View file

@ -15,13 +15,14 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*/
#include <glib.h>
#include "nm-active-connection.h"
#include "NetworkManager.h"
#include "nm-active-connection-glue.h"
#include "nm-logging.h"
char *
nm_active_connection_get_next_object_path (void)
@ -54,7 +55,7 @@ nm_active_connection_scope_to_value (NMConnection *connection, GValue *value)
g_value_set_string (value, NM_DBUS_SERVICE_USER_SETTINGS);
break;
default:
g_warning ("%s: unknown connection scope!", __func__);
nm_log_err (LOGD_CORE, "unknown connection scope!");
break;
}
}

View file

@ -16,10 +16,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 Novell, Inc.
* Copyright (C) 2010 Red Hat, Inc.
*/
#include "nm-call-store.h"
#include "nm-utils.h"
#include "nm-logging.h"
NMCallStore *
nm_call_store_new (void)
@ -68,12 +69,12 @@ nm_call_store_remove (NMCallStore *store,
call_ids_hash = g_hash_table_lookup (store, object);
if (!call_ids_hash) {
nm_warning ("Trying to remove a non-existant call id.");
nm_log_warn (LOGD_CORE, "Trying to remove a non-existant call id.");
return;
}
if (!g_hash_table_remove (call_ids_hash, call_id))
nm_warning ("Trying to remove a non-existant call id.");
nm_log_warn (LOGD_CORE, "Trying to remove a non-existant call id.");
if (g_hash_table_size (call_ids_hash) == 0) {
g_hash_table_remove (store, object);
@ -162,7 +163,7 @@ nm_call_store_foreach (NMCallStore *store,
call_ids_hash = g_hash_table_lookup (store, object);
if (!call_ids_hash) {
nm_warning ("Object not in store");
nm_log_warn (LOGD_CORE, "Object not in store");
return -1;
}

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) 2006 - 2008 Novell, Inc.
*/
@ -29,7 +29,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <string.h>
#include "nm-utils.h"
#include "nm-logging.h"
enum {
DBUS_CONNECTION_CHANGED = 0,
@ -158,7 +158,7 @@ nm_dbus_manager_reconnect (gpointer user_data)
if (nm_dbus_manager_init_bus (self)) {
if (nm_dbus_manager_start_service (self)) {
nm_info ("reconnected to the system bus.");
nm_log_info (LOGD_CORE, "reconnected to the system bus.");
g_signal_emit (self, signals[DBUS_CONNECTION_CHANGED],
0, priv->connection);
priv->reconnect_id = 0;
@ -223,8 +223,8 @@ nm_dbus_manager_name_has_owner (NMDBusManager *self,
G_TYPE_INVALID,
G_TYPE_BOOLEAN, &has_owner,
G_TYPE_INVALID)) {
nm_warning ("NameHasOwner request failed: %s",
(err && err->message) ? err->message : "(unknown)");
nm_log_warn (LOGD_CORE, "NameHasOwner request failed: %s",
(err && err->message) ? err->message : "(unknown)");
g_clear_error (&err);
}
@ -248,7 +248,7 @@ destroy_cb (DBusGProxy *proxy, gpointer user_data)
NMDBusManager *self = NM_DBUS_MANAGER (user_data);
/* Clean up existing connection */
nm_info ("disconnected by the system bus.");
nm_log_warn (LOGD_CORE, "disconnected by the system bus.");
NM_DBUS_MANAGER_GET_PRIVATE (self)->proxy = NULL;
nm_dbus_manager_cleanup (self, FALSE);
@ -265,7 +265,7 @@ nm_dbus_manager_init_bus (NMDBusManager *self)
GError *err = NULL;
if (priv->connection) {
nm_warning ("DBus Manager already has a valid connection.");
nm_log_warn (LOGD_CORE, "DBus Manager already has a valid connection.");
return FALSE;
}
@ -273,7 +273,7 @@ nm_dbus_manager_init_bus (NMDBusManager *self)
priv->g_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
if (!priv->g_connection) {
nm_warning ("Could not get the system bus. Make sure "
nm_log_err (LOGD_CORE, "Could not get the system bus. Make sure "
"the message bus daemon is running! Message: %s",
err->message);
g_error_free (err);
@ -317,7 +317,7 @@ nm_dbus_manager_start_service (NMDBusManager *self)
priv = NM_DBUS_MANAGER_GET_PRIVATE (self);
if (priv->started) {
nm_warning ("Service has already started.");
nm_log_err (LOGD_CORE, "Service has already started.");
return FALSE;
}
@ -327,7 +327,7 @@ nm_dbus_manager_start_service (NMDBusManager *self)
G_TYPE_INVALID,
G_TYPE_UINT, &result,
G_TYPE_INVALID)) {
nm_warning ("Could not acquire the NetworkManager service.\n"
nm_log_err (LOGD_CORE, "Could not acquire the NetworkManager service.\n"
" Error: '%s'",
(err && err->message) ? err->message : "(unknown)");
g_error_free (err);
@ -335,7 +335,7 @@ nm_dbus_manager_start_service (NMDBusManager *self)
}
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
nm_warning ("Could not acquire the NetworkManager service as it is already taken.");
nm_log_err (LOGD_CORE, "Could not acquire the NetworkManager service as it is already taken.");
return FALSE;
}
@ -345,15 +345,15 @@ nm_dbus_manager_start_service (NMDBusManager *self)
G_TYPE_INVALID,
G_TYPE_UINT, &result,
G_TYPE_INVALID)) {
g_warning ("Could not acquire the NetworkManagerSystemSettings service.\n"
" Message: '%s'", err->message);
nm_log_warn (LOGD_CORE, "Could not acquire the NetworkManagerSystemSettings service.\n"
" Message: '%s'", err->message);
g_error_free (err);
return FALSE;
}
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
g_warning ("Could not acquire the NetworkManagerSystemSettings service "
"as it is already taken.");
nm_log_warn (LOGD_CORE, "Could not acquire the NetworkManagerSystemSettings service "
"as it is already taken.");
return FALSE;
}

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <stdio.h>
@ -28,7 +28,7 @@
#include "nm-device-bt.h"
#include "nm-device-interface.h"
#include "nm-device-private.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-marshal.h"
#include "ppp-manager/nm-ppp-manager.h"
#include "nm-properties-changed-signal.h"
@ -366,10 +366,11 @@ modem_ip4_config_result (NMModem *self,
g_return_if_fail (state == NM_DEVICE_STATE_IP_CONFIG);
if (error) {
nm_warning ("%s: retrieving IP4 configuration failed: (%d) %s",
__func__,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB | LOGD_IP4 | LOGD_BT,
"(%s): retrieving IP4 configuration failed: (%d) %s",
nm_device_get_ip_iface (device),
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
} else {
@ -483,14 +484,16 @@ nm_device_bt_modem_added (NMDeviceBt *self,
*/
state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self));
if (state != NM_DEVICE_STATE_CONFIG) {
nm_warning ("(%s): modem found but device not in correct state (%d)",
nm_device_get_iface (NM_DEVICE (self)),
nm_device_get_state (NM_DEVICE (self)));
nm_log_warn (LOGD_BT | LOGD_MB,
"(%s): modem found but device not in correct state (%d)",
nm_device_get_iface (NM_DEVICE (self)),
nm_device_get_state (NM_DEVICE (self)));
return TRUE;
}
nm_info ("Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) modem found.",
nm_device_get_iface (NM_DEVICE (self)));
nm_log_info (LOGD_BT | LOGD_MB,
"Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) modem found.",
nm_device_get_iface (NM_DEVICE (self)));
if (priv->modem) {
g_warn_if_reached ();
@ -561,11 +564,11 @@ check_connect_continue (NMDeviceBt *self)
if (!priv->connected || !priv->have_iface)
return;
nm_info ("Activation (%s %s/bluetooth) Stage 2 of 5 (Device Configure) "
"successful. Will connect via %s.",
nm_device_get_iface (device),
nm_device_get_ip_iface (device),
dun ? "DUN" : (pan ? "PAN" : "unknown"));
nm_log_info (LOGD_BT, "Activation (%s %s/bluetooth) Stage 2 of 5 (Device Configure) "
"successful. Will connect via %s.",
nm_device_get_iface (device),
nm_device_get_ip_iface (device),
dun ? "DUN" : (pan ? "PAN" : "unknown"));
if (pan) {
/* Bluez says we're connected now. Start IP config. */
@ -576,9 +579,9 @@ check_connect_continue (NMDeviceBt *self)
g_source_remove (priv->timeout_id);
priv->timeout_id = g_timeout_add_seconds (20, modem_find_timeout, self);
nm_info ("Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) "
"waiting for modem to appear.",
nm_device_get_iface (device));
nm_log_info (LOGD_BT | LOGD_MB, "Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) "
"waiting for modem to appear.",
nm_device_get_iface (device));
} else
g_assert_not_reached ();
}
@ -596,8 +599,8 @@ bluez_connect_cb (DBusGProxy *proxy,
if (dbus_g_proxy_end_call (proxy, call_id, &error,
G_TYPE_STRING, &device,
G_TYPE_INVALID) == FALSE) {
nm_warning ("Error connecting with bluez: %s",
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_BT, "Error connecting with bluez: %s",
error && error->message ? error->message : "(unknown)");
g_clear_error (&error);
nm_device_state_changed (NM_DEVICE (self),
@ -607,7 +610,7 @@ bluez_connect_cb (DBusGProxy *proxy,
}
if (!device || !strlen (device)) {
nm_warning ("Invalid network device returned by bluez");
nm_log_warn (LOGD_BT, "Invalid network device returned by bluez");
nm_device_state_changed (NM_DEVICE (self),
NM_DEVICE_STATE_FAILED,
@ -655,11 +658,13 @@ bluez_property_changed (DBusGProxy *proxy,
/* Bluez says we're disconnected from the device. Suck. */
if (nm_device_is_activating (device)) {
nm_info ("Activation (%s/bluetooth): bluetooth link disconnected.",
nm_device_get_iface (device));
nm_log_info (LOGD_BT,
"Activation (%s/bluetooth): bluetooth link disconnected.",
nm_device_get_iface (device));
fail = TRUE;
} else if (state == NM_DEVICE_STATE_ACTIVATED) {
nm_info ("%s: bluetooth link disconnected.", nm_device_get_iface (device));
nm_log_info (LOGD_BT, "(%s): bluetooth link disconnected.",
nm_device_get_iface (device));
fail = TRUE;
}

View file

@ -51,7 +51,7 @@
#include "nm-setting-8021x.h"
#include "nm-setting-pppoe.h"
#include "ppp-manager/nm-ppp-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-properties-changed-signal.h"
#include "nm-dhcp-manager.h"
@ -227,11 +227,11 @@ set_carrier (NMDeviceEthernet *self,
g_object_notify (G_OBJECT (self), NM_DEVICE_ETHERNET_CARRIER);
state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self));
nm_info ("(%s): carrier now %s (device state %d%s)",
nm_device_get_iface (NM_DEVICE (self)),
carrier ? "ON" : "OFF",
state,
defer_action ? ", deferring action for 4 seconds" : "");
nm_log_info (LOGD_HW | LOGD_ETHER, "(%s): carrier now %s (device state %d%s)",
nm_device_get_iface (NM_DEVICE (self)),
carrier ? "ON" : "OFF",
state,
defer_action ? ", deferring action for 4 seconds" : "");
if (defer_action)
priv->carrier_action_defer_id = g_timeout_add_seconds (4, carrier_action_defer_cb, self);
@ -311,6 +311,9 @@ constructor (GType type,
self = NM_DEVICE (object);
priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
nm_log_dbg (LOGD_HW | LOGD_OLPC_MESH, "(%s): kernel ifindex %d",
nm_device_get_iface (NM_DEVICE (self)), priv->ifindex);
caps = nm_device_get_capabilities (self);
if (caps & NM_DEVICE_CAP_CARRIER_DETECT) {
GError *error = NULL;
@ -331,30 +334,36 @@ constructor (GType type,
priv->ifindex,
&ifflags,
&error)) {
nm_warning ("couldn't get initial carrier state: (%d) %s",
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
nm_log_warn (LOGD_HW | LOGD_ETHER,
"(%s): couldn't get initial carrier state: (%d) %s",
nm_device_get_iface (NM_DEVICE (self)),
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
g_clear_error (&error);
} else
priv->carrier = !!(ifflags & IFF_LOWER_UP);
nm_info ("(%s): carrier is %s",
nm_device_get_iface (NM_DEVICE (self)),
priv->carrier ? "ON" : "OFF");
nm_log_info (LOGD_HW | LOGD_ETHER,
"(%s): carrier is %s",
nm_device_get_iface (NM_DEVICE (self)),
priv->carrier ? "ON" : "OFF");
/* Request link state again just in case an error occurred getting the
* initial link state.
*/
if (!nm_netlink_monitor_request_status (priv->monitor, &error)) {
nm_warning ("couldn't request carrier state: (%d) %s",
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
nm_log_warn (LOGD_HW | LOGD_ETHER,
"(%s): couldn't request carrier state: (%d) %s",
nm_device_get_iface (NM_DEVICE (self)),
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
g_clear_error (&error);
}
} else {
nm_info ("(%s): driver '%s' does not support carrier detection.",
nm_device_get_iface (self),
nm_device_get_driver (self));
nm_log_info (LOGD_HW | LOGD_ETHER,
"(%s): driver '%s' does not support carrier detection.",
nm_device_get_iface (self),
nm_device_get_driver (self));
priv->carrier = TRUE;
}
@ -473,7 +482,7 @@ nm_device_ethernet_get_speed (NMDeviceEthernet *self)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
nm_warning ("couldn't open control socket.");
nm_log_warn (LOGD_HW, "couldn't open control socket.");
return 0;
}
@ -508,15 +517,16 @@ real_update_hw_address (NMDevice *dev)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
nm_warning ("couldn't open control socket.");
nm_log_warn (LOGD_HW, "couldn't open control socket.");
return;
}
memset (&req, 0, sizeof (struct ifreq));
strncpy (req.ifr_name, nm_device_get_iface (dev), IFNAMSIZ);
if (ioctl (fd, SIOCGIFHWADDR, &req) < 0) {
nm_warning ("%s: (%s) error getting hardware address: %d",
__func__, nm_device_get_iface (dev), errno);
nm_log_err (LOGD_HW | LOGD_ETHER,
"(%s) error getting hardware address: %d",
nm_device_get_iface (dev), errno);
goto out;
}
@ -670,7 +680,8 @@ real_connection_secrets_updated (NMDevice *dev,
if (!strcmp (setting_name, NM_SETTING_802_1X_SETTING_NAME)) {
valid = TRUE;
} else {
nm_warning ("Ignoring updated secrets for setting '%s'.", setting_name);
nm_log_warn (LOGD_DEVICE, "Ignoring updated secrets for setting '%s'.",
setting_name);
}
}
@ -827,8 +838,10 @@ link_timeout_cb (gpointer user_data)
if (!setting_name)
goto time_out;
nm_info ("Activation (%s/wired): disconnected during authentication,"
" asking for new key.", nm_device_get_iface (dev));
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): disconnected during authentication,"
" asking for new key.",
nm_device_get_iface (dev));
supplicant_interface_release (self);
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT);
@ -842,7 +855,8 @@ link_timeout_cb (gpointer user_data)
return FALSE;
time_out:
nm_info ("%s: link timed out.", nm_device_get_iface (dev));
nm_log_warn (LOGD_DEVICE | LOGD_ETHER,
"(%s): link timed out.", nm_device_get_iface (dev));
nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT);
return FALSE;
@ -863,7 +877,7 @@ schedule_state_handler (NMDeviceEthernet *self,
task = g_slice_new0 (SupplicantStateTask);
if (!task) {
nm_warning ("Not enough memory to process supplicant manager state change.");
nm_log_err (LOGD_DEVICE, "Not enough memory to process supplicant manager state change.");
return FALSE;
}
@ -906,10 +920,11 @@ supplicant_mgr_state_cb (NMSupplicantInterface * iface,
guint32 old_state,
gpointer user_data)
{
nm_info ("(%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));
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,
@ -936,7 +951,7 @@ build_supplicant_config (NMDeviceEthernet *self)
security = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
if (!nm_supplicant_config_add_setting_8021x (config, security, con_path, TRUE)) {
nm_warning ("Couldn't add 802.1X security setting to supplicant config.");
nm_log_warn (LOGD_DEVICE, "Couldn't add 802.1X security setting to supplicant config.");
g_object_unref (config);
config = NULL;
}
@ -962,11 +977,17 @@ supplicant_iface_state_cb_handler (gpointer user_data)
success = nm_supplicant_interface_set_config (priv->supplicant.iface, config);
g_object_unref (config);
if (!success)
nm_warning ("Activation (%s/wired): couldn't send security "
"configuration to the supplicant.", iface);
} else
nm_warning ("Activation (%s/wired): couldn't build security configuration.", iface);
if (!success) {
nm_log_err (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): couldn't send security "
"configuration to the supplicant.",
iface);
}
} else {
nm_log_warn (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): couldn't build security configuration.",
iface);
}
if (!success)
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED);
@ -990,10 +1011,11 @@ supplicant_iface_state_cb (NMSupplicantInterface * iface,
gpointer user_data)
{
nm_info ("(%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));
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,
@ -1016,8 +1038,9 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
* schedule the next activation stage.
*/
if (nm_device_get_state (dev) == NM_DEVICE_STATE_CONFIG) {
nm_info ("Activation (%s/wired) Stage 2 of 5 (Device Configure) successful.",
nm_device_get_iface (dev));
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);
}
} else if (task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED) {
@ -1040,10 +1063,11 @@ supplicant_iface_connection_state_cb (NMSupplicantInterface * iface,
guint32 old_state,
gpointer user_data)
{
nm_info ("(%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));
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,
@ -1075,8 +1099,9 @@ supplicant_iface_connection_error_cb (NMSupplicantInterface *iface,
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
guint id;
nm_info ("Activation (%s/wired): association request to the supplicant failed: %s - %s",
nm_device_get_iface (NM_DEVICE (self)), name, message);
nm_log_warn (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): association request to the supplicant failed: %s - %s",
nm_device_get_iface (NM_DEVICE (self)), name, message);
if (priv->supplicant.iface_con_error_cb_id)
g_source_remove (priv->supplicant.iface_con_error_cb_id);
@ -1120,8 +1145,9 @@ handle_auth_or_fail (NMDeviceEthernet *self,
NULL);
g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
} else
nm_warning ("Cleared secrets, but setting didn't need any secrets.");
} else {
nm_log_info (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
}
return NM_ACT_STAGE_RETURN_POSTPONE;
}
@ -1140,15 +1166,17 @@ supplicant_connection_timeout_cb (gpointer user_data)
iface = nm_device_get_iface (device);
/* Authentication failed, encryption key is probably bad */
nm_info ("Activation (%s/wired): association took too long.", iface);
nm_log_warn (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): association took too long.", iface);
supplicant_interface_release (self);
req = nm_device_get_act_request (device);
g_assert (req);
if (handle_auth_or_fail (self, req, TRUE) == NM_ACT_STAGE_RETURN_POSTPONE)
nm_info ("Activation (%s/wired): asking for new secrets", iface);
else
if (handle_auth_or_fail (self, req, TRUE) == NM_ACT_STAGE_RETURN_POSTPONE) {
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): asking for new secrets", iface);
} else
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS);
return FALSE;
@ -1165,7 +1193,9 @@ supplicant_interface_init (NMDeviceEthernet *self)
/* Create supplicant interface */
priv->supplicant.iface = nm_supplicant_manager_get_iface (priv->supplicant.mgr, iface, FALSE);
if (!priv->supplicant.iface) {
nm_warning ("Couldn't initialize supplicant interface for %s.", iface);
nm_log_err (LOGD_DEVICE | LOGD_ETHER,
"Couldn't initialize supplicant interface for %s.",
iface);
supplicant_interface_release (self);
return FALSE;
@ -1213,7 +1243,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
connection = nm_act_request_get_connection (nm_device_get_act_request (NM_DEVICE (self)));
security = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
if (!security) {
nm_warning ("Invalid or missing 802.1X security");
nm_log_err (LOGD_DEVICE, "Invalid or missing 802.1X security");
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
return ret;
}
@ -1226,15 +1256,17 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
if (setting_name) {
NMActRequest *req = nm_device_get_act_request (NM_DEVICE (self));
nm_info ("Activation (%s/wired): connection '%s' has security, but secrets are required.",
iface, nm_setting_connection_get_id (s_connection));
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): connection '%s' has security, but secrets are required.",
iface, nm_setting_connection_get_id (s_connection));
ret = handle_auth_or_fail (self, req, FALSE);
if (ret != NM_ACT_STAGE_RETURN_POSTPONE)
*reason = NM_DEVICE_STATE_REASON_NO_SECRETS;
} else {
nm_info ("Activation (%s/wired): connection '%s' requires no security. No secrets needed.",
iface, nm_setting_connection_get_id (s_connection));
nm_log_info (LOGD_DEVICE | LOGD_ETHER,
"Activation (%s/wired): connection '%s' requires no security. No secrets needed.",
iface, nm_setting_connection_get_id (s_connection));
if (supplicant_interface_init (self))
ret = NM_ACT_STAGE_RETURN_POSTPONE;
@ -1311,8 +1343,8 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas
self);
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else {
nm_warning ("(%s): PPPoE failed to start: %s",
nm_device_get_iface (NM_DEVICE (self)), err->message);
nm_log_warn (LOGD_DEVICE, "(%s): PPPoE failed to start: %s",
nm_device_get_iface (NM_DEVICE (self)), err->message);
g_error_free (err);
g_object_unref (priv->ppp_manager);
@ -1880,7 +1912,7 @@ supports_ethtool_carrier_detect (NMDeviceEthernet *self)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
nm_warning ("couldn't open control socket.");
nm_log_err (LOGD_HW, "couldn't open control socket.");
return FALSE;
}
@ -1890,13 +1922,18 @@ supports_ethtool_carrier_detect (NMDeviceEthernet *self)
edata.cmd = ETHTOOL_GLINK;
ifr.ifr_data = (char *) &edata;
if (ioctl (fd, SIOCETHTOOL, &ifr) < 0)
errno = 0;
if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) {
nm_log_dbg (LOGD_HW | LOGD_ETHER, "SIOCETHTOOL failed: %d", errno);
goto out;
}
supports_ethtool = TRUE;
out:
close (fd);
nm_log_dbg (LOGD_HW | LOGD_ETHER, "ethtool %s supported",
supports_ethtool ? "is" : "not");
return supports_ethtool;
}
@ -1920,8 +1957,13 @@ mdio_read (NMDeviceEthernet *self, int fd, struct ifreq *ifr, int location)
mii = (struct mii_ioctl_data *) &ifr->ifr_ifru;
mii->reg_num = location;
if (ioctl (fd, SIOCGMIIREG, ifr) == 0)
errno = 0;
if (ioctl (fd, SIOCGMIIREG, ifr) == 0) {
nm_log_dbg (LOGD_HW | LOGD_ETHER, "SIOCGMIIREG result 0x%X", mii->val_out);
val = mii->val_out;
} else {
nm_log_dbg (LOGD_HW | LOGD_ETHER, "SIOCGMIIREG failed: %d", errno);
}
return val;
}
@ -1937,19 +1979,24 @@ supports_mii_carrier_detect (NMDeviceEthernet *self)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
nm_warning ("couldn't open control socket.");
nm_log_err (LOGD_HW, "couldn't open control socket.");
return 0;
}
memset (&ifr, 0, sizeof (struct ifreq));
strncpy (ifr.ifr_name, nm_device_get_iface (NM_DEVICE (self)), IFNAMSIZ);
if (ioctl (fd, SIOCGMIIPHY, &ifr) < 0)
errno = 0;
if (ioctl (fd, SIOCGMIIPHY, &ifr) < 0) {
nm_log_dbg (LOGD_HW | LOGD_ETHER, "SIOCGMIIPHY failed: %d", errno);
goto out;
}
/* If we can read the BMSR register, we assume that the card supports MII link detection */
bmsr = mdio_read (self, fd, &ifr, MII_BMSR);
supports_mii = (bmsr != -1) ? TRUE : FALSE;
nm_log_dbg (LOGD_HW | LOGD_ETHER, "MII %s supported",
supports_mii ? "is" : "not");
out:
close (fd);

View file

@ -22,7 +22,7 @@
#include "nm-marshal.h"
#include "nm-setting-connection.h"
#include "nm-device-interface.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-properties-changed-signal.h"
#include "nm-rfkill.h"
@ -282,8 +282,8 @@ nm_device_interface_activate (NMDeviceInterface *device,
g_assert (s_con);
iface = nm_device_interface_get_iface (device);
nm_info ("Activation (%s) starting connection '%s'", iface,
nm_setting_connection_get_id (s_con));
nm_log_info (LOGD_DEVICE, "Activation (%s) starting connection '%s'", iface,
nm_setting_connection_get_id (s_con));
g_free (iface);
success = NM_DEVICE_INTERFACE_GET_INTERFACE (device)->activate (device, req, error);

View file

@ -26,6 +26,7 @@
#include "nm-device-private.h"
#include "nm-properties-changed-signal.h"
#include "nm-marshal.h"
#include "nm-logging.h"
static void device_interface_init (NMDeviceInterface *iface_class);
@ -131,10 +132,9 @@ modem_ip4_config_result (NMModem *self,
g_return_if_fail (state == NM_DEVICE_STATE_IP_CONFIG);
if (error) {
g_warning ("%s: retrieving IP4 configuration failed: (%d) %s",
__func__,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_MB | LOGD_IP4, "retrieving IP4 configuration failed: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
} else {

View file

@ -19,7 +19,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2005 - 2008 Red Hat, Inc.
* (C) Copyright 2005 - 2010 Red Hat, Inc.
* (C) Copyright 2008 Collabora Ltd.
* (C) Copyright 2009 One Laptop per Child
*/
@ -42,6 +42,7 @@
#include "nm-device-interface.h"
#include "nm-device-private.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "NetworkManagerUtils.h"
#include "nm-activation-request.h"
#include "nm-properties-changed-signal.h"
@ -109,7 +110,7 @@ struct _NMDeviceOlpcMeshPrivate
NMDevice * companion;
gboolean stage1_waiting;
guint device_added_cb;
guint device_added_id;
};
static GQuark
@ -157,7 +158,7 @@ real_get_generic_capabilities (NMDevice *dev)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
nm_warning ("couldn't open control socket.");
nm_log_warn (LOGD_OLPC_MESH, "couldn't open control socket.");
goto out;
}
@ -168,13 +169,14 @@ real_get_generic_capabilities (NMDevice *dev)
wrq.u.data.length = sizeof (struct iw_range);
if (ioctl (fd, SIOCGIWRANGE, &wrq) < 0) {
nm_warning ("couldn't get driver range information.");
nm_log_warn (LOGD_OLPC_MESH, "couldn't get driver range information.");
goto out;
}
if ((wrq.u.data.length < 300) || (range.we_version_compiled < 16)) {
nm_warning ("%s: driver's Wireless Extensions version (%d) is too old.",
iface, range.we_version_compiled);
nm_log_warn (LOGD_OLPC_MESH,
"(%s): driver's Wireless Extensions version (%d) is too old.",
iface, range.we_version_compiled);
goto out;
} else {
caps |= NM_DEVICE_CAP_NM_SUPPORTED;
@ -260,6 +262,9 @@ constructor (GType type,
self = NM_DEVICE_OLPC_MESH (object);
priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
nm_log_dbg (LOGD_HW | LOGD_OLPC_MESH, "(%s): kernel ifindex %d",
nm_device_get_iface (NM_DEVICE (self)), priv->ifindex);
iface = nm_device_get_iface (NM_DEVICE (self));
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
@ -345,9 +350,7 @@ device_cleanup (NMDeviceOlpcMesh *self)
static void
real_take_down (NMDevice *dev)
{
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev);
device_cleanup (self);
device_cleanup (NM_DEVICE_OLPC_MESH (dev));
}
static gboolean
@ -406,7 +409,7 @@ create_socket_with_request (NMDevice *self, struct iwreq *req)
sk = socket (AF_INET, SOCK_DGRAM, 0);
if (!sk) {
nm_error ("Couldn't create socket: %d.", errno);
nm_log_err (LOGD_OLPC_MESH, "Couldn't create socket: %d.", errno);
return -1;
}
@ -432,8 +435,8 @@ nm_device_olpc_mesh_get_channel (NMDeviceOlpcMesh *self)
return 0;
if ((ioctl (sk, SIOCGIWFREQ, &req)) != 0) {
nm_warning ("%s: failed to get channel (errno: %d))",
nm_device_get_iface (NM_DEVICE (self)), errno);
nm_log_warn (LOGD_OLPC_MESH, "(%s): failed to get channel (errno: %d)",
nm_device_get_iface (NM_DEVICE (self)), errno);
goto out;
}
@ -471,10 +474,10 @@ nm_device_olpc_mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel)
req.u.freq.m = channel;
}
if (ioctl (sk, SIOCSIWFREQ, &req) != 0)
nm_warning ("%s: failed to set to channel %d (errno: %d))",
nm_device_get_iface (NM_DEVICE (self)), channel, errno);
else
if (ioctl (sk, SIOCSIWFREQ, &req) != 0) {
nm_log_warn (LOGD_OLPC_MESH, "(%s): failed to set to channel %d (errno: %d)",
nm_device_get_iface (NM_DEVICE (self)), channel, errno);
} else
g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL);
close (sk);
@ -494,7 +497,7 @@ nm_device_olpc_mesh_set_ssid (NMDeviceOlpcMesh *self, const GByteArray * ssid)
sk = socket (AF_INET, SOCK_DGRAM, 0);
if (!sk) {
nm_error ("Couldn't create socket: %d.", errno);
nm_log_err (LOGD_OLPC_MESH, "Couldn't create socket: %d.", errno);
return;
}
@ -526,9 +529,10 @@ nm_device_olpc_mesh_set_ssid (NMDeviceOlpcMesh *self, const GByteArray * ssid)
if (ioctl (sk, SIOCSIWESSID, &wrq) < 0) {
if (errno != ENODEV) {
nm_warning ("error setting SSID to '%s' for device %s: %s",
nm_log_err (LOGD_OLPC_MESH, "(%s): error setting SSID to '%s': %s",
iface,
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(null)",
iface, strerror (errno));
strerror (errno));
}
}
@ -556,7 +560,7 @@ real_update_hw_address (NMDevice *dev)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
g_warning ("could not open control socket.");
nm_log_warn (LOGD_OLPC_MESH, "could not open control socket.");
return;
}
@ -564,8 +568,8 @@ real_update_hw_address (NMDevice *dev)
strncpy (req.ifr_name, nm_device_get_iface (dev), IFNAMSIZ);
ret = ioctl (fd, SIOCGIFHWADDR, &req);
if (ret) {
nm_warning ("%s: (%s) error getting hardware address: %d",
__func__, nm_device_get_iface (dev), errno);
nm_log_warn (LOGD_OLPC_MESH, "(%s): error getting hardware address: %d",
nm_device_get_iface (dev), errno);
goto out;
}
@ -587,17 +591,20 @@ real_act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
/* disconnect companion device, if it is connected */
if (nm_device_get_act_request (NM_DEVICE (priv->companion))) {
nm_warning ("disconnecting companion device");
nm_log_info (LOGD_OLPC_MESH, "(%s): disconnecting companion device %s",
nm_device_get_iface (dev),
nm_device_get_iface (priv->companion));
/* FIXME: VPN stuff here is a bug; but we can't really change API now... */
nm_device_state_changed (NM_DEVICE (priv->companion),
NM_DEVICE_STATE_DISCONNECTED,
NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
nm_warning ("companion disconnected");
nm_log_info (LOGD_OLPC_MESH, "(%s): companion %s disconnected",
nm_device_get_iface (dev),
nm_device_get_iface (priv->companion));
}
/* wait with continuing configuration untill the companion device is done
* scanning */
/* wait with continuing configuration untill the companion device is done scanning */
g_object_get (priv->companion, "scanning", &scanning, NULL);
if (scanning) {
priv->stage1_waiting = TRUE;
@ -650,24 +657,24 @@ real_act_stage4_ip4_config_timeout (NMDevice *dev,
static void
nm_device_olpc_mesh_dispose (GObject *object)
dispose (GObject *object)
{
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (object);
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
NMManager *manager;
if (priv->dispose_has_run) {
G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->dispose (object);
return;
}
priv->dispose_has_run = TRUE;
device_cleanup (self);
if (priv->device_added_cb != 0)
g_source_remove (priv->device_added_cb);
priv->device_added_cb = 0;
manager = nm_manager_get (NULL, NULL, NULL, FALSE, FALSE, FALSE, NULL);
if (priv->device_added_id)
g_signal_handler_disconnect (manager, priv->device_added_id);
g_object_unref (manager);
G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->dispose (object);
}
@ -731,7 +738,7 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
object_class->constructor = constructor;
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->dispose = nm_device_olpc_mesh_dispose;
object_class->dispose = dispose;
parent_class->get_type_capabilities = NULL;
parent_class->get_generic_capabilities = real_get_generic_capabilities;
@ -825,7 +832,8 @@ companion_state_changed_cb (NMDeviceWifi *companion,
|| state > NM_DEVICE_STATE_ACTIVATED)
return;
nm_debug ("disconnecting mesh due to companion connectivity");
nm_log_dbg (LOGD_OLPC_MESH, "(%s): disconnecting mesh due to companion connectivity",
nm_device_get_iface (NM_DEVICE (self)));
/* FIXME: VPN stuff here is a bug; but we can't really change API now... */
nm_device_state_changed (NM_DEVICE (self),
NM_DEVICE_STATE_DISCONNECTED,
@ -862,6 +870,7 @@ is_companion (NMDeviceOlpcMesh *self, NMDevice *other)
{
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
struct ether_addr their_addr;
NMManager *manager;
if (!NM_IS_DEVICE_WIFI (other))
return FALSE;
@ -876,14 +885,21 @@ is_companion (NMDeviceOlpcMesh *self, NMDevice *other)
/* FIXME detect when our companion leaves */
priv->companion = other;
g_source_remove (priv->device_added_cb);
priv->device_added_cb = 0;
/* When we've found the companion, stop listening for other devices */
manager = nm_manager_get (NULL, NULL, NULL, FALSE, FALSE, FALSE, NULL);
if (priv->device_added_id) {
g_signal_handler_disconnect (manager, priv->device_added_id);
priv->device_added_id = 0;
}
g_object_unref (manager);
nm_device_state_changed (NM_DEVICE (self),
NM_DEVICE_STATE_DISCONNECTED,
NM_DEVICE_STATE_REASON_NONE);
nm_debug ("Found companion device: %s", nm_device_get_iface (other));
nm_log_info (LOGD_OLPC_MESH, "(%s): found companion WiFi device %s",
nm_device_get_iface (NM_DEVICE (self)),
nm_device_get_iface (other));
g_signal_connect (G_OBJECT (other), "state-changed",
G_CALLBACK (companion_state_changed_cb), self);
@ -922,18 +938,19 @@ check_companion_cb (gpointer user_data)
return FALSE;
}
if (priv->device_added_cb != 0)
if (priv->device_added_id != 0)
return FALSE;
manager = nm_manager_get (NULL, NULL, NULL, FALSE, FALSE, FALSE, NULL);
priv->device_added_cb = g_signal_connect (manager, "device-added",
priv->device_added_id = g_signal_connect (manager, "device-added",
G_CALLBACK (device_added_cb), self);
list = nm_manager_get_devices (manager);
for (; list != NULL ; list = list->next)
/* Try to find the companion if it's already known to the NMManager */
for (list = nm_manager_get_devices (manager); list ; list = g_slist_next (list)) {
if (is_companion (self, NM_DEVICE (list->data)))
break;
}
g_object_unref (manager);

File diff suppressed because it is too large Load diff

View file

@ -44,6 +44,7 @@
#include "nm-dbus-manager.h"
#include "nm-named-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-netlink.h"
#include "nm-setting-ip4-config.h"
#include "nm-setting-ip6-config.h"
@ -218,18 +219,18 @@ constructor (GType type,
priv = NM_DEVICE_GET_PRIVATE (dev);
if (!priv->udi) {
nm_warning ("No device udi provided, ignoring");
nm_log_err (LOGD_DEVICE, "No device udi provided, ignoring");
goto error;
}
if (!priv->iface) {
nm_warning ("No device interface provided, ignoring");
nm_log_err (LOGD_DEVICE, "No device interface provided, ignoring");
goto error;
}
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
if (!(priv->capabilities & NM_DEVICE_CAP_NM_SUPPORTED)) {
nm_warning ("(%s): Device unsupported, ignoring.", priv->iface);
nm_log_warn (LOGD_DEVICE, "(%s): Device unsupported, ignoring.", priv->iface);
goto error;
}
@ -526,8 +527,9 @@ activation_source_schedule (NMDevice *self, GSourceFunc func, int family)
act_source_func = &priv->act_source_func;
}
if (*act_source_id)
nm_warning ("activation stage already scheduled");
if (*act_source_id) {
nm_log_err (LOGD_DEVICE, "activation stage already scheduled");
}
/* Don't bother rescheduling the same function that's about to
* run anyway. Fixes issues with crappy wireless drivers sending
@ -589,9 +591,10 @@ ip6_addrconf_complete (NMIP6Manager *ip6_manager,
if ((state != NM_DEVICE_STATE_IP_CONFIG) || priv->dhcp6_client)
return;
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) starting DHCPv6"
" as requested by IPv6 router...",
priv->iface);
nm_log_info (LOGD_DEVICE | LOGD_DHCP6,
"Activation (%s) Stage 3 of 5 (IP Configure Start) starting DHCPv6"
" as requested by IPv6 router...",
priv->iface);
ret = dhcp6_start (self, connection, dhcp_opts, &reason);
switch (ret) {
@ -726,7 +729,7 @@ nm_device_activate_stage1_device_prepare (gpointer user_data)
priv->ip4_ready = priv->ip6_ready = FALSE;
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) started...", iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) started...", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE);
ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self, &reason);
@ -741,7 +744,7 @@ nm_device_activate_stage1_device_prepare (gpointer user_data)
nm_device_activate_schedule_stage2_device_config (self);
out:
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) complete.", iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) complete.", iface);
return FALSE;
}
@ -764,8 +767,8 @@ nm_device_activate_schedule_stage1_device_prepare (NMDevice *self)
activation_source_schedule (self, nm_device_activate_stage1_device_prepare, 0);
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) scheduled...",
nm_device_get_iface (self));
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) scheduled...",
nm_device_get_iface (self));
}
static NMActStageReturn
@ -795,7 +798,7 @@ nm_device_activate_stage2_device_config (gpointer user_data)
activation_source_clear (self, FALSE, 0);
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
if (!nm_device_bring_up (self, FALSE, &no_firmware)) {
@ -816,12 +819,12 @@ nm_device_activate_stage2_device_config (gpointer user_data)
}
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) successful.", iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) successful.", iface);
nm_device_activate_schedule_stage3_ip_config_start (self);
out:
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) complete.", iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) complete.", iface);
return FALSE;
}
@ -844,7 +847,7 @@ nm_device_activate_schedule_stage2_device_config (NMDevice *self)
activation_source_schedule (self, nm_device_activate_stage2_device_config, 0);
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) scheduled...",
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) scheduled...",
nm_device_get_iface (self));
}
@ -873,9 +876,9 @@ aipd_cleanup (NMDevice *self)
kill (priv->aipd_pid, SIGKILL);
/* ensure the child is reaped */
nm_debug ("waiting for ppp pid %d to exit", priv->aipd_pid);
nm_log_dbg (LOGD_AUTOIP4, "waiting for avahi-autoipd pid %d to exit", priv->aipd_pid);
waitpid (priv->aipd_pid, NULL, 0);
nm_debug ("ppp pid %d cleaned up", priv->aipd_pid);
nm_log_dbg (LOGD_AUTOIP4, "avahi-autoip pid %d cleaned up", priv->aipd_pid);
priv->aipd_pid = -1;
}
@ -919,7 +922,7 @@ handle_autoip_change (NMDevice *self, NMDeviceStateReason *reason)
config = aipd_get_ip4_config (self, reason);
if (!config) {
nm_warning ("failed to get autoip config for rebind");
nm_log_err (LOGD_AUTOIP4, "failed to get autoip config for rebind");
return FALSE;
}
@ -931,7 +934,7 @@ handle_autoip_change (NMDevice *self, NMDeviceStateReason *reason)
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, config);
if (!nm_device_set_ip4_config (self, config, FALSE, reason)) {
nm_warning ("(%s): failed to update IP4 config in response to autoip event.",
nm_log_err (LOGD_AUTOIP4, "(%s): failed to update IP4 config in response to autoip event.",
nm_device_get_iface (self));
return FALSE;
}
@ -980,14 +983,14 @@ nm_device_handle_autoip4_event (NMDevice *self,
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
if (inet_pton (AF_INET, address, &ip) <= 0) {
nm_warning ("(%s): invalid address %s received from avahi-autoipd.",
nm_log_err (LOGD_AUTOIP4, "(%s): invalid address %s received from avahi-autoipd.",
iface, address);
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR);
return;
}
if ((ip.s_addr & IPV4LL_NETMASK) != IPV4LL_NETWORK) {
nm_warning ("(%s): invalid address %s received from avahi-autoipd.",
nm_log_err (LOGD_AUTOIP4, "(%s): invalid address %s received from avahi-autoipd (not link-local).",
iface, address);
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR);
return;
@ -996,7 +999,7 @@ nm_device_handle_autoip4_event (NMDevice *self,
switch (state) {
case NM_DEVICE_STATE_IP_CONFIG:
if (priv->aipd_addr) {
nm_warning ("(%s): already have autoip address!", iface);
nm_log_warn (LOGD_AUTOIP4, "(%s): already have autoip address!", iface);
return;
}
@ -1010,12 +1013,12 @@ nm_device_handle_autoip4_event (NMDevice *self,
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
break;
default:
nm_warning ("(%s): unexpected avahi-autoip event %s for %s.",
nm_log_warn (LOGD_AUTOIP4, "(%s): unexpected avahi-autoip event %s for %s.",
iface, event, address);
break;
}
} else {
nm_warning ("%s: autoip address %s no longer valid because '%s'.",
nm_log_warn (LOGD_AUTOIP4, "(%s): autoip address %s no longer valid because '%s'.",
iface, address, event);
/* The address is gone; terminate the connection or fail activation */
@ -1037,14 +1040,18 @@ aipd_watch_cb (GPid pid, gint status, gpointer user_data)
iface = nm_device_get_iface (self);
if (WIFEXITED (status))
nm_warning ("%s: avahi-autoipd exited with error code %d", iface, WEXITSTATUS (status));
else if (WIFSTOPPED (status))
nm_warning ("%s: avahi-autoipd stopped unexpectedly with signal %d", iface, WSTOPSIG (status));
else if (WIFSIGNALED (status))
nm_warning ("%s: avahi-autoipd died with signal %d", iface, WTERMSIG (status));
else
nm_warning ("%s: avahi-autoipd died from an unknown cause", iface);
if (WIFEXITED (status)) {
nm_log_dbg (LOGD_AUTOIP4, "(%s): avahi-autoipd exited with error code %d",
iface, WEXITSTATUS (status));
} else if (WIFSTOPPED (status)) {
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd stopped unexpectedly with signal %d",
iface, WSTOPSIG (status));
} else if (WIFSIGNALED (status)) {
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd died with signal %d",
iface, WTERMSIG (status));
} else {
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd died from an unknown cause", iface);
}
aipd_cleanup (self);
@ -1063,7 +1070,7 @@ aipd_timeout_cb (gpointer user_data)
return FALSE;
priv->aipd_timeout = 0;
nm_info ("%s: avahi-autoipd timed out.", nm_device_get_iface (self));
nm_log_info (LOGD_AUTOIP4, "(%s): avahi-autoipd timed out.", nm_device_get_iface (self));
aipd_cleanup (self);
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
@ -1169,7 +1176,8 @@ handle_dhcp_lease_change (NMDevice *device, gboolean ipv6)
if (ipv6) {
ip6_config = nm_dhcp_client_get_ip6_config (priv->dhcp6_client, FALSE);
if (!ip6_config) {
nm_warning ("failed to get DHCPv6 config for rebind");
nm_log_warn (LOGD_DHCP6, "(%s): failed to get DHCPv6 config for rebind",
nm_device_get_ip_iface (device));
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
return;
}
@ -1185,13 +1193,15 @@ handle_dhcp_lease_change (NMDevice *device, gboolean ipv6)
dhcp6_add_option_cb,
priv->dhcp6_config);
} else {
nm_warning ("Failed to update IPv6 config in response to DHCP event.");
nm_log_warn (LOGD_DHCP6, "(%s): failed to update IPv6 config in response to DHCP event.",
nm_device_get_ip_iface (device));
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
}
} else {
ip4_config = nm_dhcp_client_get_ip4_config (priv->dhcp4_client, FALSE);
if (!ip4_config) {
nm_warning ("failed to get DHCPv4 config for rebind");
nm_log_warn (LOGD_DHCP6, "(%s): failed to get DHCPv4 config for rebind",
nm_device_get_ip_iface (device));
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
return;
}
@ -1207,7 +1217,8 @@ handle_dhcp_lease_change (NMDevice *device, gboolean ipv6)
dhcp4_add_option_cb,
priv->dhcp4_config);
} else {
nm_warning ("Failed to update IPv4 config in response to DHCP event.");
nm_log_warn (LOGD_DHCP6, "(%s): failed to update IPv4 config in response to DHCP event.",
nm_device_get_ip_iface (device));
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
}
}
@ -1365,12 +1376,14 @@ real_act_stage3_ip4_config_start (NMDevice *self, NMDeviceStateReason *reason)
/* Start avahi-autoipd */
if (aipd_exec (self, &error)) {
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) started"
" avahi-autoipd...", iface);
nm_log_info (LOGD_DEVICE | LOGD_AUTOIP4,
"Activation (%s) Stage 3 of 5 (IP Configure Start) started"
" avahi-autoipd...", iface);
ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else {
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) failed"
" to start avahi-autoipd: %s", iface, error->message);
nm_log_info (LOGD_DEVICE | LOGD_AUTOIP4,
"Activation (%s) Stage 3 of 5 (IP Configure Start) failed"
" to start avahi-autoipd: %s", iface, error->message);
g_error_free (error);
aipd_cleanup (self);
*reason = NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED;
@ -1495,7 +1508,7 @@ nm_device_activate_stage3_ip_config_start (gpointer user_data)
activation_source_clear (self, FALSE, 0);
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) started...", iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) started...", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &reason);
@ -1517,7 +1530,7 @@ nm_device_activate_stage3_ip_config_start (gpointer user_data)
g_assert (ret == NM_ACT_STAGE_RETURN_POSTPONE);
out:
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) complete.", iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) complete.", iface);
return FALSE;
}
@ -1539,8 +1552,8 @@ nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self)
activation_source_schedule (self, nm_device_activate_stage3_ip_config_start, 0);
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) scheduled.",
nm_device_get_iface (self));
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) scheduled.",
nm_device_get_iface (self));
}
static GHashTable *shared_ips = NULL;
@ -1560,7 +1573,7 @@ reserve_shared_ip (void)
while (g_hash_table_lookup (shared_ips, GUINT_TO_POINTER (start + count))) {
count += ntohl (0x100);
if (count > ntohl (0xFE00)) {
nm_warning ("%s: ran out of shared IP addresses!", __func__);
nm_log_err (LOGD_SHARING, "ran out of shared IP addresses!");
return 0;
}
}
@ -1692,7 +1705,9 @@ nm_device_activate_stage4_ip4_config_get (gpointer user_data)
activation_source_clear (self, FALSE, AF_INET);
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 4 of 5 (IP4 Configure Get) started...", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP4,
"Activation (%s) Stage 4 of 5 (IP4 Configure Get) started...",
iface);
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip4_config (self, &ip4_config, &reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
@ -1710,7 +1725,9 @@ nm_device_activate_stage4_ip4_config_get (gpointer user_data)
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET);
out:
nm_info ("Activation (%s) Stage 4 of 5 (IP4 Configure Get) complete.", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP4,
"Activation (%s) Stage 4 of 5 (IP4 Configure Get) complete.",
iface);
return FALSE;
}
@ -1733,8 +1750,9 @@ nm_device_activate_schedule_stage4_ip4_config_get (NMDevice *self)
activation_source_schedule (self, nm_device_activate_stage4_ip4_config_get, AF_INET);
nm_info ("Activation (%s) Stage 4 of 5 (IP4 Configure Get) scheduled...",
nm_device_get_iface (self));
nm_log_info (LOGD_DEVICE | LOGD_IP4,
"Activation (%s) Stage 4 of 5 (IP4 Configure Get) scheduled...",
nm_device_get_iface (self));
}
@ -1774,7 +1792,9 @@ nm_device_activate_stage4_ip4_config_timeout (gpointer user_data)
activation_source_clear (self, FALSE, AF_INET);
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) started...", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP4,
"Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) started...",
iface);
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip4_config_timeout (self, &ip4_config, &reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
@ -1792,7 +1812,9 @@ nm_device_activate_stage4_ip4_config_timeout (gpointer user_data)
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET);
out:
nm_info ("Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) complete.", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP4,
"Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) complete.",
iface);
return FALSE;
}
@ -1815,8 +1837,9 @@ nm_device_activate_schedule_stage4_ip4_config_timeout (NMDevice *self)
activation_source_schedule (self, nm_device_activate_stage4_ip4_config_timeout, AF_INET);
nm_info ("Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) scheduled...",
nm_device_get_iface (self));
nm_log_info (LOGD_DEVICE | LOGD_IP4,
"Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) scheduled...",
nm_device_get_iface (self));
}
static NMActStageReturn
@ -1901,7 +1924,9 @@ nm_device_activate_stage4_ip6_config_get (gpointer user_data)
activation_source_clear (self, FALSE, AF_INET6);
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 4 of 5 (IP6 Configure Get) started...", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP6,
"Activation (%s) Stage 4 of 5 (IP6 Configure Get) started...",
iface);
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip6_config (self, &ip6_config, &reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
@ -1919,7 +1944,9 @@ nm_device_activate_stage4_ip6_config_get (gpointer user_data)
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET6);
out:
nm_info ("Activation (%s) Stage 4 of 5 (IP6 Configure Get) complete.", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP6,
"Activation (%s) Stage 4 of 5 (IP6 Configure Get) complete.",
iface);
return FALSE;
}
@ -1942,8 +1969,9 @@ nm_device_activate_schedule_stage4_ip6_config_get (NMDevice *self)
activation_source_schedule (self, nm_device_activate_stage4_ip6_config_get, AF_INET6);
nm_info ("Activation (%s) Stage 4 of 5 (IP6 Configure Get) scheduled...",
nm_device_get_iface (self));
nm_log_info (LOGD_DEVICE | LOGD_IP6,
"Activation (%s) Stage 4 of 5 (IP6 Configure Get) scheduled...",
nm_device_get_iface (self));
}
@ -1982,7 +2010,9 @@ nm_device_activate_stage4_ip6_config_timeout (gpointer user_data)
activation_source_clear (self, FALSE, AF_INET6);
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) started...", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP6,
"Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) started...",
iface);
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip6_config_timeout (self, &ip6_config, &reason);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
@ -2000,7 +2030,9 @@ nm_device_activate_stage4_ip6_config_timeout (gpointer user_data)
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET6);
out:
nm_info ("Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) complete.", iface);
nm_log_info (LOGD_DEVICE | LOGD_IP6,
"Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) complete.",
iface);
return FALSE;
}
@ -2023,8 +2055,9 @@ nm_device_activate_schedule_stage4_ip6_config_timeout (NMDevice *self)
activation_source_schedule (self, nm_device_activate_stage4_ip6_config_timeout, AF_INET6);
nm_info ("Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) scheduled...",
nm_device_get_iface (self));
nm_log_info (LOGD_DEVICE | LOGD_IP6,
"Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) scheduled...",
nm_device_get_iface (self));
}
static void
@ -2045,14 +2078,14 @@ share_init (void)
char **iter;
if (!nm_utils_do_sysctl ("/proc/sys/net/ipv4/ip_forward", "1\n")) {
nm_warning ("%s: Error starting IP forwarding: (%d) %s",
__func__, errno, strerror (errno));
nm_log_err (LOGD_SHARING, "Error starting IP forwarding: (%d) %s",
errno, strerror (errno));
return FALSE;
}
if (!nm_utils_do_sysctl ("/proc/sys/net/ipv4/ip_dynaddr", "1\n")) {
nm_warning ("%s: Error starting IP forwarding: (%d) %s",
__func__, errno, strerror (errno));
nm_log_err (LOGD_SHARING, "error starting IP forwarding: (%d) %s",
errno, strerror (errno));
}
for (iter = modules; *iter; iter++) {
@ -2062,9 +2095,9 @@ share_init (void)
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
share_child_setup, NULL, NULL, NULL, &status, &error)) {
nm_info ("%s: Error loading NAT module %s: (%d) %s",
__func__, *iter, error ? error->code : 0,
(error && error->message) ? error->message : "unknown");
nm_log_err (LOGD_SHARING, "error loading NAT module %s: (%d) %s",
*iter, error ? error->code : 0,
(error && error->message) ? error->message : "unknown");
if (error)
g_error_free (error);
}
@ -2138,7 +2171,7 @@ start_sharing (NMDevice *self)
nm_act_request_set_shared (req, TRUE);
if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, ip4_config, &error)) {
nm_warning ("(%s/%s): failed to start dnsmasq: %s",
nm_log_err (LOGD_SHARING, "(%s/%s): failed to start dnsmasq: %s",
nm_device_get_iface (self), ip_iface, error->message);
g_error_free (error);
nm_act_request_set_shared (req, FALSE);
@ -2192,8 +2225,8 @@ nm_device_activate_stage5_ip_config_commit (gpointer user_data)
activation_source_clear (self, FALSE, 0);
iface = nm_device_get_iface (self);
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) started...",
iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IP Configure Commit) started...",
iface);
assumed = nm_act_request_get_assumed (priv->act_request);
@ -2203,8 +2236,9 @@ nm_device_activate_stage5_ip_config_commit (gpointer user_data)
}
if (ip6_config && !nm_device_set_ip6_config (self, ip6_config, assumed, &reason)) {
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) IPv6 failed",
iface);
nm_log_info (LOGD_DEVICE | LOGD_IP6,
"Activation (%s) Stage 5 of 5 (IP Configure Commit) IPv6 failed",
iface);
}
connection = nm_act_request_get_connection (nm_device_get_act_request (self));
@ -2216,7 +2250,7 @@ nm_device_activate_stage5_ip_config_commit (gpointer user_data)
if (s_ip4 && !strcmp (method, "shared")) {
if (!start_sharing (self)) {
nm_warning ("Activation (%s) Stage 5 of 5 (IP Configure Commit) start sharing failed.", iface);
nm_log_warn (LOGD_SHARING, "Activation (%s) Stage 5 of 5 (IP Configure Commit) start sharing failed.", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
goto out;
}
@ -2226,8 +2260,8 @@ nm_device_activate_stage5_ip_config_commit (gpointer user_data)
nm_device_state_changed (self, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE);
out:
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) complete.",
iface);
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IP Configure Commit) complete.",
iface);
/* Balance IP config creation; device takes ownership in set_ip*_config() */
if (ip4_config)
@ -2269,8 +2303,9 @@ nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self, int family)
activation_source_schedule (self, nm_device_activate_stage5_ip_config_commit, 0);
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) scheduled...",
nm_device_get_iface (self));
nm_log_info (LOGD_DEVICE,
"Activation (%s) Stage 5 of 5 (IP Configure Commit) scheduled...",
nm_device_get_iface (self));
}
@ -2310,10 +2345,14 @@ delayed_transitions_clear (NMDevice *self)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
if (priv->failed_to_disconnected_id) {
nm_log_dbg (LOGD_DEVICE, "(%s): clearing failed->disconnected transition",
nm_device_get_iface (self));
g_source_remove (priv->failed_to_disconnected_id);
priv->failed_to_disconnected_id = 0;
}
if (priv->unavailable_to_disconnected_id) {
nm_log_dbg (LOGD_DEVICE, "(%s): clearing unavailable->disconnected transition",
nm_device_get_iface (self));
g_source_remove (priv->unavailable_to_disconnected_id);
priv->unavailable_to_disconnected_id = 0;
}
@ -2452,9 +2491,8 @@ nm_device_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason)
g_return_if_fail (self != NULL);
nm_info ("(%s): deactivating device (reason: %d).",
nm_device_get_iface (self),
reason);
nm_log_info (LOGD_DEVICE, "(%s): deactivating device (reason: %d).",
nm_device_get_iface (self), reason);
nm_device_deactivate_quickly (self);
@ -2750,7 +2788,7 @@ nm_device_update_ip4_address (NMDevice *self)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
nm_warning ("couldn't open control socket.");
nm_log_err (LOGD_IP4, "couldn't open control socket.");
return;
}
@ -2865,7 +2903,7 @@ nm_device_hw_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
if (nm_device_hw_is_up (self))
goto out;
nm_info ("(%s): bringing up device.", nm_device_get_iface (self));
nm_log_info (LOGD_HW, "(%s): bringing up device.", nm_device_get_iface (self));
if (NM_DEVICE_GET_CLASS (self)->hw_bring_up) {
success = NM_DEVICE_GET_CLASS (self)->hw_bring_up (self, no_firmware);
@ -2878,7 +2916,7 @@ nm_device_hw_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
g_usleep (200);
if (!nm_device_hw_is_up (self)) {
nm_warning ("(%s): device not up after timeout!", nm_device_get_iface (self));
nm_log_warn (LOGD_HW, "(%s): device not up after timeout!", nm_device_get_iface (self));
return FALSE;
}
@ -2901,7 +2939,7 @@ nm_device_hw_take_down (NMDevice *self, gboolean block)
if (!nm_device_hw_is_up (self))
return;
nm_info ("(%s): taking down device.", nm_device_get_iface (self));
nm_log_info (LOGD_HW, "(%s): taking down device.", nm_device_get_iface (self));
if (NM_DEVICE_GET_CLASS (self)->hw_take_down)
NM_DEVICE_GET_CLASS (self)->hw_take_down (self);
@ -2924,7 +2962,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
if (nm_device_is_up (self))
return TRUE;
nm_info ("(%s): preparing device.", nm_device_get_iface (self));
nm_log_info (LOGD_HW, "(%s): preparing device.", nm_device_get_iface (self));
if (NM_DEVICE_GET_CLASS (self)->bring_up)
success = NM_DEVICE_GET_CLASS (self)->bring_up (self);
@ -2941,7 +2979,7 @@ nm_device_take_down (NMDevice *self, gboolean block, NMDeviceStateReason reason)
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self), reason);
if (nm_device_is_up (self)) {
nm_info ("(%s): cleaning up...", nm_device_get_iface (self));
nm_log_info (LOGD_HW, "(%s): cleaning up...", nm_device_get_iface (self));
if (NM_DEVICE_GET_CLASS (self)->take_down)
NM_DEVICE_GET_CLASS (self)->take_down (self);
@ -3260,6 +3298,8 @@ failed_to_disconnected (gpointer user_data)
NMDevice *self = NM_DEVICE (user_data);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
nm_log_dbg (LOGD_DEVICE, "(%s): running failed->disconnected transition",
nm_device_get_iface (self));
priv->failed_to_disconnected_id = 0;
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
return FALSE;
@ -3271,6 +3311,8 @@ unavailable_to_disconnected (gpointer user_data)
NMDevice *self = NM_DEVICE (user_data);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
nm_log_dbg (LOGD_DEVICE, "(%s): running unavailable->disconnected transition",
nm_device_get_iface (self));
priv->unavailable_to_disconnected_id = 0;
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
return FALSE;
@ -3294,8 +3336,8 @@ nm_device_state_changed (NMDevice *device,
old_state = priv->state;
priv->state = state;
nm_info ("(%s): device state change: %d -> %d (reason %d)",
nm_device_get_iface (device), old_state, state, reason);
nm_log_info (LOGD_DEVICE, "(%s): device state change: %d -> %d (reason %d)",
nm_device_get_iface (device), old_state, state, reason);
/* Clear any delayed transitions */
delayed_transitions_clear (device);
@ -3313,8 +3355,9 @@ nm_device_state_changed (NMDevice *device,
break;
case NM_DEVICE_STATE_UNAVAILABLE:
if (old_state == NM_DEVICE_STATE_UNMANAGED) {
if (!nm_device_bring_up (device, TRUE, &no_firmware) && no_firmware)
nm_warning ("%s: firmware may be missing.", nm_device_get_iface (device));
if (!nm_device_bring_up (device, TRUE, &no_firmware) && no_firmware) {
nm_log_warn (LOGD_HW, "%s: firmware may be missing.", nm_device_get_iface (device));
}
}
/* Ensure the device gets deactivated in response to stuff like
* carrier changes or rfkill. But don't deactivate devices that are
@ -3346,15 +3389,22 @@ nm_device_state_changed (NMDevice *device,
* we can't change states again from the state handler for a variety of
* reasons.
*/
if (nm_device_is_available (device))
if (nm_device_is_available (device)) {
nm_log_dbg (LOGD_DEVICE, "(%s): device is available, will transition to DISCONNECTED",
nm_device_get_iface (device));
priv->unavailable_to_disconnected_id = g_idle_add (unavailable_to_disconnected, device);
} else {
nm_log_dbg (LOGD_DEVICE, "(%s): device not yet available for transition to DISCONNECTED",
nm_device_get_iface (device));
}
break;
case NM_DEVICE_STATE_ACTIVATED:
nm_info ("Activation (%s) successful, device activated.", nm_device_get_iface (device));
nm_log_info (LOGD_DEVICE, "Activation (%s) successful, device activated.",
nm_device_get_iface (device));
nm_utils_call_dispatcher ("up", nm_act_request_get_connection (req), device, NULL);
break;
case NM_DEVICE_STATE_FAILED:
nm_info ("Activation (%s) failed.", nm_device_get_iface (device));
nm_log_warn (LOGD_DEVICE, "Activation (%s) failed.", nm_device_get_iface (device));
/* Schedule the transition to DISCONNECTED. The device can't transition
* immediately becuase we can't change states again from the state
* handler for a variety of reasons.
@ -3403,7 +3453,9 @@ nm_device_set_managed (NMDevice *device,
return;
priv->managed = managed;
nm_info ("(%s): now %s", nm_device_get_iface (device), managed ? "managed" : "unmanaged");
nm_log_info (LOGD_DEVICE, "(%s): now %s",
nm_device_get_iface (device),
managed ? "managed" : "unmanaged");
g_object_notify (G_OBJECT (device), NM_DEVICE_INTERFACE_MANAGED);

View file

@ -1,175 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
*
* Copyright (C) 2006 - 2008 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
#define _GNU_SOURCE
#include <dlfcn.h>
#include <syslog.h>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <execinfo.h>
#include "nm-logging.h"
#include "nm-utils.h"
static void
fallback_get_backtrace (void)
{
void *frames[64];
Dl_info info;
size_t size;
guint32 i;
const char *name;
size = backtrace (frames, G_N_ELEMENTS (frames));
syslog (LOG_CRIT, "******************* START **********************************");
for (i = 0; i < size; i++) {
dladdr (frames[i], &info);
name = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
if (info.dli_saddr) {
syslog (LOG_CRIT, "Frame %d: %s (%s+0x%lx) [%p]",
i, name,
info.dli_sname,
(gulong)(frames[i] - info.dli_saddr),
frames[i]);
} else {
syslog (LOG_CRIT, "Frame %d: %s (%p+0x%lx) [%p]",
i, name,
info.dli_fbase,
(gulong)(frames[i] - info.dli_saddr),
frames[i]);
}
}
syslog (LOG_CRIT, "******************* END **********************************");
}
static gboolean
crashlogger_get_backtrace (void)
{
gboolean success = FALSE;
int pid;
pid = fork();
if (pid > 0)
{
/* Wait for the child to finish */
int estatus;
if (waitpid (pid, &estatus, 0) != -1)
{
/* Only succeed if the crashlogger succeeded */
if (WIFEXITED (estatus) && (WEXITSTATUS (estatus) == 0))
success = TRUE;
}
}
else if (pid == 0)
{
/* Child process */
execl (LIBEXECDIR"/nm-crash-logger",
LIBEXECDIR"/nm-crash-logger", NULL);
}
return success;
}
void
nm_logging_backtrace (void)
{
struct stat s;
gboolean fallback = TRUE;
/* Try to use gdb via nm-crash-logger if it exists, since
* we get much better information out of it. Otherwise
* fall back to execinfo.
*/
if (stat (LIBEXECDIR"/nm-crash-logger", &s) == 0)
fallback = crashlogger_get_backtrace () ? FALSE : TRUE;
if (fallback)
fallback_get_backtrace ();
}
static void
nm_log_handler (const gchar * log_domain,
GLogLevelFlags log_level,
const gchar * message,
gpointer ignored)
{
int syslog_priority;
switch (log_level)
{
case G_LOG_LEVEL_ERROR:
syslog_priority = LOG_CRIT;
break;
case G_LOG_LEVEL_CRITICAL:
syslog_priority = LOG_ERR;
break;
case G_LOG_LEVEL_WARNING:
syslog_priority = LOG_WARNING;
break;
case G_LOG_LEVEL_MESSAGE:
syslog_priority = LOG_NOTICE;
break;
case G_LOG_LEVEL_DEBUG:
syslog_priority = LOG_DEBUG;
break;
case G_LOG_LEVEL_INFO:
default:
syslog_priority = LOG_INFO;
break;
}
syslog (syslog_priority, "%s", message);
}
void
nm_logging_setup (gboolean become_daemon)
{
if (become_daemon)
openlog (G_LOG_DOMAIN, 0, LOG_DAEMON);
else
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR, LOG_USER);
g_log_set_handler (G_LOG_DOMAIN,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
nm_log_handler,
NULL);
}
void
nm_logging_shutdown (void)
{
closelog ();
}

View file

@ -1,31 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
*
* Copyright (C) 2006 - 2008 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
#ifndef NM_LOGGING_H
#define NM_LOGGING_H
#include <glib.h>
void nm_logging_setup (gboolean become_daemon);
void nm_logging_backtrace (void);
void nm_logging_shutdown (void);
#endif /* NM_LOGGING_H */

View file

@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2009 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include <netinet/ether.h>
@ -26,7 +26,7 @@
#include "nm-glib-compat.h"
#include "nm-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-manager.h"
#include "nm-vpn-manager.h"
#include "nm-modem-manager.h"
@ -79,6 +79,11 @@ static gboolean impl_manager_deactivate_connection (NMManager *manager,
static gboolean impl_manager_sleep (NMManager *manager, gboolean sleep, GError **err);
static gboolean impl_manager_set_logging (NMManager *manager,
const char *level,
const char *domains,
GError **error);
/* Legacy 0.6 compatibility interface */
static gboolean impl_manager_legacy_sleep (NMManager *manager, GError **err);
@ -341,8 +346,7 @@ modem_added (NMModemManager *modem_manager,
* by the Bluetooth code during the connection process.
*/
if (driver && !strcmp (driver, "bluetooth")) {
g_message ("%s: ignoring modem '%s' (no associated Bluetooth device)",
__func__, ip_iface);
nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)", ip_iface);
return;
}
@ -352,7 +356,7 @@ modem_added (NMModemManager *modem_manager,
else if (NM_IS_MODEM_CDMA (modem))
device = nm_device_cdma_new (NM_MODEM_CDMA (modem), driver);
else
g_message ("%s: unhandled modem '%s'", __func__, ip_iface);
nm_log_info (LOGD_MB, "unhandled modem '%s'", ip_iface);
if (device)
add_device (self, device);
@ -488,7 +492,7 @@ aipd_handle_event (DBusGProxy *proxy,
gboolean handled = FALSE;
if (!event || !iface) {
nm_warning ("Incomplete message received from avahi-autoipd");
nm_log_warn (LOGD_AUTOIP4, "incomplete message received from avahi-autoipd");
return;
}
@ -496,7 +500,7 @@ aipd_handle_event (DBusGProxy *proxy,
&& (strcmp (event, "CONFLICT") != 0)
&& (strcmp (event, "UNBIND") != 0)
&& (strcmp (event, "STOP") != 0)) {
nm_warning ("Unknown event '%s' received from avahi-autoipd", event);
nm_log_warn (LOGD_AUTOIP4, "unknown event '%s' received from avahi-autoipd", event);
return;
}
@ -511,7 +515,7 @@ aipd_handle_event (DBusGProxy *proxy,
}
if (!handled)
nm_warning ("Unhandled avahi-autoipd event for '%s'", iface);
nm_log_warn (LOGD_AUTOIP4, "(%s): unhandled avahi-autoipd event", iface);
}
static const char *
@ -693,7 +697,8 @@ user_connection_get_settings_cb (DBusGProxy *proxy,
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
G_TYPE_INVALID)) {
nm_warning ("Couldn't retrieve connection settings: %s.", err->message);
nm_log_info (LOGD_USER_SET, "couldn't retrieve connection settings: %s.",
err && err->message ? err->message : "(unknown)");
g_error_free (err);
goto out;
}
@ -708,10 +713,9 @@ user_connection_get_settings_cb (DBusGProxy *proxy,
connection = nm_connection_new_from_hash (settings, &error);
if (connection == NULL) {
nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
nm_log_warn (LOGD_USER_SET, "invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
g_error_free (error);
goto out;
}
@ -754,7 +758,7 @@ user_connection_get_settings_cb (DBusGProxy *proxy,
}
} else {
// FIXME: merge settings? or just replace?
nm_warning ("%s (#%d): implement merge settings", __func__, __LINE__);
nm_log_dbg (LOGD_USER_SET, "implement merge settings");
}
out:
@ -802,10 +806,9 @@ user_connection_updated_cb (DBusGProxy *proxy,
new_connection = nm_connection_new_from_hash (settings, &error);
if (!new_connection) {
/* New connection invalid, remove existing connection */
nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
nm_log_warn (LOGD_USER_SET, "invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
g_error_free (error);
remove_connection (manager, old_connection, priv->user_connections);
return;
@ -842,7 +845,7 @@ user_internal_new_connection_cb (DBusGProxy *proxy,
path,
NM_DBUS_IFACE_SETTINGS_CONNECTION);
if (!con_proxy) {
nm_warning ("Error: could not init user connection proxy");
nm_log_err (LOGD_USER_SET, "could not init user connection proxy");
return;
}
@ -888,7 +891,8 @@ user_list_connections_cb (DBusGProxy *proxy,
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &ops,
G_TYPE_INVALID)) {
nm_warning ("Couldn't retrieve connections: %s.", err->message);
nm_log_warn (LOGD_USER_SET, "couldn't retrieve connections: %s",
err && err->message ? err->message : "(unknown)");
g_error_free (err);
goto out;
}
@ -934,7 +938,7 @@ user_query_connections (NMManager *manager)
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
if (!priv->user_proxy) {
nm_warning ("Error: could not init settings proxy");
nm_log_err (LOGD_USER_SET, "could not init user settings proxy");
return;
}
@ -977,16 +981,15 @@ system_connection_updated_cb (NMSettingsConnectionInterface *connection,
if (!existing)
return;
if (existing != connection) {
g_warning ("%s: existing connection didn't matched updated.", __func__);
nm_log_warn (LOGD_SYS_SET, "existing connection didn't matched updated.");
return;
}
if (!nm_connection_verify (NM_CONNECTION (existing), &error)) {
/* Updated connection invalid, remove existing connection */
nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
nm_log_warn (LOGD_SYS_SET, "invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
g_error_free (error);
remove_connection (manager, NM_CONNECTION (existing), priv->system_connections);
return;
@ -1228,10 +1231,10 @@ manager_set_radio_enabled (NMManager *manager,
"main", rstate->key,
G_TYPE_BOOLEAN, (gpointer) &enabled,
&error)) {
g_warning ("Writing to state file %s failed: (%d) %s.",
priv->state_file,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
nm_log_warn (LOGD_CORE, "writing to state file %s failed: (%d) %s.",
priv->state_file,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
}
}
@ -1244,8 +1247,12 @@ manager_set_radio_enabled (NMManager *manager,
RfKillType devtype = RFKILL_TYPE_UNKNOWN;
g_object_get (G_OBJECT (iter->data), NM_DEVICE_INTERFACE_RFKILL_TYPE, &devtype, NULL);
if (devtype == rstate->rtype)
if (devtype == rstate->rtype) {
nm_log_dbg (LOGD_RFKILL, "(%s): setting radio %s",
nm_device_get_iface (NM_DEVICE (iter->data)),
enabled ? "enabled" : "disabled");
nm_device_interface_set_enabled (NM_DEVICE_INTERFACE (iter->data), enabled);
}
}
}
@ -1400,13 +1407,19 @@ manager_rfkill_update_one_type (NMManager *self,
break;
}
if (rstate->desc) {
nm_log_dbg (LOGD_RFKILL, "%s hw-enabled %d enabled %d",
rstate->desc, new_he, new_e);
}
if (new_he != rstate->hw_enabled) {
nm_info ("%s now %s by radio killswitch",
rstate->desc,
(new_e && new_he) ? "enabled" : "disabled");
nm_log_info (LOGD_RFKILL, "%s now %s by radio killswitch",
rstate->desc,
(new_e && new_he) ? "enabled" : "disabled");
rstate->hw_enabled = new_he;
g_object_notify (G_OBJECT (self), rstate->hw_prop);
if (rstate->hw_prop)
g_object_notify (G_OBJECT (self), rstate->hw_prop);
}
manager_set_radio_enabled (self, rstate, new_e);
}
@ -1510,14 +1523,14 @@ add_device (NMManager *self, NMDevice *device)
driver = nm_device_get_driver (device);
if (!driver)
driver = "unknown";
nm_info ("(%s): new %s device (driver: '%s')", iface, type_desc, driver);
nm_log_info (LOGD_HW, "(%s): new %s device (driver: '%s')", iface, type_desc, driver);
path = g_strdup_printf ("/org/freedesktop/NetworkManager/Devices/%d", devcount++);
nm_device_set_path (device, path);
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (priv->dbus_mgr),
path,
G_OBJECT (device));
nm_info ("(%s): exported as %s", iface, path);
nm_log_info (LOGD_CORE, "(%s): exported as %s", iface, path);
g_free (path);
/* Check if we should assume the device's active connection by matching its
@ -1532,6 +1545,15 @@ add_device (NMManager *self, NMDevice *device)
existing = nm_device_interface_connection_match_config (NM_DEVICE_INTERFACE (device),
(const GSList *) connections);
g_slist_free (connections);
if (existing) {
NMSettingConnection *s_con;
s_con = (NMSettingConnection *) nm_connection_get_setting (existing, NM_TYPE_SETTING_CONNECTION);
nm_log_dbg (LOGD_DEVICE, "(%s): found existing device connection '%s'",
nm_device_get_iface (device),
nm_setting_connection_get_id (s_con));
}
}
/* Start the device if it's supposed to be managed */
@ -1553,15 +1575,18 @@ add_device (NMManager *self, NMDevice *device)
const char *ac_path;
GError *error = NULL;
nm_log_dbg (LOGD_DEVICE, "(%s): will attempt to assume existing connection",
nm_device_get_iface (device));
ac_path = internal_activate_device (self, device, existing, NULL, FALSE, TRUE, &error);
if (ac_path)
g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS);
else {
nm_warning ("Assumed connection (%d) %s failed to activate: (%d) %s",
nm_connection_get_scope (existing),
nm_connection_get_path (existing),
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_DEVICE, "assumed connection (%d) %s failed to activate: (%d) %s",
nm_connection_get_scope (existing),
nm_connection_get_path (existing),
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_error_free (error);
}
}
@ -1710,13 +1735,12 @@ bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr,
device = nm_device_bt_new (object_path, bdaddr, name, capabilities, FALSE);
if (device) {
g_message ("%s: BT device %s (%s) added (%s%s%s)",
__func__,
name,
bdaddr,
has_dun ? "DUN" : "",
has_dun && has_nap ? " " : "",
has_nap ? "NAP" : "");
nm_log_info (LOGD_HW, "BT device %s (%s) added (%s%s%s)",
name,
bdaddr,
has_dun ? "DUN" : "",
has_dun && has_nap ? " " : "",
has_nap ? "NAP" : "");
add_device (manager, device);
}
@ -1735,7 +1759,7 @@ bluez_manager_bdaddr_removed_cb (NMBluezManager *bluez_mgr,
g_return_if_fail (bdaddr != NULL);
g_return_if_fail (object_path != NULL);
g_message ("%s: BT device %s removed", __func__, bdaddr);
nm_log_info (LOGD_HW, "BT device %s removed", bdaddr);
for (iter = priv->devices; iter; iter = iter->next) {
NMDevice *device = NM_DEVICE (iter->data);
@ -2010,7 +2034,7 @@ user_get_secrets (NMManager *self,
nm_connection_get_path (connection),
NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS);
if (!info->proxy) {
nm_warning ("%s: could not create user connection secrets proxy", __func__);
nm_log_warn (LOGD_USER_SET, "could not create user connection secrets proxy");
g_free (info);
return NULL;
}
@ -2075,7 +2099,9 @@ system_get_secrets_idle_cb (gpointer user_data)
connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (priv->sys_settings),
info->connection_path);
if (!connection) {
error = g_error_new_literal (0, 0, "unknown connection (not exported by system settings)");
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
"unknown connection (not exported by system settings)");
nm_secrets_provider_interface_get_secrets_result (info->provider,
info->setting_name,
info->caller,
@ -2225,8 +2251,8 @@ wait_for_connection_expired (gpointer data)
g_set_error (&error,
NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
"%s", "Connection was not provided by any settings service");
nm_warning ("Connection (%d) %s failed to activate (timeout): (%d) %s",
info->scope, info->connection_path, error->code, error->message);
nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate (timeout): (%d) %s",
info->scope, info->connection_path, error->code, error->message);
dbus_g_method_return_error (info->context, error);
g_error_free (error);
@ -2377,8 +2403,8 @@ connection_added_default_handler (NMManager *manager,
g_object_notify (G_OBJECT (manager), NM_MANAGER_ACTIVE_CONNECTIONS);
} else {
dbus_g_method_return_error (info->context, error);
nm_warning ("Connection (%d) %s failed to activate: (%d) %s",
scope, info->connection_path, error->code, error->message);
nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate: (%d) %s",
scope, info->connection_path, error->code, error->message);
g_error_free (error);
}
@ -2561,8 +2587,8 @@ impl_manager_activate_connection (NMManager *manager,
err:
if (error) {
dbus_g_method_return_error (context, error);
nm_warning ("Connection (%d) %s failed to activate: (%d) %s",
scope, connection_path, error->code, error->message);
nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate: (%d) %s",
scope, connection_path, error->code, error->message);
g_error_free (error);
}
@ -2656,16 +2682,16 @@ impl_manager_sleep (NMManager *self, gboolean sleep, GError **error)
"main", "NetworkingEnabled",
G_TYPE_BOOLEAN, (gpointer) &networking_enabled,
&err)) {
g_warning ("Writing to state file %s failed: (%d) %s.",
priv->state_file,
err ? err->code : -1,
(err && err->message) ? err->message : "unknown");
nm_log_warn (LOGD_SUSPEND, "writing to state file %s failed: (%d) %s.",
priv->state_file,
err ? err->code : -1,
(err && err->message) ? err->message : "unknown");
}
}
if (sleep) {
nm_info ("Sleeping...");
nm_log_info (LOGD_SUSPEND, "sleeping...");
/* Just deactivate and down all devices from the device list,
* we'll remove them in 'wake' for speed's sake.
@ -2675,7 +2701,7 @@ impl_manager_sleep (NMManager *self, gboolean sleep, GError **error)
} else {
const GSList *unmanaged_specs;
nm_info ("Waking up...");
nm_log_info (LOGD_SUSPEND, "waking up...");
unmanaged_specs = nm_sysconfig_settings_get_unmanaged_specs (priv->sys_settings);
@ -2697,6 +2723,12 @@ impl_manager_sleep (NMManager *self, gboolean sleep, GError **error)
gboolean enabled = (rstate->hw_enabled && rstate->enabled);
RfKillType devtype = RFKILL_TYPE_UNKNOWN;
if (rstate->desc) {
nm_log_dbg (LOGD_RFKILL, "%s %s devices (hw_enabled %d, enabled %d)",
enabled ? "enabling" : "disabling",
rstate->desc, rstate->hw_enabled, rstate->enabled);
}
g_object_get (G_OBJECT (device), NM_DEVICE_INTERFACE_RFKILL_TYPE, &devtype, NULL);
if (devtype == rstate->rtype)
nm_device_interface_set_enabled (NM_DEVICE_INTERFACE (device), enabled);
@ -2743,6 +2775,18 @@ impl_manager_legacy_state (NMManager *manager, guint32 *state, GError **err)
return TRUE;
}
static gboolean
impl_manager_set_logging (NMManager *manager,
const char *level,
const char *domains,
GError **error)
{
if (nm_logging_setup (level, domains, error)) {
nm_log_info (LOGD_CORE, "logging: level '%s' domains '%s'", level, domains);
return TRUE;
}
return FALSE;
}
/* Connections */
@ -2798,7 +2842,7 @@ nm_manager_get_connections (NMManager *manager,
else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
g_hash_table_foreach (priv->system_connections, connections_to_slist, &list);
else
nm_warning ("Unknown NMConnectionScope %d", scope);
nm_log_err (LOGD_CORE, "unknown NMConnectionScope %d", scope);
return list;
}
@ -2819,7 +2863,7 @@ nm_manager_get_connection_by_object_path (NMManager *manager,
else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path);
else
nm_warning ("Unknown NMConnectionScope %d", scope);
nm_log_err (LOGD_CORE, "unknown NMConnectionScope %d", scope);
return connection;
}
@ -2862,13 +2906,17 @@ nm_manager_start (NMManager *self)
}
rstate->hw_enabled = hw_enabled;
nm_info ("%s %s by radio killswitch; %s by state file",
rstate->desc,
(rstate->hw_enabled && enabled) ? "enabled" : "disabled",
(rstate->enabled) ? "enabled" : "disabled");
nm_log_info (LOGD_RFKILL, "%s %s by radio killswitch; %s by state file",
rstate->desc,
(rstate->hw_enabled && enabled) ? "enabled" : "disabled",
(rstate->enabled) ? "enabled" : "disabled");
manager_set_radio_enabled (self, rstate, rstate->enabled && enabled);
}
/* Log overall networking status - asleep/running */
nm_log_info (LOGD_CORE, "Networking is %s by state file",
priv->sleeping ? "disabled" : "enabled");
system_unmanaged_devices_changed_cb (priv->sys_settings, NULL, self);
system_hostname_changed_cb (priv->sys_settings, NULL, self);
system_query_connections (self);
@ -3124,6 +3172,14 @@ nm_manager_init (NMManager *manager)
priv->radio_states[RFKILL_TYPE_WWAN].other_enabled_func = nm_manager_get_modem_enabled_state;
priv->radio_states[RFKILL_TYPE_WWAN].rtype = RFKILL_TYPE_WWAN;
priv->radio_states[RFKILL_TYPE_WIMAX].enabled = TRUE;
priv->radio_states[RFKILL_TYPE_WIMAX].key = "WiMAXEnabled";
priv->radio_states[RFKILL_TYPE_WIMAX].prop = NULL;
priv->radio_states[RFKILL_TYPE_WIMAX].hw_prop = NULL;
priv->radio_states[RFKILL_TYPE_WIMAX].desc = "WiMAX";
priv->radio_states[RFKILL_TYPE_WIMAX].other_enabled_func = NULL;
priv->radio_states[RFKILL_TYPE_WIMAX].rtype = RFKILL_TYPE_WIMAX;
for (i = 0; i < RFKILL_TYPE_MAX; i++)
priv->radio_states[i].hw_enabled = TRUE;
@ -3176,7 +3232,7 @@ nm_manager_init (NMManager *manager)
manager,
NULL);
} else
nm_warning ("%s: could not initialize avahi-autoipd D-Bus proxy", __func__);
nm_log_warn (LOGD_AUTOIP4, "could not initialize avahi-autoipd D-Bus proxy");
}
static void
@ -3340,5 +3396,6 @@ nm_manager_class_init (NMManagerClass *manager_class)
&dbus_glib_nm_manager_object_info);
dbus_g_error_domain_register (NM_MANAGER_ERROR, NULL, NM_TYPE_MANAGER_ERROR);
dbus_g_error_domain_register (NM_LOGGING_ERROR, "org.freedesktop.NetworkManager.Logging", NM_TYPE_LOGGING_ERROR);
}

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) 2005 - 2008 Red Hat, Inc.
* Copyright (C) 2005 - 2010 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
* Copyright (C) 2005 Ray Strode
*
@ -43,7 +43,7 @@
#include "NetworkManager.h"
#include "nm-system.h"
#include "nm-netlink-monitor.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-marshal.h"
#include "nm-netlink.h"
@ -186,6 +186,7 @@ netlink_object_message_handler (struct nl_object *obj, void *arg)
struct rtnl_link *filter;
struct rtnl_link *link_obj;
guint flags;
guint ifidx;
filter = rtnl_link_alloc ();
if (!filter) {
@ -206,19 +207,17 @@ netlink_object_message_handler (struct nl_object *obj, void *arg)
link_obj = (struct rtnl_link *) obj;
flags = rtnl_link_get_flags (link_obj);
ifidx = rtnl_link_get_ifindex (link_obj);
nm_log_dbg (LOGD_HW, "netlink link message: iface idx %d flags 0x%X", ifidx, flags);
/* IFF_LOWER_UP is the indicator of carrier status since kernel commit
* b00055aacdb172c05067612278ba27265fcd05ce in 2.6.17.
*/
if (flags & IFF_LOWER_UP) {
g_signal_emit (G_OBJECT (monitor),
signals[CARRIER_ON],
0, rtnl_link_get_ifindex (link_obj));
} else {
g_signal_emit (G_OBJECT (monitor),
signals[CARRIER_OFF],
0, rtnl_link_get_ifindex (link_obj));
}
if (flags & IFF_LOWER_UP)
g_signal_emit (G_OBJECT (monitor), signals[CARRIER_ON], 0, ifidx);
else
g_signal_emit (G_OBJECT (monitor), signals[CARRIER_OFF], 0, ifidx);
out:
rtnl_link_put (filter);
@ -407,9 +406,9 @@ deferred_emit_carrier_state (gpointer user_data)
/* Update the link cache with latest state, and if there are no errors
* emit the link states for all the interfaces in the cache.
*/
if (nl_cache_refill (priv->nlh, priv->nlh_link_cache))
nm_warning ("error updating link cache: %s", nl_geterror ());
else {
if (nl_cache_refill (priv->nlh, priv->nlh_link_cache)) {
nm_log_err (LOGD_HW, "error updating link cache: %s", nl_geterror ());
} else {
nl_cache_foreach_filter (priv->nlh_link_cache,
NULL,
netlink_object_message_handler,

View file

@ -21,7 +21,7 @@
#include "config.h"
#include "nm-netlink.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include <glib.h>
#include <signal.h>
@ -40,7 +40,7 @@ get_link_cache (void)
nlh = nm_netlink_get_default_handle ();
if (G_UNLIKELY (!nlh)) {
nm_warning ("couldn't allocate netlink handle.");
nm_log_err (LOGD_HW, "couldn't allocate netlink handle.");
return NULL;
}
@ -48,7 +48,7 @@ get_link_cache (void)
link_cache = rtnl_link_alloc_cache (nlh);
if (G_UNLIKELY (!link_cache)) {
nm_warning ("couldn't allocate netlink link cache: %s", nl_geterror ());
nm_log_err (LOGD_HW, "couldn't allocate netlink link cache: %s", nl_geterror ());
return NULL;
}
@ -71,12 +71,12 @@ nm_netlink_get_default_handle (void)
cb = nl_cb_alloc(NL_CB_VERBOSE);
def_nl_handle = nl_handle_alloc_cb (cb);
if (!def_nl_handle) {
nm_warning ("couldn't allocate netlink handle.");
nm_log_err (LOGD_HW, "couldn't allocate netlink handle.");
return NULL;
}
if (nl_connect (def_nl_handle, NETLINK_ROUTE) < 0) {
nm_error ("couldn't connect to netlink: %s", nl_geterror ());
nm_log_err (LOGD_HW, "couldn't connect to netlink: %s", nl_geterror ());
return NULL;
}
@ -123,7 +123,7 @@ nm_netlink_index_to_iface (int idx)
buf = g_malloc0 (MAX_IFACE_LEN);
if (buf == NULL) {
nm_warning ("Not enough memory to allocate interface name buffer.");
nm_log_warn (LOGD_HW, "Not enough memory to allocate interface name buffer.");
return NULL;
}

View file

@ -29,7 +29,7 @@
#include "NetworkManagerUtils.h"
#include "nm-wifi-ap.h"
#include "nm-activation-request.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-device-interface.h"
#include "nm-device.h"
#include "nm-device-wifi.h"
@ -269,9 +269,9 @@ update_etc_hosts (const char *hostname, gboolean *out_changed)
g_return_val_if_fail (out_changed != NULL, FALSE);
if (!g_file_get_contents (SYSCONFDIR "/hosts", &contents, &contents_len, &error)) {
nm_warning ("%s: couldn't read " SYSCONFDIR "/hosts: (%d) %s",
__func__, error ? error->code : 0,
(error && error->message) ? error->message : "(unknown)");
nm_log_warn (LOGD_DNS, "couldn't read " SYSCONFDIR "/hosts: (%d) %s",
error ? error->code : 0,
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
return FALSE;
}
@ -287,14 +287,14 @@ update_etc_hosts (const char *hostname, gboolean *out_changed)
g_free (contents);
if (new_contents) {
nm_info ("Updating /etc/hosts with new system hostname");
nm_log_info (LOGD_DNS, "Updating /etc/hosts with new system hostname");
g_clear_error (&error);
/* And actually update /etc/hosts */
if (!g_file_set_contents (SYSCONFDIR "/hosts", new_contents->str, -1, &error)) {
nm_warning ("%s: couldn't update " SYSCONFDIR "/hosts: (%d) %s",
__func__, error ? error->code : 0,
(error && error->message) ? error->message : "(unknown)");
nm_log_warn (LOGD_DNS, "couldn't update " SYSCONFDIR "/hosts: (%d) %s",
error ? error->code : 0,
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
} else {
success = TRUE;
@ -306,8 +306,8 @@ update_etc_hosts (const char *hostname, gboolean *out_changed)
/* No change required */
success = TRUE;
} else {
nm_warning ("%s: couldn't read " SYSCONFDIR "/hosts: (%d) %s",
__func__, error->code, error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_DNS, "couldn't read " SYSCONFDIR "/hosts: (%d) %s",
error->code, error->message ? error->message : "(unknown)");
g_clear_error (&error);
}
@ -326,8 +326,8 @@ set_system_hostname (const char *new_hostname, const char *msg)
errno = 0;
ret = gethostname (old_hostname, HOST_NAME_MAX);
if (ret != 0) {
nm_warning ("%s: couldn't get the system hostname: (%d) %s",
__func__, errno, strerror (errno));
nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
errno, strerror (errno));
} else {
/* Don't set the hostname if it isn't actually changing */
if ( (new_hostname && !strcmp (old_hostname, new_hostname))
@ -336,11 +336,11 @@ set_system_hostname (const char *new_hostname, const char *msg)
}
if (set_hostname) {
nm_info ("Setting system hostname to '%s' (%s)", name, msg);
nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
ret = sethostname (name, strlen (name));
if (ret != 0) {
nm_warning ("%s: couldn't set the system hostname to '%s': (%d) %s",
__func__, name, errno, strerror (errno));
nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
name, errno, strerror (errno));
return;
}
}
@ -353,11 +353,11 @@ set_system_hostname (const char *new_hostname, const char *msg)
*/
if (!update_etc_hosts (name, &changed)) {
/* error updating /etc/hosts; fallback to localhost.localdomain */
nm_info ("Setting system hostname to '" FALLBACK_HOSTNAME "' (error updating /etc/hosts)");
nm_log_info (LOGD_DNS, "Setting system hostname to '" FALLBACK_HOSTNAME "' (error updating /etc/hosts)");
ret = sethostname (FALLBACK_HOSTNAME, strlen (FALLBACK_HOSTNAME));
if (ret != 0) {
nm_warning ("%s: couldn't set the fallback system hostname (%s): (%d) %s",
__func__, FALLBACK_HOSTNAME, errno, strerror (errno));
nm_log_warn (LOGD_DNS, "couldn't set the fallback system hostname (%s): (%d) %s",
FALLBACK_HOSTNAME, errno, strerror (errno));
}
}
@ -450,8 +450,8 @@ update_system_hostname (NMPolicy *policy, NMDevice *best)
return;
}
}
nm_warning ("%s: DHCP-provided hostname '%s' looks invalid; ignoring it",
__func__, dhcp4_hostname);
nm_log_warn (LOGD_DNS, "DHCP-provided hostname '%s' looks invalid; ignoring it",
dhcp4_hostname);
}
}
@ -563,8 +563,8 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
}
if (!ip_iface || !ip4_config) {
nm_warning ("%s: couldn't determine IP interface (%p) or IPv4 config (%p)!",
__func__, ip_iface, ip4_config);
nm_log_warn (LOGD_CORE, "couldn't determine IP interface (%p) or IPv4 config (%p)!",
ip_iface, ip4_config);
goto out;
}
@ -597,10 +597,11 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update)
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
connection_id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
if (connection_id)
nm_info ("Policy set '%s' (%s) as default for routing and DNS.", connection_id, ip_iface);
else
nm_info ("Policy set (%s) as default for routing and DNS.", ip_iface);
if (connection_id) {
nm_log_info (LOGD_CORE, "Policy set '%s' (%s) as default for routing and DNS.", connection_id, ip_iface);
} else {
nm_log_info (LOGD_CORE, "Policy set (%s) as default for routing and DNS.", ip_iface);
}
out:
/* Update the system hostname */
@ -669,8 +670,8 @@ auto_activate_device (gpointer user_data)
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (best_connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
nm_warning ("Connection '%s' auto-activation failed: (%d) %s",
nm_setting_connection_get_id (s_con), error->code, error->message);
nm_log_info (LOGD_DEVICE, "Connection '%s' auto-activation failed: (%d) %s",
nm_setting_connection_get_id (s_con), error->code, error->message);
g_error_free (error);
}
}
@ -797,16 +798,22 @@ device_state_changed (NMDevice *device,
*/
if (connection && IS_ACTIVATING_STATE (old_state)) {
g_object_set_data (G_OBJECT (connection), INVALID_TAG, GUINT_TO_POINTER (TRUE));
nm_info ("Marking connection '%s' invalid.", get_connection_id (connection));
nm_log_info (LOGD_DEVICE, "Marking connection '%s' invalid.", get_connection_id (connection));
nm_connection_clear_secrets (connection);
}
schedule_activate_check (policy, device, 3);
break;
case NM_DEVICE_STATE_ACTIVATED:
/* Clear the invalid tag on the connection */
if (connection)
if (connection) {
/* Clear the invalid tag on the connection */
g_object_set_data (G_OBJECT (connection), INVALID_TAG, NULL);
/* And clear secrets so they will always be requested from the
* settings service when the next connection is made.
*/
nm_connection_clear_secrets (connection);
}
update_routing_and_dns (policy, FALSE);
break;
case NM_DEVICE_STATE_UNMANAGED:
@ -982,8 +989,8 @@ connection_removed (NMManager *manager,
GError *error = NULL;
if (!nm_manager_deactivate_connection (manager, path, NM_DEVICE_STATE_REASON_CONNECTION_REMOVED, &error)) {
nm_warning ("Connection '%s' disappeared, but error deactivating it: (%d) %s",
nm_setting_connection_get_id (s_con), error->code, error->message);
nm_log_warn (LOGD_DEVICE, "Connection '%s' disappeared, but error deactivating it: (%d) %s",
nm_setting_connection_get_id (s_con), error->code, error->message);
g_error_free (error);
}
g_free (path);

View file

@ -106,7 +106,7 @@ properties_changed (gpointer data)
{
char buf[2048] = { 0, };
g_hash_table_foreach (info->hash, add_to_string, &buf);
g_message ("%s: %s -> %s", __func__, G_OBJECT_TYPE_NAME (object), buf);
nm_log_dbg (LOGD_CORE, "%s -> %s", G_OBJECT_TYPE_NAME (object), buf);
}
#endif

View file

@ -25,7 +25,7 @@
#include <nm-setting-8021x.h>
#include <nm-setting-wireless-security.h>
#include "nm-utils.h"
#include "nm-logging.h"
static void
nm_secrets_provider_interface_init (gpointer g_iface)
@ -108,7 +108,7 @@ nm_secrets_provider_interface_get_secrets (NMSecretsProviderInterface *self,
connection, setting_name, request_new, caller, hint1, hint2,
&success);
if (!success) {
nm_warning ("failed to get connection secrets.");
nm_log_warn (LOGD_CORE, "failed to get connection secrets.");
return FALSE;
}
@ -193,7 +193,7 @@ nm_secrets_provider_interface_get_secrets_result (NMSecretsProviderInterface *se
hash = g_hash_table_lookup (settings, name);
if (!hash) {
nm_warning ("couldn't get setting secrets for '%s'", name);
nm_log_warn (LOGD_CORE, "couldn't get setting secrets for '%s'", name);
continue;
}

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) 2004 - 2008 Red Hat, Inc.
* Copyright (C) 2004 - 2010 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
* Copyright (C) 1996 - 1997 Yoichi Hariguchi <yoichi@fore.com>
* Copyright (C) January, 1998 Sergei Viznyuk <sv@phystech.com>
@ -47,6 +47,7 @@
#include "nm-named-manager.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-netlink.h"
/* Because of a bug in libnl, rtnl.h should be included before route.h */
@ -95,10 +96,11 @@ create_route (int iface_idx, int mss)
if (route) {
rtnl_route_set_oif (route, iface_idx);
if (mss && rtnl_route_set_metric (route, RTAX_ADVMSS, mss) < 0)
nm_warning ("Could not set mss");
if (mss && rtnl_route_set_metric (route, RTAX_ADVMSS, mss) < 0) {
nm_log_warn (LOGD_DEVICE, "could not set mss");
}
} else
nm_warning ("Could not allocate route");
nm_log_err (LOGD_DEVICE, "could not allocate route");
return route;
}
@ -141,7 +143,7 @@ nm_system_device_set_ip4_route (const char *iface,
rtnl_route_set_gateway (route, gw_addr);
rtnl_route_set_scope (route, RT_SCOPE_UNIVERSE);
} else {
nm_warning ("Invalid gateway");
nm_log_err (LOGD_DEVICE | LOGD_IP4, "Invalid gateway 0x%X", ip4_gateway);
rtnl_route_put (route);
return NULL;
}
@ -176,7 +178,9 @@ nm_system_device_set_ip4_route (const char *iface,
nl_addr_put (gw_addr);
if (err) {
nm_warning ("Failed to set IPv4 route on '%s': %s", iface, nl_geterror ());
nm_log_err (LOGD_DEVICE | LOGD_IP4,
"(%s): failed to set IPv4 route: %s",
iface, nl_geterror ());
rtnl_route_put (route);
route = NULL;
}
@ -193,6 +197,9 @@ sync_addresses (const char *iface, int ifindex, int family,
struct rtnl_addr *filter_addr, *match_addr;
struct nl_object *match;
int i, err;
guint32 log_domain = (family == AF_INET) ? LOGD_IP4 : LOGD_IP6;
log_domain |= LOGD_DEVICE;
nlh = nm_netlink_get_default_handle ();
if (!nlh)
@ -247,7 +254,7 @@ sync_addresses (const char *iface, int ifindex, int family,
/* Otherwise, match_addr should be removed from the interface. */
err = rtnl_addr_delete (nlh, match_addr, 0);
if (err < 0) {
nm_warning ("(%s) error %d returned from rtnl_addr_delete(): %s",
nm_log_err (log_domain, "(%s): error %d returned from rtnl_addr_delete(): %s",
iface, err, nl_geterror ());
}
}
@ -262,7 +269,8 @@ sync_addresses (const char *iface, int ifindex, int family,
err = rtnl_addr_add (nlh, addrs[i], 0);
if (err < 0) {
nm_warning ("(%s) error %d returned from rtnl_addr_add():\n%s",
nm_log_err (log_domain,
"(%s): error %d returned from rtnl_addr_add():\n%s",
iface, err, nl_geterror ());
}
@ -301,7 +309,9 @@ add_ip4_addresses (NMIP4Config *config, const char *iface)
addrs[i] = nm_ip4_config_to_rtnl_addr (config, i, flags);
if (!addrs[i]) {
nm_warning ("couldn't create rtnl address!\n");
nm_log_warn (LOGD_DEVICE | LOGD_IP4,
"(%s): couldn't create rtnl address!",
iface);
continue;
}
rtnl_addr_set_ifindex (addrs[i], iface_idx);
@ -464,7 +474,7 @@ nm_system_device_set_ip6_route (const char *iface,
rtnl_route_set_gateway (route, gw_addr);
rtnl_route_set_scope (route, RT_SCOPE_UNIVERSE);
} else {
nm_warning ("Invalid gateway");
nm_log_warn (LOGD_DEVICE | LOGD_IP6, "Invalid gateway");
rtnl_route_put (route);
return NULL;
}
@ -499,7 +509,9 @@ nm_system_device_set_ip6_route (const char *iface,
nl_addr_put (gw_addr);
if (err) {
nm_warning ("Failed to set IPv6 route on '%s': %s", iface, nl_geterror ());
nm_log_err (LOGD_DEVICE | LOGD_IP6,
"(%s): failed to set IPv6 route: %s",
iface, nl_geterror ());
rtnl_route_put (route);
route = NULL;
}
@ -526,7 +538,9 @@ add_ip6_addresses (NMIP6Config *config, const char *iface)
addrs[i] = nm_ip6_config_to_rtnl_addr (config, i, NM_RTNL_ADDR_DEFAULT);
if (!addrs[i]) {
nm_warning ("couldn't create rtnl address!\n");
nm_log_warn (LOGD_DEVICE | LOGD_IP6,
"(%s): couldn't create rtnl address!",
iface);
continue;
}
rtnl_addr_set_ifindex (addrs[i], iface_idx);
@ -661,7 +675,7 @@ nm_system_device_is_up_with_iface (const char *iface)
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
nm_warning ("couldn't open control socket.");
nm_log_err (LOGD_HW, "couldn't open control socket.");
return FALSE;
}
@ -670,8 +684,8 @@ nm_system_device_is_up_with_iface (const char *iface)
strncpy (ifr.ifr_name, iface, IFNAMSIZ);
if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0) {
if (errno != ENODEV) {
nm_warning ("%s: could not get flags for device %s. errno = %d",
__func__, iface, errno);
nm_log_err (LOGD_HW, "(%s): could not get flags: errno %d",
iface, errno);
}
} else {
up = !!(ifr.ifr_flags & IFF_UP);
@ -753,7 +767,9 @@ add_ip4_route_to_gateway (const char *iface, guint32 gw, guint32 mss)
/* Add direct route to the gateway */
err = rtnl_route_add (nlh, route, 0);
if (err) {
nm_warning ("(%s): failed to add IPv4 route to gateway (%d)", iface, err);
nm_log_err (LOGD_DEVICE | LOGD_IP4,
"(%s): failed to add IPv4 route to gateway (%d)",
iface, err);
goto error;
}
@ -853,7 +869,8 @@ nm_system_replace_default_ip4_route_vpn (const char *iface,
if (err == 0) {
return TRUE;
} else if (err != -ESRCH) {
nm_warning ("(%s): failed to set IPv4 default route: %d",
nm_log_err (LOGD_DEVICE | LOGD_IP4,
"(%s): failed to set IPv4 default route: %d",
iface, err);
return FALSE;
}
@ -867,7 +884,8 @@ nm_system_replace_default_ip4_route_vpn (const char *iface,
err = replace_default_ip4_route (iface, int_gw, mss);
if (err != 0) {
rtnl_route_del (nlh, gw_route, 0);
nm_warning ("(%s): failed to set IPv4 default route (pass #2): %d",
nm_log_err (LOGD_DEVICE | LOGD_IP4,
"(%s): failed to set IPv4 default route (pass #2): %d",
iface, err);
} else
success = TRUE;
@ -897,7 +915,8 @@ nm_system_replace_default_ip4_route (const char *iface, guint32 gw, guint32 mss)
if (err == 0) {
return TRUE;
} else if (err != -ESRCH) {
nm_warning ("(%s): failed to set IPv4 default route: %d",
nm_log_err (LOGD_DEVICE | LOGD_IP4,
"(%s): failed to set IPv4 default route: %d",
iface, err);
return FALSE;
}
@ -911,7 +930,8 @@ nm_system_replace_default_ip4_route (const char *iface, guint32 gw, guint32 mss)
err = replace_default_ip4_route (iface, gw, mss);
if (err != 0) {
rtnl_route_del (nlh, gw_route, 0);
nm_warning ("(%s): failed to set IPv4 default route (pass #2): %d",
nm_log_err (LOGD_DEVICE | LOGD_IP4,
"(%s): failed to set IPv4 default route (pass #2): %d",
iface, err);
} else
success = TRUE;
@ -993,7 +1013,8 @@ check_one_route (struct nl_object *object, void *user_data)
err = rtnl_route_del (nm_netlink_get_default_handle (), route, 0);
if (err < 0) {
nm_warning ("(%s) error %d returned from rtnl_route_del(): %s",
nm_log_err (LOGD_DEVICE,
"(%s): error %d returned from rtnl_route_del(): %s",
data->iface, err, nl_geterror());
}
}

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <signal.h>
@ -33,7 +33,7 @@
#include "nm-udev-manager.h"
#include "nm-marshal.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "NetworkManagerUtils.h"
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
@ -82,6 +82,30 @@ nm_udev_manager_get_rfkill_state (NMUdevManager *self, RfKillType rtype)
return NM_UDEV_MANAGER_GET_PRIVATE (self)->rfkill_states[rtype];
}
static const char *
rfkill_type_to_desc (RfKillType rtype)
{
if (rtype == 0)
return "WiFi";
else if (rtype == 1)
return "WWan";
else if (rtype == 2)
return "WiMAX";
return "unknown";
}
static const char *
rfkill_state_to_desc (RfKillState rstate)
{
if (rstate == 0)
return "unblocked";
else if (rstate == 1)
return "soft-blocked";
else if (rstate == 2)
return "hard-blocked";
return "unknown";
}
static Killswitch *
killswitch_new (GUdevDevice *device, RfKillType rtype)
{
@ -139,7 +163,7 @@ sysfs_state_to_nm_state (gint sysfs_state)
case 2:
return RFKILL_HARD_BLOCKED;
default:
g_warning ("%s: Unhandled rfkill state %d", __func__, sysfs_state);
nm_log_warn (LOGD_RFKILL, "unhandled rfkill state %d", sysfs_state);
break;
}
return RFKILL_UNBLOCKED;
@ -175,6 +199,10 @@ recheck_killswitches (NMUdevManager *self)
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
if (poll_states[i] != priv->rfkill_states[i]) {
nm_log_dbg (LOGD_RFKILL, "%s rfkill state now '%s'",
rfkill_type_to_desc (i),
rfkill_state_to_desc (poll_states[i]));
priv->rfkill_states[i] = poll_states[i];
g_signal_emit (self, signals[RFKILL_CHANGED], 0, i, priv->rfkill_states[i]);
}
@ -229,11 +257,11 @@ add_one_killswitch (NMUdevManager *self, GUdevDevice *device)
ks = killswitch_new (device, rtype);
priv->killswitches = g_slist_prepend (priv->killswitches, ks);
nm_info ("Found %s radio killswitch %s (at %s) (driver %s)",
str_type,
ks->name,
ks->path,
ks->driver ? ks->driver : "<unknown>");
nm_log_info (LOGD_RFKILL, "found %s radio killswitch %s (at %s) (driver %s)",
rfkill_type_to_desc (rtype),
ks->name,
ks->path,
ks->driver ? ks->driver : "<unknown>");
}
static void
@ -265,7 +293,7 @@ rfkill_remove (NMUdevManager *self,
Killswitch *ks = iter->data;
if (!strcmp (ks->name, name)) {
nm_info ("Radio killswitch %s disappeared", ks->path);
nm_log_info (LOGD_RFKILL, "radio killswitch %s disappeared", ks->path);
priv->killswitches = g_slist_remove (priv->killswitches, ks);
killswitch_destroy (ks);
break;
@ -322,7 +350,7 @@ device_creator (NMUdevManager *manager,
path = g_udev_device_get_sysfs_path (udev_device);
if (!path) {
nm_warning ("couldn't determine device path; ignoring...");
nm_log_warn (LOGD_HW, "couldn't determine device path; ignoring...");
return NULL;
}
@ -345,13 +373,13 @@ device_creator (NMUdevManager *manager,
}
if (!driver) {
nm_warning ("%s: couldn't determine device driver; ignoring...", path);
nm_log_warn (LOGD_HW, "%s: couldn't determine device driver; ignoring...", path);
goto out;
}
ifindex = g_udev_device_get_sysfs_attr_as_int (udev_device, "ifindex");
if (ifindex <= 0) {
nm_warning ("%s: device had invalid ifindex %d; ignoring...", path, (guint32) ifindex);
nm_log_warn (LOGD_HW, "%s: device had invalid ifindex %d; ignoring...", path, (guint32) ifindex);
goto out;
}
@ -373,18 +401,36 @@ out:
static void
net_add (NMUdevManager *self, GUdevDevice *device)
{
gint devtype;
gint etype;
const char *iface;
const char *devtype;
g_return_if_fail (device != NULL);
devtype = g_udev_device_get_sysfs_attr_as_int (device, "type");
if (devtype != 1)
etype = g_udev_device_get_sysfs_attr_as_int (device, "type");
if (etype != 1) {
nm_log_dbg (LOGD_HW, "ignoring interface with type %d", etype);
return; /* Not using ethernet encapsulation, don't care */
}
/* Not all ethernet devices are immediately usable; newer mobile broadband
* devices (Ericsson, Option, Sierra) require setup on the tty before the
* ethernet device is usable. 2.6.33 and later kernels set the 'DEVTYPE'
* uevent variable which we can use to ignore the interface as a NMDevice
* subclass. ModemManager will pick it up though and so we'll handle it
* through the mobile broadband stuff.
*/
devtype = g_udev_device_get_property (device, "DEVTYPE");
if (devtype && !strcmp (devtype, "wwan")) {
nm_log_dbg (LOGD_HW, "ignoring interface with devtype '%s'", devtype);
return;
}
iface = g_udev_device_get_name (device);
if (!iface)
if (!iface) {
nm_log_dbg (LOGD_HW, "failed to get device's interface");
return;
}
g_signal_emit (self, signals[DEVICE_ADDED], 0, device, device_creator);
}
@ -427,6 +473,9 @@ handle_uevent (GUdevClient *client,
subsys = g_udev_device_get_subsystem (device);
g_return_if_fail (subsys != NULL);
nm_log_dbg (LOGD_HW, "UDEV event: action '%s' subsys '%s' device '%s'",
action, subsys, g_udev_device_get_name (device));
g_return_if_fail (!strcmp (subsys, "rfkill") || !strcmp (subsys, "net"));
if (!strcmp (action, "add")) {

View file

@ -26,6 +26,7 @@
#include "nm-wifi-ap.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-manager.h"
#include "wpa.h"
#include "nm-properties-changed-signal.h"
@ -333,7 +334,7 @@ nm_ap_export_to_dbus (NMAccessPoint *ap)
priv = NM_AP_GET_PRIVATE (ap);
if (priv->dbus_path) {
nm_warning ("Tried to export AP %s twice.", priv->dbus_path);
nm_log_err (LOGD_CORE, "Tried to export AP %s twice.", priv->dbus_path);
return;
}
@ -696,25 +697,25 @@ nm_ap_print_self (NMAccessPoint *ap,
{
NMAccessPointPrivate *priv;
g_return_if_fail (ap != NULL);
g_return_if_fail (NM_IS_AP (ap));
priv = NM_AP_GET_PRIVATE (ap);
nm_info ("%s'%s' (%p) stamp=%ld flags=0x%X wpa-flags=0x%X rsn-flags=0x%x "
"bssid=" MAC_FMT " strength=%d freq=%d rate=%d mode=%d seen=%ld",
prefix,
priv->ssid ? nm_utils_escape_ssid (priv->ssid->data, priv->ssid->len) : "(none)",
ap,
priv->timestamp.tv_sec,
priv->flags,
priv->wpa_flags,
priv->rsn_flags,
MAC_ARG (priv->address.ether_addr_octet),
priv->strength,
priv->freq,
priv->max_bitrate,
priv->mode,
priv->last_seen);
nm_log_dbg (LOGD_WIFI_SCAN, "%s'%s' (%p)",
prefix,
priv->ssid ? nm_utils_escape_ssid (priv->ssid->data, priv->ssid->len) : "(none)",
ap);
nm_log_dbg (LOGD_WIFI_SCAN, " BSSID " MAC_FMT, MAC_ARG (priv->address.ether_addr_octet));
nm_log_dbg (LOGD_WIFI_SCAN, " mode %d", priv->mode);
nm_log_dbg (LOGD_WIFI_SCAN, " timestamp %ld", priv->timestamp.tv_sec);
nm_log_dbg (LOGD_WIFI_SCAN, " flags 0x%X", priv->flags);
nm_log_dbg (LOGD_WIFI_SCAN, " wpa flags 0x%X", priv->wpa_flags);
nm_log_dbg (LOGD_WIFI_SCAN, " rsn flags 0x%X", priv->rsn_flags);
nm_log_dbg (LOGD_WIFI_SCAN, " quality %d", priv->strength);
nm_log_dbg (LOGD_WIFI_SCAN, " frequency %d", priv->freq);
nm_log_dbg (LOGD_WIFI_SCAN, " max rate %d", priv->max_bitrate);
nm_log_dbg (LOGD_WIFI_SCAN, " last-seen %ld", priv->last_seen);
}
const char *
@ -940,7 +941,7 @@ void nm_ap_set_mode (NMAccessPoint *ap, const NM80211Mode mode)
g_object_notify (G_OBJECT (ap), NM_AP_MODE);
}
} else
nm_warning ("Invalid AP mode '%d'", mode);
nm_log_warn (LOGD_WIFI, "Invalid AP mode '%d'", mode);
}
@ -1468,7 +1469,7 @@ channel_to_freq (guint32 channel, const char *band)
} else if (!strcmp (band, "bg")) {
while (bg_table[i].chan && (bg_table[i].chan != channel))
i++;
return a_table[i].freq;
return bg_table[i].freq;
}
return 0;

View file

@ -3,6 +3,7 @@ INCLUDES = \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/src \
-I${top_srcdir}/src/logging \
-I${top_builddir}/marshallers
noinst_LTLIBRARIES = libppp-manager.la
@ -28,6 +29,7 @@ libppp_manager_la_CPPFLAGS = \
libppp_manager_la_LIBADD = \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)

View file

@ -49,7 +49,7 @@
#include "nm-setting-gsm.h"
#include "nm-setting-cdma.h"
#include "nm-dbus-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-marshal.h"
static void impl_ppp_manager_need_secrets (NMPPPManager *manager,
@ -296,12 +296,13 @@ monitor_cb (gpointer user_data)
req.stats_ptr = (caddr_t) &req.stats;
strncpy (req.ifr__name, priv->ip_iface, sizeof (req.ifr__name));
if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0)
nm_warning ("Could not read ppp stats: %s", strerror (errno));
else
if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) {
nm_log_warn (LOGD_PPP, "could not read ppp stats: %s", strerror (errno));
} else {
g_signal_emit (manager, signals[STATS], 0,
req.stats.p.ppp_ibytes,
req.stats.p.ppp_obytes);
req.stats.p.ppp_ibytes,
req.stats.p.ppp_obytes);
}
return TRUE;
}
@ -315,7 +316,7 @@ monitor_stats (NMPPPManager *manager)
if (priv->monitor_fd > 0)
priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, manager);
else
nm_warning ("Could not open pppd monitor: %s", strerror (errno));
nm_log_warn (LOGD_PPP, "could not monitor PPP stats: %s", strerror (errno));
}
/*******************************************/
@ -387,8 +388,8 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
GError *err = NULL;
g_set_error (&err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN,
"Missing type-specific setting; no secrets could be found.");
nm_warning ("%s", err->message);
"Missing type-specific setting; no secrets could be found.");
nm_log_warn (LOGD_PPP, "%s", err->message);
dbus_g_method_return_error (context, err);
}
return;
@ -442,7 +443,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
GValue *val;
int i;
nm_info ("PPP manager(IP Config Get) reply received.");
nm_log_info (LOGD_PPP, "PPP manager(IP Config Get) reply received.");
remove_timeout_handler (manager);
@ -467,7 +468,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
if (nm_ip4_address_get_address (addr) && nm_ip4_address_get_prefix (addr)) {
nm_ip4_config_take_address (config, addr);
} else {
nm_warning ("%s: invalid IPv4 address received!", __func__);
nm_log_err (LOGD_PPP, "invalid IPv4 address received!");
nm_ip4_address_unref (addr);
goto out;
}
@ -490,7 +491,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_INTERFACE);
if (!val || !G_VALUE_HOLDS_STRING (val)) {
nm_warning ("No interface");
nm_log_err (LOGD_PPP, "no interface received!");
goto out;
}
priv->ip_iface = g_value_dup_string (val);
@ -582,13 +583,12 @@ nm_cmd_line_add_int (NMCmdLine *cmd, int i)
static inline const char *
nm_find_pppd (void)
{
static const char *pppd_binary_paths[] =
{
"/usr/local/sbin/pppd",
"/usr/sbin/pppd",
"/sbin/pppd",
NULL
};
static const char *pppd_binary_paths[] = {
"/usr/local/sbin/pppd",
"/usr/sbin/pppd",
"/sbin/pppd",
NULL
};
const char **pppd_binary = pppd_binary_paths;
@ -670,7 +670,7 @@ ppp_exit_code (guint pppd_exit_status, GPid pid)
msg = "Unknown error";
}
nm_warning ("ppp pid %d exited with error: %s", pid, msg);
nm_log_warn (LOGD_PPP, "pppd pid %d exited with error: %s", pid, msg);
}
static void
@ -686,14 +686,14 @@ ppp_watch_cb (GPid pid, gint status, gpointer user_data)
err = WEXITSTATUS (status);
if (err != 0)
ppp_exit_code (err, priv->pid);
} else if (WIFSTOPPED (status))
nm_warning ("ppp pid %d stopped unexpectedly with signal %d", priv->pid, WSTOPSIG (status));
else if (WIFSIGNALED (status))
nm_warning ("ppp pid %d died with signal %d", priv->pid, WTERMSIG (status));
else
nm_warning ("ppp pid %d died from an unknown cause", priv->pid);
} else if (WIFSTOPPED (status)) {
nm_log_info (LOGD_PPP, "pppd pid %d stopped unexpectedly with signal %d", priv->pid, WSTOPSIG (status));
} else if (WIFSIGNALED (status)) {
nm_log_info (LOGD_PPP, "pppd pid %d died with signal %d", priv->pid, WTERMSIG (status));
} else
nm_log_info (LOGD_PPP, "pppd pid %d died from an unknown cause", priv->pid);
nm_debug ("ppp pid %d cleaned up", priv->pid);
nm_log_dbg (LOGD_PPP, "pppd pid %d cleaned up", priv->pid);
priv->pid = 0;
g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD);
}
@ -703,7 +703,7 @@ pppd_timed_out (gpointer data)
{
NMPPPManager *manager = NM_PPP_MANAGER (data);
nm_warning ("Looks like pppd didn't initialize our dbus module");
nm_log_warn (LOGD_PPP, "pppd timed out or didn't initialize our dbus module");
nm_ppp_manager_stop (manager);
g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD);
@ -913,10 +913,10 @@ nm_ppp_manager_start (NMPPPManager *manager,
priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
nm_info ("Starting pppd connection");
nm_log_info (LOGD_PPP, "starting PPP connection");
cmd_str = nm_cmd_line_to_str (ppp_cmd);
nm_debug ("Command line: %s", cmd_str);
nm_log_dbg (LOGD_PPP, "command line: %s", cmd_str);
g_free (cmd_str);
priv->pid = 0;
@ -927,7 +927,7 @@ nm_ppp_manager_start (NMPPPManager *manager,
goto out;
}
nm_debug ("ppp started with pid %d", priv->pid);
nm_log_info (LOGD_PPP, "pppd started with pid %d", priv->pid);
priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, manager);
priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, manager);
@ -965,7 +965,7 @@ nm_ppp_manager_update_secrets (NMPPPManager *manager,
GError *err = NULL;
g_set_error (&err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR_UNKOWN, "%s", error_message);
nm_warning ("%s", error_message);
nm_log_warn (LOGD_PPP, "%s", error_message);
dbus_g_method_return_error (priv->pending_secrets_context, err);
g_error_free (err);
} else {
@ -989,9 +989,9 @@ ensure_killed (gpointer data)
kill (pid, SIGKILL);
/* ensure the child is reaped */
nm_debug ("waiting for ppp pid %d to exit", pid);
nm_log_dbg (LOGD_PPP, "waiting for pppd pid %d to exit", pid);
waitpid (pid, NULL, 0);
nm_debug ("ppp pid %d cleaned up", pid);
nm_log_dbg (LOGD_PPP, "pppd pid %d cleaned up", pid);
return FALSE;
}
@ -1034,9 +1034,9 @@ nm_ppp_manager_stop (NMPPPManager *manager)
kill (priv->pid, SIGKILL);
/* ensure the child is reaped */
nm_debug ("waiting for ppp pid %d to exit", priv->pid);
nm_log_dbg (LOGD_PPP, "waiting for pppd pid %d to exit", priv->pid);
waitpid (priv->pid, NULL, 0);
nm_debug ("ppp pid %d cleaned up", priv->pid);
nm_log_dbg (LOGD_PPP, "pppd pid %d cleaned up", priv->pid);
}
priv->pid = 0;

View file

@ -34,7 +34,6 @@
#include "nm-pppd-plugin.h"
#include "nm-ppp-status.h"
#include "nm-dbus-glib-types.h"
#include "nm-utils.h"
int plugin_init (void);

View file

@ -2,6 +2,7 @@ SUBDIRS=. tests
INCLUDES = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_builddir}/marshallers \
@ -28,6 +29,7 @@ libsupplicant_manager_la_CPPFLAGS = \
libsupplicant_manager_la_LIBADD = \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)

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.
*/
@ -31,7 +31,7 @@
#include "nm-supplicant-config.h"
#include "nm-supplicant-settings-verify.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-setting.h"
#include "NetworkManagerUtils.h"
@ -123,26 +123,26 @@ nm_supplicant_config_add_option_with_type (NMSupplicantConfig *self,
char buf[255];
memset (&buf[0], 0, sizeof (buf));
memcpy (&buf[0], value, len > 254 ? 254 : len);
nm_debug ("Key '%s' and/or value '%s' invalid.", key, buf);
nm_log_warn (LOGD_SUPPLICANT, "Key '%s' and/or value '%s' invalid.", key, buf);
return FALSE;
}
}
old_opt = (ConfigOption *) g_hash_table_lookup (priv->config, key);
if (old_opt) {
nm_debug ("Key '%s' already in table.", key);
nm_log_warn (LOGD_SUPPLICANT, "Key '%s' already in table.", key);
return FALSE;
}
opt = g_slice_new0 (ConfigOption);
if (opt == NULL) {
nm_debug ("Couldn't allocate memory for new config option.");
nm_log_warn (LOGD_SUPPLICANT, "Couldn't allocate memory for new config option.");
return FALSE;
}
opt->value = g_malloc0 ((sizeof (char) * len) + 1);
if (opt->value == NULL) {
nm_debug ("Couldn't allocate memory for new config option value.");
nm_log_warn (LOGD_SUPPLICANT, "Couldn't allocate memory for new config option value.");
g_slice_free (ConfigOption, opt);
return FALSE;
}
@ -151,12 +151,13 @@ nm_supplicant_config_add_option_with_type (NMSupplicantConfig *self,
opt->len = len;
opt->type = type;
{
char buf[255];
memset (&buf[0], 0, sizeof (buf));
memcpy (&buf[0], opt->value, opt->len > 254 ? 254 : opt->len);
nm_info ("Config: added '%s' value '%s'", key, secret ? "<omitted>" : &buf[0]);
}
{
char buf[255];
memset (&buf[0], 0, sizeof (buf));
memcpy (&buf[0], opt->value, opt->len > 254 ? 254 : opt->len);
nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, secret ? "<omitted>" : &buf[0]);
}
g_hash_table_insert (priv->config, g_strdup (key), opt);
return TRUE;
@ -194,33 +195,33 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self,
type = nm_supplicant_settings_verify_setting (key, (const char *) value->data, value->len);
if (type == TYPE_INVALID) {
nm_debug ("Key '%s' and/or it's contained value is invalid.", key);
nm_log_warn (LOGD_SUPPLICANT, "Key '%s' and/or it's contained value is invalid.", key);
return FALSE;
}
old_opt = (ConfigOption *) g_hash_table_lookup (priv->config, key);
if (old_opt) {
nm_debug ("Key '%s' already in table.", key);
nm_log_warn (LOGD_SUPPLICANT, "Key '%s' already in table.", key);
return FALSE;
}
blob = g_byte_array_sized_new (value->len);
if (!blob) {
nm_debug ("Couldn't allocate memory for new config blob.");
nm_log_warn (LOGD_SUPPLICANT, "Couldn't allocate memory for new config blob.");
return FALSE;
}
g_byte_array_append (blob, value->data, value->len);
opt = g_slice_new0 (ConfigOption);
if (opt == NULL) {
nm_debug ("Couldn't allocate memory for new config option.");
nm_log_warn (LOGD_SUPPLICANT, "Couldn't allocate memory for new config option.");
g_byte_array_free (blob, TRUE);
return FALSE;
}
opt->value = g_strdup_printf ("blob://%s", blobid);
if (opt->value == NULL) {
nm_debug ("Couldn't allocate memory for new config option value.");
nm_log_warn (LOGD_SUPPLICANT, "Couldn't allocate memory for new config option value.");
g_byte_array_free (blob, TRUE);
g_slice_free (ConfigOption, opt);
return FALSE;
@ -229,7 +230,7 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self,
opt->len = strlen (opt->value);
opt->type = type;
nm_info ("Config: added '%s' value '%s'", key, opt->value);
nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, opt->value);
g_hash_table_insert (priv->config, g_strdup (key), opt);
g_hash_table_insert (priv->blobs, g_strdup (blobid), blob);
@ -378,13 +379,13 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
id = nm_setting_wireless_get_ssid (setting);
if (!nm_supplicant_config_add_option (self, "ssid", (char *) id->data, id->len, FALSE)) {
nm_warning ("Error adding SSID to supplicant config.");
nm_log_warn (LOGD_SUPPLICANT, "Error adding SSID to supplicant config.");
return FALSE;
}
if (is_adhoc) {
if (!nm_supplicant_config_add_option (self, "mode", "1", -1, FALSE)) {
nm_warning ("Error adding mode to supplicant config.");
nm_log_warn (LOGD_SUPPLICANT, "Error adding mode to supplicant config.");
return FALSE;
}
@ -394,7 +395,7 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
str_freq = g_strdup_printf ("%u", adhoc_freq);
if (!nm_supplicant_config_add_option (self, "frequency", str_freq, -1, FALSE)) {
g_free (str_freq);
nm_warning ("Error adding Ad-Hoc frequency to supplicant config.");
nm_log_warn (LOGD_SUPPLICANT, "Error adding Ad-Hoc frequency to supplicant config.");
return FALSE;
}
g_free (str_freq);
@ -418,7 +419,7 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
str_bssid, strlen (str_bssid),
FALSE)) {
g_free (str_bssid);
nm_warning ("Error adding BSSID to supplicant config.");
nm_log_warn (LOGD_SUPPLICANT, "Error adding BSSID to supplicant config.");
return FALSE;
}
g_free (str_bssid);
@ -445,7 +446,7 @@ add_string_val (NMSupplicantConfig *self,
value = ucase ? g_ascii_strup (field, -1) : g_strdup (field);
success = nm_supplicant_config_add_option (self, name, value, strlen (field), secret);
if (!success)
nm_warning ("Error adding %s to supplicant config.", name);
nm_log_warn (LOGD_SUPPLICANT, "Error adding %s to supplicant config.", name);
g_free (value);
return success;
}
@ -471,7 +472,7 @@ add_string_val (NMSupplicantConfig *self,
success = TRUE; \
g_string_free (str, TRUE); \
if (!success) { \
nm_warning ("Error adding %s to supplicant config.", name); \
nm_log_warn (LOGD_SUPPLICANT, "Error adding %s to supplicant config.", name); \
return FALSE; \
} \
}
@ -494,7 +495,7 @@ get_blob_id (const char *name, const char *seed_uid)
success = nm_supplicant_config_add_blob (self, name, field, uid); \
g_free (uid); \
if (!success) { \
nm_warning ("Error adding %s to supplicant config.", name); \
nm_log_warn (LOGD_SUPPLICANT, "Error adding %s to supplicant config.", name); \
return FALSE; \
} \
}
@ -550,16 +551,16 @@ add_wep_key (NMSupplicantConfig *self,
success = nm_supplicant_config_add_option (self, name, value, key_len / 2, TRUE);
g_free (value);
if (!success) {
nm_warning ("Error adding %s to supplicant config.", name);
nm_log_warn (LOGD_SUPPLICANT, "Error adding %s to supplicant config.", name);
return FALSE;
}
} else if ((key_len == 5) || (key_len == 13)) {
if (!nm_supplicant_config_add_option (self, name, key, key_len, TRUE)) {
nm_warning ("Error adding %s to supplicant config.", name);
nm_log_warn (LOGD_SUPPLICANT, "Error adding %s to supplicant config.", name);
return FALSE;
}
} else {
nm_warning ("Invalid WEP key '%s'", name);
nm_log_warn (LOGD_SUPPLICANT, "Invalid WEP key '%s'", name);
return FALSE;
}
} else if (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE) {
@ -570,7 +571,7 @@ add_wep_key (NMSupplicantConfig *self,
if (success)
success = nm_supplicant_config_add_option (self, name, (const char *) digest, digest_len, TRUE);
if (!success) {
nm_warning ("Error adding %s to supplicant config.", name);
nm_log_warn (LOGD_SUPPLICANT, "Error adding %s to supplicant config.", name);
return FALSE;
}
}
@ -611,7 +612,7 @@ nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self,
success = nm_supplicant_config_add_option (self, "psk", value, psk_len / 2, TRUE);
g_free (value);
if (!success) {
nm_warning ("Error adding 'psk' to supplicant config.");
nm_log_warn (LOGD_SUPPLICANT, "Error adding 'psk' to supplicant config.");
return FALSE;
}
} else if (psk_len >= 8 && psk_len <= 63) {
@ -621,12 +622,12 @@ nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self,
* passphrase and not a hex key.
*/
if (!nm_supplicant_config_add_option_with_type (self, "psk", psk, -1, TYPE_STRING, TRUE)) {
nm_warning ("Error adding 'psk' to supplicant config.");
nm_log_warn (LOGD_SUPPLICANT, "Error adding 'psk' to supplicant config.");
return FALSE;
}
} else {
/* Invalid PSK */
nm_warning ("Invalid PSK length %u: not between 8 and 63 characters inclusive.", (guint32) psk_len);
nm_log_warn (LOGD_SUPPLICANT, "Invalid PSK length %u: not between 8 and 63 characters inclusive.", (guint32) psk_len);
return FALSE;
}
}
@ -662,7 +663,7 @@ nm_supplicant_config_add_setting_wireless_security (NMSupplicantConfig *self,
success = nm_supplicant_config_add_option (self, "wep_tx_keyidx", value, -1, FALSE);
g_free (value);
if (!success) {
nm_warning ("Error adding wep_tx_keyidx to supplicant config.");
nm_log_warn (LOGD_SUPPLICANT, "Error adding wep_tx_keyidx to supplicant config.");
return FALSE;
}
}

View file

@ -25,7 +25,7 @@
#include "nm-supplicant-interface.h"
#include "nm-supplicant-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-marshal.h"
#include "nm-supplicant-config.h"
#include "nm-dbus-manager.h"
@ -144,6 +144,7 @@ typedef struct {
DBusGProxy *proxy;
NMCallStore *store;
DBusGProxyCall *call;
gboolean disposing;
} NMSupplicantInfo;
static NMSupplicantInfo *
@ -164,10 +165,11 @@ nm_supplicant_info_new (NMSupplicantInterface *interface,
static void
nm_supplicant_info_set_call (NMSupplicantInfo *info, DBusGProxyCall *call)
{
if (call) {
nm_call_store_add (info->store, G_OBJECT (info->proxy), (gpointer) call);
info->call = call;
}
g_return_if_fail (info != NULL);
g_return_if_fail (call != NULL);
nm_call_store_add (info->store, G_OBJECT (info->proxy), (gpointer) call);
info->call = call;
}
static void
@ -175,13 +177,30 @@ nm_supplicant_info_destroy (gpointer user_data)
{
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
if (info->call)
nm_call_store_remove (info->store, G_OBJECT (info->proxy), info->call);
/* Guard against double-disposal; since DBusGProxy doesn't guard against
* double-disposal, we could infinite loop here if we're in the middle of
* some wpa_supplicant D-Bus calls. When the supplicant dies we'll dispose
* of the proxy, which kills all its pending calls, which brings us here.
* Then when we unref the proxy here, its dispose() function will get called
* again, and we get right back here until we segfault because our callstack
* is too long.
*/
if (!info->disposing) {
info->disposing = TRUE;
g_object_unref (info->proxy);
g_object_unref (info->interface);
if (info->call) {
nm_call_store_remove (info->store, G_OBJECT (info->proxy), info->call);
info->call = NULL;
}
g_slice_free (NMSupplicantInfo, info);
g_object_unref (info->proxy);
info->proxy = NULL;
g_object_unref (info->interface);
info->interface = NULL;
memset (info, 0, sizeof (NMSupplicantInfo));
g_slice_free (NMSupplicantInfo, info);
}
}
@ -498,8 +517,10 @@ bssid_properties_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
DBUS_TYPE_G_MAP_OF_VARIANT, &hash,
G_TYPE_INVALID)) {
if (!strstr (err->message, "The BSSID requested was invalid"))
nm_warning ("Couldn't retrieve BSSID properties: %s.", err->message);
if (!strstr (err->message, "The BSSID requested was invalid")) {
nm_log_warn (LOGD_SUPPLICANT, "Couldn't retrieve BSSID properties: %s.",
err->message);
}
g_error_free (err);
} else {
g_signal_emit (info->interface,
@ -543,7 +564,7 @@ scan_results_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &array,
G_TYPE_INVALID)) {
nm_warning ("could not get scan results: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "could not get scan results: %s.", err->message);
g_error_free (err);
} else {
int i;
@ -672,7 +693,7 @@ iface_state_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
G_TYPE_STRING, &state_str,
G_TYPE_INVALID)) {
nm_warning ("could not get interface state: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "could not get interface state: %s.", err->message);
g_error_free (err);
} else {
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
@ -766,6 +787,7 @@ static void
nm_supplicant_interface_add_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
{
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
GError *err = NULL;
char *path = NULL;
@ -780,12 +802,13 @@ nm_supplicant_interface_add_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpoi
/* Interface already added, just try to get the interface */
nm_supplicant_interface_add_to_supplicant (info->interface, TRUE);
} else {
nm_warning ("Unexpected supplicant error getting interface: %s", err->message);
nm_log_err (LOGD_SUPPLICANT, "(%s): error getting interface: %s",
priv->dev, err->message);
}
g_error_free (err);
} else {
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
nm_log_dbg (LOGD_SUPPLICANT, "(%s): interface added to supplicant", priv->dev);
priv->object_path = path;
@ -884,6 +907,8 @@ nm_supplicant_interface_start (NMSupplicantInterface * self)
/* Can only start the interface from INIT state */
g_return_if_fail (priv->state == NM_SUPPLICANT_INTERFACE_STATE_INIT);
nm_log_dbg (LOGD_SUPPLICANT, "(%s): adding interface to supplicant", priv->dev);
state = nm_supplicant_manager_get_state (priv->smgr);
if (state == NM_SUPPLICANT_MANAGER_STATE_IDLE) {
nm_supplicant_interface_set_state (self, NM_SUPPLICANT_INTERFACE_STATE_STARTING);
@ -893,7 +918,7 @@ nm_supplicant_interface_start (NMSupplicantInterface * self)
* that its state has changed.
*/
} else
nm_warning ("Unknown supplicant manager state!");
nm_log_warn (LOGD_SUPPLICANT, "Unknown supplicant manager state!");
}
static void
@ -914,7 +939,7 @@ nm_supplicant_interface_handle_supplicant_manager_idle_state (NMSupplicantInterf
/* Don't do anything here; interface can't get out of DOWN state */
break;
default:
nm_warning ("Unknown supplicant interface state!");
nm_log_warn (LOGD_SUPPLICANT, "Unknown supplicant interface state!");
break;
}
}
@ -970,7 +995,7 @@ nm_supplicant_interface_smgr_state_changed (NMSupplicantManager * smgr,
nm_supplicant_interface_handle_supplicant_manager_idle_state (self);
break;
default:
nm_warning ("Unknown supplicant manager state!");
nm_log_warn (LOGD_SUPPLICANT, "Unknown supplicant manager state!");
break;
}
}
@ -983,7 +1008,8 @@ remove_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_dat
guint tmp;
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
nm_warning ("Couldn't remove network from supplicant interface: %s.", err->message);
nm_log_dbg (LOGD_SUPPLICANT, "Couldn't remove network from supplicant interface: %s.",
err->message);
g_error_free (err);
}
}
@ -995,7 +1021,8 @@ disconnect_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
guint tmp;
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
nm_warning ("Couldn't disconnect supplicant interface: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "Couldn't disconnect supplicant interface: %s.",
err->message);
g_error_free (err);
}
}
@ -1057,7 +1084,7 @@ select_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_dat
guint tmp;
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
nm_warning ("Couldn't select network config: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "Couldn't select network config: %s.", err->message);
emit_error_helper (info->interface, err);
g_error_free (err);
}
@ -1072,7 +1099,7 @@ set_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
guint tmp;
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
nm_warning ("Couldn't set network config: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "Couldn't set network config: %s.", err->message);
emit_error_helper (info->interface, err);
g_error_free (err);
} else {
@ -1116,7 +1143,7 @@ set_blobs_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
guint tmp;
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
nm_warning ("Couldn't set network blobs: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "Couldn't set network certificates: %s.", err->message);
emit_error_helper (info->interface, err);
g_error_free (err);
} else {
@ -1165,7 +1192,8 @@ call_set_blobs (NMSupplicantInfo *info, GHashTable *orig_blobs)
(GDestroyNotify) blob_free);
if (!blobs) {
const char *msg = "Not enough memory to create blob table.";
nm_warning ("%s", msg);
nm_log_warn (LOGD_SUPPLICANT, "%s", msg);
g_signal_emit (info->interface,
nm_supplicant_interface_signals[CONNECTION_ERROR],
0, "SendBlobError", msg);
@ -1194,7 +1222,8 @@ add_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
DBUS_TYPE_G_OBJECT_PATH, &path,
G_TYPE_INVALID)) {
nm_warning ("Couldn't add a network to the supplicant interface: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "Couldn't add a network to the supplicant interface: %s.",
err->message);
emit_error_helper (info->interface, err);
g_error_free (err);
} else {
@ -1225,22 +1254,21 @@ static void
set_ap_scan_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
{
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
GError *err = NULL;
guint32 tmp;
DBusGProxyCall *call;
if (!dbus_g_proxy_end_call (proxy, call_id, &err, G_TYPE_UINT, &tmp, G_TYPE_INVALID)) {
nm_warning ("Couldn't send AP scan mode to the supplicant interface: %s.", err->message);
nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.",
err->message);
emit_error_helper (info->interface, err);
g_error_free (err);
return;
}
{
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
int ap_scan = nm_supplicant_config_get_ap_scan (priv->cfg);
nm_info ("Config: set interface ap_scan to %d", ap_scan);
}
nm_log_info (LOGD_SUPPLICANT, "Config: set interface ap_scan to %d",
nm_supplicant_config_get_ap_scan (priv->cfg));
info = nm_supplicant_info_new (info->interface, proxy, info->store);
call = dbus_g_proxy_begin_call (proxy, "addNetwork",
@ -1306,7 +1334,7 @@ scan_request_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
G_TYPE_UINT, &success,
G_TYPE_INVALID)) {
nm_warning ("Could not get scan request result: %s", err->message);
nm_log_warn (LOGD_SUPPLICANT, "Could not get scan request result: %s", err->message);
g_error_free (err);
}

View file

@ -27,7 +27,7 @@
#include "nm-supplicant-interface.h"
#include "nm-dbus-manager.h"
#include "nm-marshal.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-glib-compat.h"
#define SUPPLICANT_POKE_INTERVAL 120
@ -97,11 +97,11 @@ poke_supplicant_cb (gpointer user_data)
WPAS_DBUS_PATH,
WPAS_DBUS_INTERFACE);
if (!proxy) {
nm_warning ("Error: could not init wpa_supplicant proxy");
nm_log_warn (LOGD_SUPPLICANT, "Error: could not init wpa_supplicant proxy");
goto out;
}
nm_info ("Trying to start the supplicant...");
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);
@ -288,9 +288,12 @@ nm_supplicant_manager_get_iface (NMSupplicantManager * self,
}
if (!iface) {
nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname);
iface = nm_supplicant_interface_new (self, ifname, is_wireless);
if (iface)
priv->ifaces = g_slist_append (priv->ifaces, iface);
} else {
nm_log_dbg (LOGD_SUPPLICANT, "(%s): returning existing supplicant interface", ifname);
}
return iface;

View file

@ -2,6 +2,7 @@ INCLUDES = -I${top_srcdir} \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/libnm-glib \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/src \
-I${top_builddir}/marshallers
@ -44,6 +45,7 @@ libsystem_settings_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/libnm-glib/libnm-glib.la \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
$(GMODULE_LIBS) \

View file

@ -25,6 +25,7 @@
#include "nm-marshal.h"
#include "nm-inotify-helper.h"
#include "nm-logging.h"
G_DEFINE_TYPE (NMInotifyHelper, nm_inotify_helper, G_TYPE_OBJECT)
@ -122,14 +123,14 @@ init_inotify (NMInotifyHelper *self)
priv->ifd = inotify_init ();
if (priv->ifd == -1) {
g_warning ("%s: couldn't initialize inotify", __func__);
nm_log_warn (LOGD_SYS_SET, "couldn't initialize inotify");
return FALSE;
}
/* Watch the inotify descriptor for file/directory change events */
channel = g_io_channel_unix_new (priv->ifd);
if (!channel) {
g_warning ("%s: couldn't create new GIOChannel", __func__);
nm_log_warn (LOGD_SYS_SET, "couldn't create new GIOChannel");
close (priv->ifd);
priv->ifd = -1;
return FALSE;

View file

@ -28,6 +28,7 @@
#include "nm-settings-connection-interface.h"
#include "nm-settings-interface.h"
#include "nm-polkit-helpers.h"
#include "nm-logging.h"
static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
@ -613,8 +614,9 @@ nm_sysconfig_connection_init (NMSysconfigConnection *self)
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
priv->authority = polkit_authority_get ();
if (!priv->authority)
g_warning ("%s: error creating PolicyKit authority", __func__);
if (!priv->authority) {
nm_log_err (LOGD_SYS_SET, "%s: error creating PolicyKit authority");
}
}
static void

View file

@ -19,7 +19,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2009 Red Hat, Inc.
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2008 Novell, Inc.
*/
@ -57,8 +57,8 @@
#include "nm-sysconfig-connection.h"
#include "nm-polkit-helpers.h"
#include "nm-system-config-error.h"
#include "nm-utils.h"
#include "nm-default-wired-connection.h"
#include "nm-logging.h"
#define CONFIG_KEY_NO_AUTO_DEFAULT "no-auto-default"
@ -357,8 +357,6 @@ add_plugin (NMSysconfigSettings *self, NMSystemConfigInterface *plugin)
g_signal_connect (plugin, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED,
G_CALLBACK (plugin_connection_added), self);
g_signal_connect (plugin, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED,
G_CALLBACK (unmanaged_specs_changed), self);
g_signal_connect (plugin, "notify::hostname", G_CALLBACK (hostname_changed), self);
nm_system_config_interface_init (plugin, NULL);
@ -368,7 +366,10 @@ add_plugin (NMSysconfigSettings *self, NMSystemConfigInterface *plugin)
NM_SYSTEM_CONFIG_INTERFACE_INFO, &pinfo,
NULL);
g_message ("Loaded plugin %s: %s", pname, pinfo);
g_signal_connect (plugin, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED,
G_CALLBACK (unmanaged_specs_changed), self);
nm_log_info (LOGD_SYS_SET, "Loaded plugin %s: %s", pname, pinfo);
g_free (pname);
g_free (pinfo);
}
@ -859,11 +860,11 @@ permission_call_done (GObject *object, GAsyncResult *result, gpointer user_data)
&error);
/* Some random error happened */
if (error) {
g_warning ("%s.%d (%s): error checking '%s' permission: (%d) %s",
__FILE__, __LINE__, __func__,
call->pk_action,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_err (LOGD_SYS_SET, "error checking '%s' permission: (%d) %s",
__FILE__, __LINE__, __func__,
call->pk_action,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
if (error)
g_error_free (error);
} else {
@ -1064,7 +1065,7 @@ is_mac_auto_wired_blacklisted (NMSysconfigSettings *self, const GByteArray *mac)
config = g_key_file_new ();
if (!config) {
g_warning ("%s: not enough memory to load config file.", __func__);
nm_log_warn (LOGD_SYS_SET, "not enough memory to load config file.");
return FALSE;
}
@ -1216,14 +1217,14 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
g_object_set_data (G_OBJECT (nm_default_wired_connection_get_device (wired)),
DEFAULT_WIRED_TAG,
NULL);
g_message ("Saved default wired connection '%s' to persistent storage", id);
nm_log_info (LOGD_SYS_SET, "Saved default wired connection '%s' to persistent storage", id);
return FALSE;
}
g_warning ("%s: couldn't save default wired connection '%s': %d / %s",
__func__, id,
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
nm_log_warn (LOGD_SYS_SET, "couldn't save default wired connection '%s': %d / %s",
id,
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
/* If there was an error, don't destroy the default wired connection,
* but add it back to the system settings service. Connection is already
@ -1275,7 +1276,8 @@ nm_sysconfig_settings_device_added (NMSysconfigSettings *self, NMDevice *device)
id = nm_setting_connection_get_id (s_con);
g_assert (id);
g_message ("Added default wired connection '%s' for %s", id, nm_device_get_udi (device));
nm_log_info (LOGD_SYS_SET, "Added default wired connection '%s' for %s",
id, nm_device_get_udi (device));
g_signal_connect (wired, "try-update", (GCallback) default_wired_try_update, self);
g_signal_connect (wired, "deleted", (GCallback) default_wired_deleted, self);
@ -1327,6 +1329,7 @@ nm_sysconfig_settings_new (const char *config_file,
g_object_unref (self);
return NULL;
}
unmanaged_specs_changed (NULL, self);
}
return self;
@ -1474,7 +1477,12 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
NM_DBUS_IFACE_SETTINGS_SYSTEM,
NM_TYPE_SYSCONFIG_SETTINGS_ERROR);
dbus_g_error_domain_register (NM_SETTINGS_INTERFACE_ERROR,
NM_DBUS_IFACE_SETTINGS,
NM_TYPE_SETTINGS_INTERFACE_ERROR);
/* And register all the settings errors with D-Bus */
dbus_g_error_domain_register (NM_CONNECTION_ERROR, NULL, NM_TYPE_CONNECTION_ERROR);
dbus_g_error_domain_register (NM_SETTING_802_1X_ERROR, NULL, NM_TYPE_SETTING_802_1X_ERROR);
dbus_g_error_domain_register (NM_SETTING_BLUETOOTH_ERROR, NULL, NM_TYPE_SETTING_BLUETOOTH_ERROR);
dbus_g_error_domain_register (NM_SETTING_CDMA_ERROR, NULL, NM_TYPE_SETTING_CDMA_ERROR);
@ -1507,6 +1515,6 @@ nm_sysconfig_settings_init (NMSysconfigSettings *self)
G_CALLBACK (pk_authority_changed_cb),
self);
} else
g_warning ("%s: failed to create PolicyKit authority.", __func__);
nm_log_warn (LOGD_SYS_SET, "failed to create PolicyKit authority.");
}

View file

@ -2,6 +2,7 @@ INCLUDES = \
-I${top_srcdir} \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/src \
-I${top_builddir}/marshallers \
-I${top_srcdir}/src/named-manager \
@ -25,6 +26,7 @@ libvpn_manager_la_CPPFLAGS = \
libvpn_manager_la_LIBADD = \
$(top_builddir)/marshallers/libmarshallers.la \
$(top_builddir)/src/logging/libnm-logging.la \
$(top_builddir)/libnm-util/libnm-util.la \
$(DBUS_LIBS) \
$(GLIB_LIBS)

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) 2005 - 2009 Red Hat, Inc.
* Copyright (C) 2005 - 2010 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
@ -36,6 +36,7 @@
#include "nm-dbus-manager.h"
#include "nm-manager.h"
#include "nm-system.h"
#include "nm-logging.h"
#include "nm-utils.h"
#include "nm-vpn-plugin-bindings.h"
#include "nm-marshal.h"
@ -269,7 +270,7 @@ plugin_failed (DBusGProxy *proxy,
{
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (user_data);
nm_info ("VPN plugin failed: %d", plugin_failure);
nm_log_warn (LOGD_VPN, "VPN plugin failed: %d", plugin_failure);
switch (plugin_failure) {
case NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED:
@ -291,7 +292,7 @@ plugin_state_changed (DBusGProxy *proxy,
NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
nm_info ("VPN plugin state changed: %d", state);
nm_log_info (LOGD_VPN, "VPN plugin state changed: %d", state);
if (state == NM_VPN_SERVICE_STATE_STOPPED) {
/* Clear connection secrets to ensure secrets get requested each time the
@ -305,7 +306,7 @@ plugin_state_changed (DBusGProxy *proxy,
case NM_VPN_CONNECTION_STATE_CONNECT:
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
case NM_VPN_CONNECTION_STATE_ACTIVATED:
nm_info ("VPN plugin state change reason: %d", priv->failure_reason);
nm_log_info (LOGD_VPN, "VPN plugin state change reason: %d", priv->failure_reason);
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
priv->failure_reason);
@ -331,8 +332,8 @@ ip_address_to_string (guint32 numeric)
if (inet_ntop (AF_INET, &temp_addr, buf, INET_ADDRSTRLEN)) {
return buf;
} else {
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (temp_addr.s_addr));
nm_log_warn (LOGD_VPN, "error converting IP4 address 0x%X",
ntohl (temp_addr.s_addr));
return NULL;
}
}
@ -351,38 +352,44 @@ print_vpn_config (NMIP4Config *config,
addr = nm_ip4_config_get_address (config, 0);
nm_info ("VPN Gateway: %s", ip_address_to_string (nm_ip4_address_get_gateway (addr)));
nm_log_info (LOGD_VPN, "VPN Gateway: %s", ip_address_to_string (nm_ip4_address_get_gateway (addr)));
if (internal_gw)
nm_info ("Internal Gateway: %s", ip_address_to_string (internal_gw));
nm_info ("Tunnel Device: %s", tundev);
nm_info ("Internal IP4 Address: %s", ip_address_to_string (nm_ip4_address_get_address (addr)));
nm_info ("Internal IP4 Prefix: %d", nm_ip4_address_get_prefix (addr));
nm_info ("Internal IP4 Point-to-Point Address: %s",
ip_address_to_string (nm_ip4_config_get_ptp_address (config)));
nm_info ("Maximum Segment Size (MSS): %d", nm_ip4_config_get_mss (config));
nm_log_info (LOGD_VPN, "Internal Gateway: %s", ip_address_to_string (internal_gw));
nm_log_info (LOGD_VPN, "Tunnel Device: %s", tundev);
nm_log_info (LOGD_VPN, "Internal IP4 Address: %s", ip_address_to_string (nm_ip4_address_get_address (addr)));
nm_log_info (LOGD_VPN, "Internal IP4 Prefix: %d", nm_ip4_address_get_prefix (addr));
nm_log_info (LOGD_VPN, "Internal IP4 Point-to-Point Address: %s",
ip_address_to_string (nm_ip4_config_get_ptp_address (config)));
nm_log_info (LOGD_VPN, "Maximum Segment Size (MSS): %d", nm_ip4_config_get_mss (config));
num = nm_ip4_config_get_num_routes (config);
for (i = 0; i < num; i++) {
NMIP4Route *route;
route = nm_ip4_config_get_route (config, i);
nm_info ("Static Route: %s/%d Next Hop: %s",
ip_address_to_string (nm_ip4_route_get_dest (route)),
nm_ip4_route_get_prefix (route),
ip_address_to_string (nm_ip4_route_get_next_hop (route)));
nm_log_info (LOGD_VPN, "Static Route: %s/%d Next Hop: %s",
ip_address_to_string (nm_ip4_route_get_dest (route)),
nm_ip4_route_get_prefix (route),
ip_address_to_string (nm_ip4_route_get_next_hop (route)));
}
num = nm_ip4_config_get_num_nameservers (config);
for (i = 0; i < num; i++)
nm_info ("Internal IP4 DNS: %s", ip_address_to_string (nm_ip4_config_get_nameserver (config, i)));
for (i = 0; i < num; i++) {
nm_log_info (LOGD_VPN, "Internal IP4 DNS: %s",
ip_address_to_string (nm_ip4_config_get_nameserver (config, i)));
}
if (nm_ip4_config_get_num_domains (config) > 0)
dns_domain = (char *) nm_ip4_config_get_domain (config, 0);
nm_info ("DNS Domain: '%s'", dns_domain ? dns_domain : "(none)");
nm_info ("Login Banner:");
nm_info ("-----------------------------------------");
nm_info ("%s", banner);
nm_info ("-----------------------------------------");
nm_log_info (LOGD_VPN, "DNS Domain: '%s'", dns_domain ? dns_domain : "(none)");
if (banner && strlen (banner)) {
nm_log_info (LOGD_VPN, "Login Banner:");
nm_log_info (LOGD_VPN, "-----------------------------------------");
nm_log_info (LOGD_VPN, "%s", banner);
nm_log_info (LOGD_VPN, "-----------------------------------------");
}
}
static void
@ -399,8 +406,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
int i;
guint32 vpn_ext_gw = 0;
nm_info ("VPN connection '%s' (IP Config Get) reply received.",
nm_vpn_connection_get_name (connection));
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP Config Get) reply received.",
nm_vpn_connection_get_name (connection));
g_source_remove (priv->ipconfig_timeout);
priv->ipconfig_timeout = 0;
@ -411,7 +418,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
if (val)
priv->tundev = g_strdup (g_value_get_string (val));
else {
nm_warning ("%s: invalid or missing tunnel device received!", __func__);
nm_log_err (LOGD_VPN, "invalid or missing tunnel device received!");
goto error;
}
@ -445,7 +452,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
if (nm_ip4_address_get_address (addr) && nm_ip4_address_get_prefix (addr)) {
nm_ip4_config_take_address (config, addr);
} else {
nm_warning ("%s: invalid IP4 config received!", __func__);
nm_log_err (LOGD_VPN, "invalid IP4 config received!");
nm_ip4_address_unref (addr);
goto error;
}
@ -532,8 +539,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
priv->ip4_config = config;
nm_info ("VPN connection '%s' (IP Config Get) complete.",
nm_vpn_connection_get_name (connection));
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP Config Get) complete.",
nm_vpn_connection_get_name (connection));
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_ACTIVATED,
NM_VPN_CONNECTION_STATE_REASON_NONE);
@ -541,8 +548,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
}
error:
nm_warning ("VPN connection '%s' did not receive valid IP config information.",
nm_vpn_connection_get_name (connection));
nm_log_warn (LOGD_VPN, "VPN connection '%s' did not receive valid IP config information.",
nm_vpn_connection_get_name (connection));
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID);
@ -561,8 +568,8 @@ nm_vpn_connection_ip_config_timeout (gpointer user_data)
* in this timeout, cancel activation because it's taken too long.
*/
if (nm_vpn_connection_get_vpn_state (connection) == NM_VPN_CONNECTION_STATE_IP_CONFIG_GET) {
nm_info ("VPN connection '%s' (IP Config Get) timeout exceeded.",
nm_vpn_connection_get_name (connection));
nm_log_warn (LOGD_VPN, "VPN connection '%s' (IP Config Get) timeout exceeded.",
nm_vpn_connection_get_name (connection));
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT);
@ -577,12 +584,12 @@ nm_vpn_connection_connect_cb (DBusGProxy *proxy, GError *err, gpointer user_data
NMVPNConnection *connection = NM_VPN_CONNECTION (user_data);
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
nm_info ("VPN connection '%s' (Connect) reply received.",
nm_vpn_connection_get_name (connection));
nm_log_info (LOGD_VPN, "VPN connection '%s' (Connect) reply received.",
nm_vpn_connection_get_name (connection));
if (err) {
nm_warning ("VPN connection '%s' failed to connect: '%s'.",
nm_vpn_connection_get_name (connection), err->message);
nm_log_warn (LOGD_VPN, "VPN connection '%s' failed to connect: '%s'.",
nm_vpn_connection_get_name (connection), err->message);
nm_vpn_connection_set_vpn_state (connection,
NM_VPN_CONNECTION_STATE_FAILED,
NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED);
@ -777,9 +784,9 @@ secrets_update_setting (NMSecretsProviderInterface *interface,
return FALSE;
if (!nm_connection_update_secrets (priv->connection, NM_SETTING_VPN_SETTING_NAME, new, &error)) {
nm_warning ("Failed to update VPN secrets: %d %s",
error ? error->code : -1,
error && error->message ? error->message : "(none)");
nm_log_warn (LOGD_VPN, "Failed to update VPN secrets: %d %s",
error ? error->code : -1,
error && error->message ? error->message : "(none)");
g_clear_error (&error);
return FALSE;
}
@ -823,9 +830,9 @@ connection_need_secrets_cb (DBusGProxy *proxy,
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
if (error) {
g_warning ("%s.%d: NeedSecrets failed: %s %s",
__FILE__, __LINE__,
g_quark_to_string (error->domain), error->message);
nm_log_err (LOGD_VPN, "NeedSecrets failed: %s %s",
g_quark_to_string (error->domain),
error->message);
nm_vpn_connection_fail (self, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS);
return;
}
@ -893,7 +900,7 @@ vpn_cleanup (NMVPNConnection *connection)
nm_device_get_ip4_config (priv->parent_dev),
nm_device_get_priority (priv->parent_dev),
NM_IP4_COMPARE_FLAG_ADDRESSES | NM_IP4_COMPARE_FLAG_ROUTES)) {
nm_warning ("%s: failed to re-apply VPN parent device addresses and routes.", __func__);
nm_log_err (LOGD_VPN, "failed to re-apply VPN parent device addresses and routes.");
}
}
}
@ -940,7 +947,7 @@ connection_state_changed (NMVPNConnection *connection,
org_freedesktop_NetworkManager_VPN_Plugin_disconnect (priv->proxy, &err);
if (err) {
nm_warning ("%s", err->message);
nm_log_warn (LOGD_VPN, "error disconnecting VPN: %s", err->message);
g_error_free (err);
}

View file

@ -27,7 +27,6 @@
#include "nm-setting-vpn.h"
#include "nm-dbus-manager.h"
#include "NetworkManagerVPN.h"
#include "nm-utils.h"
#include "nm-marshal.h"
G_DEFINE_TYPE (NMVPNManager, nm_vpn_manager, G_TYPE_OBJECT)

View file

@ -29,7 +29,7 @@
#include "nm-vpn-service.h"
#include "nm-dbus-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-vpn-manager.h"
#include "nm-glib-compat.h"
@ -198,18 +198,20 @@ vpn_service_watch_cb (GPid pid, gint status, gpointer user_data)
if (WIFEXITED (status)) {
guint err = WEXITSTATUS (status);
if (err != 0)
nm_warning ("VPN service '%s' exited with error: %d",
nm_vpn_service_get_name (service), WSTOPSIG (status));
} else if (WIFSTOPPED (status))
nm_warning ("VPN service '%s' stopped unexpectedly with signal %d",
nm_vpn_service_get_name (service), WSTOPSIG (status));
else if (WIFSIGNALED (status))
nm_warning ("VPN service '%s' died with signal %d",
nm_vpn_service_get_name (service), WTERMSIG (status));
else
nm_warning ("VPN service '%s' died from an unknown cause",
nm_vpn_service_get_name (service));
if (err != 0) {
nm_log_warn (LOGD_VPN, "VPN service '%s' exited with error: %d",
nm_vpn_service_get_name (service), WSTOPSIG (status));
}
} else if (WIFSTOPPED (status)) {
nm_log_warn (LOGD_VPN, "VPN service '%s' stopped unexpectedly with signal %d",
nm_vpn_service_get_name (service), WSTOPSIG (status));
} else if (WIFSIGNALED (status)) {
nm_log_warn (LOGD_VPN, "VPN service '%s' died with signal %d",
nm_vpn_service_get_name (service), WTERMSIG (status));
} else {
nm_log_warn (LOGD_VPN, "VPN service '%s' died from an unknown cause",
nm_vpn_service_get_name (service));
}
priv->pid = 0;
priv->service_child_watch = 0;
@ -222,8 +224,8 @@ nm_vpn_service_timeout (gpointer data)
{
NMVPNService *service = NM_VPN_SERVICE (data);
nm_info ("VPN service '%s' did not start in time, cancelling connections",
nm_vpn_service_get_name (service));
nm_log_warn (LOGD_VPN, "VPN service '%s' did not start in time, cancelling connections",
nm_vpn_service_get_name (service));
NM_VPN_SERVICE_GET_PRIVATE (service)->service_start_timeout = 0;
nm_vpn_service_connections_stop (service, TRUE, NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT);
@ -250,14 +252,14 @@ nm_vpn_service_daemon_exec (NMVPNService *service, GError **error)
nm_vpn_service_child_setup, NULL, &priv->pid,
&spawn_error);
if (success) {
nm_info ("VPN service '%s' started (%s), PID %d",
nm_vpn_service_get_name (service), priv->dbus_service, priv->pid);
nm_log_info (LOGD_VPN, "VPN service '%s' started (%s), PID %d",
nm_vpn_service_get_name (service), priv->dbus_service, priv->pid);
priv->service_child_watch = g_child_watch_add (priv->pid, vpn_service_watch_cb, service);
priv->service_start_timeout = g_timeout_add_seconds (5, nm_vpn_service_timeout, service);
} else {
nm_warning ("VPN service '%s': could not launch the VPN service. error: (%d) %s.",
nm_vpn_service_get_name (service), spawn_error->code, spawn_error->message);
nm_log_warn (LOGD_VPN, "VPN service '%s': could not launch the VPN service. error: (%d) %s.",
nm_vpn_service_get_name (service), spawn_error->code, spawn_error->message);
g_set_error (error,
NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_SERVICE_START_FAILED,
@ -334,7 +336,8 @@ nm_vpn_service_activate (NMVPNService *service,
// FIXME: fill in error when errors happen
nm_vpn_connection_activate (vpn);
} else if (priv->service_start_timeout == 0) {
nm_info ("Starting VPN service '%s'...", nm_vpn_service_get_name (service));
nm_log_info (LOGD_VPN, "Starting VPN service '%s'...",
nm_vpn_service_get_name (service));
if (!nm_vpn_service_daemon_exec (service, error))
vpn = NULL;
}
@ -378,16 +381,16 @@ nm_vpn_service_name_owner_changed (NMDBusManager *mgr,
/* service just appeared */
GSList *iter;
nm_info ("VPN service '%s' just appeared, activating connections",
nm_vpn_service_get_name (service));
nm_log_info (LOGD_VPN, "VPN service '%s' appeared, activating connections",
nm_vpn_service_get_name (service));
for (iter = priv->connections; iter; iter = iter->next)
nm_vpn_connection_activate (NM_VPN_CONNECTION (iter->data));
} else if (old_owner_good && !new_owner_good) {
/* service went away */
nm_info ("VPN service '%s' disappeared, cancelling connections",
nm_vpn_service_get_name (service));
nm_log_info (LOGD_VPN, "VPN service '%s' disappeared, cancelling connections",
nm_vpn_service_get_name (service));
nm_vpn_service_connections_stop (service, TRUE, NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED);
}
}
@ -415,9 +418,9 @@ ensure_killed (gpointer data)
kill (pid, SIGKILL);
/* ensure the child is reaped */
nm_debug ("waiting for vpn service pid %d to exit", pid);
nm_log_dbg (LOGD_VPN, "waiting for VPN service pid %d to exit", pid);
waitpid (pid, NULL, 0);
nm_debug ("vpn service pid %d cleaned up", pid);
nm_log_dbg (LOGD_VPN, "VPN service pid %d cleaned up", pid);
return FALSE;
}
@ -446,9 +449,9 @@ finalize (GObject *object)
kill (priv->pid, SIGKILL);
/* ensure the child is reaped */
nm_debug ("waiting for vpn service pid %d to exit", priv->pid);
nm_log_dbg (LOGD_VPN, "waiting for VPN service pid %d to exit", priv->pid);
waitpid (priv->pid, NULL, 0);
nm_debug ("vpn service pid %d cleaned up", priv->pid);
nm_log_dbg (LOGD_VPN, "VPN service pid %d cleaned up", priv->pid);
}
priv->pid = 0;

View file

@ -1,3 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* WPA Supplicant - WPA state machine and EAPOL-Key processing
* Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.fi>
@ -19,7 +20,7 @@
#include <glib.h>
#include "wpa.h"
#include "nm-utils.h"
#include "nm-logging.h"
typedef guint16 u16;
typedef guint8 u8;
@ -207,8 +208,8 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
}
if (wpa_ie_len < sizeof(struct wpa_ie_hdr)) {
nm_debug ("%s: ie len too short %lu",
__func__, (unsigned long) wpa_ie_len);
nm_log_dbg (LOGD_WIFI, "IE len too short %lu",
(unsigned long) wpa_ie_len);
return -1;
}
@ -218,8 +219,7 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
hdr->len != wpa_ie_len - 2 ||
memcmp(hdr->oui, WPA_OUI_TYPE, WPA_SELECTOR_LEN) != 0 ||
WPA_GET_LE16(hdr->version) != WPA_VERSION) {
nm_debug ("%s: malformed ie or unknown version",
__func__);
nm_log_dbg (LOGD_WIFI, "malformed IE or unknown version");
return -1;
}
@ -231,8 +231,7 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
} else if (left > 0) {
nm_debug ("%s: ie length mismatch, %u too much",
__func__, left);
nm_log_dbg (LOGD_WIFI, "IE length mismatch, %u too much", left);
return -1;
}
@ -242,8 +241,8 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
pos += 2;
left -= 2;
if (count == 0 || left < count * WPA_SELECTOR_LEN) {
nm_debug ("%s: ie count botch (pairwise), "
"count %u left %u", __func__, count, left);
nm_log_dbg (LOGD_WIFI, "IE count botch (pairwise), "
"count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
@ -252,8 +251,7 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
left -= WPA_SELECTOR_LEN;
}
} else if (left == 1) {
nm_debug ("%s: ie too short (for key mgmt)",
__func__);
nm_log_dbg (LOGD_WIFI, "IE too short (for key mgmt)");
return -1;
}
@ -263,8 +261,8 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
pos += 2;
left -= 2;
if (count == 0 || left < count * WPA_SELECTOR_LEN) {
nm_debug ("%s: ie count botch (key mgmt), "
"count %u left %u", __func__, count, left);
nm_log_dbg (LOGD_WIFI, "IE count botch (key mgmt), "
"count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
@ -273,8 +271,7 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
left -= WPA_SELECTOR_LEN;
}
} else if (left == 1) {
nm_debug ("%s: ie too short (for capabilities)",
__func__);
nm_log_dbg (LOGD_WIFI, "IE too short (for capabilities)");
return -1;
}
@ -286,8 +283,7 @@ static int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len,
}
if (left > 0) {
nm_debug ("%s: ie has %u trailing bytes",
__func__, left);
nm_log_dbg (LOGD_WIFI, "IE has %u trailing bytes", left);
return -1;
}
@ -317,8 +313,8 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
}
if (rsn_ie_len < sizeof(struct rsn_ie_hdr)) {
nm_debug ("%s: ie len too short %lu",
__func__, (unsigned long) rsn_ie_len);
nm_log_dbg (LOGD_WIFI, "IE len too short %lu",
(unsigned long) rsn_ie_len);
return -1;
}
@ -327,8 +323,7 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
if (hdr->elem_id != WPA_RSN_INFO_ELEM ||
hdr->len != rsn_ie_len - 2 ||
WPA_GET_LE16(hdr->version) != RSN_VERSION) {
nm_debug ("%s: malformed ie or unknown version",
__func__);
nm_log_dbg (LOGD_WIFI, "malformed IE or unknown version");
return -1;
}
@ -340,8 +335,7 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
} else if (left > 0) {
nm_debug ("%s: ie length mismatch, %u too much",
__func__, left);
nm_log_dbg (LOGD_WIFI, "IE length mismatch, %u too much", left);
return -1;
}
@ -351,8 +345,8 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN) {
nm_debug ("%s: ie count botch (pairwise), "
"count %u left %u", __func__, count, left);
nm_log_dbg (LOGD_WIFI, "IE count botch (pairwise), "
"count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
@ -361,8 +355,7 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
left -= RSN_SELECTOR_LEN;
}
} else if (left == 1) {
nm_debug ("%s: ie too short (for key mgmt)",
__func__);
nm_log_dbg (LOGD_WIFI, "IE too short (for key mgmt)");
return -1;
}
@ -372,8 +365,8 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN) {
nm_debug ("%s: ie count botch (key mgmt), "
"count %u left %u", __func__, count, left);
nm_log_dbg (LOGD_WIFI, "IE count botch (key mgmt), "
"count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
@ -382,8 +375,7 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
left -= RSN_SELECTOR_LEN;
}
} else if (left == 1) {
nm_debug ("%s: ie too short (for capabilities)",
__func__);
nm_log_dbg (LOGD_WIFI, "IE too short (for capabilities)");
return -1;
}
@ -399,9 +391,9 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += 2;
left -= 2;
if (left < data->num_pmkid * PMKID_LEN) {
nm_debug ("%s: PMKID underflow "
"(num_pmkid=%d left=%d)",
__func__, data->num_pmkid, left);
nm_log_dbg (LOGD_WIFI, "PMKID underflow "
"(num_pmkid=%d left=%d)",
data->num_pmkid, left);
data->num_pmkid = 0;
} else {
data->pmkid = pos;
@ -411,8 +403,7 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
}
if (left > 0) {
nm_debug ("%s: ie has %u trailing bytes - ignored",
__func__, left);
nm_log_dbg (LOGD_WIFI, "IE has %u trailing bytes - ignored", left);
}
return 0;
@ -430,8 +421,8 @@ static int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
*/
wpa_ie_data * wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len)
{
wpa_ie_data * data = NULL;
int err = -1;
wpa_ie_data *data = NULL;
int err = -1;
if (!wpa_ie || wpa_ie_len <= 0)
return NULL;
@ -443,25 +434,21 @@ wpa_ie_data * wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len)
else
err = wpa_parse_wpa_ie_wpa(wpa_ie, wpa_ie_len, data);
if (err != 0)
{
if (err != 0) {
g_slice_free (wpa_ie_data, data);
data = NULL;
}
#if 0
if (data)
{
nm_debug ("WPA IE: -------------------");
nm_debug (" proto 0x%X", data->proto);
nm_debug (" pw cipher 0x%X", data->pairwise_cipher);
nm_debug (" gr cipher 0x%X", data->group_cipher);
nm_debug (" key mgmt 0x%X", data->key_mgmt);
nm_debug (" capabilities 0x%X", data->capabilities);
nm_debug (" # pmkid 0x%X", data->num_pmkid);
nm_debug ("");
if (data) {
nm_log_dbg (LOGD_WIFI, "WPA IE: -------------------");
nm_log_dbg (LOGD_WIFI, " proto 0x%X", data->proto);
nm_log_dbg (LOGD_WIFI, " pw cipher 0x%X", data->pairwise_cipher);
nm_log_dbg (LOGD_WIFI, " gr cipher 0x%X", data->group_cipher);
nm_log_dbg (LOGD_WIFI, " key mgmt 0x%X", data->key_mgmt);
nm_log_dbg (LOGD_WIFI, " capabilities 0x%X", data->capabilities);
nm_log_dbg (LOGD_WIFI, " # pmkid 0x%X", data->num_pmkid);
nm_log_dbg (LOGD_WIFI, "");
}
#endif
return data;
}

View file

@ -38,6 +38,7 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <nm-setting-connection.h>
#include <nm-settings-interface.h>
#include "common.h"
#include "nm-dbus-glib-types.h"
@ -535,31 +536,46 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
const char *path;
if (!g_path_is_absolute (in_ifcfg)) {
g_set_error (error, 0, 0, "ifcfg path '%s' is not absolute", in_ifcfg);
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"ifcfg path '%s' is not absolute", in_ifcfg);
return FALSE;
}
connection = g_hash_table_lookup (priv->connections, in_ifcfg);
if (!connection) {
g_set_error (error, 0, 0, "ifcfg file '%s' unknown", in_ifcfg);
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"ifcfg file '%s' unknown", in_ifcfg);
return FALSE;
}
s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
if (!s_con) {
g_set_error_literal (error, 0, 0, "unable to retrieve the connection setting");
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"unable to retrieve the connection setting");
return FALSE;
}
uuid = nm_setting_connection_get_uuid (s_con);
if (!uuid) {
g_set_error_literal (error, 0, 0, "unable to get the UUID");
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"unable to get the UUID");
return FALSE;
}
path = nm_connection_get_path (NM_CONNECTION (connection));
if (!path) {
g_set_error_literal (error, 0, 0, "unable to get the connection D-Bus path");
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"unable to get the connection D-Bus path");
return FALSE;
}

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) 2008 - 2009 Red Hat, Inc.
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*/
#include <stdlib.h>
@ -1115,6 +1115,7 @@ static NMSetting *
make_ip4_setting (shvarFile *ifcfg,
const char *network_file,
const char *iscsiadm_path,
gboolean valid_ip6_config,
GError **error)
{
NMSettingIP4Config *s_ip4 = NULL;
@ -1192,14 +1193,17 @@ make_ip4_setting (shvarFile *ifcfg,
g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Unknown BOOTPROTO '%s'", value);
g_free (value);
goto error;
goto done;
}
g_free (value);
} else {
char *tmp_ip4, *tmp_prefix, *tmp_netmask;
/* If there is no BOOTPROTO, no IPADDR, no PREFIX, and no NETMASK,
* assume DHCP is to be used. Happens with minimal ifcfg files like:
/* If there is no BOOTPROTO, no IPADDR, no PREFIX, no NETMASK, but
* valid IPv6 configuration, assume that IPv4 is disabled. Otherwise,
* if there is no IPv6 configuration, assume DHCP is to be used.
* Happens with minimal ifcfg files like the following that anaconda
* sometimes used to write out:
*
* DEVICE=eth0
* HWADDR=11:22:33:44:55:66
@ -1208,8 +1212,14 @@ make_ip4_setting (shvarFile *ifcfg,
tmp_ip4 = svGetValue (ifcfg, "IPADDR", FALSE);
tmp_prefix = svGetValue (ifcfg, "PREFIX", FALSE);
tmp_netmask = svGetValue (ifcfg, "NETMASK", FALSE);
if (!tmp_ip4 && !tmp_prefix && !tmp_netmask)
if (!tmp_ip4 && !tmp_prefix && !tmp_netmask) {
if (valid_ip6_config) {
/* Nope, no IPv4 */
goto done;
}
method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
}
g_free (tmp_ip4);
g_free (tmp_prefix);
g_free (tmp_netmask);
@ -1229,7 +1239,7 @@ make_ip4_setting (shvarFile *ifcfg,
for (i = 1; i < 256; i++) {
addr = read_full_ip4_address (ifcfg, network_file, i, error);
if (error && *error)
goto error;
goto done;
if (!addr)
break;
@ -1271,7 +1281,7 @@ make_ip4_setting (shvarFile *ifcfg,
}
if (!tmp_success) {
g_free (tag);
goto error;
goto done;
}
g_clear_error (error);
}
@ -1305,7 +1315,7 @@ make_ip4_setting (shvarFile *ifcfg,
if (!route_path) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Could not get route file path for '%s'", ifcfg->fileName);
goto error;
goto done;
}
/* First test new/legacy syntax */
@ -1319,7 +1329,7 @@ make_ip4_setting (shvarFile *ifcfg,
route = read_one_ip4_route (route_ifcfg, network_file, i, error);
if (error && *error) {
svCloseFile (route_ifcfg);
goto error;
goto done;
}
if (!route)
break;
@ -1334,7 +1344,7 @@ make_ip4_setting (shvarFile *ifcfg,
read_route_file_legacy (route_path, s_ip4, error);
g_free (route_path);
if (error && *error)
goto error;
goto done;
}
/* Legacy value NM used for a while but is incorrect (rh #459370) */
@ -1360,7 +1370,7 @@ make_ip4_setting (shvarFile *ifcfg,
return NM_SETTING (s_ip4);
error:
done:
g_object_unref (s_ip4);
return NULL;
}
@ -1568,6 +1578,7 @@ static gboolean
add_one_wep_key (shvarFile *ifcfg,
const char *shvar_key,
guint8 key_idx,
gboolean passphrase,
NMSettingWirelessSecurity *s_wsec,
GError **error)
{
@ -1587,42 +1598,51 @@ add_one_wep_key (shvarFile *ifcfg,
}
/* Validate keys */
if (strlen (value) == 10 || strlen (value) == 26) {
/* Hexadecimal WEP key */
char *p = value;
while (*p) {
if (!g_ascii_isxdigit (*p)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Invalid hexadecimal WEP key.");
goto out;
}
p++;
if (passphrase) {
if (strlen (value) && strlen (value) < 64) {
key = g_strdup (value);
g_object_set (G_OBJECT (s_wsec),
NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE,
NM_WEP_KEY_TYPE_PASSPHRASE,
NULL);
}
key = g_strdup (value);
} else if ( strncmp (value, "s:", 2)
&& (strlen (value) == 7 || strlen (value) == 15)) {
/* ASCII passphrase */
char *p = value + 2;
while (*p) {
if (!isascii ((int) (*p))) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Invalid ASCII WEP passphrase.");
goto out;
}
p++;
}
key = utils_bin2hexstr (value, strlen (value), strlen (value) * 2);
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0, "Invalid WEP key length.");
if (strlen (value) == 10 || strlen (value) == 26) {
/* Hexadecimal WEP key */
char *p = value;
while (*p) {
if (!g_ascii_isxdigit (*p)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Invalid hexadecimal WEP key.");
goto out;
}
p++;
}
key = g_strdup (value);
} else if ( strncmp (value, "s:", 2)
&& (strlen (value) == 7 || strlen (value) == 15)) {
/* ASCII passphrase */
char *p = value + 2;
while (*p) {
if (!isascii ((int) (*p))) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Invalid ASCII WEP passphrase.");
goto out;
}
p++;
}
key = utils_bin2hexstr (value, strlen (value), strlen (value) * 2);
}
}
if (key) {
nm_setting_wireless_security_set_wep_key (s_wsec, key_idx, key);
success = TRUE;
}
} else
g_set_error (error, ifcfg_plugin_error_quark (), 0, "Invalid WEP key length.");
out:
g_free (value);
@ -1635,15 +1655,26 @@ read_wep_keys (shvarFile *ifcfg,
NMSettingWirelessSecurity *s_wsec,
GError **error)
{
if (!add_one_wep_key (ifcfg, "KEY1", 0, s_wsec, error))
/* Try hex/ascii keys first */
if (!add_one_wep_key (ifcfg, "KEY1", 0, FALSE, s_wsec, error))
return FALSE;
if (!add_one_wep_key (ifcfg, "KEY2", 1, s_wsec, error))
if (!add_one_wep_key (ifcfg, "KEY2", 1, FALSE, s_wsec, error))
return FALSE;
if (!add_one_wep_key (ifcfg, "KEY3", 2, s_wsec, error))
if (!add_one_wep_key (ifcfg, "KEY3", 2, FALSE, s_wsec, error))
return FALSE;
if (!add_one_wep_key (ifcfg, "KEY4", 3, s_wsec, error))
if (!add_one_wep_key (ifcfg, "KEY4", 3, FALSE, s_wsec, error))
return FALSE;
if (!add_one_wep_key (ifcfg, "KEY", def_idx, s_wsec, error))
if (!add_one_wep_key (ifcfg, "KEY", def_idx, FALSE, s_wsec, error))
return FALSE;
/* And then passphrases */
if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE1", 0, TRUE, s_wsec, error))
return FALSE;
if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE2", 1, TRUE, s_wsec, error))
return FALSE;
if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE3", 2, TRUE, s_wsec, error))
return FALSE;
if (!add_one_wep_key (ifcfg, "KEY_PASSPHRASE4", 3, TRUE, s_wsec, error))
return FALSE;
return TRUE;
@ -1691,6 +1722,7 @@ make_wep_setting (shvarFile *ifcfg,
goto error;
}
svCloseFile (keys_ifcfg);
g_assert (error == NULL || *error == NULL);
}
/* If there's a default key, ensure that key exists */
@ -3058,6 +3090,7 @@ connection_from_file (const char *filename,
NMSetting *s_ip4, *s_ip6;
const char *ifcfg_name = NULL;
gboolean nm_controlled = TRUE;
gboolean ip6_used = FALSE;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (unmanaged != NULL, NULL);
@ -3161,22 +3194,27 @@ connection_from_file (const char *filename,
if (!connection || *unmanaged)
goto done;
s_ip4 = make_ip4_setting (parsed, network_file, iscsiadm_path, error);
if (*error) {
g_object_unref (connection);
connection = NULL;
goto done;
} else if (s_ip4) {
nm_connection_add_setting (connection, s_ip4);
}
s_ip6 = make_ip6_setting (parsed, network_file, iscsiadm_path, error);
if (*error) {
g_object_unref (connection);
connection = NULL;
goto done;
} else if (s_ip6)
} else if (s_ip6) {
const char *method;
nm_connection_add_setting (connection, s_ip6);
method = nm_setting_ip6_config_get_method (NM_SETTING_IP6_CONFIG (s_ip6));
if (method && strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE))
ip6_used = TRUE;
}
s_ip4 = make_ip4_setting (parsed, network_file, iscsiadm_path, ip6_used, error);
if (*error) {
g_object_unref (connection);
connection = NULL;
goto done;
} else if (s_ip4)
nm_connection_add_setting (connection, s_ip4);
/* iSCSI / ibft connections are read-only since their settings are
* stored in NVRAM and can only be changed in BIOS.

View file

@ -57,7 +57,10 @@ EXTRA_DIST = \
route6-test-wired-ipv6-manual \
ifcfg-test-wired-static-no-prefix-8 \
ifcfg-test-wired-static-no-prefix-16 \
ifcfg-test-wired-static-no-prefix-24
ifcfg-test-wired-static-no-prefix-24 \
ifcfg-test-wired-ipv6-only \
ifcfg-test-wifi-wep-passphrase \
keys-test-wifi-wep-passphrase
check-local:
@for f in $(EXTRA_DIST); do \

View file

@ -0,0 +1,14 @@
TYPE=Wireless
DEVICE=eth2
HWADDR=00:16:41:11:22:33
NM_CONTROLLED=yes
BOOTPROTO=dhcp
ESSID=blahblah
CHANNEL=1
MODE=Managed
RATE=auto
ONBOOT=yes
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
SECURITYMODE=open

View file

@ -0,0 +1,14 @@
# Intel Corporation 82567LM Gigabit Network Connection
TYPE=Ethernet
DEVICE=eth2
HWADDR=00:11:22:33:44:ee
ONBOOT=yes
USERCTL=yes
NM_CONTROLLED=yes
PEERDNS=yes
DNS1=1:2:3:4::a
DOMAIN="lorem.com ipsum.org dolor.edu"
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR="1001:abba::1234/56"

View file

@ -0,0 +1 @@
KEY_PASSPHRASE1="foobar222blahblah"

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) 2008 - 2009 Red Hat, Inc.
* Copyright (C) 2008 - 2010 Red Hat, Inc.
*/
#include <stdio.h>
@ -2142,6 +2142,155 @@ test_read_wired_ipv6_manual (void)
g_object_unref (connection);
}
#define TEST_IFCFG_WIRED_IPV6_ONLY TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv6-only"
static void
test_read_wired_ipv6_only (void)
{
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
char *unmanaged = NULL;
char *keyfile = NULL;
char *routefile = NULL;
char *route6file = NULL;
gboolean ignore_error = FALSE;
GError *error = NULL;
const char *tmp;
const char *expected_id = "System test-wired-ipv6-only";
const char *expected_address1 = "1001:abba::1234";
guint32 expected_prefix1 = 56;
const char *expected_dns1 = "1:2:3:4::a";
NMIP6Address *ip6_addr;
struct in6_addr addr;
connection = connection_from_file (TEST_IFCFG_WIRED_IPV6_ONLY,
NULL,
TYPE_ETHERNET,
NULL,
&unmanaged,
&keyfile,
&routefile,
&route6file,
&error,
&ignore_error);
ASSERT (connection != NULL,
"wired-ipv6-only-read", "failed to read %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, error->message);
ASSERT (nm_connection_verify (connection, &error),
"wired-ipv6-only-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, error->message);
ASSERT (unmanaged == FALSE,
"wired-ipv6-only-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_IPV6_MANUAL);
/* ===== CONNECTION SETTING ===== */
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
ASSERT (s_con != NULL,
"wired-ipv6-only-verify-connection", "failed to verify %s: missing %s setting",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_CONNECTION_SETTING_NAME);
/* ID */
tmp = nm_setting_connection_get_id (s_con);
ASSERT (tmp != NULL,
"wired-ipv6-only-verify-connection", "failed to verify %s: missing %s / %s key",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_ID);
ASSERT (strcmp (tmp, expected_id) == 0,
"wired-ipv6-only-verify-connection", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_ID);
/* ===== WIRED SETTING ===== */
s_wired = NM_SETTING_WIRED (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED));
ASSERT (s_wired != NULL,
"wired-ipv6-only-verify-wired", "failed to verify %s: missing %s setting",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_WIRED_SETTING_NAME);
/* ===== IPv4 SETTING ===== */
s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
ASSERT (s_ip4 == NULL,
"wired-ipv6-only-verify-ip4", "failed to verify %s: unexpected %s setting",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_IP4_CONFIG_SETTING_NAME);
/* ===== IPv6 SETTING ===== */
s_ip6 = NM_SETTING_IP6_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG));
ASSERT (s_ip6 != NULL,
"wired-ipv6-only-verify-ip6", "failed to verify %s: missing %s setting",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_IP6_CONFIG_SETTING_NAME);
/* Method */
tmp = nm_setting_ip6_config_get_method (s_ip6);
ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0,
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_IP6_CONFIG_SETTING_NAME,
NM_SETTING_IP6_CONFIG_METHOD);
/* IP addresses */
ASSERT (nm_setting_ip6_config_get_num_addresses (s_ip6) == 1,
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_IP6_CONFIG_SETTING_NAME,
NM_SETTING_IP6_CONFIG_ADDRESSES);
/* Address #1 */
ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 0);
ASSERT (ip6_addr,
"wired-ipv6-only-verify-ip6", "failed to verify %s: missing IP6 address #1",
TEST_IFCFG_WIRED_IPV6_MANUAL);
ASSERT (nm_ip6_address_get_prefix (ip6_addr) == expected_prefix1,
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected IP6 address #1 prefix",
TEST_IFCFG_WIRED_IPV6_MANUAL);
ASSERT (inet_pton (AF_INET6, expected_address1, &addr) > 0,
"wired-ipv6-only-verify-ip6", "failed to verify %s: couldn't convert IP address #1",
TEST_IFCFG_WIRED_IPV6_MANUAL);
ASSERT (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), &addr),
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected IP6 address #1",
TEST_IFCFG_WIRED_IPV6_MANUAL);
/* DNS Addresses */
ASSERT (nm_setting_ip6_config_get_num_dns (s_ip6) == 1,
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_IP6_CONFIG_SETTING_NAME,
NM_SETTING_IP6_CONFIG_DNS);
ASSERT (inet_pton (AF_INET6, expected_dns1, &addr) > 0,
"wired-ipv6-only-verify-ip6", "failed to verify %s: couldn't convert DNS IP address #1",
TEST_IFCFG_WIRED_IPV6_MANUAL);
ASSERT (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 0), &addr),
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value #1",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_IP6_CONFIG_SETTING_NAME,
NM_SETTING_IP6_CONFIG_DNS);
/* DNS domains - none as domains are stuffed to 'ipv4' setting */
ASSERT (nm_setting_ip6_config_get_num_dns_searches (s_ip6) == 0,
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIRED_IPV6_MANUAL,
NM_SETTING_IP6_CONFIG_SETTING_NAME,
NM_SETTING_IP6_CONFIG_DNS);
g_free (keyfile);
g_free (routefile);
g_free (route6file);
g_object_unref (connection);
}
#define TEST_IFCFG_ONBOOT_NO TEST_IFCFG_DIR"/network-scripts/ifcfg-test-onboot-no"
static void
@ -2855,6 +3004,7 @@ test_read_wifi_wep (void)
const char *expected_mode = "infrastructure";
const guint32 expected_channel = 1;
const char *expected_wep_key0 = "0123456789abcdef0123456789";
NMWepKeyType key_type;
connection = connection_from_file (TEST_IFCFG_WIFI_WEP,
NULL,
@ -3026,6 +3176,13 @@ test_read_wifi_wep (void)
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX);
/* WEP key type */
key_type = nm_setting_wireless_security_get_wep_key_type (s_wsec);
ASSERT (key_type == NM_WEP_KEY_TYPE_UNKNOWN || key_type == NM_WEP_KEY_TYPE_KEY,
"wifi-wep-verify-wireless", "failed to verify %s: unexpected WEP key type %d",
TEST_IFCFG_WIFI_WEP,
key_type);
/* WEP key index 0 */
tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0);
ASSERT (tmp != NULL,
@ -3359,6 +3516,142 @@ test_read_wifi_wep_adhoc (void)
g_object_unref (connection);
}
#define TEST_IFCFG_WIFI_WEP_PASSPHRASE TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-wep-passphrase"
static void
test_read_wifi_wep_passphrase (void)
{
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wsec;
char *unmanaged = NULL;
char *keyfile = NULL;
char *routefile = NULL;
char *route6file = NULL;
gboolean ignore_error = FALSE;
GError *error = NULL;
const char *tmp;
const char *expected_wep_key0 = "foobar222blahblah";
NMWepKeyType key_type;
connection = connection_from_file (TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NULL,
TYPE_WIRELESS,
NULL,
&unmanaged,
&keyfile,
&routefile,
&route6file,
&error,
&ignore_error);
ASSERT (connection != NULL,
"wifi-wep-passphrase-read", "failed to read %s: %s",
TEST_IFCFG_WIFI_WEP_PASSPHRASE, error->message);
ASSERT (nm_connection_verify (connection, &error),
"wifi-wep-passphrase-verify", "failed to verify %s: %s",
TEST_IFCFG_WIFI_WEP_PASSPHRASE, error->message);
/* ===== CONNECTION SETTING ===== */
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
ASSERT (s_con != NULL,
"wifi-wep-passphrase-verify-connection", "failed to verify %s: missing %s setting",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_CONNECTION_SETTING_NAME);
/* ===== WIRELESS SETTING ===== */
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
ASSERT (s_wireless != NULL,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: missing %s setting",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SETTING_NAME);
/* Security */
tmp = nm_setting_wireless_get_security (s_wireless);
ASSERT (tmp != NULL,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: missing %s / %s key",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SETTING_NAME,
NM_SETTING_WIRELESS_SEC);
ASSERT (strcmp (tmp, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) == 0,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SETTING_NAME,
NM_SETTING_WIRELESS_SEC);
/* ===== WIRELESS SECURITY SETTING ===== */
s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
ASSERT (s_wsec != NULL,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: missing %s setting",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
/* Key management */
ASSERT (strcmp (nm_setting_wireless_security_get_key_mgmt (s_wsec), "none") == 0,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: missing %s / %s key",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
/* WEP key index */
ASSERT (nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec) == 0,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX);
/* WEP key type */
key_type = nm_setting_wireless_security_get_wep_key_type (s_wsec);
ASSERT (key_type == NM_WEP_KEY_TYPE_PASSPHRASE,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: unexpected WEP key type %d",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
key_type);
/* WEP key index 0 */
tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0);
ASSERT (tmp != NULL,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: missing %s / %s key",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
ASSERT (strcmp (tmp, expected_wep_key0) == 0,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: unexpected %s / %s key value",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
/* WEP key index 1 */
tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 1);
ASSERT (tmp == NULL,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: unexpected %s / %s key",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
/* WEP key index 2 */
tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 2);
ASSERT (tmp == NULL,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: unexpected %s / %s key",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
/* WEP key index 3 */
tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 3);
ASSERT (tmp == NULL,
"wifi-wep-passphrase-verify-wireless", "failed to verify %s: unexpected %s / %s key",
TEST_IFCFG_WIFI_WEP_PASSPHRASE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
g_object_unref (connection);
}
#define TEST_IFCFG_WIFI_LEAP TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-leap"
static void
@ -5108,6 +5401,140 @@ test_write_wired_dhcp (void)
g_object_unref (reread);
}
static void
test_write_wired_static_ip6_only (void)
{
NMConnection *connection;
NMConnection *reread;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
NMSettingIP6Config *s_ip6;
static unsigned char tmpmac[] = { 0x31, 0x33, 0x33, 0x37, 0xbe, 0xcd };
GByteArray *mac;
char *uuid;
guint64 timestamp = 0x12344433L;
struct in6_addr ip6;
struct in6_addr dns6;
NMIP6Address *addr6;
gboolean success;
GError *error = NULL;
char *testfile = NULL;
char *unmanaged = NULL;
char *keyfile = NULL;
char *routefile = NULL;
char *route6file = NULL;
gboolean ignore_error = FALSE;
inet_pton (AF_INET6, "1003:1234:abcd::1", &ip6);
inet_pton (AF_INET6, "fade:0102:0103::face", &dns6);
connection = nm_connection_new ();
ASSERT (connection != NULL,
"wired-static-ip6-only-write", "failed to allocate new connection");
/* Connection setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
ASSERT (s_con != NULL,
"wired-static-ip6-only-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
g_object_set (s_con,
NM_SETTING_CONNECTION_ID, "Test Write Wired Static IP6 Only",
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
NM_SETTING_CONNECTION_TIMESTAMP, timestamp,
NULL);
g_free (uuid);
/* Wired setting */
s_wired = (NMSettingWired *) nm_setting_wired_new ();
ASSERT (s_wired != NULL,
"wired-static-ip6-only-write", "failed to allocate new %s setting",
NM_SETTING_WIRED_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wired));
mac = g_byte_array_sized_new (sizeof (tmpmac));
g_byte_array_append (mac, &tmpmac[0], sizeof (tmpmac));
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL);
g_byte_array_free (mac, TRUE);
/* IP6 setting */
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
ASSERT (s_ip6 != NULL,
"wired-static-ip6-only-write", "failed to allocate new %s setting",
NM_SETTING_IP6_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
g_object_set (s_ip6,
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
NULL);
/* Add addresses */
addr6 = nm_ip6_address_new ();
nm_ip6_address_set_address (addr6, &ip6);
nm_ip6_address_set_prefix (addr6, 11);
nm_setting_ip6_config_add_address (s_ip6, addr6);
nm_ip6_address_unref (addr6);
/* DNS server */
nm_setting_ip6_config_add_dns (s_ip6, &dns6);
ASSERT (nm_connection_verify (connection, &error) == TRUE,
"wired-static-ip6-only-write", "failed to verify connection: %s",
(error && error->message) ? error->message : "(unknown)");
/* Save the ifcfg */
success = writer_new_connection (connection,
TEST_SCRATCH_DIR "/network-scripts/",
&testfile,
&error);
ASSERT (success == TRUE,
"wired-static-ip6-only-write", "failed to write connection to disk: %s",
(error && error->message) ? error->message : "(unknown)");
ASSERT (testfile != NULL,
"wired-static-ip6-only-write", "didn't get ifcfg file path back after writing connection");
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
TYPE_ETHERNET,
NULL,
&unmanaged,
&keyfile,
&routefile,
&route6file,
&error,
&ignore_error);
unlink (testfile);
ASSERT (reread != NULL,
"wired-static-ip6-only-write-reread", "failed to read %s: %s", testfile, error->message);
ASSERT (nm_connection_verify (reread, &error),
"wired-static-ip6-only-write-reread-verify", "failed to verify %s: %s", testfile, error->message);
ASSERT (nm_connection_get_setting (reread, NM_TYPE_SETTING_IP4_CONFIG) == NULL,
"wired-static-ip6-only-write-reread-verify", "unexpected IPv4 setting");
ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
"wired-static-ip6-only-write", "written and re-read connection weren't the same.");
if (route6file)
unlink (route6file);
g_free (testfile);
g_free (keyfile);
g_free (routefile);
g_free (route6file);
g_object_unref (connection);
g_object_unref (reread);
}
#define TEST_IFCFG_READ_WRITE_STATIC_ROUTES_LEGACY TEST_IFCFG_DIR"/network-scripts/ifcfg-test-static-routes-legacy"
static void
@ -6136,6 +6563,155 @@ test_write_wifi_wep_adhoc (void)
g_object_unref (reread);
}
static void
test_write_wifi_wep_passphrase (void)
{
NMConnection *connection;
NMConnection *reread;
NMSettingConnection *s_con;
NMSettingWireless *s_wifi;
NMSettingWirelessSecurity *s_wsec;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
char *uuid;
gboolean success;
GError *error = NULL;
char *testfile = NULL;
char *unmanaged = NULL;
char *keyfile = NULL;
char *routefile = NULL;
char *route6file = NULL;
gboolean ignore_error = FALSE;
GByteArray *ssid;
const unsigned char ssid_data[] = "blahblah";
struct stat statbuf;
connection = nm_connection_new ();
ASSERT (connection != NULL,
"wifi-wep-passphrase-write", "failed to allocate new connection");
/* Connection setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
ASSERT (s_con != NULL,
"wifi-wep-passphrase-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
g_object_set (s_con,
NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP Passphrase",
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
NULL);
g_free (uuid);
/* Wifi setting */
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
ASSERT (s_wifi != NULL,
"wifi-wep-passphrase-write", "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
ssid = g_byte_array_sized_new (sizeof (ssid_data));
g_byte_array_append (ssid, ssid_data, sizeof (ssid_data));
g_object_set (s_wifi,
NM_SETTING_WIRELESS_SSID, ssid,
NM_SETTING_WIRELESS_MODE, "infrastructure",
NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NULL);
g_byte_array_free (ssid, TRUE);
/* Wireless security setting */
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
ASSERT (s_wsec != NULL,
"wifi-wep-passphrase-write", "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wsec));
g_object_set (s_wsec,
NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none",
NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, 0,
NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared",
NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_PASSPHRASE,
NULL);
nm_setting_wireless_security_set_wep_key (s_wsec, 0, "asdfdjaslfjasd;flasjdfl;aksdf");
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
ASSERT (s_ip4 != NULL,
"wifi-wep-passphrase-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
/* IP6 setting */
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
ASSERT (s_ip6 != NULL,
"wifi-wep-adhoc-write", "failed to allocate new %s setting",
NM_SETTING_IP6_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL);
ASSERT (nm_connection_verify (connection, &error) == TRUE,
"wifi-wep-passphrase-write", "failed to verify connection: %s",
(error && error->message) ? error->message : "(unknown)");
/* Save the ifcfg */
success = writer_new_connection (connection,
TEST_SCRATCH_DIR "/network-scripts/",
&testfile,
&error);
ASSERT (success == TRUE,
"wifi-wep-passphrase-write", "failed to write connection to disk: %s",
(error && error->message) ? error->message : "(unknown)");
ASSERT (testfile != NULL,
"wifi-wep-passphrase-write", "didn't get ifcfg file path back after writing connection");
/* re-read the connection for comparison */
reread = connection_from_file (testfile,
NULL,
TYPE_WIRELESS,
NULL,
&unmanaged,
&keyfile,
&routefile,
&route6file,
&error,
&ignore_error);
unlink (testfile);
ASSERT (keyfile != NULL,
"wifi-wep-passphrase-write-reread", "expected keyfile for '%s'", testfile);
ASSERT (stat (keyfile, &statbuf) == 0,
"wifi-wep-passphrase-write-reread", "couldn't stat() '%s'", keyfile);
ASSERT (S_ISREG (statbuf.st_mode),
"wifi-wep-passphrase-write-reread", "keyfile '%s' wasn't a normal file", keyfile);
ASSERT ((statbuf.st_mode & 0077) == 0,
"wifi-wep-passphrase-write-reread", "keyfile '%s' wasn't readable only by its owner", keyfile);
unlink (keyfile);
ASSERT (reread != NULL,
"wifi-wep-passphrase-write-reread", "failed to read %s: %s", testfile, error->message);
ASSERT (nm_connection_verify (reread, &error),
"wifi-wep-passphrase-write-reread-verify", "failed to verify %s: %s", testfile, error->message);
ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE,
"wifi-wep-passphrase-write", "written and re-read connection weren't the same.");
g_free (testfile);
g_object_unref (connection);
g_object_unref (reread);
}
static void
test_write_wifi_leap (void)
{
@ -7813,6 +8389,7 @@ int main (int argc, char **argv)
test_read_wired_static_routes ();
test_read_wired_static_routes_legacy ();
test_read_wired_ipv6_manual ();
test_read_wired_ipv6_only ();
test_read_onboot_no ();
test_read_wired_8021x_peap_mschapv2 ();
test_read_wifi_open ();
@ -7824,6 +8401,7 @@ int main (int argc, char **argv)
test_read_wifi_open_ssid_quoted ();
test_read_wifi_wep ();
test_read_wifi_wep_adhoc ();
test_read_wifi_wep_passphrase ();
test_read_wifi_leap ();
test_read_wifi_wpa_psk ();
test_read_wifi_wpa_psk_unquoted ();
@ -7835,6 +8413,7 @@ int main (int argc, char **argv)
test_read_wifi_wep_eap_ttls_chap ();
test_write_wired_static ();
test_write_wired_static_ip6_only ();
test_write_wired_static_routes ();
test_read_write_static_routes_legacy ();
test_write_wired_dhcp ();
@ -7843,6 +8422,7 @@ int main (int argc, char **argv)
test_write_wifi_open_hex_ssid ();
test_write_wifi_wep ();
test_write_wifi_wep_adhoc ();
test_write_wifi_wep_passphrase ();
test_write_wifi_leap ();
test_write_wifi_wpa_psk ("Test Write Wifi WPA PSK",
"wifi-wpa-psk-write",

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) 2009 Red Hat, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include <ctype.h>
@ -579,20 +579,46 @@ write_wireless_security_setting (NMConnection *connection,
}
}
/* WEP keys */
/* Clear existing keys */
set_secret (ifcfg, "KEY", NULL, FALSE); /* Clear any default key */
for (i = 0; i < 4; i++) {
tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1);
set_secret (ifcfg, tmp, NULL, FALSE);
g_free (tmp);
tmp = g_strdup_printf ("KEY%d", i + 1);
set_secret (ifcfg, tmp, NULL, FALSE);
g_free (tmp);
}
/* And write the new ones out */
if (wep) {
/* Default WEP TX key index */
tmp = g_strdup_printf ("%d", nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec) + 1);
svSetValue (ifcfg, "DEFAULTKEY", tmp, FALSE);
g_free (tmp);
}
/* WEP keys */
set_secret (ifcfg, "KEY", NULL, FALSE); /* Clear any default key */
for (i = 0; i < 4; i++) {
key = nm_setting_wireless_security_get_wep_key (s_wsec, i);
tmp = g_strdup_printf ("KEY%d", i + 1);
set_secret (ifcfg, tmp, (wep && key) ? key : NULL, FALSE);
g_free (tmp);
for (i = 0; i < 4; i++) {
NMWepKeyType key_type;
key = nm_setting_wireless_security_get_wep_key (s_wsec, i);
if (key) {
/* Passphrase needs a different ifcfg key since with WEP, there
* are some passphrases that are indistinguishable from WEP hex
* keys.
*/
key_type = nm_setting_wireless_security_get_wep_key_type (s_wsec);
if (key_type == NM_WEP_KEY_TYPE_PASSPHRASE)
tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1);
else
tmp = g_strdup_printf ("KEY%d", i + 1);
set_secret (ifcfg, tmp, key, FALSE);
g_free (tmp);
}
}
}
/* WPA protos */
@ -807,6 +833,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
g_free (tmp);
}
svSetValue (ifcfg, "MTU", NULL, FALSE);
mtu = nm_setting_wired_get_mtu (s_wired);
if (mtu) {
tmp = g_strdup_printf ("%u", mtu);
@ -910,9 +937,30 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
if (!s_ip4) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Missing '%s' setting", NM_SETTING_IP4_CONFIG_SETTING_NAME);
return FALSE;
int result;
/* IPv4 disabled, clear IPv4 related parameters */
svSetValue (ifcfg, "BOOTPROTO", NULL, FALSE);
for (i = 0; i < 254; i++) {
if (i == 0) {
addr_key = g_strdup ("IPADDR");
prefix_key = g_strdup ("PREFIX");
gw_key = g_strdup ("GATEWAY");
} else {
addr_key = g_strdup_printf ("IPADDR%d", i + 1);
prefix_key = g_strdup_printf ("PREFIX%d", i + 1);
gw_key = g_strdup_printf ("GATEWAY%d", i + 1);
}
svSetValue (ifcfg, addr_key, NULL, FALSE);
svSetValue (ifcfg, prefix_key, NULL, FALSE);
svSetValue (ifcfg, gw_key, NULL, FALSE);
}
route_path = utils_get_route_path (ifcfg->fileName);
result = unlink (route_path);
g_free (route_path);
return TRUE;
}
value = nm_setting_ip4_config_get_method (s_ip4);