2004-08-23 Dan Willemsen <dan@willemsen.us>
authorDan Willemsen <dan@willemsen.us>
Mon, 23 Aug 2004 19:20:49 +0000 (19:20 +0000)
committerDan Williams <dcbw@redhat.com>
Mon, 23 Aug 2004 19:20:49 +0000 (19:20 +0000)
* dispatcher-daemon/NetworkManagerDispatcher.c
  info-daemon/NetworkManagerInfo.[ch]
  info-daemon/NetworkManagerInfoDbus.c
  info-daemon/NetworkManagerInfoPassphraseDialog.c
  src/NetworkManager.c
  src/NetworkManagerAP.c
  src/NetworkManagerAPList.c
  src/NetworkManagerDbus.c
  src/NetworkManagerDevice.c
  src/NetworkManagerPolicy.c
  src/NetworkManagerUtils.[ch]
  src/NetworkManagerWireless.c
- Used syslog functions for logging instead of NM_DEBUG_DISPLAY & fprintf

* src/NetworkManager.c
- Fixed usage wording for --no-daemon

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@61 4912f4e0-d625-0410-9fb7-b9a5a253dbdc

16 files changed:
ChangeLog
TODO
dispatcher-daemon/NetworkManagerDispatcher.c
info-daemon/NetworkManagerInfo.c
info-daemon/NetworkManagerInfo.h
info-daemon/NetworkManagerInfoDbus.c
info-daemon/NetworkManagerInfoPassphraseDialog.c
src/NetworkManager.c
src/NetworkManagerAP.c
src/NetworkManagerAPList.c
src/NetworkManagerDbus.c
src/NetworkManagerDevice.c
src/NetworkManagerPolicy.c
src/NetworkManagerUtils.c
src/NetworkManagerUtils.h
src/NetworkManagerWireless.c

index e67037d..bec0284 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2004-08-23  Dan Willemsen <dan@willemsen.us>
+
+       * dispatcher-daemon/NetworkManagerDispatcher.c
+         info-daemon/NetworkManagerInfo.[ch]
+         info-daemon/NetworkManagerInfoDbus.c
+         info-daemon/NetworkManagerInfoPassphraseDialog.c
+         src/NetworkManager.c
+         src/NetworkManagerAP.c
+         src/NetworkManagerAPList.c
+         src/NetworkManagerDbus.c
+         src/NetworkManagerDevice.c
+         src/NetworkManagerPolicy.c
+         src/NetworkManagerUtils.[ch]
+         src/NetworkManagerWireless.c
+               - Used syslog functions for logging instead of NM_DEBUG_DISPLAY & fprintf
+
+       * src/NetworkManager.c
+               - Fixed usage wording for --no-daemon
+
 2004-08-23  Dan Williams <dcbw@redhat.com>
 
        * panel-applet/NMWirelessApplet.c
diff --git a/TODO b/TODO
index 805fa45..51cf1c6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -28,14 +28,11 @@ Wireless link checking could be enhanced to check the signal strength of an acce
 There is currently no logic to gracefully recover from a crashed/killed dbus or hal.  While we don't depend as heavily on NetworkManagerInfo, we need to make sure that we can operate effectively when it's not there.  There are dbus functions for notification when services come up and go away which could be used here.  Remeber that when dbus dies, hal also dies at the moment.
 
 
-- Proper logging support
-
-We need to replace NM_DEBUG_PRINT with proper logging support to syslog or something.
-
 - Deal with blank ESSIDs
 
 Access points can be set not to broadcast their ESSIDs, which the client must know.  These appear as blank ESSIDs to cards doing wireless scanning, even though the rest of the AP's information is known (channel, rate, etc).  There has to be a way to deal with this as many companies do not broadcast ESSIDs for security measures.  Workarounds for this practice could include brute-forcing the Allowed Networks list if no suitable wireless network is found to begin with.  Obviously, there would be no way to detect if a WEP key was wrong, because unless the ESSID and WEP key are both correct, we cannot associate with the access point to see if we have a link.  Code exists to do this for wireless cards that do not support wireless scanning, and this code could be adapted.
 
+
 - Shorten standoff time between Pending and Active device promotion
 
 Currently, there is a 2 second wait between when a device is set as the Pending device, to when it may be promoted to Active device.  2 seconds is not technically necessary, the only reason to wait is that the GLib main loop must run at least once to deliver and receive queued up messages.  This wait is also only necessary for wireless cards, where we may need to request a key from the user.  This wait should be eliminated without breaking the Pending/Active device mechanism.
index 08d2c0d..a2f7c2f 100644 (file)
@@ -27,6 +27,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <syslog.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -67,7 +68,7 @@ void nmd_execute_scripts (NMDAction action, char *iface_name, guint32 new_ip4_ad
 
        if (!dir)
        {
-               fprintf (stderr, "nmd_execute_scripts(): opendir() could not open /etc/NetworkManager.d.  errno = %d\n", errno);
+               syslog (LOG_ERR, "nmd_execute_scripts(): opendir() could not open /etc/NetworkManager.d.  errno = %d", errno);
                return;
        }
 
@@ -124,7 +125,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")))
        {
-               fprintf (stderr, "Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "Couldn't allocate the dbus message");
                return (NULL);
        }
 
@@ -132,14 +133,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))
        {
-               fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
+               syslog (LOG_ERR, "%s raised: %s", error.name, error.message);
                dbus_message_unref (message);
                return (NULL);
        }
 
        if (reply == NULL)
        {
-               fprintf( stderr, "dbus reply message was NULL\n" );
+               syslog( LOG_ERR, "dbus reply message was NULL" );
                dbus_message_unref (message);
                return (NULL);
        }
@@ -148,7 +149,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))
        {
-               fprintf (stderr, "There was an error getting the device name from NetworkManager." );
+               syslog (LOG_ERR, "There was an error getting the device name from NetworkManager." );
                dev_name = NULL;
        }
 
@@ -173,7 +174,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")))
        {
-               fprintf (stderr, "Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "Couldn't allocate the dbus message");
                return (0);
        }
 
@@ -181,14 +182,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))
        {
-               fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
+               syslog (LOG_ERR, "%s raised: %s", error.name, error.message);
                dbus_message_unref (message);
                return (0);
        }
 
        if (reply == NULL)
        {
-               fprintf( stderr, "dbus reply message was NULL\n" );
+               syslog( LOG_ERR, "dbus reply message was NULL" );
                dbus_message_unref (message);
                return (0);
        }
@@ -197,7 +198,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))
        {
-               fprintf (stderr, "There was an error getting the device's IPv4 address from NetworkManager." );
+               syslog (LOG_ERR, "There was an error getting the device's IPv4 address from NetworkManager." );
                address = 0;
        }
 
