Parse nm-system-settings.conf and allow admins to either use managed 
and unmanaged
        mode of the ifupdown system config plugin.


=== modified file 'ChangeLog'
--- a/ChangeLog 2008-10-07 20:43:19 +0000
+++ b/ChangeLog 2008-10-07 20:50:35 +0000
@@ -1,10 +1,20 @@
 2008-10-07  Alexander Sack  <[EMAIL PROTECTED]>
 
+       Parse nm-system-settings.conf and allow admins to either use managed 
and unmanaged
+       mode of the ifupdown system config plugin.
+
+       * system-settings/plugins/ifupdown/plugin.c
+               - (SCPluginIfupdown_init): parse nm-system-settings.conf 
keyfile and set
+                       private unmanage_well_known state field accordingly
+
+
+2008-10-07  Alexander Sack  <[EMAIL PROTECTED]>
+
        Implement unmanaged mode that will prevent all devices in the
        well_known_udis set from being touched by NetworkManager
 
        * system-settings/plugins/ifupdown/plugin.c
                - (typedef struct SCPluginIfupdownPrivate): add gboolean
                        unmanage_well_known field used to turn on/off unmanaged
                        mode
                - (hal_device_added_cb,hal_device_remove_cb): emit 
|unmanaged-devices-changed|

=== modified file 'system-settings/plugins/ifupdown/plugin.c'
--- a/system-settings/plugins/ifupdown/plugin.c 2008-10-07 20:43:19 +0000
+++ b/system-settings/plugins/ifupdown/plugin.c 2008-10-07 20:50:35 +0000
@@ -47,16 +47,21 @@
 #include <sha1.h>
 
 #include <arpa/inet.h>
 
 #define IFUPDOWN_PLUGIN_NAME "ifupdown"
 #define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd.  To report bugs please 
use the NetworkManager mailing list."
 #define IFUPDOWN_SYSTEM_HOSTNAME_FILE "/etc/hostname"
 
+#define IFUPDOWN_SYSTEM_SETTINGS_KEY_FILE SYSCONFDIR 
"/NetworkManager/nm-system-settings.conf"
+#define IFUPDOWN_KEY_FILE_GROUP "ifupdown"
+#define IFUPDOWN_KEY_FILE_KEY_MANAGED "managed"
+#define IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT TRUE
+
 /* #define ALWAYS_UNMANAGE TRUE */
 #ifndef ALWAYS_UNMANAGE
 #      define ALWAYS_UNMANAGE FALSE
 #endif
 
 typedef struct {
 
        DBusGConnection *g_connection;
@@ -269,16 +274,18 @@ hal_device_added_cb2 (gpointer data,
 static void
 SCPluginIfupdown_init (NMSystemConfigInterface *config,
                                   NMSystemConfigHalManager *hal_manager)
 {
        SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config);
        GHashTable *auto_ifaces = g_hash_table_new (g_str_hash, g_str_equal);
        if_block *block = NULL;
        NMInotifyHelper *inotify_helper;
+       GKeyFile* keyfile;
+       GError *error = NULL;
 
        if(!priv->iface_connections)
                priv->iface_connections = g_hash_table_new (g_str_hash, 
g_str_equal);
 
        if(!priv->well_known_udis)
                priv->well_known_udis = g_hash_table_new (g_str_hash, 
g_str_equal);
 
        PLUGIN_PRINT("SCPlugin-Ifupdown", "init!");
@@ -342,16 +349,48 @@ SCPluginIfupdown_init (NMSystemConfigInt
                                                    "autoconnect", TRUE,
                                                    NULL);
                                PLUGIN_PRINT("SCPlugin-Ifupdown", 
"autoconnect");
                        }
                        key_it = key_it -> next;
                }
        }
 
+       priv->unmanage_well_known = IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT;
+       keyfile = g_key_file_new ();
+       if (!g_key_file_load_from_file (keyfile,
+                                                         
IFUPDOWN_SYSTEM_SETTINGS_KEY_FILE,
+                                                         G_KEY_FILE_NONE,
+                                                         &error)) {
+               nm_info ("loading system config file (%s) caused error: %s 
(%d)",
+                           IFUPDOWN_SYSTEM_SETTINGS_KEY_FILE,
+                           error->message,
+                           error->code);
+       } else {
+               gboolean manage_well_known;
+               error = NULL;
+
+               manage_well_known = g_key_file_get_boolean (keyfile,
+                                                                               
    IFUPDOWN_KEY_FILE_GROUP,
+                                                                               
    IFUPDOWN_KEY_FILE_KEY_MANAGED,
+                                                                               
    &error);
+               if (error) {
+                       nm_info ("getting keyfile key '%s' in group '%s' 
failed: %s (%d)",
+                                   IFUPDOWN_KEY_FILE_GROUP,
+                                   IFUPDOWN_KEY_FILE_KEY_MANAGED,
+                                   error->message,
+                                   error->code);
+               } else {
+                       priv->unmanage_well_known = !manage_well_known;
+               }
+       }
+       PLUGIN_PRINT ("SCPluginIfupdown", "management mode: %s", 
priv->unmanage_well_known ? "unmanaged" : "managed");
+       if (keyfile)
+               g_key_file_free (keyfile);
+
        {
                /* init well_known_udis */
                GSList *wired_devices = 
nm_system_config_hal_manager_get_devices_of_type (hal_manager, 
NM_DEVICE_TYPE_ETHERNET);
                GSList *wifi_devices = 
nm_system_config_hal_manager_get_devices_of_type (hal_manager, 
NM_DEVICE_TYPE_WIFI);
                gpointer *user_data;
 
                /* 3g in /etc/network/interfaces? no clue if thats mappable
 



 - Alexander

_______________________________________________
NetworkManager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to