Commit 278e500f authored by Ray Strode's avatar Ray Strode
Browse files

2005-03-14 Ray Strode <rstrode@redhat.com>

	Fourth (probably working) cut at porting to
	dbus 0.30 api and new hal. This cut adds
	some new logging macros to make debugging
	easier.

	* dispatcher-daemon/NetworkManagerDispatcher.c:
	* info-daemon/NetworkmanagerInfo.c:
	* info-daemon/NetworkManagerInfoPassphraseDialog.c:
	* info-daemon/NetworkManagerInfoVPN.c:
	* src/NetworkManager.c:
	* src/NetworkManagerAP.c:
	* src/NetworkManagerAPList.c:
	* src/NetworkManagerDHCP.c:
	* src/NetworkManagerDbus.c:
	* src/NetworkManagerDevice.c:
	* src/NetworkManagerPolicy.c:
	* src/NetworkManagerSystem.c:
	* src/NetworkManagerUtils.c:
	* src/NetworkManagerWireless.c:
	* src/autoip.c:
	* src/nm-dbus-nm.c:
	* src/backends/NetworkManagerDebian.c:
	* src/backends/NetworkManagerGentoo.c:
	* src/backends/NetworkManagerRedHat.c:
	* src/backends/NetworkManagerSlackware.c:
	use new logging macros.

	* dispatcher-daemon/NetworkManagerDispatcher.c:
	(nmd_dbus_filter): s/dbus_free/g_free/

	* info-daemon/Makefile.am: link in utils library.
	* info-daemon/NetworkmanagerInfo.c: use new logging
	macros.
	(nmi_dbus_get_network): don't assume enumerations
	are 32-bit.
	(nmi_dbus_nmi_message_handler): don't free what
	doesn't belong to us.

	* libnm_glib/libnm_glib.c:
	(libnm_glib_get_nm_status):
	(libnm_glib_init): don't free what doesn't
	belong to us.
	(libnm_glib_dbus): strdup result, so it doesn't get
	lost when message is unref'd.

	* panel-applet/NMWirelessAppletDbus.c:
	(nmwa_dbus_update_devices): s/dbus_free/g_free/

	* src/NetworkManager.c:
	(nm_monitor_wired_link_state): request initial status
	dump of all cards when we start up, instead of relying
	on /sys/.../carrier.
	(nm_info_handler), (nm_set_up_log_handlers):
	log handlers to specify what syslog priorites
	the logging macros default to.

	* src/NetworkManagerAPList.c:
	(nm_ap_list_populate_from_nmi):
	s/dbus_free_string_array/g_strfreev/

	* src/NetworkManagerDbus.c:
	(nm_dbus_get_network_object):
	validate d-bus message argument types.
	Advance message iterator after reading argument,
	prepend instead of append to GSList.

	* src/NetworkManagerDevice.c:
	(nm_device_probe_wired_link_status):
	remove redundant /sys in /sys path. remove wrong
	contents == NULL means has carrier assumption.

	* src/nm-netlink-monitor.c
	(nm_netlink_monitor_request_status): implement
	function to ask kernel to dump interface link
	status over netlink socket.

	* test/*.c: s/dbus_free/g_free/

	* utils/nm-utils.h:
	(nm_print_backtrace): new macro to print backtrace.
	(nm_get_timestamp): new macro to get sub-second precise
	unix timestamp.
	(nm_info), (nm_debug), (nm_warning), (nm_error):
	new logging functions. nm_info just prints,
	nm_debug includes timestamp and function,
	nm_warning includes function, nm_error includes
	backtrace and sigtrap.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 0790d2fc
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
2005-03-11 Ray Strode <rstrode@redhat.com>
Third (unfinished, partially working) cut at porting to
......
......@@ -70,7 +70,7 @@ void nmd_execute_scripts (NMDAction action, char *iface_name, guint32 new_ip4_ad
if (!dir)
{
syslog (LOG_ERR, "nmd_execute_scripts(): opendir() could not open /etc/NetworkManager.d. errno = %d", errno);
nm_warning ("nmd_execute_scripts(): opendir() could not open /etc/NetworkManager.d. errno = %d", errno);
return;
}
......@@ -127,7 +127,7 @@ char * nmd_get_device_name (DBusConnection *connection, char *path)
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, "getName")))
{
syslog (LOG_ERR, "Couldn't allocate the dbus message");
nm_warning ("Couldn't allocate the dbus message");
return (NULL);
}
......@@ -135,14 +135,14 @@ char * nmd_get_device_name (DBusConnection *connection, char *path)
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
if (dbus_error_is_set (&error))
{
syslog (LOG_ERR, "%s raised: %s", error.name, error.message);
nm_warning ("%s raised: %s", error.name, error.message);
dbus_message_unref (message);
return (NULL);
}
if (reply == NULL)
{
syslog( LOG_ERR, "dbus reply message was NULL" );
nm_warning ("dbus reply message was NULL" );
dbus_message_unref (message);
return (NULL);
}
......@@ -151,7 +151,7 @@ char * nmd_get_device_name (DBusConnection *connection, char *path)
dbus_error_init (&error);
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dev_name, DBUS_TYPE_INVALID))
{
syslog (LOG_ERR, "There was an error getting the device name from NetworkManager." );
nm_warning ("There was an error getting the device name from NetworkManager." );
dev_name = NULL;
}
......@@ -176,7 +176,7 @@ guint32 nmd_get_device_ip4_address (DBusConnection *connection, char *path)
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, "getIP4Address")))
{
syslog (LOG_ERR, "Couldn't allocate the dbus message");
nm_warning ("Couldn't allocate the dbus message");
return (0);
}
......@@ -184,14 +184,14 @@ guint32 nmd_get_device_ip4_address (DBusConnection *connection, char *path)
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
if (dbus_error_is_set (&error))
{
syslog (LOG_ERR, "%s raised: %s", error.name, error.message);
nm_warning ("%s raised: %s", error.name, error.message);
dbus_message_unref (message);
return (0);
}
if (reply == NULL)
{
syslog( LOG_ERR, "dbus reply message was NULL" );
nm_warning ("dbus reply message was NULL" );
dbus_message_unref (message);
return (0);
}
......@@ -200,7 +200,7 @@ guint32 nmd_get_device_ip4_address (DBusConnection *connection, char *path)
dbus_error_init (&error);
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &address, DBUS_TYPE_INVALID))
{
syslog (LOG_ERR, "There was an error getting the device's IPv4 address from NetworkManager." );
nm_warning ("There was an error getting the device's IPv4 address from NetworkManager." );
address = 0;
}
......@@ -248,20 +248,20 @@ static DBusHandlerResult nmd_dbus_filter (DBusConnection *connection, DBusMessag
if (action == NMD_DEVICE_NOW_ACTIVE || action == NMD_DEVICE_NOW_INACTIVE)
{
syslog (LOG_NOTICE, "Device %s (%s) is now %s.", dev_object_path, dev_iface_name,
nm_info ("Device %s (%s) is now %s.", dev_object_path, dev_iface_name,
(action == NMD_DEVICE_NOW_INACTIVE ? "down" :
(action == NMD_DEVICE_NOW_ACTIVE ? "up" : "error")));
}
else if (action == NMD_DEVICE_IP4_ADDRESS_CHANGE)
{
syslog (LOG_NOTICE, "Device %s (%s) now has address %u.%u.%u.%u", dev_object_path, dev_iface_name,
nm_info ("Device %s (%s) now has address %u.%u.%u.%u", dev_object_path, dev_iface_name,
NIPQUAD(dev_ip4_address));
}
nmd_execute_scripts (action, dev_iface_name, dev_ip4_address);
dbus_free (dev_iface_name);
dbus_free (dev_object_path);
g_free (dev_iface_name);
g_free (dev_object_path);
handled = TRUE;
}
......@@ -286,7 +286,7 @@ static DBusConnection *nmd_dbus_init (void)
connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
if (connection == NULL)
{
syslog (LOG_ERR, "nmd_dbus_init(): could not connect to the message bus. dbus says: '%s'", error.message);
nm_warning ("nmd_dbus_init(): could not connect to the message bus. dbus says: '%s'", error.message);
dbus_error_free (&error);
return (NULL);
}
......@@ -388,7 +388,7 @@ int main( int argc, char *argv[] )
if (become_daemon && daemon (FALSE, FALSE) < 0)
{
syslog( LOG_ERR, "NetworkManagerDispatcher could not daemonize. errno = %d", errno );
nm_warning ("NetworkManagerDispatcher could not daemonize. errno = %d", errno );
exit (1);
}
......
INCLUDES = -I${top_srcdir}
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
AM_CPPFLAGS = \
$(DBUS_CFLAGS) \
......@@ -43,7 +43,8 @@ NetworkManagerInfo_LDADD = \
$(GTK_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(GNOME_KEYRING_LIBS) \
$(LIBGNOMEUI_LIBS)
$(LIBGNOMEUI_LIBS) \
$(top_builddir)/utils/libnmutils.la
gladedir = $(datadir)/NetworkManagerInfo/glade
......
......@@ -43,6 +43,7 @@
#include "NetworkManagerInfoDbus.h"
#include "NetworkManagerInfo.h"
#include "NetworkManagerInfoPassphraseDialog.h"
#include "nm-utils.h"
static void nmi_spawn_notification_icon (NMIAppInfo *info);
......@@ -203,14 +204,14 @@ int main( int argc, char *argv[] )
if (!no_daemon && daemon (FALSE, FALSE) < 0)
{
syslog( LOG_ERR, "NetworkManagerInfo could not daemonize. errno = %d", errno );
nm_warning ("NetworkManagerInfo could not daemonize. errno = %d", errno );
exit (1);
}
app_info = g_new0 (NMIAppInfo, 1);
if (!app_info)
{
syslog (LOG_CRIT, "Not enough memory for application data.");
nm_error ("Not enough memory for application data.");
exit (1);
}
......@@ -223,7 +224,7 @@ int main( int argc, char *argv[] )
dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
if (dbus_connection == NULL)
{
syslog (LOG_CRIT, "NetworkManagerInfo could not get the system bus. Make sure the message bus daemon is running?");
nm_error ("NetworkManagerInfo could not get the system bus. Make sure the message bus daemon is running?");
exit (1);
}
dbus_connection_set_change_sigpipe (TRUE);
......
......@@ -33,6 +33,7 @@
#include "NetworkManagerInfoDbus.h"
#include "NetworkManagerInfoPassphraseDialog.h"
#include "NetworkManagerInfoVPN.h"
#include "nm-utils.h"
/*
......@@ -168,7 +169,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setKeyForNetwork")))
{
syslog (LOG_ERR, "nmi_dbus_return_user_key(): Couldn't allocate the dbus message");
nm_warning ("nmi_dbus_return_user_key(): Couldn't allocate the dbus message");
return;
}
......@@ -180,7 +181,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
DBUS_TYPE_INVALID))
{
if (!dbus_connection_send (connection, message, NULL))
syslog (LOG_ERR, "nmi_dbus_return_user_key(): dbus could not send the message");
nm_warning ("nmi_dbus_return_user_key(): dbus could not send the message");
}
dbus_message_unref (message);
......@@ -236,13 +237,13 @@ void nmi_dbus_signal_update_network (DBusConnection *connection, const char *net
message = dbus_message_new_signal (NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "WirelessNetworkUpdate");
if (!message)
{
syslog (LOG_ERR, "nmi_dbus_signal_update_network(): Not enough memory for new dbus message!");
nm_warning ("nmi_dbus_signal_update_network(): Not enough memory for new dbus message!");
return;
}
dbus_message_append_args (message, DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID);
if (!dbus_connection_send (connection, message, NULL))
syslog (LOG_WARNING, "nmi_dbus_signal_update_network(): Could not raise the 'WirelessNetworkUpdate' signal!");
nm_warning ("nmi_dbus_signal_update_network(): Could not raise the 'WirelessNetworkUpdate' signal!");
dbus_message_unref (message);
}
......@@ -349,6 +350,7 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
char *essid = NULL;
gint timestamp = -1;
gint32 i;
char *key = NULL;
NMEncKeyType key_type = -1;
gboolean trusted = FALSE;
......@@ -456,10 +458,13 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
dbus_message_iter_init_append (reply, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &essid);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &timestamp);
i = (gint32) timestamp;
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &key);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &key_type);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &auth_method);
i = (gint32) key_type;
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
i = (gint32) auth_method;
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &trusted);
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &array_iter);
......@@ -654,7 +659,7 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
method = dbus_message_get_member (message);
path = dbus_message_get_path (message);
/* syslog (LOG_WARNING, "nmi_dbus_nmi_message_handler() got method %s for path %s", method, path);*/
/* nm_warning ("nmi_dbus_nmi_message_handler() got method %s for path %s", method, path);*/
if (strcmp ("getKeyForNetwork", method) == 0)
{
......@@ -674,7 +679,7 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
}
else if (strcmp ("networkNotFound", method) == 0)
{
char *network;
const char *network;
DBusError error;
dbus_error_init (&error);
......@@ -686,7 +691,6 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
dbus_error_free (&error);
text = g_strdup_printf ( "The requested wireless network '%s' does not appear to be in range. "
"A different wireless network will be used if any are available.", network);
dbus_free (network);
dialog = GTK_DIALOG (gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text, NULL));
gtk_dialog_run (dialog);
......@@ -816,7 +820,7 @@ int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info)
&dbus_error);
if (dbus_error_is_set (&dbus_error))
{
syslog (LOG_ERR, "nmi_dbus_service_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'", dbus_error.message);
nm_warning ("nmi_dbus_service_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'", dbus_error.message);
dbus_error_free (&dbus_error);
return (-1);
}
......@@ -831,7 +835,7 @@ int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info)
if (!dbus_connection_register_object_path (dbus_connection, NMI_DBUS_PATH, &nmi_vtable, info))
{
syslog (LOG_ERR, "nmi_dbus_service_init() could not register a handler for NetworkManagerInfo. Not enough memory?");
nm_warning ("nmi_dbus_service_init() could not register a handler for NetworkManagerInfo. Not enough memory?");
return (-1);
}
......
......@@ -38,6 +38,7 @@
#include "NetworkManagerInfoDbus.h"
#include "NetworkManagerInfoPassphraseDialog.h"
#include "nm-utils.h"
enum NMIPassphraseDialogKeyTypes
{
......@@ -318,7 +319,7 @@ int nmi_passphrase_dialog_init (NMIAppInfo *info)
info->passphrase_dialog = glade_xml_new(GLADEDIR"/passphrase.glade", NULL, NULL);
if (!info->passphrase_dialog)
{
syslog (LOG_ERR, "Could not open the passphrase dialog glade file!");
nm_warning ("Could not open the passphrase dialog glade file!");
return (-1);
}
......
......@@ -40,6 +40,7 @@
#include "NetworkManagerInfoDbus.h"
#include "NetworkManagerInfoVPN.h"
#include "nm-utils.h"
int nmi_vpn_init (NMIAppInfo *info)
{
......@@ -90,7 +91,7 @@ static void save_vpn_password (const char *vpn, const char *keyring, const char
if (keyring_result != GNOME_KEYRING_RESULT_OK)
{
syslog (LOG_ERR, "Couldn't store password in keyring, code %d",
nm_warning ("Couldn't store password in keyring, code %d",
(int) keyring_result);
}
}
......@@ -120,7 +121,7 @@ static void response_cb (GtkWidget *dialog, int response, gpointer user_data)
username = g_object_get_data (G_OBJECT (passwd_dialog), "NetworkManagerInfoVPN-username");
vpn = g_object_get_data (G_OBJECT (passwd_dialog), "NetworkManagerInfoVPN-vpn");
password = gnome_password_dialog_get_password (passwd_dialog);
syslog (LOG_ERR, "returning VPN vpn_password for %s@%s: %s", username, vpn, password);
nm_warning ("returning VPN vpn_password for %s@%s: %s", username, vpn, password);
nmi_dbus_return_vpn_password (info->connection, info->vpn_password_message, password);
switch (gnome_password_dialog_get_remember (passwd_dialog))
{
......
......@@ -105,9 +105,8 @@ static char *libnm_glib_get_nm_status (DBusConnection *con)
dbus_message_unref (reply);
return g_strdup ("error");
}
dbus_message_unref (reply);
ret = g_strdup (status);
dbus_free (status);
dbus_message_unref (reply);
return ret;
}
......@@ -298,6 +297,8 @@ static DBusHandlerResult libnm_glib_dbus_filter (DBusConnection *connection, DBu
if (!(dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &status_string, DBUS_TYPE_INVALID)))
status_string = g_strdup ("error");
else
status_string = g_strdup (status_string);
libnm_glib_update_status (ctx, status_string);
g_free (status_string);
......@@ -518,7 +519,7 @@ libnm_glib_ctx *libnm_glib_init (void)
{
char *status_string = libnm_glib_get_nm_status (ctx->dbus_con);
libnm_glib_update_status (ctx, status_string);
dbus_free (status_string);
g_free (status_string);
}
if (!g_thread_create (libnm_glib_dbus_worker, ctx, FALSE, &error))
......
......@@ -1433,7 +1433,7 @@ static void nmwa_dbus_update_devices (NMWirelessApplet *applet)
if (!devices)
{
dbus_free (nm_status);
g_free (nm_status);
return;
}
......@@ -1479,7 +1479,7 @@ static void nmwa_dbus_update_devices (NMWirelessApplet *applet)
}
}
}
dbus_free (name);
g_free (name);
}
g_free (nm_act_dev);
g_strfreev (devices);
......
......@@ -34,6 +34,7 @@
#include <sys/types.h>
#include "NetworkManager.h"
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "NetworkManagerDevice.h"
#include "NetworkManagerPolicy.h"
......@@ -107,8 +108,9 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons
*/
if (!data->enable_test_devices && test_device)
{
syslog (LOG_ERR, "nm_create_device_and_add_to_list(): attempt to create a test device,"
" but test devices were not enabled on the command line. Will not create the device.\n");
nm_warning ("attempted to create a test device, "
"but test devices were not enabled "
"on the command line.");
return (NULL);
}
......@@ -123,7 +125,7 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons
*/
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
{
syslog (LOG_INFO, "Now managing %s device '%s'.",
nm_info ("Now managing %s device '%s'.",
nm_device_is_wireless (dev) ? "wireless" : "wired", nm_device_get_iface (dev));
data->dev_list = g_slist_append (data->dev_list, dev);
......@@ -139,11 +141,11 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons
else
{
/* If we couldn't add the device to our list, free its data. */
syslog ( LOG_ERR, "nm_create_device_and_add_to_list() could not acquire device list mutex." );
nm_warning ("could not acquire device list mutex." );
nm_device_unref (dev);
dev = NULL;
}
} else syslog ( LOG_ERR, "nm_create_device_and_add_to_list() could not allocate device data." );
} else nm_warning ("could not allocate device data." );
return (dev);
}
......@@ -194,7 +196,7 @@ void nm_remove_device_from_list (NMData *data, const char *udi)
}
}
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
} else syslog ( LOG_ERR, "nm_remove_device_from_list() could not acquire device list mutex." );
} else nm_warning ("could not acquire device list mutex." );
}
/* Hal doesn't really give us any way to pass a GMainContext to our
......@@ -223,7 +225,7 @@ static void nm_hal_device_added (LibHalContext *ctx, const char *udi)
g_return_if_fail (data != NULL);
syslog ( LOG_DEBUG, "New device added (hal udi is '%s').", udi );
nm_debug ("New device added (hal udi is '%s').", udi );
/* Sometimes the device's properties (like net.interface) are not set up yet,
* so this call will fail, and it will actually be added when hal sets the device's
......@@ -247,7 +249,7 @@ static void nm_hal_device_removed (LibHalContext *ctx, const char *udi)
g_return_if_fail (data != NULL);
syslog ( LOG_DEBUG, "Device removed (hal udi is '%s').", udi );
nm_debug ("Device removed (hal udi is '%s').", udi );
nm_remove_device_from_list (data, udi);
}
......@@ -263,7 +265,7 @@ static void nm_hal_device_new_capability (LibHalContext *ctx, const char *udi, c
g_return_if_fail (data != NULL);
/*syslog ( LOG_DEBUG, "nm_hal_device_new_capability() called with udi = %s, capability = %s", udi, capability );*/
/*nm_debug ("nm_hal_device_new_capability() called with udi = %s, capability = %s", udi, capability );*/
if (capability && ((strcmp (capability, "net.80203") == 0) || (strcmp (capability, "net.80211") == 0)))
{
......@@ -284,7 +286,7 @@ static void nm_hal_device_new_capability (LibHalContext *ctx, const char *udi, c
*/
static void nm_hal_device_lost_capability (LibHalContext *ctx, const char *udi, const char *capability)
{
/* syslog ( LOG_DEBUG, "nm_hal_device_lost_capability() called with udi = %s, capability = %s", udi, capability );*/
/* nm_debug ("nm_hal_device_lost_capability() called with udi = %s, capability = %s", udi, capability );*/
}
/*
......@@ -308,8 +310,8 @@ static void nm_add_initial_devices (NMData *data)
net_devices = libhal_find_device_by_capability (data->hal_ctx, "net", &num_net_devices, &error);
if (dbus_error_is_set (&error))
{
syslog (LOG_ERR, "nm_add_initial_devices() could not find existing"
"networking devices: %s", error.message);
nm_warning ("could not find existing networking devices: %s",
error.message);
dbus_error_free (&error);
}
......@@ -404,7 +406,7 @@ gboolean nm_poll_and_update_wireless_link_state (NMData *data)
}
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
} else syslog ( LOG_ERR, "nm_poll_and_update_wireless_link_state() could not acquire device list mutex." );
} else nm_warning ("could not acquire device list mutex." );
return (TRUE);
}
......@@ -429,7 +431,7 @@ static NMData *nm_data_new (gboolean enable_test_devices)
if (pipe(data->sigterm_pipe) < 0)
{
syslog (LOG_CRIT, "Couldn't create pipe: %s", g_strerror (errno));
nm_error ("Couldn't create pipe: %s", g_strerror (errno));
exit (EXIT_FAILURE);
}
......@@ -453,7 +455,7 @@ static NMData *nm_data_new (gboolean enable_test_devices)
if (!data->dev_list_mutex)
{
nm_data_free (data);
syslog (LOG_ERR, "Could not initialize data structure locks.");
nm_warning ("could not initialize data structure locks.");
return (NULL);
}
nm_register_mutex_desc (data->dev_list_mutex, "Device List Mutex");
......@@ -464,7 +466,7 @@ static NMData *nm_data_new (gboolean enable_test_devices)
if (!data->allowed_ap_list || !data->invalid_ap_list)
{
nm_data_free (data);
syslog (LOG_ERR, "Could not create access point lists. Whacky stuff going on?");
nm_warning ("could not create access point lists.");
return (NULL);
}
......@@ -508,19 +510,29 @@ static void nm_data_free (NMData *data)
memset (data, 0, sizeof (NMData));
}
static void sigterm_handler (int signum)
{
int ignore;
syslog (LOG_NOTICE, "Caught SIGINT/SIGTERM");
/* FIXME: This line is probably not a great
* thing to have in a signal handler
*/
nm_info ("Caught SIGINT/SIGTERM");
ignore = write (nm_data->sigterm_pipe[1], "X", 1);
}
static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, gpointer user_data)
{
NMData *data = user_data;
syslog (LOG_NOTICE, "Caught terminiation signal");
/* FIXME: These lines are definitely not great
* things to have in a signal handler
*
* The fix is to have a pipe that non-signal handling
* code can watch and respond to.
*/