@@ -240,13 +241,13 @@ static DBusHandlerResult nmd_dbus_filter (DBusConnection *connection, DBusMessag
 
                        if (action == NMD_DEVICE_NOW_ACTIVE || action == NMD_DEVICE_NOW_INACTIVE)
                        {
-                               fprintf (stderr, "Device %s (%s) is now %s.\n", dev_object_path, dev_iface_name,
+                               syslog (LOG_NOTICE, "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)
                        {
-                               fprintf (stderr, "Device %s (%s) now has address %u.%u.%u.%u\n", dev_object_path, dev_iface_name,
+                               syslog (LOG_NOTICE, "Device %s (%s) now has address %u.%u.%u.%u", dev_object_path, dev_iface_name,
                                                        NIPQUAD(dev_ip4_address));
                        }
 
@@ -278,7 +279,7 @@ static DBusConnection *nmd_dbus_init (void)
        connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
        if (connection == NULL)
        {
-               fprintf (stderr, "nmd_dbus_init(): could not connect to the message bus.  dbus says: '%s'\n", error.message);
+               syslog (LOG_ERR, "nmd_dbus_init(): could not connect to the message bus.  dbus says: '%s'", error.message);
                dbus_error_free (&error);
                return (NULL);
        }
@@ -376,13 +377,15 @@ int main( int argc, char *argv[] )
                }
        }
 
+       openlog("NetworkManagerDispatcher", (become_daemon) ? LOG_CONS : LOG_CONS | LOG_PERROR, (become_daemon) ? LOG_DAEMON : LOG_USER);
+
        if (become_daemon)
        {
                int child_pid;
 
                if (chdir ("/") < 0)
                {
-                       fprintf( stderr, "NetworkManagerDispatcher could not chdir to /.  errno=%d", errno);
+                       syslog( LOG_CRIT, "NetworkManagerDispatcher could not chdir to /.  errno=%d", errno);
                        return 1;
                }
 
@@ -390,7 +393,7 @@ int main( int argc, char *argv[] )
                switch (child_pid)
                {
                        case -1:
-                               fprintf( stderr, "NetworkManagerDispatcher could not daemonize.  errno = %d\n", errno );
+                               syslog( LOG_ERR, "NetworkManagerDispatcher could not daemonize.  errno = %d", errno );
                                break;
 
                        case 0:
index c2318bc..b22fe92 100644 (file)
@@ -184,13 +184,15 @@ int main( int argc, char *argv[] )
                                                        GNOME_PARAM_HUMAN_READABLE_NAME, "Network Manager User Info Service",
                                                        NULL);
 
+       openlog("NetworkManagerInfo", (no_daemon) ? LOG_CONS | LOG_PERROR : LOG_CONS, (no_daemon) ? LOG_USER : LOG_DAEMON);
+
        if (!no_daemon)
        {
                int child_pid;
 
                if (chdir ("/") < 0)
                {
-                       fprintf( stderr, "NetworkManagerInfo could not chdir to /.  errno=%d", errno);
+                       syslog( LOG_CRIT, "NetworkManagerInfo could not chdir to /.  errno=%d", errno);
                        return 1;
                }
 
@@ -198,7 +200,7 @@ int main( int argc, char *argv[] )
                switch (child_pid)
                {
                        case -1:
-                               fprintf( stderr, "NetworkManagerInfo could not daemonize.  errno = %d\n", errno );
+                               syslog( LOG_ERR, "NetworkManagerInfo could not daemonize.  errno = %d", errno );
                                break;
 
                        case 0:
@@ -214,7 +216,7 @@ int main( int argc, char *argv[] )
        app_info = g_new0 (NMIAppInfo, 1);
        if (!app_info)
        {
-               fprintf (stderr, "Not enough memory for application data.\n");
+               syslog (LOG_CRIT, "Not enough memory for application data.");
                exit (1);
        }
 
@@ -227,7 +229,7 @@ int main( int argc, char *argv[] )
        dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
        if (dbus_connection == NULL)
        {
-               fprintf (stderr, "NetworkManagerInfo could not get the system bus.  Make sure the message bus daemon is running?\n");
+               syslog (LOG_CRIT, "NetworkManagerInfo could not get the system bus.  Make sure the message bus daemon is running?");
                exit (1);
        }
        dbus_connection_set_change_sigpipe (TRUE);
index c2cf9cb..c66bcb0 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef NETWORK_MANAGER_INFO_H
 #define NETWORK_MANAGER_INFO_H
 
+#include <syslog.h>
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <glade/glade.h>
index 565fcff..8247bfe 100644 (file)
@@ -126,7 +126,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")))
        {
-               fprintf (stderr, "nmi_dbus_return_user_key(): Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "nmi_dbus_return_user_key(): Couldn't allocate the dbus message");
                return;
        }
 
@@ -137,7 +137,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
                                                                DBUS_TYPE_INVALID))
        {
                if (!dbus_connection_send (connection, message, NULL))
-                       fprintf (stderr, "nmi_dbus_return_user_key(): dbus could not send the message\n");
+                       syslog (LOG_ERR, "nmi_dbus_return_user_key(): dbus could not send the message");
        }
 
        dbus_message_unref (message);
@@ -171,13 +171,13 @@ void nmi_dbus_signal_update_network (DBusConnection *connection, const char *net
        message = dbus_message_new_signal (NMI_DBUS_PATH, NMI_DBUS_INTERFACE, signal);
        if (!message)
        {
-               fprintf (stderr, "nmi_dbus_signal_update_network(): Not enough memory for new dbus message!\n");
+               syslog (LOG_ERR, "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))
-               fprintf (stderr, "nmi_dbus_signal_update_network(): Could not raise the '%s' signal!\n", signal);
+               syslog (LOG_WARNING, "nmi_dbus_signal_update_network(): Could not raise the '%s' signal!", signal);
 
        dbus_message_unref (message);
 }
@@ -471,7 +471,7 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
        method = dbus_message_get_member (message);
        path = dbus_message_get_path (message);
 
-       /* fprintf (stderr, "nmi_dbus_nmi_message_handler() got method %s for path %s\n", method, path); */
+       /* syslog (LOG_DEBUG, "nmi_dbus_nmi_message_handler() got method %s for path %s", method, path); */
 
        if (strcmp ("getKeyForNetwork", method) == 0)
        {
@@ -579,13 +579,13 @@ int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info)
        dbus_bus_acquire_service (dbus_connection, NMI_DBUS_SERVICE, 0, &dbus_error);
        if (dbus_error_is_set (&dbus_error))
        {
-               fprintf (stderr, "nmi_dbus_service_init() could not acquire its service.  dbus_bus_acquire_service() says: '%s'\n", dbus_error.message);
+               syslog (LOG_ERR, "nmi_dbus_service_init() could not acquire its service.  dbus_bus_acquire_service() says: '%s'", dbus_error.message);
                return (-1);
        }
 
        if (!dbus_connection_register_object_path (dbus_connection, NMI_DBUS_PATH, &nmi_vtable, info))
        {
-               fprintf (stderr, "nmi_dbus_service_init() could not register a handler for NetworkManagerInfo.  Not enough memory?\n");
+               syslog (LOG_ERR, "nmi_dbus_service_init() could not register a handler for NetworkManagerInfo.  Not enough memory?");
                return (-1);
        }
 
index 9f79e18..44ceb1d 100644 (file)
@@ -208,7 +208,7 @@ int nmi_passphrase_dialog_init (NMIAppInfo *info)
        info->passphrase_dialog = glade_xml_new(GLADEDIR"/passphrase.glade", NULL, NULL);
        if (!info->passphrase_dialog)
        {
-               fprintf (stderr, "Could not open the passphrase dialog glade file!\n");
+               syslog (LOG_ERR, "Could not open the passphrase dialog glade file!");
                return (-1);
        }
        
index 56b30dd..ba39916 100644 (file)
@@ -91,7 +91,7 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi)
                         */
                        if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
                        {
-                               NM_DEBUG_PRINT_2( "nm_create_device_and_add_to_list(): adding device '%s' (%s)\n",
+                               syslog( LOG_INFO, "nm_create_device_and_add_to_list(): adding device '%s' (%s)",
                                        nm_device_get_iface (dev), nm_device_is_wireless (dev) ? "wireless" : "wired" );
 
                                data->dev_list = g_slist_append (data->dev_list, dev);
@@ -99,8 +99,8 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi)
                                success = TRUE;
 
                                nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
-                       } else NM_DEBUG_PRINT( "nm_create_device_and_add_to_list() could not acquire device list mutex.\n" );
-               } else NM_DEBUG_PRINT( "nm_create_device_and_add_to_list() could not allocate device data.\n" );
+                       } else syslog( LOG_ERR, "nm_create_device_and_add_to_list() could not acquire device list mutex." );
+               } else syslog( LOG_ERR, "nm_create_device_and_add_to_list() could not allocate device data." );
 
                hal_free_string (iface_name);
 
@@ -164,7 +164,7 @@ void nm_remove_device_from_list (NMData *data, const char *udi)
                        element = g_slist_next (element);
                }
                nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
-       } else NM_DEBUG_PRINT( "nm_remove_device_from_list() could not acquire device list mutex.\n" );
+       } else syslog( LOG_ERR, "nm_remove_device_from_list() could not acquire device list mutex." );
 }
 
 
