2008-10-10 Alexander Sack <asac@ubuntu.com>
authorAlexander Sack <asac@ubuntu.com>
Fri, 10 Oct 2008 11:14:26 +0000 (11:14 +0000)
committerDan Williams <dcbw@redhat.com>
Fri, 10 Oct 2008 11:14:26 +0000 (11:14 +0000)
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

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

ChangeLog
system-settings/plugins/ifupdown/plugin.c

index 496a778..7f304aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-10  Alexander Sack  <asac@ubuntu.com>
+
+       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-10  Alexander Sack  <asac@ubuntu.com>
 
        Implement unmanaged mode that will prevent all devices in the
index 8043b74..eddca3f 100644 (file)
 #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
@@ -274,6 +279,8 @@ SCPluginIfupdown_init (NMSystemConfigInterface *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);
@@ -347,6 +354,38 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config,
                }
        }
 
+       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);