1. 13 Jan, 2015 3 commits
    • Thomas Haller's avatar
      settings: avoid duplicate UUID in settings · 7b807b11
      Thomas Haller authored
      When adding a connection to NMSettings we did not check for
      duplicate connection UUIDs (which could for example happen
      if two different plugins report a conflicting UUID).
      Also, we would not check that an already added connection
      changes it's UUID.
      
      Both could lead to have duplicate connections (by UUID).
      
      Avoid that two ways:
      - when adding a connection to NMSettings, ensure that we don't add
        a conflicting UUID. Otherwise just bail out and do nothing.
      - when modifying a connection that is already added to NMSettings,
        enforce that the UUID cannot change. Otherwise fail with error.
      
      For ifcfg-rh plugin this situation still can happen during reload.
      In this case error out and refuse to update the connection. After
      all, the user configured invalid UUIDs.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1171751
      7b807b11
    • Thomas Haller's avatar
      settings: log connection diffs in replace_settings only where appropriate · e14ea681
      Thomas Haller authored
      Only log connection diffs when we update a connection that we actually
      care about.
      
      Note that most plugin specific connections use
      nm_settings_connection_replace_settings() in their constructor
      to initialize themselves. These occurrences are not interesting
      and spam the logfile.
      e14ea681
    • Thomas Haller's avatar
      settings: no need to check nm_connection_compare() before nm_settings_connection_replace_settings() · 750f01df
      Thomas Haller authored
      nm_settings_connection_replace_settings() does nothing, if there are no changes.
      750f01df
  2. 12 Jan, 2015 3 commits
  3. 09 Jan, 2015 1 commit
  4. 05 Jan, 2015 3 commits
  5. 11 Dec, 2014 2 commits
  6. 07 Nov, 2014 1 commit
  7. 28 Oct, 2014 1 commit
    • Dan Winship's avatar
      libnm-core: add nm-core-types.h, remove cross-includes · b1087908
      Dan Winship authored
      Add nm-core-types.h, typedefing all of the GObject types in
      libnm-core; this is needed so that nm-setting.h can reference
      NMConnection in addition to nm-connection.h referencing NMSetting.
      
      Removing the cross-includes from the various headers causes lots of
      fallout elsewhere. (In particular, nm-utils.h used to include
      nm-connection.h, which included every setting header, so any file that
      included nm-utils.h automatically got most of the rest of libnm-core
      without needing to pay attention to specifics.) Fix this up by
      including nm-core-internal.h from those files that are now missing
      includes.
      b1087908
  8. 22 Oct, 2014 1 commit
    • Dan Winship's avatar
      libnm-core, settings: move NMSettingsError to nm-errors · 3be53899
      Dan Winship authored
      Move the definition of NMSettingsError to nm-errors, register it with
      D-Bus, and verify in the tests that it maps correctly.
      
      Remove a few unused error codes, simplify a few others, and rename
      GENERAL to FAILED and HOSTNAME_INVALID to INVALID_HOSTNAME, for
      consistency.
      3be53899
  9. 12 Oct, 2014 2 commits
    • Thomas Haller's avatar
    • Thomas Haller's avatar
      libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion... · 978724da
      Thomas Haller authored
      libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
      
      When secret providers return the connection hash in GetSecrets(),
      this hash should only contain secrets. However, some providers also
      return non-secret properties.
      
      for_each_secret() iterated over all entries of the @secrets hash
      and triggered the assertion in nm_setting_get_secret_flags() (see
      below).
      
      NM should not assert against user provided input. Change
      nm_setting_get_secret_flags() to silently return FALSE, if the property
      is not a secret.
      
      Indeed, handling of secrets is very different for NMSettingVpn and
      others. Hence nm_setting_get_secret_flags() has only an inconsistent
      behavior and we have to fix all call sites to do the right thing
      (depending on whether we have a VPN setting or not).
      
      Now for_each_secret() checks whether the property is a secret
      without hitting the assertion. Adjust all other calls of
      nm_setting_get_secret_flags(), to anticipate non-secret flags and
      assert/warn where appropriate.
      
      Also, agent_secrets_done_cb() clears now all non-secrets properties
      from the hash, using the new argument @remove_non_secrets when calling
      for_each_secret().
      
        #0  0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
        #1  0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
        #2  0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
        #3  0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
        #4  0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
        #5  0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
            flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
        #6  0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
        #7  0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
        #8  0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
        #9  0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
        #10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
        #11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
        #12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
        #13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
        #14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
        #15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
        #16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644
      Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
      978724da
  10. 29 Sep, 2014 2 commits
  11. 26 Sep, 2014 2 commits
  12. 24 Sep, 2014 3 commits
  13. 18 Sep, 2014 2 commits
    • Dan Winship's avatar
      libnm: port to GDBus · 6793a32a
      Dan Winship authored
      Port libnm-core/libnm to GDBus.
      
      The NetworkManager daemon continues to use dbus-glib; the
      previously-added connection hash/variant conversion methods are now
      moved to NetworkManagerUtils (along with a few other utilities that
      are now only needed by the daemon code).
      6793a32a
    • Dan Winship's avatar
      libnm-core: change connection hash tables to variants in API · acf86f68
      Dan Winship authored
      In preparation for porting to GDBus, make nm_connection_to_dbus(),
      etc, represent connections as GVariants of type 'a{sa{sv}}' rather
      than as GHashTables-of-GHashTables-of-GValues.
      
      This means we're constantly converting back and forth internally, but
      this is just a stepping stone on the way to the full GDBus port, and
      all of that code will go away again later.
      acf86f68
  14. 17 Sep, 2014 1 commit
    • Dan Winship's avatar
      libnm-core: fix up connection deserialize/copy/replace semantics · ad8b1309
      Dan Winship authored
      libnm-util's connection deserializing/copying/replacing functions have
      odd semantics where sometimes they both modify a connection AND return
      an error. libnm-core tried to improve things by guaranteeing that the
      connection would not be modified if the new settings were invalid, but
      this ended up breaking a bunch of places that needed to be able to
      work with invalid connections. So re-fix the functions by reverting
      back to the old semantics, but having return values that clearly
      distinguish whether the connection was modified or not.
      
      For comparison:
      
        - nm_connection_new_from_hash() / nm_simple_connection_new_from_dbus():
      
            - libnm-util: returns a valid connection or NULL.
      
            - OLD libnm-core: returned a valid connection or NULL.
      
            - NEW libnm-core: returns a valid connection or NULL.
      
        - nm_connection_duplicate() / nm_simple_connection_new_clone():
      
            - libnm-util: always succeeds, whether or not the connection is
              valid.
      
            - OLD libnm-core: returned a valid connection or NULL
      
            - NEW libnm-core: always succeeds, whether or not the connection
              is valid.
      
          - nm_connection_replace_settings_from_connection():
      
            - libnm-util: always replaces the settings, but returns FALSE if
              the connection is now invalid.
      
            - OLD libnm-core: either replaced the settings and returned TRUE
              (if the settings were valid), or else left the connection
              unchanged and returned FALSE (if not).
      
            - NEW libnm-core: always replaces the settings, and has no
              return value. (The modified connection is valid if and only if
              the replaced-from connection was valid; just like with the
              libnm-util version.)
      
          - nm_connection_replace_settings():
      
            - libnm-util: returns TRUE if the new settings are valid, or
              FALSE if either (a) the new settings could not be deserialized
              and the connection is unchanged, or (b) the new settings were
              deserialized, and the connection was updated, but is now not
              valid.
      
            - OLD libnm-core: either replaced the settings and returned TRUE
              (if the settings were valid), or else left the connection
              unchanged and returned FALSE (if not).
      
            - NEW libnm-core: returns TRUE if the connection was updated
              (whether or not it is valid), or FALSE if the new settings
              could not be deserialized and the connection is unchanged.
      ad8b1309
  15. 04 Sep, 2014 4 commits
    • Dan Winship's avatar
      libnm-core: change list-of-string and array-of-string properties to G_TYPE_STRV · 6a4127cf
      Dan Winship authored
      Change all DBUS_TYPE_G_LIST_OF_STRING and DBUS_TYPE_G_ARRAY_OF_STRING
      properties to G_TYPE_STRV, and update everything accordingly.
      
      (This doesn't actually require using
      _nm_setting_class_transform_property(); dbus-glib is happy to transform
      between 'as' and G_TYPE_STRV.)
      6a4127cf
    • Dan Winship's avatar
      libnm-core: change all mac-address properties to G_TYPE_STRING · 3a54d050
      Dan Winship authored
      Make all mac-address properties (including NMSettingBluetooth:bdaddr,
      NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be
      strings, using _nm_setting_class_transform_property() to handle
      translating to/from binary form when dealing with D-Bus.
      
      Update everything accordingly for the change, and also add a test for
      transformed setting properties to test-general.
      3a54d050
    • Dan Winship's avatar
      libnm-core: drop previously-deprecated NMSetting properties · a5ac95ca
      Dan Winship authored
      Drop the NMSetting properties that were marked deprecated in
      libnm-util in 0.9.10, but use nm_setting_class_add_dbus_property() to
      deal with them appropriately when serializing/deserializing.
      a5ac95ca
    • Dan Winship's avatar
      libnm-core: rename NMConnection to/from_hash methods · 773d3f0a
      Dan Winship authored
      Rename nm_connection_to_hash() to nm_connection_to_dbus(), and
      nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In
      addition to clarifying that this is specifically the D-Bus
      serialization format, these names will also work better in the
      GDBus-based future where the serialization format is GVariant, not
      GHashTable.
      
      Also, move NMSettingHashFlags to nm-connection.h, and rename it
      NMConnectionSerializationFlags.
      773d3f0a
  16. 28 Aug, 2014 1 commit
    • Jiří Klimeš's avatar
      settings: fix a crash in emit_updated() accessing invalid pointer · f6b4ab7d
      Jiří Klimeš authored
      by disconnecting signal handlers in dispose().
      
      Commit 6a19e68a moved nm_connection_clear_secrets() from plugins' finalize() to
      NMSettingsConnection's dispose(). But clearing secrets emits "changed" signal
      which cause changed_cb() to be called and emit_updated() scheduled. And
      emit_updated() was called later after finalize() on released object.
      
      The crash can be invoked by having two keyfile connection files with the same
      uuid in them.
      
      Backtrace:
       (NetworkManager:12262): GLib-GObject-WARNING **: attempt to retrieve private data for invalid type 'NMSettingsConnection'
       Program received signal SIGSEGV, Segmentation fault.
       emit_updated (self=0xf38dd0 [NMSettingConnection]) at settings/nm-settings-connection.c:401
       401		NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->updated_idle_id = 0;
       (gdb) bt
       #0  emit_updated (self=0xf38dd0 [NMSettingConnection]) at settings/nm-settings-connection.c:401
       #1  0x0000003c49647825 in g_main_dispatch (context=0x785970) at gmain.c:2539
       #2  g_main_context_dispatch (context=context@entry=0x785970) at gmain.c:3075
       #3  0x0000003c49647b58 in g_main_context_iterate (context=0x785970, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3146
       #4  0x0000003c49647f52 in g_main_loop_run (loop=0x7857c0) at gmain.c:3340
       #5  0x000000000042d4e9 in main (argc=1, argv=0x7fffffffe508) at main.c:679
      f6b4ab7d
  17. 22 Aug, 2014 1 commit
  18. 20 Aug, 2014 1 commit
    • Dan Williams's avatar
      libnm-core: clear secrets from NMSimpleConnection and NMSettingsConnection dispose() · 6a19e68a
      Dan Williams authored
      A few of the settings plugins were calling nm_connection_clear_secrets()
      from their finalize() method, but this call can emit signals, and by
      the time finalize() runs, the object has a refcount of 0.  Signals
      cannot be emitted from a finalized object, but instead could be
      emitted from dispose() before the object is finalized.
      
      Instead of moving the nm_connection_clear_secrets() to dispose() in each
      plugin, make the behavior generic instead.  The settings plugins' parent
      object is NMSettingsConnection, so clear secrets there.  Plus,
      NMSettingsConnection caches system & agent secrets with NMSimpleConnection
      objects, so clear secrets in NMSimpleConnection's dispose too.
      6a19e68a
  19. 18 Aug, 2014 1 commit
  20. 16 Aug, 2014 1 commit
    • Dan Winship's avatar
      libnm-core, libnm, core: make NMConnection an interface · e1ba13a4
      Dan Winship authored
      The fact that NMRemoteConnection has to be an NMConnection and
      therefore can't be an NMObject means that it needs to reimplement bits
      of NMObject functionality (and likewise NMObject needs some special
      magic to deal with it). Likewise, we will need a daemon-side
      equivalent of NMObject as part of the gdbus port, and we would want
      NMSettingsConnection to be able to inherit from this as well.
      
      Solve this problem by making NMConnection into an interface, and
      having NMRemoteConnection and NMSettingsConnection implement it. (We
      use some hacks to keep the GHashTable of NMSettings objects inside
      nm-connection.c rather than having to be implemented by the
      implementations.)
      
      Since NMConnection is no longer an instantiable type, this adds
      NMSimpleConnection to replace the various non-D-Bus-based uses of
      NMConnection throughout the code. nm_connection_new() becomes
      nm_simple_connection_new(), nm_connection_new_from_hash() becomes
      nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
      becomes nm_simple_connection_new_clone().
      e1ba13a4
  21. 07 Aug, 2014 3 commits
    • Dan Winship's avatar
      libnm-core: include ETH_ALEN/INFINIBAND_ALEN defines in nm-utils.h · 357efd26
      Dan Winship authored
      Include <linux/if_ether.h> and <linux/if_infiniband.h> from
      nm-utils.h, to get ETH_ALEN and INFINIBAND_ALEN, and remove those
      includes (as well as <net/ethernet.h> and <netinet/ether.h>, and
      various headers that had been included to get the ARPHRD_* constants)
      from other files where they're not needed now.
      357efd26
    • Dan Winship's avatar
      all: remove use of struct ether_addr / ether_aton() · ea456aaa
      Dan Winship authored
      Lots of old code used struct ether_addr to store hardware addresses,
      and ether_aton() to parse them, but more recent code generally uses
      guint8 arrays, and the nm_utils_hwaddr_* methods, to be able to share
      code between ETH_ALEN and INFINIBAND_ALEN cases. So update the old
      code to match the new. (In many places, this ends up getting rid of
      casts between struct ether_addr and guint8* anyway.)
      
      (Also, in some places, variables were switched from struct ether_addr
      to guint8[] a while back, but some code still used "&" when referring
      to them even though that's unnecessary now. Clean that up.)
      ea456aaa
    • Dan Winship's avatar
      libnm-core, etc: drop type-based hwaddr funcs, port to length-based ones · 35f36ba4
      Dan Winship authored
      Drop the arptype-based nm_utils_hwaddr funcs, and rename the
      length-based ones to no longer have _len in their names. This also
      switches nm_utils_hwaddr_atoba() to using a length rather than an
      arptype, and adds a length argument to nm_utils_hwaddr_valid() (making
      nm_utils_hwaddr_valid() now a replacement for nm_utils_hwaddr_aton()
      in some places, where we were only using aton() to do validity
      checking).
      35f36ba4
  22. 01 Aug, 2014 1 commit
    • Dan Winship's avatar
      libnm: rename NetworkManager.h and NetworkManagerVPN.h · 3ddce748
      Dan Winship authored
      "NetworkManager.h"'s name (and non-standard capitalization) suggest
      that it's some sort of high-level super-important header, but it's
      really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h"
      and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
      3ddce748