@@ -188,7 +188,7 @@ static void nm_hal_device_added (LibHalContext *ctx, const char *udi)
 
        g_return_if_fail (data != NULL);
 
-       NM_DEBUG_PRINT_1( "nm_hal_device_added() called with udi = %s\n", udi );
+       syslog( LOG_DEBUG, "nm_hal_device_added() called with udi = %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
@@ -208,7 +208,7 @@ static void nm_hal_device_removed (LibHalContext *ctx, const char *udi)
 
        g_return_if_fail (data != NULL);
 
-       NM_DEBUG_PRINT_1( "nm_hal_device_removed() called with udi = %s\n", udi );
+       syslog( LOG_DEBUG, "nm_hal_device_removed() called with udi = %s", udi );
 
        nm_remove_device_from_list (data, udi);
 }
@@ -224,7 +224,7 @@ static void nm_hal_device_new_capability (LibHalContext *ctx, const char *udi, c
 
        g_return_if_fail (data != NULL);
 
-       NM_DEBUG_PRINT_2( "nm_hal_device_new_capability() called with udi = %s, capability = %s\n", udi, capability );
+       syslog( LOG_DEBUG, "nm_hal_device_new_capability() called with udi = %s, capability = %s", udi, capability );
 
        if (capability && (strcmp (capability, "net.ethernet") == 0))
                nm_create_device_and_add_to_list (data, udi);
@@ -237,7 +237,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)
 {
-       NM_DEBUG_PRINT_2( "nm_hal_device_lost_capability() called with udi = %s, capability = %s\n", udi, capability );
+       syslog( LOG_DEBUG, "nm_hal_device_lost_capability() called with udi = %s, capability = %s", udi, capability );
 }
 
 
@@ -248,7 +248,7 @@ static void nm_hal_device_lost_capability (LibHalContext *ctx, const char *udi,
 static void nm_hal_device_property_modified (LibHalContext *ctx, const char *udi, const char *key, dbus_bool_t is_removed, dbus_bool_t is_added)
 {
 /*
-       NM_DEBUG_PRINT_4( "nm_hal_device_property_modified() called with udi = %s, key = %s, is_removed = %d, is_added = %d\n", udi, key, is_removed, is_added );
+       syslog( LOG_DEBUG, "nm_hal_device_property_modified() called with udi = %s, key = %s, is_removed = %d, is_added = %d", udi, key, is_removed, is_added );
 */
 }
 
@@ -345,7 +345,7 @@ gboolean nm_link_state_monitor (gpointer user_data)
                }
 
                nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
-       } else NM_DEBUG_PRINT( "nm_link_state_monitor() could not acquire device list mutex.\n" );
+       } else syslog( LOG_ERR, "nm_link_state_monitor() could not acquire device list mutex." );
        
        return (TRUE);
 }
@@ -379,7 +379,7 @@ static NMData *nm_data_new (void)
        data = g_new0 (NMData, 1);
        if (!data)
        {
-               NM_DEBUG_PRINT("Could not allocate our NetworkManager data... Not enough memory?\n");
+               syslog( LOG_ERR, "Could not allocate our NetworkManager data... Not enough memory?");
                return (NULL);
        }
 
@@ -388,7 +388,7 @@ static NMData *nm_data_new (void)
        if (!data->dev_list_mutex)
        {
                nm_data_free (data);
-               NM_DEBUG_PRINT("Could not create device list mutex.  Whacky shit going on?\n");
+               syslog( LOG_ERR, "Could not create device list mutex.  Whacky shit going on?");
                return (NULL);
        }
 
@@ -397,7 +397,7 @@ static NMData *nm_data_new (void)
        if (!data->state_modified_mutex)
        {
                nm_data_free (data);
-               NM_DEBUG_PRINT("Could not create state_modified mutex.  Whacky stuff going on?\n");
+               syslog( LOG_ERR, "Could not create state_modified mutex.  Whacky stuff going on?");
                return (NULL);
        }
 
@@ -409,7 +409,7 @@ static NMData *nm_data_new (void)
        if (!data->trusted_ap_list || !data->preferred_ap_list || !data->invalid_ap_list)
        {
                nm_data_free (data);
-               NM_DEBUG_PRINT("Could not create access point lists.  Whacky stuff going on?\n");
+               syslog( LOG_ERR, "Could not create access point lists.  Whacky stuff going on?");
                return (NULL);
        }
 
