~ubuntu-branches/debian/sid/network-manager/sid

« back to all changes in this revision

Viewing changes to src/settings/nm-settings.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-11-03 21:32:50 UTC
  • mfrom: (1.4.6)
  • Revision ID: package-import@ubuntu.com-20111103213250-w49ucjmux3hbwnta
Tags: 0.9.1.95-1
* New upstream release (0.9.2 rc1).
  - Fix connection sharing with newer iptables versions. (Closes: #638995)
  - Fix handling of numeric SSIDs in the keyfile plugin. (Closes: #642912)
* debian/watch: Track .xz tarballs.
* debian/libnm-util2.symbols: Add new symbols for libnm-util.
* debian/patches/04-dont-update-routing-and-dns-for-unmanaged-devices.patch
  - Avoid blowing away existing routes and resolv.conf if NM never managed
    any devices. (Closes: #546893, #624159, #637005, #641904)
* debian/control: Add Build-Depends on libglib2.0-doc for proper
  cross-references in the gtk-doc API documentation.
* Enable default hardening options from dpkg-buildflags.
  - Use buildflags.mk snippet in debian/rules.
  - Add Build-Depends on dpkg-dev (>= 1.6.1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include <unistd.h>
29
29
#include <string.h>
 
30
#include <ctype.h>
30
31
#include <gmodule.h>
31
32
#include <net/ethernet.h>
32
33
#include <netinet/ether.h>
546
547
}
547
548
 
548
549
static gboolean
549
 
load_plugins (NMSettings *self, const char *plugins, GError **error)
 
550
load_plugins (NMSettings *self, const char **plugins, GError **error)
550
551
{
551
552
        GSList *list = NULL;
552
 
        char **plist;
553
 
        char **iter;
 
553
        const char **iter;
554
554
        gboolean success = TRUE;
555
555
 
556
 
        plist = g_strsplit (plugins, ",", 0);
557
 
        if (!plist)
558
 
                return FALSE;
559
 
 
560
 
        for (iter = plist; *iter; iter++) {
 
556
        for (iter = plugins; *iter; iter++) {
561
557
                GModule *plugin;
562
558
                char *full_name, *path;
563
 
                const char *pname = g_strstrip (*iter);
 
559
                const char *pname = *iter;
564
560
                GObject *obj;
565
561
                GObject * (*factory_func) (void);
566
562
 
 
563
                /* strip leading spaces */
 
564
                while (isblank (*pname))
 
565
                        pname++;
 
566
 
567
567
                /* keyfile plugin built in now */
568
568
                if (!strcmp (pname, "keyfile"))
569
569
                        continue;
616
616
                list = g_slist_append (list, obj);
617
617
        }
618
618
 
619
 
        g_strfreev (plist);
620
 
 
621
619
        g_slist_foreach (list, (GFunc) g_object_unref, NULL);
622
620
        g_slist_free (list);
623
621
 
634
632
{
635
633
        GObject *connection = G_OBJECT (obj);
636
634
        guint id;
 
635
 
637
636
        g_object_ref (connection);
638
637
 
639
638
        /* Disconnect signal handlers, as plugins might still keep references
653
652
        if (id)
654
653
                g_signal_handler_disconnect (connection, id);
655
654
 
656
 
        /* Forget about the connection internall */
 
655
        /* Forget about the connection internally */
657
656
        g_hash_table_remove (NM_SETTINGS_GET_PRIVATE (user_data)->connections,
658
657
                             (gpointer) nm_connection_get_path (NM_CONNECTION (connection)));
659
658
 
840
839
        }
841
840
}
842
841
 
843
 
// TODO it seems that this is only ever used to remove a
844
 
// NMDefaultWiredConnection, and it probably needs to stay that way. So this
845
 
// *needs* a better name!
846
842
static void
847
843
remove_default_wired_connection (NMSettings *self,
848
844
                                 NMSettingsConnection *connection,
852
848
        const char *path = nm_connection_get_path (NM_CONNECTION (connection));
853
849
 
854
850
        if (g_hash_table_lookup (priv->connections, path)) {
855
 
                g_signal_emit_by_name (G_OBJECT (connection), NM_SETTINGS_CONNECTION_REMOVED);
 
851
                if (do_signal)
 
852
                        g_signal_emit_by_name (G_OBJECT (connection), NM_SETTINGS_CONNECTION_REMOVED);
856
853
                g_hash_table_remove (priv->connections, path);
857
854
        }
858
855
}
1378
1375
{
1379
1376
}
1380
1377
 
1381
 
static gboolean
 
1378
static void
1382
1379
default_wired_try_update (NMDefaultWiredConnection *wired,
1383
1380
                          NMSettings *self)
1384
1381
{
1390
1387
         * persistent storage.
1391
1388
         */
1392
1389
 
 
1390
        /* Keep it alive over removal so we can re-add it if we need to */
 
1391
        g_object_ref (wired);
 
1392
 
1393
1393
        id = nm_connection_get_id (NM_CONNECTION (wired));
1394
1394
        g_assert (id);
1395
1395
 
1402
1402
                                   DEFAULT_WIRED_TAG,
1403
1403
                                   NULL);
1404
1404
                nm_log_info (LOGD_SETTINGS, "Saved default wired connection '%s' to persistent storage", id);
1405
 
                return FALSE;
 
1405
        } else {
 
1406
                nm_log_warn (LOGD_SETTINGS, "couldn't save default wired connection '%s': %d / %s",
 
1407
                                 id,
 
1408
                                 error ? error->code : -1,
 
1409
                                 (error && error->message) ? error->message : "(unknown)");
 
1410
                g_clear_error (&error);
 
1411
 
 
1412
                /* If there was an error, don't destroy the default wired connection,
 
1413
                 * but add it back to the system settings service. Connection is already
 
1414
                 * exported on the bus, don't export it again, thus do_export == FALSE.
 
1415
                 */
 
1416
                claim_connection (self, NM_SETTINGS_CONNECTION (wired), FALSE);
1406
1417
        }
1407
1418
 
1408
 
        nm_log_warn (LOGD_SETTINGS, "couldn't save default wired connection '%s': %d / %s",
1409
 
                     id,
1410
 
                     error ? error->code : -1,
1411
 
                     (error && error->message) ? error->message : "(unknown)");
1412
 
        g_clear_error (&error);
1413
 
 
1414
 
        /* If there was an error, don't destroy the default wired connection,
1415
 
         * but add it back to the system settings service. Connection is already
1416
 
         * exported on the bus, don't export it again, thus do_export == FALSE.
1417
 
         */
1418
 
        claim_connection (self, NM_SETTINGS_CONNECTION (wired), FALSE);
1419
 
        return TRUE;
 
1419
        g_object_unref (wired);
1420
1420
}
1421
1421
 
1422
1422
void
1492
1492
 
1493
1493
NMSettings *
1494
1494
nm_settings_new (const char *config_file,
1495
 
                 const char *plugins,
 
1495
                 const char **plugins,
1496
1496
                 GError **error)
1497
1497
{
1498
1498
        NMSettings *self;