supplicant: update logging

This commit is contained in:
Dan Williams 2010-04-07 10:13:12 -07:00
parent 75e789399c
commit 15e32cd4dc
4 changed files with 68 additions and 59 deletions

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"
@ -498,8 +498,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 +545,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 +674,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;
@ -780,7 +782,8 @@ 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_warn (LOGD_SUPPLICANT, "Unexpected supplicant error getting interface: %s",
err->message);
}
g_error_free (err);
@ -893,7 +896,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 +917,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 +973,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 +986,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 +999,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 +1062,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 +1077,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 +1121,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 +1170,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 +1200,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 +1232,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 +1312,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);