@@ -483,7 +483,7 @@ static void nm_print_usage (void)
        fprintf (stderr, "\n" "usage : NetworkManager [--no-daemon] [--help]\n");
        fprintf (stderr,
                "\n"
-               "        --no-daemon    Become a daemon\n"
+               "        --no-daemon    Don't become a daemon\n"
                "        --help         Show this information and exit\n"
                "\n"
                "NetworkManager monitors all network connections and automatically\n"
@@ -547,6 +547,9 @@ int main( int argc, char *argv[] )
        if (!g_thread_supported ())
                g_thread_init (NULL);
 
+       openlog ("NetworkManager", (become_daemon) ? LOG_CONS : LOG_CONS | LOG_PERROR, (become_daemon) ? LOG_DAEMON : LOG_USER);
+       syslog (LOG_NOTICE, "starting...");
+
        /* Load all network device kernel modules.
         * NOTE: this hack is temporary until device modules get loaded
         * on startup by something else.  The problem is that unless
@@ -559,7 +562,7 @@ int main( int argc, char *argv[] )
        nm_data = nm_data_new ();
        if (!nm_data)
        {
-               NM_DEBUG_PRINT("nm_data_new() failed... Not enough memory?\n");
+               syslog( LOG_CRIT, "nm_data_new() failed... Not enough memory?");
                exit (EXIT_FAILURE);
        }       
 
@@ -567,6 +570,7 @@ int main( int argc, char *argv[] )
        nm_data->dbus_connection = nm_dbus_init (nm_data);
        if (!nm_data->dbus_connection)
        {
+               syslog( LOG_CRIT, "nm_dbus_init() failed, exiting");
                hal_shutdown (nm_data->hal_ctx);
                nm_data_free (nm_data);
                exit (EXIT_FAILURE);
@@ -577,7 +581,7 @@ int main( int argc, char *argv[] )
        /* Initialize libhal.  We get a connection to the hal daemon here. */
        if ((ctx = hal_initialize (&hal_functions, FALSE)) == NULL)
        {
-               NM_DEBUG_PRINT("hal_initialize() failed, exiting...  Make sure the hal daemon is running?\n");
+               syslog( LOG_CRIT, "hal_initialize() failed, exiting...  Make sure the hal daemon is running?");
                exit (EXIT_FAILURE);
        }
        nm_data->hal_ctx = ctx;
@@ -614,7 +618,7 @@ int main( int argc, char *argv[] )
 
                if (chdir ("/") < 0)
                {
-                       fprintf( stderr, "NetworkManager could not chdir to /.  errno=%d", errno);
+                       syslog( LOG_CRIT, "NetworkManager could not chdir to /.  errno=%d", errno);
                        return (1);
                }
 
@@ -622,7 +626,7 @@ int main( int argc, char *argv[] )
                switch (child_pid)
                {
                        case -1:
-                               fprintf( stderr, "NetworkManager could not daemonize.  errno = %d\n", errno );
+                               syslog( LOG_ERR, "NetworkManager could not daemonize.  errno = %d", errno );
                                break;
 
                        case 0:
@@ -639,6 +643,8 @@ int main( int argc, char *argv[] )
        loop = g_main_loop_new (NULL, FALSE);
        g_main_loop_run (loop);
 
+       syslog (LOG_NOTICE, "exiting");
+
        /* Kill the watch functions */
        g_source_remove (link_source);
        g_source_remove (policy_source);
index 4d7d9eb..9fed082 100644 (file)
@@ -59,7 +59,7 @@ NMAccessPoint * nm_ap_new (void)
        
        ap = g_new0 (NMAccessPoint, 1);
        if (!ap)
-               NM_DEBUG_PRINT( "nm_ap_new() could not allocate a new user access point info structure.  Not enough memory?" )
+               syslog( LOG_ERR, "nm_ap_new() could not allocate a new user access point info structure.  Not enough memory?" );
 
        ap->priority = NM_AP_PRIORITY_WORST;
        ap->refcount = 1;
@@ -86,7 +86,7 @@ NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *src_ap)
 
        new_ap = nm_ap_new();
        if (!new_ap)
-               NM_DEBUG_PRINT( "nm_ap_new_from_uap() could not allocate a new user access point info structure.  Not enough memory?" )
+               syslog( LOG_ERR, "nm_ap_new_from_uap() could not allocate a new user access point info structure.  Not enough memory?" );
 
        new_ap->refcount = 1;
 
index 43f57e4..e2d7d35 100644 (file)
@@ -55,7 +55,7 @@ NMAccessPointList *nm_ap_list_new (NMNetworkType type)
        if (!list->mutex)
        {
                g_free (list);
-               NM_DEBUG_PRINT ("nm_ap_list_new() could not create list mutex\n");
+               syslog (LOG_ERR, "nm_ap_list_new() could not create list mutex");
                return (NULL);
        }
 
@@ -130,7 +130,7 @@ void nm_ap_list_append_ap (NMAccessPointList *list, NMAccessPoint *ap)
 
        if (!nm_try_acquire_mutex (list->mutex, __FUNCTION__))
        {
-               NM_DEBUG_PRINT( "nm_ap_list_append_ap() could not acquire AP list mutex.\n" );
+               syslog( LOG_ERR, "nm_ap_list_append_ap() could not acquire AP list mutex." );
                return;
        }
 
@@ -156,7 +156,7 @@ void nm_ap_list_remove_ap (NMAccessPointList *list, NMAccessPoint *ap)
 
        if (!nm_try_acquire_mutex (list->mutex, __FUNCTION__))
        {
-               NM_DEBUG_PRINT( "nm_ap_list_append_ap() could not acquire AP list mutex.\n" );
+               syslog( LOG_ERR, "nm_ap_list_append_ap() could not acquire AP list mutex." );
                return;
        }
 
@@ -463,15 +463,15 @@ void nm_ap_list_print_members (NMAccessPointList *list, const char *name)
        if (!(iter = nm_ap_list_iter_new (list)))
                return;
 
-       fprintf (stderr, "AP_LIST_PRINT: printing members of '%s'\n", name);
+       syslog (LOG_DEBUG, "AP_LIST_PRINT: printing members of '%s'", name);
        while ((ap = nm_ap_list_iter_next (iter)))
        {
-               fprintf (stderr, "\t%d)\tessid='%s', prio=%d, key='%s', enc=%d, addr=0x%X, qual=%d, freq=%f, rate=%d, inval=%d\n",
+               syslog (LOG_DEBUG, "\t%d)\tessid='%s', prio=%d, key='%s', enc=%d, addr=0x%X, qual=%d, freq=%f, rate=%d, inval=%d",
                                i, nm_ap_get_essid (ap), nm_ap_get_priority (ap), nm_ap_get_wep_key (ap), nm_ap_get_encrypted (ap),
                                nm_ap_get_address (ap), nm_ap_get_quality (ap), nm_ap_get_freq (ap), nm_ap_get_rate (ap),
                                nm_ap_get_invalid (ap));
                i++;
        }
-       fprintf (stderr, "AP_LIST_PRINT: done\n");
+       syslog (LOG_DEBUG, "AP_LIST_PRINT: done");
        nm_ap_list_iter_free (iter);
 }
index 987837a..6f3d2fa 100644 (file)
@@ -286,7 +286,7 @@ void nm_dbus_signal_device_no_longer_active (DBusConnection *connection, NMDevic
        message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeviceNoLongerActive");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_signal_device_no_longer_active(): Not enough memory for new dbus message!\n");
+               syslog (LOG_ERR, "nm_dbus_signal_device_no_longer_active(): Not enough memory for new dbus message!");
                g_free (dev_path);
                return;
        }
@@ -295,7 +295,7 @@ void nm_dbus_signal_device_no_longer_active (DBusConnection *connection, NMDevic
        g_free (dev_path);
 
        if (!dbus_connection_send (connection, message, NULL))
-               NM_DEBUG_PRINT ("nm_dbus_signal_device_no_longer_active(): Could not raise the DeviceNoLongerActive signal!\n");
+               syslog (LOG_WARNING, "nm_dbus_signal_device_no_longer_active(): Could not raise the DeviceNoLongerActive signal!");
 
        dbus_message_unref (message);
 }
@@ -321,7 +321,7 @@ void nm_dbus_signal_device_now_active (DBusConnection *connection, NMDevice *dev
        message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeviceNowActive");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_signal_device_now_active(): Not enough memory for new dbus message!\n");
+               syslog (LOG_ERR, "nm_dbus_signal_device_now_active(): Not enough memory for new dbus message!");
                g_free (dev_path);
                return;
        }
@@ -330,7 +330,7 @@ void nm_dbus_signal_device_now_active (DBusConnection *connection, NMDevice *dev
        g_free (dev_path);
 
        if (!dbus_connection_send (connection, message, NULL))
-               NM_DEBUG_PRINT ("nm_dbus_signal_device_now_active(): Could not raise the DeviceNowActive signal!\n");
+               syslog (LOG_WARNING, "nm_dbus_signal_device_now_active(): Could not raise the DeviceNowActive signal!");
 
        dbus_message_unref (message);
 }
@@ -356,7 +356,7 @@ void nm_dbus_signal_device_ip4_address_change (DBusConnection *connection, NMDev
        message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeviceIP4AddressChange");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_signal_device_ip4_address_change(): Not enough memory for new dbus message!\n");
+               syslog (LOG_ERR, "nm_dbus_signal_device_ip4_address_change(): Not enough memory for new dbus message!");
                g_free (dev_path);
                return;
        }
@@ -365,7 +365,7 @@ void nm_dbus_signal_device_ip4_address_change (DBusConnection *connection, NMDev
        g_free (dev_path);
 
        if (!dbus_connection_send (connection, message, NULL))
-               NM_DEBUG_PRINT ("nm_dbus_signal_device_ip4_address_change(): Could not raise the IP4AddressChange signal!\n");
+               syslog (LOG_WARNING, "nm_dbus_signal_device_ip4_address_change(): Could not raise the IP4AddressChange signal!");
 
        dbus_message_unref (message);
 }
@@ -399,7 +399,7 @@ void nm_dbus_signal_wireless_network_appeared (DBusConnection *connection, NMDev
        message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "WirelessNetworkAppeared");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_signal_wireless_network_appeared(): Not enough memory for new dbus message!\n");
+               syslog (LOG_ERR, "nm_dbus_signal_wireless_network_appeared(): Not enough memory for new dbus message!");
                g_free (dev_path);
                g_free (ap_path);
                return;
@@ -413,7 +413,7 @@ void nm_dbus_signal_wireless_network_appeared (DBusConnection *connection, NMDev
        g_free (dev_path);
 
        if (!dbus_connection_send (connection, message, NULL))
-               NM_DEBUG_PRINT ("nnm_dbus_signal_wireless_network_appeared(): Could not raise the WirelessNetworkAppeared signal!\n");
+               syslog (LOG_WARNING, "nnm_dbus_signal_wireless_network_appeared(): Could not raise the WirelessNetworkAppeared signal!");
 
        dbus_message_unref (message);
 }
