From 32daa1d99a9fb7a073bea26bbac6bb927b70a5e4 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Wed, 8 Mar 2006 18:33:44 +0000 Subject: [PATCH] 2006-03-06 Robert Love * src/NetworkManagerSystem.h, src/nm-device.c, NetworkManagerDebian.c, NetworkManagerRedHat.c, NetworkManagerGentoo.c, NetworkManagerSlackware.c: Pass nm_system_device_get_system_config() a second argument, NMData. * src/nm-ap-security.h, src/nm-ap-security.c: Export nm_ap_security_new. * src/backends/NetworkManagerSuSE.c: Add wireless networks from ifcfg-* config files as trusted. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1564 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 10 +++++ configure.in | 2 +- src/NetworkManagerSystem.h | 3 +- src/backends/NetworkManagerDebian.c | 2 +- src/backends/NetworkManagerGentoo.c | 2 +- src/backends/NetworkManagerRedHat.c | 2 +- src/backends/NetworkManagerSlackware.c | 2 +- src/backends/NetworkManagerSuSE.c | 53 +++++++++++++++++++++++++- src/nm-ap-security.c | 2 +- src/nm-ap-security.h | 2 + src/nm-device.c | 2 +- 11 files changed, 72 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50247fbe2..08eb3ff56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-03-06 Robert Love + + * src/NetworkManagerSystem.h, src/nm-device.c, NetworkManagerDebian.c, + NetworkManagerRedHat.c, NetworkManagerGentoo.c, + NetworkManagerSlackware.c: Pass nm_system_device_get_system_config() + a second argument, NMData. + * src/nm-ap-security.h, src/nm-ap-security.c: Export nm_ap_security_new. + * src/backends/NetworkManagerSuSE.c: Add wireless networks from ifcfg-* + config files as trusted. + 2006-03-06 Robert Love * gnome/applet/Makefile.am: Define AUTOSTARTDIR. diff --git a/configure.in b/configure.in index 335cc8ddc..41cb68878 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ AC_PREREQ(2.52) -AC_INIT(NetworkManager, 0.6.0, dcbw@redhat.com, NetworkManager) +AC_INIT(NetworkManager, 0.6.0cvs20060308, dcbw@redhat.com, NetworkManager) AM_INIT_AUTOMAKE([subdir-objects]) AM_MAINTAINER_MODE diff --git a/src/NetworkManagerSystem.h b/src/NetworkManagerSystem.h index 82c83c4d2..86963edc6 100644 --- a/src/NetworkManagerSystem.h +++ b/src/NetworkManagerSystem.h @@ -27,6 +27,7 @@ #include "nm-ip4-config.h" #include "nm-named-manager.h" +struct NMData; /* Prototypes for system/distribution dependent functions, * implemented in the backend files in backends/ directory @@ -58,7 +59,7 @@ void nm_system_update_dns (void); void nm_system_restart_mdns_responder (void); void nm_system_device_add_ip6_link_address (NMDevice *dev); -void * nm_system_device_get_system_config (NMDevice *dev); +void * nm_system_device_get_system_config (NMDevice *dev, struct NMData *data); void nm_system_device_free_system_config (NMDevice *dev, void *system_config_data); NMIP4Config * nm_system_device_new_ip4_system_config (NMDevice *dev); diff --git a/src/backends/NetworkManagerDebian.c b/src/backends/NetworkManagerDebian.c index db90fad3d..63cfafb63 100644 --- a/src/backends/NetworkManagerDebian.c +++ b/src/backends/NetworkManagerDebian.c @@ -384,7 +384,7 @@ out: * info before setting stuff too. * */ -void* nm_system_device_get_system_config (NMDevice *dev) +void* nm_system_device_get_system_config (NMDevice *dev, NMData *app_data) { DebSystemConfigData * sys_data = NULL; if_block *curr_device; diff --git a/src/backends/NetworkManagerGentoo.c b/src/backends/NetworkManagerGentoo.c index c77855b56..338a8e50f 100644 --- a/src/backends/NetworkManagerGentoo.c +++ b/src/backends/NetworkManagerGentoo.c @@ -300,7 +300,7 @@ typedef struct GentooSystemConfigData * info before setting stuff too. * */ -void *nm_system_device_get_system_config (NMDevice *dev) +void *nm_system_device_get_system_config (NMDevice *dev, NMData *app_data) { char *cfg_file_path = NULL; FILE *file = NULL; diff --git a/src/backends/NetworkManagerRedHat.c b/src/backends/NetworkManagerRedHat.c index 2676ca51f..c6cba7d8a 100644 --- a/src/backends/NetworkManagerRedHat.c +++ b/src/backends/NetworkManagerRedHat.c @@ -454,7 +454,7 @@ out: * Read in the config file for a device. * */ -void *nm_system_device_get_system_config (NMDevice *dev) +void *nm_system_device_get_system_config (NMDevice *dev, NMData *app_data) { char * cfg_file_path = NULL; shvarFile * file; diff --git a/src/backends/NetworkManagerSlackware.c b/src/backends/NetworkManagerSlackware.c index 91dbb0aa8..ae7816a0c 100644 --- a/src/backends/NetworkManagerSlackware.c +++ b/src/backends/NetworkManagerSlackware.c @@ -139,7 +139,7 @@ gboolean nm_system_device_setup_static_ip4_config (NMDevice *dev) * info before setting stuff too. * */ -void *nm_system_device_get_system_config (NMDevice *dev) +void *nm_system_device_get_system_config (NMDevice *dev, NMData *app_data) { return NULL; } diff --git a/src/backends/NetworkManagerSuSE.c b/src/backends/NetworkManagerSuSE.c index 43cc79e63..4cc1bfcc0 100644 --- a/src/backends/NetworkManagerSuSE.c +++ b/src/backends/NetworkManagerSuSE.c @@ -31,7 +31,11 @@ #include "NetworkManagerSystem.h" #include "NetworkManagerUtils.h" +#include "NetworkManagerMain.h" #include "nm-device.h" +#include "nm-ap-security.h" +#include "NetworkManagerAPList.h" +#include "NetworkManagerPolicy.h" #include "nm-device-802-3-ethernet.h" #include "nm-device-802-11-wireless.h" #include "NetworkManagerDialup.h" @@ -428,7 +432,7 @@ out: * SuSE stores this information in /etc/sysconfig/network/ifcfg-*- * */ -void *nm_system_device_get_system_config (NMDevice *dev) +void *nm_system_device_get_system_config (NMDevice *dev, NMData *app_data) { char *cfg_file_path = NULL; char mac[18]; @@ -507,7 +511,52 @@ found: sys_data->system_disabled = TRUE; } free (buf); - } + } + + if ((buf = svGetValue (file, "WIRELESS_ESSID"))) + { + NMAccessPoint * ap; + NMAccessPoint * list_ap; + NMAPSecurity * security; + GTimeVal * timestamp; + + ap = nm_ap_new (); + security = nm_ap_security_new (IW_AUTH_CIPHER_NONE); + + nm_ap_set_essid (ap, buf); + nm_ap_set_security (ap, security); + g_object_unref (G_OBJECT (security)); /* set_security copies the object */ + + timestamp = g_malloc0 (sizeof (GTimeVal)); + timestamp->tv_sec = time (NULL); + timestamp->tv_usec = 0; + nm_ap_set_timestamp (ap, timestamp); + g_free (timestamp); + + nm_ap_set_trusted (ap, TRUE); + + if ((list_ap = nm_ap_list_get_ap_by_essid (app_data->allowed_ap_list, buf))) + { + nm_ap_set_essid (list_ap, nm_ap_get_essid (ap)); + nm_ap_set_timestamp (list_ap, nm_ap_get_timestamp (ap)); + nm_ap_set_trusted (list_ap, nm_ap_get_trusted (ap)); + nm_ap_set_security (list_ap, nm_ap_get_security (ap)); + nm_ap_set_user_addresses (list_ap, nm_ap_get_user_addresses (ap)); + } + else + { + /* New AP, just add it to the list */ + nm_ap_list_append_ap (app_data->allowed_ap_list, ap); + } + nm_ap_unref (ap); + + nm_debug ("Adding '%s' to the list of trusted networks", buf); + + /* Ensure all devices get new information copied into their device lists */ + nm_policy_schedule_device_ap_lists_update_from_allowed (app_data); + + free (buf); + } sys_data->config = nm_ip4_config_new (); diff --git a/src/nm-ap-security.c b/src/nm-ap-security.c index ffeabe14e..c9161b3da 100644 --- a/src/nm-ap-security.c +++ b/src/nm-ap-security.c @@ -45,7 +45,7 @@ struct _NMAPSecurityPrivate gboolean dispose_has_run; }; -static NMAPSecurity * +NMAPSecurity * nm_ap_security_new (int we_cipher) { NMAPSecurity * security; diff --git a/src/nm-ap-security.h b/src/nm-ap-security.h index a2344b74e..7d5f0f9c0 100644 --- a/src/nm-ap-security.h +++ b/src/nm-ap-security.h @@ -77,6 +77,8 @@ GType nm_ap_security_get_type (void); NMAPSecurity * nm_ap_security_new_copy (NMAPSecurity *self); +NMAPSecurity * nm_ap_security_new (int we_cipher); + NMAPSecurity * nm_ap_security_new_deserialize (DBusMessageIter *iter); NMAPSecurity * nm_ap_security_new_from_ap (struct NMAccessPoint *ap); diff --git a/src/nm-device.c b/src/nm-device.c index 3fac32eea..bb729d68e 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -196,7 +196,7 @@ nm_device_new (const char *iface, nm_device_802_11_wireless_set_address (NM_DEVICE_802_11_WIRELESS (dev)); /* Grab IP config data for this device from the system configuration files */ - dev->priv->system_config_data = nm_system_device_get_system_config (dev); + dev->priv->system_config_data = nm_system_device_get_system_config (dev, app_data); dev->priv->use_dhcp = nm_system_device_get_use_dhcp (dev); /* Allow distributions to flag devices as disabled */