Skip to content
  • Thomas Haller's avatar
    properties: refactor connection import · cd2fe46e
    Thomas Haller authored
    Refactor the import code completely.
    
    - openvpn supports quoting and escaping. The parsing code sometimes
      considered quotes (e.g. see unquote() function and the line
      strcmp (file, "'auto'")).
      However, we must consider escaping/quoting while splitting the
      line into invidivual args. get_args() did that wrong in that
      it right away called g_strsplit_set().
      Now, split the line right away with args_parse_line().
    
    - don't print any g_warning() during import but instead return
      a proper error. Import will be called from nmcli and it is bad
      that a library spams stdout/strerr.
      This makes import code much less forgiving. Now instead of printing
      a warning, import fails.
    
    - also, be more strict about the number of arguments that an option
      has. Now, if the number of arguments mismatches, fail with error.
    
    - optimally, we would like to fail for every option that we don't
      understand. It is questionable to signal success during import
      when certain parts are not understood. Anyway, that did not change
      yet, unrecognized options are still silently ignored. But we got
      stricter with arguments that we understand and where we now enforce
      the right number of arguments.
    
    - adjust the blob-reading code to be similar to what openvpn does.
      E.g. the end-tag is detected with allowing leading whitespace and
      and trailing message.
    
    - also, don't treat contents as a NUL terminated C string, but consider
      the length. Lines are split at either '\0' or '\n'. E.g. a inline blob
      element with '\0' will still be written out as read-in.
    cd2fe46e