@@ -447,7 +447,7 @@ void nm_dbus_signal_wireless_network_disappeared (DBusConnection *connection, NM
        message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "WirelessNetworkDisappeared");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_signal_wireless_network_disappeared(): Not enough memory for new dbus message!\n");
+               syslog (LOG_ERR, "nm_dbus_signal_wireless_network_disappeared(): Not enough memory for new dbus message!");
                g_free (dev_path);
                g_free (ap_path);
                return;
@@ -461,7 +461,7 @@ void nm_dbus_signal_wireless_network_disappeared (DBusConnection *connection, NM
        g_free (dev_path);
 
        if (!dbus_connection_send (connection, message, NULL))
-               NM_DEBUG_PRINT ("nnm_dbus_signal_wireless_network_disappeared(): Could not raise the WirelessNetworkDisappeared signal!\n");
+               syslog (LOG_WARNING, "nnm_dbus_signal_wireless_network_disappeared(): Could not raise the WirelessNetworkDisappeared signal!");
 
        dbus_message_unref (message);
 }
@@ -492,7 +492,7 @@ void nm_dbus_get_user_key_for_network_callback (DBusPendingCall *pending, void *
                if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID))
                {
                        nm_device_pending_action_set_user_key (dev, key);
-                       fprintf (stderr, "dbus user key callback got key '%s'\n", key );
+                       syslog (LOG_DEBUG, "dbus user key callback got key '%s'", key );
                        dbus_free (key);
                        dbus_pending_call_unref (pending);
                }
@@ -533,7 +533,7 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMDevice *dev
                                                NMI_DBUS_INTERFACE, "getKeyForNetwork");
        if (message == NULL)
        {
-               NM_DEBUG_PRINT ("nm_dbus_get_user_key_for_network(): Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "nm_dbus_get_user_key_for_network(): Couldn't allocate the dbus message");
                return;
        }
 
@@ -542,13 +542,13 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMDevice *dev
                                                                DBUS_TYPE_INVALID);
 
        if (!dbus_connection_send (connection, message, NULL))
-               NM_DEBUG_PRINT ("nm_dbus_get_user_key_for_network(): could not send dbus message\n");
+               syslog (LOG_WARNING, "nm_dbus_get_user_key_for_network(): could not send dbus message");
 
        /* For asynchronous replies, disabled for now */
 #if 0
        if (!dbus_connection_send_with_reply (connection, message, pending, -1))
        {
-               fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
+               syslog (LOG_ERR, "%s raised: %s", error.name, error.message);
                dbus_message_unref (message);
                return;
        }
@@ -618,12 +618,12 @@ void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection)
                                                NMI_DBUS_INTERFACE, "cancelGetKeyForNetwork");
        if (message == NULL)
        {
-               NM_DEBUG_PRINT ("nm_dbus_cancel_get_user_key_for_network(): Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "nm_dbus_cancel_get_user_key_for_network(): Couldn't allocate the dbus message");
                return;
        }
 
        if (!dbus_connection_send (connection, message, NULL))
-               NM_DEBUG_PRINT ("nm_dbus_cancel_get_user_key_for_network(): could not send dbus message\n");
+               syslog (LOG_WARNING, "nm_dbus_cancel_get_user_key_for_network(): could not send dbus message");
 
        dbus_message_unref (message);
 }
@@ -652,7 +652,7 @@ char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type
                                                NMI_DBUS_INTERFACE, "getNetworkEssid");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_get_network_essid(): Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "nm_dbus_get_network_essid(): Couldn't allocate the dbus message");
                return (NULL);
        }
 
@@ -664,9 +664,9 @@ char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type
        dbus_error_init (&error);
        reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
        if (dbus_error_is_set (&error))
-               NM_DEBUG_PRINT_2 ("nm_dbus_get_network_essid(): %s raised %s\n", error.name, error.message)
+               syslog (LOG_ERR, "nm_dbus_get_network_essid(): %s raised %s", error.name, error.message);
        else if (!reply)
-               NM_DEBUG_PRINT ("nm_dbus_get_network_essid(): reply was NULL.\n")
+               syslog (LOG_NOTICE, "nm_dbus_get_network_essid(): reply was NULL.");
        else
        {
                char    *dbus_string;
@@ -710,7 +710,7 @@ char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type,
                                                NMI_DBUS_INTERFACE, "getNetworkKey");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_get_network_key(): Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "nm_dbus_get_network_key(): Couldn't allocate the dbus message");
                return (NULL);
        }
 
@@ -722,9 +722,9 @@ char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type,
        dbus_error_init (&error);
        reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
        if (dbus_error_is_set (&error))
-               NM_DEBUG_PRINT_2 ("nm_dbus_get_network_key(): %s raised %s\n", error.name, error.message)
+               syslog (LOG_ERR, "nm_dbus_get_network_key(): %s raised %s", error.name, error.message);
        else if (!reply)
-               NM_DEBUG_PRINT ("nm_dbus_get_network_key(): reply was NULL.\n")
+               syslog (LOG_NOTICE, "nm_dbus_get_network_key(): reply was NULL.");
        else
        {
                char    *dbus_string;
@@ -769,7 +769,7 @@ gint nm_dbus_get_network_priority (DBusConnection *connection, NMNetworkType typ
                                                NMI_DBUS_INTERFACE, "getNetworkPriority");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_get_network_priority(): Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "nm_dbus_get_network_priority(): Couldn't allocate the dbus message");
                return (-1);
        }
 
@@ -781,9 +781,9 @@ gint nm_dbus_get_network_priority (DBusConnection *connection, NMNetworkType typ
        dbus_error_init (&error);
        reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
        if (dbus_error_is_set (&error))
-               NM_DEBUG_PRINT_2 ("nm_dbus_get_network_priority(): %s raised %s\n", error.name, error.message)
+               syslog (LOG_ERR, "nm_dbus_get_network_priority(): %s raised %s", error.name, error.message);
        else if (!reply)
-               NM_DEBUG_PRINT ("nm_dbus_get_network_priority(): reply was NULL.\n")
+               syslog (LOG_NOTICE, "nm_dbus_get_network_priority(): reply was NULL.");
        else
        {
                dbus_error_init (&error);
@@ -822,7 +822,7 @@ char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, in
                                                NMI_DBUS_INTERFACE, "getNetworks");
        if (!message)
        {
-               NM_DEBUG_PRINT ("nm_dbus_get_networks(): Couldn't allocate the dbus message\n");
+               syslog (LOG_ERR, "nm_dbus_get_networks(): Couldn't allocate the dbus message");
                return (NULL);
        }
 
@@ -832,9 +832,9 @@ char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, in
        dbus_error_init (&error);
        reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
        if (dbus_error_is_set (&error))
-               NM_DEBUG_PRINT_2 ("nm_dbus_get_networks(): %s raised %s\n", error.name, error.message)
+               syslog (LOG_ERR, "nm_dbus_get_networks(): %s raised %s", error.name, error.message);
        else if (!reply)
-               NM_DEBUG_PRINT ("nm_dbus_get_networks(): reply was NULL.\n")
+               syslog (LOG_NOTICE, "nm_dbus_get_networks(): reply was NULL.");
        else
        {
                DBusMessageIter  iter;
@@ -873,7 +873,7 @@ static DBusHandlerResult nm_dbus_nmi_filter (DBusConnection *connection, DBusMes
        if (!(object_path = dbus_message_get_path (message)))
                return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
 
-       /* NM_DEBUG_PRINT_2 ("nm_dbus_nmi_filter() got method %s for path %s\n", method, object_path); /**/
+       /* syslog (LOG_DEBUG, "nm_dbus_nmi_filter() got method %s for path %s", method, object_path); /**/
 
        if (    (strcmp (object_path, NMI_DBUS_PATH) == 0)
                && dbus_message_is_signal (message, NMI_DBUS_INTERFACE, "TrustedNetworkUpdate"))
@@ -925,7 +925,7 @@ static DBusHandlerResult nm_dbus_nmi_filter (DBusConnection *connection, DBusMes
                if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID))
                        return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
 
-fprintf( stderr, "update of network '%s'\n", network);
+               syslog( LOG_DEBUG, "update of network '%s'", network);
                nm_ap_list_update_network (list, network, data);
                dbus_free (network);
 
@@ -936,10 +936,10 @@ fprintf( stderr, "update of network '%s'\n", network);
                        && nm_device_is_wireless (data->active_device)
                        && !nm_device_activating (data->active_device))
                {
-fprintf( stderr, "updating active device's best ap\n");
+                       syslog( LOG_DEBUG, "updating active device's best ap");
                        nm_device_update_best_ap (data->active_device);
                        nm_data_set_state_modified (data, TRUE);
-fprintf( stderr, "Device's best ap now '%s'\n", nm_ap_get_essid (nm_device_get_best_ap (data->active_device)));
+                       syslog( LOG_DEBUG, "Device's best ap now '%s'", nm_ap_get_essid (nm_device_get_best_ap (data->active_device)));
                }
                handled = TRUE;
        }
