1. 22 Feb, 2019 2 commits
    • Thomas Haller's avatar
      all: move nm_utils_hexstr2bin*() to shared · 53b747ff
      Thomas Haller authored
      libnm exposes simplified variants of hexstr2bin in its public API. I
      think that was a mistake, because libnm should provide NetworkManager
      specific utils. It should not provide such string functions.
      However, nmcli used to need this, so it was added to libnm.
      The better approach is to add it to our internally shared static
      library, so that all interested components can make use of it.
    • Thomas Haller's avatar
      shared: add nm_ip_addr_set_from_untrusted() helper · 98e6abb5
      Thomas Haller authored
      Will be used later. The point is to set an IP address from
      unvalidated/untrusted input (that is, the data length might
      not match the address-family).
      Will be used later when parsing netlink attributes.
  2. 21 Feb, 2019 1 commit
  3. 19 Feb, 2019 1 commit
  4. 12 Feb, 2019 3 commits
    • Thomas Haller's avatar
      all: assert that native errno numbers are positive · 4d9918aa
      Thomas Haller authored
      Use the NM_ERRNO_NATIVE() macro that asserts that these errno numbers are
      indeed positive. Using the macro also serves as a documentation of what
      the meaning of these numbers is.
      That is often not obvious, whether we have an nm_errno(), an nm_errno_native()
      (from <errno.h>), or another error number (e.g. WaitForNlResponseResult). This
      situation already improved by merging netlink error codes (nle),
      NMPlatformError enum and <errno.h> as nm_errno(). But we still must
      always be careful about not to mix error codes from different
      domains or transform them appropriately (like nm_errno_from_native()).
    • Thomas Haller's avatar
    • Thomas Haller's avatar
      all: drop unnecessary includes of <errno.h> and <string.h> · a3370af3
      Thomas Haller authored
      "nm-macros-interal.h" already includes <errno.h> and <string.h>.
      No need to include it everywhere else too.
  5. 08 Feb, 2019 1 commit
    • Thomas Haller's avatar
      shared: avoid "-Wmissing-braces" warning initalizing NMIPAddr · 395174f6
      Thomas Haller authored
      NMIPAddr contains an unnamed union. We have to either explicitly
      initialize one field, or omit it.
          ../shared/nm-utils/nm-shared-utils.c:38:36: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
          const NMIPAddr nm_ip_addr_zero = { 0 };
  6. 05 Feb, 2019 1 commit
  7. 14 Jan, 2019 1 commit
  8. 09 Jan, 2019 3 commits
  9. 07 Jan, 2019 1 commit
  10. 02 Jan, 2019 1 commit
    • Thomas Haller's avatar
      keyfile: various refactoring and restructure nm_keyfile_read() · 269c15e8
      Thomas Haller authored
      - in nm_keyfile_read(), unify _read_setting() and
        _read_setting_vpn_secret() in they way they are called
        (that is, they no longer return any value and don't accept
        any arguments aside @info).
      - use cleanup attributes
      - use nm_streq() instead of strcmp().
      - wrap lines that have multiple statements or conditions.
  11. 12 Dec, 2018 1 commit
  12. 17 Oct, 2018 2 commits
  13. 06 Oct, 2018 1 commit
    • Beniamino Galvani's avatar
      shared/nm-utils: avoid a coverity warning · e4154895
      Beniamino Galvani authored
       1. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1242: value_overwrite: Overwriting previous write to "ch" with value from "v".
       2. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1239: assigned_value: Assigning value from "++str[0]" to "ch" here, but that stored value is overwritten before it can be used.
       #  1237|   				if (ch >= '0' && ch <= '7') {
       #  1238|   					v = v * 8 + (ch - '0');
       #  1239|-> 					ch = (++str)[0];
       #  1240|   				}
       #  1241|   			}
      Don't assign ch when it is going to be overwritten.
  14. 30 Sep, 2018 1 commit
    • Rafael Fontenelle's avatar
      Fix typos · 34fd6289
      Rafael Fontenelle authored
      [thaller@redhat.com: fix generated clients/common/settings-docs.h.in file
         and fix wrong change in src/systemd/src/libsystemd/sd-event/sd-event.c]
  15. 18 Sep, 2018 1 commit
    • Thomas Haller's avatar
      shared: relax assertion in nm_utils_parse_inaddr()/nm_utils_parse_inaddr_prefix() · 9ad60ad0
      Thomas Haller authored
      The assertion fails in nmtui's ip_route_transform_from_dest_string(),
      which does not initialize the address output argument to %NULL.
      There are three possibilities how the API could work:
       - assert/require the user to pass in arguments which pre-initialized
         to NULL or unset.
       - always set the output arguments, even if the function fails.
       - don't bother and leave output values untouched, if function fails.
      It's not clear which approach is the best. Not to bother possibliy
      leaves uninitialized values, which could be error prone. Still, do
      just that.
      Fixes: 0b3197a3
  16. 17 Sep, 2018 1 commit
  17. 07 Sep, 2018 2 commits
  18. 30 Aug, 2018 1 commit
  19. 22 Aug, 2018 2 commits
    • Thomas Haller's avatar
      shared: add nm_utils_buf_utf8safe_escape() util · 57c371e3
      Thomas Haller authored
      We already have nm_utils_str_utf8safe_escape() to convert a
      NUL termianted string to an UTF-8 string. nm_utils_str_utf8safe_escape()
      operates under the assumption, that the input strig is already valid UTF-8
      and returns the input string verbatim. That way, in the common expected
      cases, the string just looks like a regular UTF-8 string.
      However, in case there are invalid UTF-8 sequences (or a backslash
      escape characters), the function will use backslash escaping to encode
      the input string as a valid UTF-8 sequence. Note that the escaped
      sequence, can be reverted to the original non-UTF-8 string via
      An example, where this is useful are file names or interface names.
      Which are not in a defined encoding, but NUL terminated and commonly ASCII or
      UTF-8 encoded.
      Extend this, to also handle not NUL terminated buffers. The same
      applies, except that the process cannot be reverted via g_strcompress()
      -- because the NUL character cannot be unescaped.
      This will be useful to escape a Wi-Fi SSID. Commonly we expect the SSID
      to be in UTF-8/ASCII encoding and we want to print it verbatim. Only
      if that is not the case, we fallback to backslash escaping. However, the
      orginal value can be fully recovered via unescape(). The difference
      between an SSID and a filename is, that the former can contain '\0'
    • Thomas Haller's avatar
  20. 11 Aug, 2018 2 commits
  21. 10 Aug, 2018 3 commits
  22. 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' \
  23. 26 May, 2018 1 commit
  24. 14 May, 2018 2 commits
    • Thomas Haller's avatar
      shared: add nm_utils_dbus_path_cmp() helper · 7ba3f4f3
      Thomas Haller authored
      At various places we sort our D-Bus paths. For example,
      server sorts them before exporting them on D-Bus.
      Server knows well, that a lot of these paths are build
      by attaching an incrementing number as last component.
      It looks nicer to sort by this number, instead of strictly
      lexical with strcmp().
      Note that this handles the cases correctly where paths have
      different prefixes, or where they don't end with a number.
    • Thomas Haller's avatar
  25. 24 Apr, 2018 1 commit
  26. 19 Apr, 2018 1 commit
    • Thomas Haller's avatar
      shared: move cmp functions to nm-shared-utils.c · bc1b15cf
      Thomas Haller authored
      For one, these functions are not often needed. No need to define them in the
      "nm-macros-internal.h" header, which is included everywhere. Move them to
      "nm-shared-utils.h", which must be explicitly included.
      Also, these functions are usually not called directly, but by passing their
      function pointer to a sort function or similar. There is no point in having
      defined in the header file.
  27. 18 Apr, 2018 1 commit
  28. 16 Apr, 2018 1 commit