1. 04 Sep, 2018 2 commits
  2. 11 Aug, 2018 1 commit
  3. 11 Jul, 2018 1 commit
    • Thomas Haller's avatar
      all: don't use gchar/gshort/gint/glong but C types · e1c7a2b5
      Thomas Haller authored
      We commonly don't use the glib typedefs for char/short/int/long,
      but their C types directly.
          $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
      One could argue that using the glib typedefs is preferable in
      public API (of our glib based libnm library) or where it clearly
      is related to glib, like during
        g_object_set (obj, PROPERTY, (gint) value, NULL);
      However, that argument does not seem strong, because in practice we don't
      follow that argument today, and seldomly use the glib typedefs.
      Also, the style guide for this would be hard to formalize, because
      "using them where clearly related to a glib" is a very loose suggestion.
      Also note that glib typedefs will always just be typedefs of the
      underlying C types. There is no danger of glib changing the meaning
      of these typedefs (because that would be a major API break of glib).
      A simple style guide is instead: don't use these typedefs.
      No manual actions, I only ran the bash script:
        FILES=($(git ls-files '*.[hc]'))
        sed -i \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>  /\1   /g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
  4. 02 Jul, 2018 1 commit
  5. 26 Jun, 2018 1 commit
  6. 18 Jun, 2018 1 commit
    • Lubomir Rintel's avatar
      all: remove CLOCK_BOOTTIME defintions · e27b15c0
      Lubomir Rintel authored
      It's useless and redundant noise.
      The original motivation seems to have been compatibility with ancient
      versions uClibc (2011), but given CLOCK_BOOTTIME definition is shipped with
      kernel headers, the libc version shall not matter anyway.
      Even if it was the case, uClibc has shipped the definition for over
      7 years now and been superseded by uClibc-ng that always had the
  7. 12 Jun, 2018 1 commit
    • Thomas Haller's avatar
      device: handle failure in generate_duid_from_machine_id() in dhcp6_get_duid() · 6d06a0e1
      Thomas Haller authored
      dhcp6_get_duid() already handles failure to generate the DUID in a
      sensible manner. No reason to duplicate the error handling in
      Especially, because generate_duid_from_machine_id() used to cache the
      random DUID in memory and reuse it from then on. There is no reason to do
      that, /etc/machine-id must be available to NetworkManager. We still
      handle such a grave error gracefully by generating a random DUID.
  8. 08 Jun, 2018 1 commit
    • Francesco Giudici's avatar
      libnm-core: add ipv6.dhcp-duid property · 7a0b6b17
      Francesco Giudici authored
      allow to specify the DUID to be used int the DHCPv6 client identifier
      option: the dhcp-duid property accepts either a hex string or the
      special values "lease", "llt", "ll", "stable-llt", "stable-ll" and
      "lease": give priority to the DUID available in the lease file if any,
               otherwise fallback to a global default dependant on the dhcp
               client used. This is the default and reflects how the DUID
               was managed previously.
      "ll": enforce generation and use of LL type DUID based on the current
            hardware address.
      "llt": enforce generation and use of LLT type DUID based on the current
             hardware address and a stable time field.
      "stable-ll": enforce generation and use of LL type DUID based on a
                   link layer address derived from the stable id.
      "stable-llt": enforce generation and use of LLT type DUID based on
                    a link layer address and a timestamp both derived from the
                    stable id.
      "stable-uuid": enforce generation and use of a UUID type DUID based on a
                     uuid generated from the stable id.
  9. 07 Jun, 2018 1 commit
  10. 28 May, 2018 3 commits
    • Thomas Haller's avatar
      all: add stable-id specifier "${DEVICE}" · eb821ead
      Thomas Haller authored
      Add new stable-id specifier "${DEVICE}" to explicitly declare that the
      connection's identity differs per-device.
      Note that for settings like "ipv6.addr-gen-mode=stable" we already hash
      the interface's name. So, in combination with addr-gen-mode, using this
      specifier has no real use. But for example, we don't do that for
      Point being, in various context we possibly already include a per-device
      token into the generation algorithm. But that is not the case for all
      contexts and uses.
      Especially the DHCPv4 client identifier is supposed to differ between interfaces
      (according to RFC). We don't do that by default with "ipv4.dhcp-client-id=stable",
      but with "${DEVICE}" can can now be configured by the user.
      Note that the fact that the client-id is the same accross interfaces, is not a
      common problem, because profiles are usually restricted to one device via
    • Thomas Haller's avatar
      core: let nm_utils_secret_key_read() handle failures internally · dbcb1d6d
      Thomas Haller authored
      and add nm_utils_secret_key_get() to cache the secret-key, to only
      obtain it once.
      nm_utils_secret_key_read() is not expected to fail. However, in case
      of an unexpected error, don't propagate the error to the caller,
      but instead handle it internally.
      That means, in case of error:
        - log a warning within nm_utils_secret_key_read() itself.
        - always return a generated secret-key. In case of error, the
          key won't be persisted (obviously). But the caller can ignore
          the error and just proceed with an in-memory key.
      Hence, also add nm_utils_secret_key_get() to cache the key. This way,
      we only try to actually generate/read the secret-key once.  Since that
      might fail and return an in-memory key, we must for future invocations
      return the same key, without generating a new one.
    • Thomas Haller's avatar
      core: ensure NUL terminated secret_key buffer · d0f1dc65
      Thomas Haller authored
      The secret_key is binary random data, so one shouldn't ever use it as a
      NUL terminated string directly.
      Still, just ensure that the entire buffer is always NUL terminated.
  11. 16 May, 2018 1 commit
  12. 10 May, 2018 1 commit
    • Lubomir Rintel's avatar
      all: use the elvis operator wherever possible · e69d3869
      Lubomir Rintel authored
        expression a, b;
        -a ? a : b
        +a ?: b
      Applied with:
        spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .
      With some manual adjustments on spots that Cocci didn't catch for
      reasons unknown.
      Thanks to the marvelous effort of the GNU compiler developer we can now
      spare a couple of bits that could be used for more important things,
      like this commit message. Standards commitees yet have to catch up.
  13. 09 May, 2018 1 commit
  14. 30 Apr, 2018 1 commit
  15. 23 Apr, 2018 1 commit
  16. 18 Apr, 2018 1 commit
  17. 16 Apr, 2018 1 commit
  18. 13 Apr, 2018 2 commits
    • Thomas Haller's avatar
      core: minor cleanup of nm_utils_g_value_set_strv() · 1b532b5f
      Thomas Haller authored
      Add some assertion, use an unsigned loop variable (that matches
      GPtrArray.len type), and add a comment.
    • Thomas Haller's avatar
      core: explicitly pass D-Bus path to nm_utils_log_connection_diff() · b0bf9b2b
      Thomas Haller authored
      No longer rely on nm_connection_get_path() being meaningful in server.
      It also was wrong. During update, nm_settings_connection_update()
      would call
        nm_utils_log_connection_diff (replace_connection, NM_CONNECTION (self), ...
      where replace_connection has no path set, and nothing was logged.
      Fix it, by explicitly passing the D-Bus path. Also, because
      nm-core-utils.c should be independent of nm-dbus-object.h.
  19. 20 Mar, 2018 1 commit
  20. 09 Feb, 2018 1 commit
    • Thomas Haller's avatar
      core: return remaining lifetime from nm_utils_lifetime_get() · 7459548f
      Thomas Haller authored
      nm_utils_lifetime_get() already has so many arguments.
      Essentially, the function returned %TRUE if and only if the
      lifetime was greater then zero.
      Combine the return value and the output argument for the lifetime.
      It also matches better the function name: to get the lifetime.
  21. 07 Feb, 2018 1 commit
  22. 12 Jan, 2018 1 commit
    • Beniamino Galvani's avatar
      dns: introduce routing domains · e91f1a7d
      Beniamino Galvani authored
      Similarly to what systemd-resolved does, introduce the concept of
      "routing" domain, which is a domain in the search list that is used
      only to decide the interface over which a query must be forwarded, but
      is not used to complete unqualified host names. Routing domains are
      those starting with a tilde ('~') before the actual domain name.
      Domains without the initial tilde are used both for completing
      unqualified names and for the routing decision.
  23. 15 Dec, 2017 1 commit
  24. 12 Dec, 2017 1 commit
  25. 27 Nov, 2017 1 commit
  26. 14 Nov, 2017 1 commit
  27. 30 Oct, 2017 2 commits
    • Thomas Haller's avatar
      all: avoid coverity warnings about "Missing Initialization" · 287d1aee
      Thomas Haller authored
      31. NetworkManager-1.9.2/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:974:
      uninit_use_in_call: Using uninitialized value "contents_rest" when
      calling "__strtok_r_1c".
      33. NetworkManager-1.9.2/src/nm-core-utils.c:1957:
      uninit_use: Using uninitialized value "s".
      148. NetworkManager-1.9.2/src/nm-core-utils.c:1924:
      uninit_use_in_call: Using uninitialized value "s" when calling
    • Thomas Haller's avatar
      all: avoid coverity warnings about "Wrong Check of Return Value" · 4a8a5495
      Thomas Haller authored
      30. NetworkManager-1.9.2/src/settings/plugins/keyfile/nms-keyfile-writer.c:218:
      check_return: Calling "g_mkdir_with_parents" without checking return
      value (as is done elsewhere 4 out of 5
      25. NetworkManager-1.9.2/src/platform/nm-linux-platform.c:3969:
      check_return: Calling "_nl_send_nlmsg" without checking return value (as
      is done elsewhere 4 out of 5 times).
      34. NetworkManager-1.9.2/src/nm-core-utils.c:2843:
      negative_returns: "fd2" is passed to a parameter that cannot be negative.
      26. NetworkManager-1.9.2/src/devices/wwan/nm-modem-broadband.c:897:
      check_return: Calling "nm_utils_parse_inaddr_bin" without checking
      return value (as is done elsewhere 4 out of 5 times).
      3. NetworkManager-1.9.2/src/devices/bluetooth/nm-bluez5-manager.c:386:
      check_return: Calling "g_variant_lookup" without checking return value
      (as is done elsewhere 79 out of 83 times).
      16. NetworkManager-1.9.2/libnm-util/nm-setting.c:405:
      check_return: Calling "nm_g_object_set_property" without checking return
      value (as is done elsewhere 4 out of 5 times).
  28. 24 Oct, 2017 3 commits
  29. 19 Oct, 2017 2 commits
  30. 18 Oct, 2017 2 commits
    • Thomas Haller's avatar
      all: add helper functions for nm_hash_update*() · 2f56de74
      Thomas Haller authored
      By using a macro, we don't cast all the types to guint. Instead,
      we use their native types directly. Hence, we don't need
      nm_hash_update_uint64() nor nm_hash_update_ptr().
      Also, for types smaller then guint like char, we save hashing
      the all zero bytes.
    • Thomas Haller's avatar
      all: refactor hashing by introducing NMHashState · 0e9e35e3
      Thomas Haller authored
      The privious NM_HASH_* macros directly operated on a guint value
      and were thus close to the actual implementation.
      Replace them by adding a NMHashState struct and accessors to
      update the hash state. This hides the implementation better
      and would allow us to carry more state. For example, we could
      switch to siphash24() transparently.
      For now, we still do a form basically djb2 hashing, albeit with
      differing start seed.
      Also add nm_hash_str() and nm_str_hash():
      - nm_hash_str() is our own string hashing implementation
      - nm_str_hash() is our own string implementation, but with a
        GHashFunc signature, suitable to pass it to g_hash_table_new().
        Also, it has this name in order to remind you of g_str_hash(),
        which it is replacing.
  31. 17 Oct, 2017 1 commit
    • Thomas Haller's avatar
      shared: split random and hash utils · 281d2d9f
      Thomas Haller authored
      "nm-utils/nm-shared-utils.h" shall contain utility function without other
      dependencies. It is intended to be used by other projects as-is.
      nm_utils_random_bytes() requires getrandom() and a HAVE_GETRANDOM configure
      check. That makes it more cumbersome to re-use "nm-shared-utils.h", in
      cases where you don't care about nm_utils_random_bytes().
      Split nm_utils_random_bytes() out to a separate file.
      Same for hash utils, which depend on nm_utils_random_bytes(). Also, hash
      utils will eventually be extended to use siphash24.