@@ -1161,7 +1161,7 @@ static DBusHandlerResult nm_dbus_nm_message_handler (DBusConnection *connection,
        method = dbus_message_get_member (message);
        path = dbus_message_get_path (message);
 
-       /* NM_DEBUG_PRINT_2 ("nm_dbus_nm_message_handler() got method %s for path %s\n", method, path); /**/
+       /* syslog (LOG_DEBUG, "nm_dbus_nm_message_handler() got method %s for path %s", method, path); /**/
 
        if (strcmp ("getActiveDevice", method) == 0)
                reply_message = nm_dbus_nm_get_active_device (connection, message, data);
@@ -1183,7 +1183,7 @@ static DBusHandlerResult nm_dbus_nm_message_handler (DBusConnection *connection,
 
                                if ((ap = nm_ap_list_get_ap_by_essid (nm_device_ap_list_get (data->active_device), network)))
                                {
-fprintf (stderr, "Forcing AP '%s'\n", nm_ap_get_essid (ap));
+                                       syslog (LOG_DEBUG, "Forcing AP '%s'", nm_ap_get_essid (ap));
                                        nm_device_freeze_best_ap (data->active_device);
                                        nm_device_set_best_ap (data->active_device, ap);
                                        nm_data_set_state_modified (data, TRUE);
@@ -1256,7 +1256,7 @@ static DBusHandlerResult nm_dbus_devices_message_handler (DBusConnection *connec
        method = dbus_message_get_member (message);
        path = dbus_message_get_path (message);
 
-       /*NM_DEBUG_PRINT_2 ("nm_dbus_devices_message_handler() got method %s for path %s\n", method, path);*/
+       /*syslog (LOG_DEBUG, "nm_dbus_devices_message_handler() got method %s for path %s", method, path);*/
 
        if ((reply_message = nm_dbus_devices_handle_request (connection, data, message, path, method)))
        {
@@ -1318,7 +1318,7 @@ DBusConnection *nm_dbus_init (NMData *data)
        connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
        if (connection == NULL)
        {
-               NM_DEBUG_PRINT ("nm_dbus_init() could not get the system bus.  Make sure the message bus daemon is running?\n");
+               syslog (LOG_ERR, "nm_dbus_init() could not get the system bus.  Make sure the message bus daemon is running?");
                return (NULL);
        }
 
@@ -1328,14 +1328,14 @@ DBusConnection *nm_dbus_init (NMData *data)
        success = dbus_connection_register_object_path (connection, NM_DBUS_PATH, &nm_vtable, data);
        if (!success)
        {
-               NM_DEBUG_PRINT ("nm_dbus_init() could not register a handler for NetworkManager.  Not enough memory?\n");
+               syslog (LOG_ERR, "nm_dbus_init() could not register a handler for NetworkManager.  Not enough memory?");
                return (NULL);
        }
 
        success = dbus_connection_register_fallback (connection, NM_DBUS_PATH_DEVICES, &devices_vtable, data);
        if (!success)
        {
-               NM_DEBUG_PRINT ("nm_dbus_init() could not register a handler for NetworkManager devices.  Not enough memory?\n");
+               syslog (LOG_ERR, "nm_dbus_init() could not register a handler for NetworkManager devices.  Not enough memory?");
                return (NULL);
        }
 
@@ -1358,7 +1358,7 @@ DBusConnection *nm_dbus_init (NMData *data)
        dbus_bus_acquire_service (connection, NM_DBUS_SERVICE, 0, &dbus_error);
        if (dbus_error_is_set (&dbus_error))
        {
-               NM_DEBUG_PRINT_1 ("nm_dbus_init() could not acquire its service.  dbus_bus_acquire_service() says: '%s'\n", dbus_error.message);
+               syslog (LOG_ERR, "nm_dbus_init() could not acquire its service.  dbus_bus_acquire_service() says: '%s'", dbus_error.message);
                return (NULL);
        }
 
index 7b42f8f..2878147 100644 (file)
@@ -233,7 +233,7 @@ NMDevice *nm_device_new (const char *iface, NMData *app_data)
        dev = g_new0 (NMDevice, 1);
        if (!dev)
        {
-               NM_DEBUG_PRINT("nm_device_new() could not allocate a new device...  Not enough memory?\n");
+               syslog (LOG_ERR, "nm_device_new() could not allocate a new device...  Not enough memory?");
                return (NULL);
        }
 
@@ -514,7 +514,7 @@ char * nm_device_get_essid (NMDevice *dev)
                        dev->options.wireless.cur_essid = g_strdup (essid);
                }
                else
-                       NM_DEBUG_PRINT_2 ("nm_device_get_essid(): error setting ESSID for device %s.  errno = %d\n", nm_device_get_iface (dev), errno);
+                       syslog (LOG_ERR, "nm_device_get_essid(): error setting ESSID for device %s.  errno = %d", nm_device_get_iface (dev), errno);
 
                close (iwlib_socket);
        }
@@ -556,7 +556,7 @@ void nm_device_set_essid (NMDevice *dev, const char *essid)
        
                err = iw_set_ext (iwlib_socket, nm_device_get_iface (dev), SIOCSIWESSID, &wreq);
                if (err == -1)
-                       NM_DEBUG_PRINT_2 ("nm_device_set_essid(): error setting ESSID for device %s.  errno = %d\n", nm_device_get_iface (dev), errno);
+                       syslog (LOG_ERR, "nm_device_set_essid(): error setting ESSID for device %s.  errno = %d", nm_device_get_iface (dev), errno);
 
                close (iwlib_socket);
        }
@@ -645,11 +645,11 @@ void nm_device_set_wep_key (NMDevice *dev, const char *wep_key)
                {
                        err = iw_set_ext (iwlib_socket, nm_device_get_iface (dev), SIOCSIWENCODE, &wreq);
                        if (err == -1)
-                               NM_DEBUG_PRINT_2 ("nm_device_set_wep_key(): error setting key for device %s.  errno = %d\n", nm_device_get_iface (dev), errno);
+                               syslog (LOG_ERR, "nm_device_set_wep_key(): error setting key for device %s.  errno = %d", nm_device_get_iface (dev), errno);
                }
 
                close (iwlib_socket);
-       } else NM_DEBUG_PRINT ("nm_device_set_wep_key(): could not get wireless control socket.\n");
+       } else syslog (LOG_ERR, "nm_device_set_wep_key(): could not get wireless control socket.");
 }
 
 
@@ -745,11 +745,11 @@ static void nm_device_set_up_down (NMDevice *dev, gboolean up)
                        ifr.ifr_flags |= IFF_UP & flags;
                        err = ioctl (iface_fd, SIOCSIFFLAGS, &ifr);
                        if (err)
-                               NM_DEBUG_PRINT_3 ("nm_device_set_up_down() could not bring device %s %s.  errno = %d\n", nm_device_get_iface (dev), (up ? "up" : "down"), errno );
+                               syslog (LOG_ERR, "nm_device_set_up_down() could not bring device %s %s.  errno = %d", nm_device_get_iface (dev), (up ? "up" : "down"), errno );
                }
        }
        else
