1. 07 May, 2019 5 commits
  2. 01 May, 2019 1 commit
  3. 29 Apr, 2019 1 commit
  4. 25 Apr, 2019 8 commits
  5. 18 Apr, 2019 12 commits
    • Thomas Haller's avatar
      shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core · 284ac92e
      Thomas Haller authored
      "libnm-core" implements common functionality for "NetworkManager" and
      "libnm".
      
      Note that clients like "nmcli" cannot access the internal API provided
      by "libnm-core". So, if nmcli wants to do something that is also done by
      "libnm-core", , "libnm", or "NetworkManager", the code would have to be
      duplicated.
      
      Instead, such code can be in "libnm-libnm-core-{intern|aux}.la".
      Note that:
      
        0) "libnm-libnm-core-intern.la" is used by libnm-core itsself.
           On the other hand, "libnm-libnm-core-aux.la" is not used by
           libnm-core, but provides utilities on top of it.
      
        1) they both extend "libnm-core" with utlities that are not public
           API of libnm itself. Maybe part of the code should one day become
           public API of libnm. On the other hand, this is code for which
           we may not want to commit to a stable interface or which we
           don't want to provide as part of the API.
      
        2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core"
           and thus directly available to "libnm" and "NetworkManager".
           On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm"
           and "NetworkManager".
           Both libraries may be statically linked by libnm clients (like
           nmcli).
      
        3) it must only use glib, libnm-glib-aux.la, and the public API
           of libnm-core.
           This is important: it must not use "libnm-core/nm-core-internal.h"
           nor "libnm-core/nm-utils-private.h" so the static library is usable
           by nmcli which couldn't access these.
      
      Note that "shared/nm-meta-setting.c" is an entirely different case,
      because it behaves differently depending on whether linking against
      "libnm-core" or the client programs. As such, this file must be compiled
      twice.
      
      (cherry picked from commit af07ed01)
      284ac92e
    • Thomas Haller's avatar
      shared: move "nm-dbus-compat.h" header to "nm-std-aux/nm-dbus-compat.h" · 87f7e684
      Thomas Haller authored
      (cherry picked from commit 81833358)
      87f7e684
    • Thomas Haller's avatar
      shared: move most of "shared/nm-utils" to "shared/nm-glib-aux" · d984b2ce
      Thomas Haller authored
      From the files under "shared/nm-utils" we build an internal library
      that provides glib-based helper utilities.
      
      Move the files of that basic library to a new subdirectory
      "shared/nm-glib-aux" and rename the helper library "libnm-core-base.la"
      to "libnm-glib-aux.la".
      
      Reasons:
      
       - the name "utils" is overused in our code-base. Everything's an
         "utils". Give this thing a more distinct name.
      
       - there were additional files under "shared/nm-utils", which are not
         part of this internal library "libnm-utils-base.la". All the files
         that are part of this library should be together in the same
         directory, but files that are not, should not be there.
      
       - the new name should better convey what this library is and what is isn't:
         it's a set of utilities and helper functions that extend glib with
         funcitonality that we commonly need.
      
      There are still some files left under "shared/nm-utils". They have less
      a unifying propose to be in their own directory, so I leave them there
      for now. But at least they are separate from "shared/nm-glib-aux",
      which has a very clear purpose.
      
      (cherry picked from commit 80db06f7)
      d984b2ce
    • Thomas Haller's avatar
      shared: move udev helper to separate directory "shared/nm-udev-aux" · 95621586
      Thomas Haller authored
      We built (among others) two libraries from the sources in "shared/nm-utils":
      "libnm-utils-base.la" and "libnm-utils-udev.la".
      
      It's confusing. Instead use directories so there is a direct
      correspondence between these internal libraries and the source files.
      
      (cherry picked from commit 2973d682)
      95621586
    • Thomas Haller's avatar
      shared: split C-only helper "shared/nm-std-aux" utils out of "shared/nm-utils" · 0a6f21fb
      Thomas Haller authored
      "shared/nm-utils" contains general purpose utility functions that only
      depend on glib (and extend glib with some helper functions).
      
      We will also add code that does not use glib, hence it would be good
      if the part of "shared/nm-utils" that does not depend on glib, could be
      used by these future projects.
      
      Also, we use the term "utils" everywhere. While that covers the purpose
      and content well, having everything called "nm-something-utils" is not
      great. Instead, call this "nm-std-aux", inspired by "c-util/c-stdaux".
      
      (cherry picked from commit b434b9ec)
      0a6f21fb
    • Thomas Haller's avatar
      shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core · af07ed01
      Thomas Haller authored
      "libnm-core" implements common functionality for "NetworkManager" and
      "libnm".
      
      Note that clients like "nmcli" cannot access the internal API provided
      by "libnm-core". So, if nmcli wants to do something that is also done by
      "libnm-core", , "libnm", or "NetworkManager", the code would have to be
      duplicated.
      
      Instead, such code can be in "libnm-libnm-core-{intern|aux}.la".
      Note that:
      
        0) "libnm-libnm-core-intern.la" is used by libnm-core itsself.
           On the other hand, "libnm-libnm-core-aux.la" is not used by
           libnm-core, but provides utilities on top of it.
      
        1) they both extend "libnm-core" with utlities that are not public
           API of libnm itself. Maybe part of the code should one day become
           public API of libnm. On the other hand, this is code for which
           we may not want to commit to a stable interface or which we
           don't want to provide as part of the API.
      
        2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core"
           and thus directly available to "libnm" and "NetworkManager".
           On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm"
           and "NetworkManager".
           Both libraries may be statically linked by libnm clients (like
           nmcli).
      
        3) it must only use glib, libnm-glib-aux.la, and the public API
           of libnm-core.
           This is important: it must not use "libnm-core/nm-core-internal.h"
           nor "libnm-core/nm-utils-private.h" so the static library is usable
           by nmcli which couldn't access these.
      
      Note that "shared/nm-meta-setting.c" is an entirely different case,
      because it behaves differently depending on whether linking against
      "libnm-core" or the client programs. As such, this file must be compiled
      twice.
      af07ed01
    • Thomas Haller's avatar
    • Thomas Haller's avatar
      shared: move most of "shared/nm-utils" to "shared/nm-glib-aux" · 80db06f7
      Thomas Haller authored
      From the files under "shared/nm-utils" we build an internal library
      that provides glib-based helper utilities.
      
      Move the files of that basic library to a new subdirectory
      "shared/nm-glib-aux" and rename the helper library "libnm-core-base.la"
      to "libnm-glib-aux.la".
      
      Reasons:
      
       - the name "utils" is overused in our code-base. Everything's an
         "utils". Give this thing a more distinct name.
      
       - there were additional files under "shared/nm-utils", which are not
         part of this internal library "libnm-utils-base.la". All the files
         that are part of this library should be together in the same
         directory, but files that are not, should not be there.
      
       - the new name should better convey what this library is and what is isn't:
         it's a set of utilities and helper functions that extend glib with
         funcitonality that we commonly need.
      
      There are still some files left under "shared/nm-utils". They have less
      a unifying propose to be in their own directory, so I leave them there
      for now. But at least they are separate from "shared/nm-glib-aux",
      which has a very clear purpose.
      80db06f7
    • Thomas Haller's avatar
      shared: move udev helper to separate directory "shared/nm-udev-aux" · 2973d682
      Thomas Haller authored
      We built (among others) two libraries from the sources in "shared/nm-utils":
      "libnm-utils-base.la" and "libnm-utils-udev.la".
      
      It's confusing. Instead use directories so there is a direct
      correspondence between these internal libraries and the source files.
      2973d682
    • Thomas Haller's avatar
      shared: split C-only helper "shared/nm-std-aux" utils out of "shared/nm-utils" · b434b9ec
      Thomas Haller authored
      "shared/nm-utils" contains general purpose utility functions that only
      depend on glib (and extend glib with some helper functions).
      
      We will also add code that does not use glib, hence it would be good
      if the part of "shared/nm-utils" that does not depend on glib, could be
      used by these future projects.
      
      Also, we use the term "utils" everywhere. While that covers the purpose
      and content well, having everything called "nm-something-utils" is not
      great. Instead, call this "nm-std-aux", inspired by "c-util/c-stdaux".
      b434b9ec
    • Thomas Haller's avatar
      shared: remove unused _nm_utils_escape_plain()/_nm_utils_escape_spaces() API · 585077c5
      Thomas Haller authored
      ... and the "unescape" variants.
      
      This is replaced by nm_utils_escaped_tokens_split()
      and nm_utils_escaped_tokens_escape*() API.
      
      (cherry picked from commit 304eab87)
      585077c5
    • Thomas Haller's avatar
      shared: remove unused _nm_utils_escape_plain()/_nm_utils_escape_spaces() API · 304eab87
      Thomas Haller authored
      ... and the "unescape" variants.
      
      This is replaced by nm_utils_escaped_tokens_split()
      and nm_utils_escaped_tokens_escape*() API.
      304eab87
  6. 17 Apr, 2019 10 commits
    • Thomas Haller's avatar
      shared: add nm_utils_escaped_tokens_escape_gstr_assert() · 45fad3bb
      Thomas Haller authored
      (cherry picked from commit 832adf32)
      45fad3bb
    • Thomas Haller's avatar
      shared: remove unused nm_utils_str_simpletokens_extract_next() · da7ce537
      Thomas Haller authored
      This can be replaced by nm_utils_escaped_tokens_split().
      
      Note that nm_utils_escaped_tokens_split() does not behave exactly
      the same. For example, nm_utils_str_simpletokens_extract_next() would
      remove all backslashes and leave only the following character.
      nm_utils_escaped_tokens_split() instead only strips backslashes
      that preceed a delimiter, whitespace or another backslash.
      
      But we should have one preferred way of tokenizing, and I find this
      preferable, because it allows for most backslashes to appear verbatim.
      
      (cherry picked from commit ced7dbe8)
      da7ce537
    • Thomas Haller's avatar
      shared: add nm_utils_escaped_tokens_escape() · 0cc5fe78
      Thomas Haller authored
      This escapes strings so that they can be concatenated with a delimiter
      and without loss tokenized with nm_utils_escaped_tokens_split().
      
      Note that this is similar to _nm_utils_escape_plain() and
      _nm_utils_escape_spaces(). The difference is that
      nm_utils_escaped_tokens_escape() also escapes the last trailing
      whitespace. That means, if delimiters contains all NM_ASCII_SPACES, then
      it is identical to _nm_utils_escape_spaces(). Otherwise, the trailing
      space is treated specially. That is, because
      nm_utils_escaped_tokens_split() uses NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP,
      to strip leading and trailing whitespace. To still express a trailing
      whitespace, the last whitespace must be escaped. Note that
      NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP also honors escaping any whitespace
      (not only at the last position), but when escaping we don't need to
      escape them, because unescaped (non-trailing) whitespace are taken just
      fine.
      
      The pair nm_utils_escaped_tokens_split() and
      nm_utils_escaped_tokens_escape() are proposed as default way of
      tokenizing a list of items. For example, with
      
        $ nmcli connection modify "$PROFILE" +ipv4.routing-rules 'priority 5 from 192.168.7.5/32 table 5, priority 6 iif a\, from 192.168.7.5/32 table 6'
      
      Here we implement a to/from string function to handle one item
      (nm_ip_routing_rule_{from,to}_string()). When such elements are combined with ',',
      then we need to support an additional layer of escaping on top of that.
      The advantage is that the indvidual to/from string functions are agnostic
      to this second layer of escaping/tokenizing that nmcli employs to handle
      a list of these items.
      The disadvantage is that we possibly get multiple layers of backslash
      escapings. That is only mitigated by the fact that nm_utils_escaped_tokens_*()
      supports a syntax for which *most* characters don't need any special escaping.
      Only delimiters, backslash, and the trailing space needs escaping, and
      these are cases are expected to be few.
      
      (cherry picked from commit e206e3d4)
      0cc5fe78
    • Thomas Haller's avatar
      shared: add NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED to nm_utils_strsplit_set_full() · 4181ed86
      Thomas Haller authored
      Add a new flag that will remove escape characters after splitting
      the string.
      
      This implements a special kind of backslash escaping. It's not C escape
      sequences (like '\n' or '\020'), but simply to take the special character
      following the backslash verbatim. Note that the backslash is only
      considered special, if it's followed by a delimiter, another backslash,
      or a whitespace (in combination with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP).
      
      The main purpose of this form of escaping is nmcli's list options, like
      
        $ nmcli connection modify "$PROFILE" +ipv4.routing-rules 'priority 5 from 192.168.7.5/32 table 5, priority 6 iif a\, from 192.168.7.5/32 table 6'
      
      It's a contrieved example, but the list options are a list of IP
      addresses, rules, etc. They implement their own syntax for one element,
      and are concatenated by ','. To support that one element may have
      arbitrary characters (including the delimiter and whitespaces), nmcli
      employs a tokenization with this special kind of escaping.
      
      (cherry picked from commit 9522aaf2)
      4181ed86
    • Thomas Haller's avatar
      shared: add NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP to nm_utils_strsplit_set_full() · c75a1d7e
      Thomas Haller authored
      This will essentially call g_strstrip() on each token.
      
      There are some specialties:
      
       - if the resulting word is empty after stripping, then according to
         %NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, the empty token will be
         removed. If that results in an empty string array, %NULL will be
         returned.
      
       - if %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING is set, then
         whitespace that is backslash escaped is not removed.
      
      Since this is a post-operation that happens after tokeninzing, it
      could be done as a separate function. And we already have this function:
      _nm_utils_unescape_plain() and _nm_utils_unescape_spaces().
      However, that is ugly for several reasons:
      
       - the stripping should be part of the tokenizing, you shouldn't need
         several steps.
      
       - nm_utils_strsplit_set_full() returns a "const char **" which
         indicates the strings must not be freed. However, it is perfectly
         valid to modify the string inplace. Hence, the post-op function
         would need to cast the strings to "char *", which seems ugly
         (although we do that on many places, and it's guaranteed to work).
      
       - _nm_utils_unescape_plain()/_nm_utils_unescape_spaces() is indeed
         already used together with nm_utils_strsplit_set_full(). However,
         it requires to initialize the cb_lookup buffer twice. I would expect
         that initializing the cb_lookup buffer is a large portion of what
         the function does already (for short strings).
         This issue will be solved in the next commit by adding yet another flag
         which allows to unescape.
      
      (cherry picked from commit 5b2b0dca)
      c75a1d7e
    • Thomas Haller's avatar
      832adf32
    • Thomas Haller's avatar
      shared: remove unused nm_utils_str_simpletokens_extract_next() · ced7dbe8
      Thomas Haller authored
      This can be replaced by nm_utils_escaped_tokens_split().
      
      Note that nm_utils_escaped_tokens_split() does not behave exactly
      the same. For example, nm_utils_str_simpletokens_extract_next() would
      remove all backslashes and leave only the following character.
      nm_utils_escaped_tokens_split() instead only strips backslashes
      that preceed a delimiter, whitespace or another backslash.
      
      But we should have one preferred way of tokenizing, and I find this
      preferable, because it allows for most backslashes to appear verbatim.
      ced7dbe8
    • Thomas Haller's avatar
      shared: add nm_utils_escaped_tokens_escape() · e206e3d4
      Thomas Haller authored
      This escapes strings so that they can be concatenated with a delimiter
      and without loss tokenized with nm_utils_escaped_tokens_split().
      
      Note that this is similar to _nm_utils_escape_plain() and
      _nm_utils_escape_spaces(). The difference is that
      nm_utils_escaped_tokens_escape() also escapes the last trailing
      whitespace. That means, if delimiters contains all NM_ASCII_SPACES, then
      it is identical to _nm_utils_escape_spaces(). Otherwise, the trailing
      space is treated specially. That is, because
      nm_utils_escaped_tokens_split() uses NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP,
      to strip leading and trailing whitespace. To still express a trailing
      whitespace, the last whitespace must be escaped. Note that
      NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP also honors escaping any whitespace
      (not only at the last position), but when escaping we don't need to
      escape them, because unescaped (non-trailing) whitespace are taken just
      fine.
      
      The pair nm_utils_escaped_tokens_split() and
      nm_utils_escaped_tokens_escape() are proposed as default way of
      tokenizing a list of items. For example, with
      
        $ nmcli connection modify "$PROFILE" +ipv4.routing-rules 'priority 5 from 192.168.7.5/32 table 5, priority 6 iif a\, from 192.168.7.5/32 table 6'
      
      Here we implement a to/from string function to handle one item
      (nm_ip_routing_rule_{from,to}_string()). When such elements are combined with ',',
      then we need to support an additional layer of escaping on top of that.
      The advantage is that the indvidual to/from string functions are agnostic
      to this second layer of escaping/tokenizing that nmcli employs to handle
      a list of these items.
      The disadvantage is that we possibly get multiple layers of backslash
      escapings. That is only mitigated by the fact that nm_utils_escaped_tokens_*()
      supports a syntax for which *most* characters don't need any special escaping.
      Only delimiters, backslash, and the trailing space needs escaping, and
      these are cases are expected to be few.
      e206e3d4
    • Thomas Haller's avatar
      shared: add NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED to nm_utils_strsplit_set_full() · 9522aaf2
      Thomas Haller authored
      Add a new flag that will remove escape characters after splitting
      the string.
      
      This implements a special kind of backslash escaping. It's not C escape
      sequences (like '\n' or '\020'), but simply to take the special character
      following the backslash verbatim. Note that the backslash is only
      considered special, if it's followed by a delimiter, another backslash,
      or a whitespace (in combination with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP).
      
      The main purpose of this form of escaping is nmcli's list options, like
      
        $ nmcli connection modify "$PROFILE" +ipv4.routing-rules 'priority 5 from 192.168.7.5/32 table 5, priority 6 iif a\, from 192.168.7.5/32 table 6'
      
      It's a contrieved example, but the list options are a list of IP
      addresses, rules, etc. They implement their own syntax for one element,
      and are concatenated by ','. To support that one element may have
      arbitrary characters (including the delimiter and whitespaces), nmcli
      employs a tokenization with this special kind of escaping.
      9522aaf2
    • Thomas Haller's avatar
      shared: add NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP to nm_utils_strsplit_set_full() · 5b2b0dca
      Thomas Haller authored
      This will essentially call g_strstrip() on each token.
      
      There are some specialties:
      
       - if the resulting word is empty after stripping, then according to
         %NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, the empty token will be
         removed. If that results in an empty string array, %NULL will be
         returned.
      
       - if %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING is set, then
         whitespace that is backslash escaped is not removed.
      
      Since this is a post-operation that happens after tokeninzing, it
      could be done as a separate function. And we already have this function:
      _nm_utils_unescape_plain() and _nm_utils_unescape_spaces().
      However, that is ugly for several reasons:
      
       - the stripping should be part of the tokenizing, you shouldn't need
         several steps.
      
       - nm_utils_strsplit_set_full() returns a "const char **" which
         indicates the strings must not be freed. However, it is perfectly
         valid to modify the string inplace. Hence, the post-op function
         would need to cast the strings to "char *", which seems ugly
         (although we do that on many places, and it's guaranteed to work).
      
       - _nm_utils_unescape_plain()/_nm_utils_unescape_spaces() is indeed
         already used together with nm_utils_strsplit_set_full(). However,
         it requires to initialize the cb_lookup buffer twice. I would expect
         that initializing the cb_lookup buffer is a large portion of what
         the function does already (for short strings).
         This issue will be solved in the next commit by adding yet another flag
         which allows to unescape.
      5b2b0dca
  7. 16 Apr, 2019 1 commit
    • Lubomir Rintel's avatar
      all: goodbye libnm-glib · 5801f89f
      Lubomir Rintel authored
      This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
      The it has been replaced with libnm since NetworkManager 1.0, disabled
      by default since 1.12 and no up-to-date distributions ship it for years
      now.
      
      Removing the libraries allows us to:
      
      * Remove the horrible hacks that were in place to deal with accidental use
        of both the new and old library in a single process.
      * Relief the translators of maintenance burden of similar yet different
        strings.
      * Get rid of known bad code without chances of ever getting fixed
        (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
      * Generally lower the footprint of the releases and our workspace
      
      If there are some really really legacy users; they can just build
      libnm-glib and friends from the NetworkManager-1.16 distribution. The
      D-Bus API is stable and old libnm-glib will keep working forever.
      
      https://github.com/NetworkManager/NetworkManager/pull/308
      5801f89f
  8. 14 Apr, 2019 2 commits