-               NM_DEBUG_PRINT_2 ("nm_device_set_up_down() could not get flags for device %s.  errno = %d\n", nm_device_get_iface (dev), errno );
+               syslog (LOG_ERR, "nm_device_set_up_down() could not get flags for device %s.  errno = %d", nm_device_get_iface (dev), errno );
 
        close (iface_fd);
 }
@@ -792,7 +792,7 @@ gboolean nm_device_is_up (NMDevice *dev)
        if (!err)
                return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
 
-       NM_DEBUG_PRINT_2 ("nm_device_is_up() could not get flags for device %s.  errno = %d\n", nm_device_get_iface (dev), errno );
+       syslog (LOG_ERR, "nm_device_is_up() could not get flags for device %s.  errno = %d", nm_device_get_iface (dev), errno );
        return (FALSE);
 }
 
@@ -825,7 +825,7 @@ gboolean nm_device_activation_begin (NMDevice *dev)
 
        if (!g_thread_create (nm_device_activation_worker, dev, FALSE, &error))
        {
-               NM_DEBUG_PRINT ("nm_device_activation_begin(): could not create activation worker thread.\n");
+               syslog (LOG_CRIT, "nm_device_activation_begin(): could not create activation worker thread.");
                return (FALSE);
        }
 
@@ -868,7 +868,7 @@ static gboolean nm_device_activate_wireless (NMDevice *dev)
                nm_device_bring_down (dev);
                nm_device_set_essid (dev, nm_ap_get_essid (best_ap));
 
-               NM_DEBUG_PRINT_2 ("nm_device_wireless_activate(%s) using essid '%s'\n", nm_device_get_iface (dev), nm_ap_get_essid (best_ap));
+               syslog (LOG_INFO, "nm_device_wireless_activate(%s) using essid '%s'", nm_device_get_iface (dev), nm_ap_get_essid (best_ap));
 
                /* Bring the device up */
                if (!nm_device_is_up (dev));
@@ -902,7 +902,7 @@ static gpointer nm_device_activation_worker (gpointer user_data)
        g_return_val_if_fail (dev  != NULL, NULL);
        g_return_val_if_fail (dev->app_data != NULL, NULL);
 
-fprintf( stderr, "nm_device_activation_worker (%s) started...\n", nm_device_get_iface (dev));
+       syslog( LOG_DEBUG, "nm_device_activation_worker (%s) started...", nm_device_get_iface (dev));
        dev->activating = TRUE;
 
        /* If its a wireless device, set the ESSID and WEP key */
@@ -935,13 +935,13 @@ fprintf( stderr, "nm_device_activation_worker (%s) started...\n", nm_device_get_
                                        /* If we were told to quit activation, stop the thread and return */
                                        if (dev->quit_activation)
                                        {
-fprintf( stderr, "nm_device_activation_worker(%s): activation canceled 1\n", nm_device_get_iface (dev));
+                                               syslog( LOG_DEBUG, "nm_device_activation_worker(%s): activation canceled 1", nm_device_get_iface (dev));
                                                dev->just_activated = FALSE;
                                                nm_device_unref (dev);
                                                return (NULL);
                                        }
 
-fprintf (stderr, "nm_device_activation_worker(%s): user key received!\n", nm_device_get_iface (dev));
+                                       syslog (LOG_DEBUG, "nm_device_activation_worker(%s): user key received!", nm_device_get_iface (dev));
                                }
 
                                nm_device_activate_wireless (dev);
@@ -952,7 +952,7 @@ fprintf (stderr, "nm_device_activation_worker(%s): user key received!\n", nm_dev
                        /* If we were told to quit activation, stop the thread and return */
                        if (dev->quit_activation)
                        {
-fprintf( stderr, "nm_device_activation_worker(%s): activation canceled 1.5\n", nm_device_get_iface (dev));
+                               syslog( LOG_DEBUG, "nm_device_activation_worker(%s): activation canceled 1.5", nm_device_get_iface (dev));
                                dev->just_activated = FALSE;
                                nm_device_unref (dev);
                                return (NULL);
@@ -1027,7 +1027,7 @@ fprintf( stderr, "nm_device_activation_worker(%s): activation canceled 1.5\n", n
                /* If we were told to quit activation, stop the thread and return */
                if (dev->quit_activation)
                {
-fprintf( stderr, "nm_device_activation_worker(%s): activation canceled 2\n", nm_device_get_iface (dev));
+                       syslog( LOG_DEBUG, "nm_device_activation_worker(%s): activation canceled 2", nm_device_get_iface (dev));
                        dev->just_activated = FALSE;
                        nm_device_unref (dev);
                        return (NULL);
@@ -1040,14 +1040,14 @@ fprintf( stderr, "nm_device_activation_worker(%s): activation canceled 2\n", nm_
        /* If we were told to quit activation, stop the thread and return */
        if (dev->quit_activation)
        {
-fprintf( stderr, "nm_device_activation_worker(%s): activation canceled 3\n", nm_device_get_iface (dev));
+               syslog( LOG_DEBUG, "nm_device_activation_worker(%s): activation canceled 3", nm_device_get_iface (dev));
                dev->just_activated = FALSE;
                nm_device_unref (dev);
                return (NULL);
        }
 
        dev->just_activated = TRUE;
-fprintf( stderr, "nm_device_activation_worker(%s): device activated\n", nm_device_get_iface (dev));
+       syslog( LOG_DEBUG, "nm_device_activation_worker(%s): device activated", nm_device_get_iface (dev));
        nm_device_update_ip4_address (dev);
 
        dev->activating = FALSE;
@@ -1101,7 +1101,7 @@ void nm_device_activation_cancel (NMDevice *dev)
 {
        g_return_if_fail (dev != NULL);
 
-fprintf( stderr, "nm_device_activation_cancel(%s): canceled\n", nm_device_get_iface (dev));
+       syslog( LOG_DEBUG, "nm_device_activation_cancel(%s): canceled", nm_device_get_iface (dev));
        dev->quit_activation = TRUE;
 }
 
@@ -1607,7 +1607,7 @@ static void nm_device_do_normal_scan (NMDevice *dev)
                nm_device_update_best_ap (dev);
        }
        else
-               NM_DEBUG_PRINT_1 ("nm_device_do_normal_scan() could not get a control socket for the wireless card %s.\n", nm_device_get_iface (dev) );
+               syslog (LOG_ERR, "nm_device_do_normal_scan() could not get a control socket for the wireless card %s.", nm_device_get_iface (dev) );
 }
 
 
@@ -1675,7 +1675,7 @@ static void nm_device_do_pseudo_scan (NMDevice *dev)
 
                if (valid)
                {
-                       NM_DEBUG_PRINT_2("%s: setting AP '%s' best\n", nm_device_get_iface (dev), nm_ap_get_essid (ap));
+                       syslog(LOG_INFO, "%s: setting AP '%s' best", nm_device_get_iface (dev), nm_ap_get_essid (ap));
 
                        nm_device_set_best_ap (dev, ap);
                        nm_data_set_state_modified (dev->app_data, TRUE);
@@ -1746,7 +1746,7 @@ static guint16 mdio_read (int sockfd, struct ifreq *ifr, int location, gboolean
        data[1] = location;
        if (ioctl (sockfd, new_ioctl_nums ? 0x8948 : SIOCDEVPRIVATE + 1, ifr) < 0)
        {
-               NM_DEBUG_PRINT_2("SIOCGMIIREG on %s failed: %s\n", ifr->ifr_name, strerror (errno));
+               syslog(LOG_ERR, "SIOCGMIIREG on %s failed: %s", ifr->ifr_name, strerror (errno));
                return -1;
        }
        return data[3];
@@ -1763,7 +1763,7 @@ static gboolean mii_get_link (NMDevice *dev)
        sockfd = socket (AF_INET, SOCK_DGRAM, 0);
        if (sockfd < 0)
        {
-               NM_DEBUG_PRINT_2("cannot open socket on interface %s; errno=%d", nm_device_get_iface (dev), errno);
+               syslog (LOG_ERR, "cannot open socket on interface %s; errno=%d", nm_device_get_iface (dev), errno);
                return (FALSE);
        }
 
@@ -1774,7 +1774,7 @@ static gboolean mii_get_link (NMDevice *dev)
                new_ioctl_nums = FALSE;
        else
        {
-               NM_DEBUG_PRINT_2("SIOCGMIIPHY on %s failed: %s", ifr.ifr_name, strerror (errno));
+               syslog (LOG_ERR, "SIOCGMIIPHY on %s failed: %s", ifr.ifr_name, strerror (errno));
                close (sockfd);
                return (FALSE);
        }
index e05c73b..7bb1379 100644 (file)
@@ -126,8 +126,8 @@ NMDevice * nm_policy_get_best_device (NMData *data)
                element = g_slist_next (element);
        }
 
-       NM_DEBUG_PRINT_1 ("Best wired device = %s\n", best_wired_dev ? nm_device_get_iface (best_wired_dev) : "(null)");
-       NM_DEBUG_PRINT_2 ("Best wireless device = %s  (%s)\n", best_wireless_dev ? nm_device_get_iface (best_wireless_dev) : "(null)",
+       syslog (LOG_NOTICE, "Best wired device = %s", best_wired_dev ? nm_device_get_iface (best_wired_dev) : "(null)");
+       syslog (LOG_NOTICE, "Best wireless device = %s  (%s)", best_wireless_dev ? nm_device_get_iface (best_wireless_dev) : "(null)",
                        best_wireless_dev ? nm_device_get_essid (best_wireless_dev) : "null" );
 
        if (best_wireless_dev || best_wired_dev)
@@ -209,7 +209,7 @@ gboolean nm_state_modification_monitor (gpointer user_data)
                                || (    best_dev && nm_device_is_wireless (best_dev) && !nm_device_activating (best_dev)
                                        && (nm_device_need_ap_switch (best_dev) || (nm_device_get_ip4_address (best_dev) == 0))))
                        {
-                               NM_DEBUG_PRINT_1 ("nm_state_modification_monitor(): beginning activation for device '%s'\n", best_dev ? nm_device_get_iface (best_dev) : "(null)");
+                               syslog (LOG_INFO, "nm_state_modification_monitor(): beginning activation for device '%s'", best_dev ? nm_device_get_iface (best_dev) : "(null)");
 
                                /* Deactivate the old device */
                                if (data->active_device)
@@ -228,12 +228,12 @@ gboolean nm_state_modification_monitor (gpointer user_data)
                        nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
                }
                else
-                       NM_DEBUG_PRINT("nm_state_modification_monitor() could not get device list mutex\n");
+                       syslog( LOG_ERR, "nm_state_modification_monitor() could not get device list mutex");
        }
        else if (data->active_device && nm_device_just_activated (data->active_device))
        {
                nm_dbus_signal_device_now_active (data->dbus_connection, data->active_device);
-               NM_DEBUG_PRINT_1 ("nm_state_modification_monitor() activated device %s\n", nm_device_get_iface (data->active_device));
+               syslog (LOG_INFO, "nm_state_modification_monitor() activated device %s", nm_device_get_iface (data->active_device));
        }
 
        return (TRUE);
@@ -368,7 +368,7 @@ void nm_policy_update_allowed_access_points (NMData *data)
 
                                        data->allowed_ap_list = g_slist_append (data->allowed_ap_list, ap);
                                        /*
-                                       NM_DEBUG_PRINT_3( "FOUND: allowed ap, prio=%d  essid=%s  wep_key=%s\n", prio_num, essid, wep_key );
+                                       syslog( LOG_DEBUG, "FOUND: allowed ap, prio=%d  essid=%s  wep_key=%s", prio_num, essid, wep_key );
                                        */
                                }
                        }
@@ -376,11 +376,11 @@ void nm_policy_update_allowed_access_points       (NMData *data)
                        fclose (ap_file);
                }
                else
-                       NM_DEBUG_PRINT_2( "nm_policy_update_allowed_access_points() could not open allowed ap list file %s.  errno %d\n", NM_ALLOWED_AP_FILE, errno );
+                       syslog( LOG_WARNING, "nm_policy_update_allowed_access_points() could not open allowed ap list file %s.  errno %d", NM_ALLOWED_AP_FILE, errno );
        
                nm_unlock_mutex (data->allowed_ap_list_mutex, __FUNCTION__);
        }
        else
-               NM_DEBUG_PRINT( "nm_policy_update_allowed_access_points() could not lock allowed ap list mutex\n" );
+               syslog( LOG_ERR, "nm_policy_update_allowed_access_points() could not lock allowed ap list mutex" );
 }
 #endif
index 04c5612..ea65095 100644 (file)
@@ -52,7 +52,7 @@ gboolean nm_try_acquire_mutex (GMutex *mutex, const char *func)
                if (g_mutex_trylock (mutex))
                {
 #ifdef LOCKING_DEBUG   
-                       if (func) NM_DEBUG_PRINT_2 ("MUTEX: %s got mutex 0x%X\n", func, mutex);
+                       if (func) syslog (LOG_DEBUG, "MUTEX: %s got mutex 0x%X", func, mutex);
 #endif
                        return (TRUE);
                }
@@ -75,7 +75,7 @@ void nm_unlock_mutex (GMutex *mutex, const char *func)
        g_return_if_fail (mutex != NULL);
 
 #ifdef LOCKING_DEBUG   
-       if (func) NM_DEBUG_PRINT_2 ("MUTEX: %s released mutex 0x%X\n", func, mutex);
+       if (func) syslog (LOG_DEBUG, "MUTEX: %s released mutex 0x%X", func, mutex);
 #endif
 
        g_mutex_unlock (mutex);
@@ -123,7 +123,7 @@ int nm_get_network_control_socket (void)
        if (fd >= 0)
                return (fd);
 
-       NM_DEBUG_PRINT ("nm_get_network_control_socket() could not get network control socket.\n");
+       syslog (LOG_ERR, "nm_get_network_control_socket() could not get network control socket.");
        return (-1);
 }
 
index 7fb2804..e08bea3 100644 (file)
 
 #include <glib.h>
 #include <stdio.h>
+#include <syslog.h>
 #include <net/ethernet.h>
 #include <iwlib.h>
 
 #include "NetworkManager.h"
 #include "NetworkManagerDevice.h"
 
-#define NM_DEBUG_PRINT(s)                              { if (debug) fprintf(stderr, s); }
-#define NM_DEBUG_PRINT_1(s, a)                 { if (debug) fprintf(stderr, s, a); }
-#define NM_DEBUG_PRINT_2(s, a, b)                      { if (debug) fprintf(stderr, s, a, b); }
-#define NM_DEBUG_PRINT_3(s, a, b, c)           { if (debug) fprintf(stderr, s, a, b, c); }
-#define NM_DEBUG_PRINT_4(s, a, b, c, d)                { if (debug) fprintf(stderr, s, a, b, c, d); }
-
-
 gboolean               nm_try_acquire_mutex                    (GMutex *mutex, const char *func);
 void                   nm_unlock_mutex                         (GMutex *mutex, const char *func);
 
index dcef515..ac5b30e 100644 (file)
@@ -100,7 +100,7 @@ gboolean nm_wireless_scan_monitor (gpointer user_data)
                nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
        }
        else
-               NM_DEBUG_PRINT( "nm_wireless_scan_monitor() could not acquire device list mutex.\n" );
+               syslog( LOG_ERR, "nm_wireless_scan_monitor() could not acquire device list mutex." );
        
        return (TRUE);
 }