1. 12 Feb, 2019 4 commits
    • Thomas Haller's avatar
      12809915
    • Thomas Haller's avatar
      shared: add nm_strerror_native() to replace strerror() and g_strerror() · e1ca3bf7
      Thomas Haller authored
      We have various options for strerror(), with ups and downsides:
      
      - strerror()
      
          - returns pointer that is overwritten on next call. It's convenient
            to use, but dangerous.
      
          - not thread-safe.
      
          - not guaranteed to be UTF-8.
      
      - strerror_r()
      
          - takes input buffer and is less convenient to use. At least, we
            are in control of when the buffer gets overwritten.
      
          - there is a Posix/XSI and a glibc variant, making it sligthly
            inconvenient to used. This could be solved by a wrapper we implement.
      
          - thread-safe.
      
          - not guaranteed to be UTF-8.
      
      - g_strerror()
      
          - convenient and safe to use. Also the buffer is never released for the
            remainder of the program.
      
          - passing untrusted error numbers to g_strerror() can result in a
            denial of service, as the internal buffer grows until out-of-memory.
      
          - thread-safe.
      
          - guaranteed to be UTF-8 (depending on locale).
      
      Add our own wrapper nm_strerror_native(). It is:
      
          - convenient to use (returning a buffer that does not require
            management).
      
          - slightly dangerous as the buffer gets overwritten on the next call
            (like strerror()).
      
          - thread-safe.
      
          - guaranteed to be UTF-8 (depending on locale).
      
          - doesn't keep an unlimited cache of strings, unlike g_strerror().
      
      You can't have it all. g_strerror() is leaking all generated error messages.
      I think that is unacceptable, because it would mean we need to
      keep track where our error numbers come from (and trust libraries we
      use to only set a restricted set of known error numbers).
      e1ca3bf7
    • Thomas Haller's avatar
      shared: cleanup separation and transition between errno and nmerr numbers · 67130e67
      Thomas Haller authored
      The native error numbers (from <errno.h>) and our nmerr extention on top
      of them are almost the same. But there are peculiarities.
      
      Both errno and nmerr must be positive values. That is because some API
      (systemd) like to return negative error codes. So, a positive errno and
      its negative counter part indicate the same error. We need normalization
      functions that make an error number positive (these are nm_errno() and
      nm_errno_native()).
      
      This means, G_MININT needs special treatment, because it cannot be
      represented as a positive integer. Also, zero needs special
      treatment, because we want to encode an error, and zero already encodes
      no-error. Take care of these special cases.
      
      On top of that, nmerr reserves a range within native error numbers for
      NetworkManager specific failure codes. So we need to transition from native
      numbers to nmerr numbers via nm_errno_from_native().
      
      Take better care of some special cases and clean them up.
      
      Also add NM_ERRNO_NATIVE() macro. While nm_errno_native() coerces a
      value in the suitable range, NM_ERRNO_NATIVE() asserts that the number
      is already positive (and returns it as-is). It's use is only for
      asserting and implicitly documenting the requirements we have on the
      number passed to it.
      67130e67
    • Thomas Haller's avatar
      shared: fix nm_errno_from_native() for negative values · 89d3c524
      Thomas Haller authored
      We first need to map negative values to their positive form,
      and then do the check for the reserved range.
      
      Fixes: 18732c34
      89d3c524
  2. 27 Dec, 2018 6 commits
    • Thomas Haller's avatar
      platform: merge NMPlatformError with nm-error · d18f4032
      Thomas Haller authored
      Platform had it's own scheme for reporting errors: NMPlatformError.
      Before, NMPlatformError indicated success via zero, negative integer
      values are numbers from <errno.h>, and positive integer values are
      platform specific codes. This changes now according to nm-error:
      success is still zero. Negative values indicate a failure, where the
      numeric value is either from <errno.h> or one of our error codes.
      The meaning of positive values depends on the functions. Most functions
      can only report an error reason (negative) and success (zero). For such
      functions, positive values should never be returned (but the caller
      should anticipate them).
      For some functions, positive values could mean additional information
      (but still success). That depends.
      
      This is also what systemd does, except that systemd only returns
      (negative) integers from <errno.h>, while we merge our own error codes
      into the range of <errno.h>.
      
      The advantage is to get rid of one way how to signal errors. The other
      advantage is, that these error codes are compatible with all other
      nm-errno values. For example, previously negative values indicated error
      codes from <errno.h>, but it did not entail error codes from netlink.
      d18f4032
    • Thomas Haller's avatar
      18732c34
    • Thomas Haller's avatar
      trivial: rename nl-errno to nm-errno · 53261000
      Thomas Haller authored
      53261000
    • Thomas Haller's avatar
      shared: move nm_errno() function to nm-errno.h · f9f022b6
      Thomas Haller authored
      No other changes (yet).
      f9f022b6
    • Thomas Haller's avatar
      core: move netlink errors to nm-errno.h · 4fe18e5b
      Thomas Haller authored
      No other changes (yet).
      4fe18e5b
    • Thomas Haller's avatar
      shared,core: add "nm-errno.h" · 943dcba5
      Thomas Haller authored
      This will be our extension on top of <errno.h>.
      
      We want to use (integer) error numbers, that can both
      contain native errors from <errno.h> and our own defines,
      both merge in one domain. That is, we will reserve a small
      range of integers for our own defines (that hopefully won't
      clash with errors from <errno.h>).
      
      We can use this at places where GError is too cumbersome to use.
      
      The advantage is, that our error numbers extend <errno.h> and can
      be mixed.
      
      This is what "src/platform/nm-netlink.h" already does with nl_errno(). Next,
      the netlink errors from there will be merged into "nm-errno.h".
      
      Also, platform has NMPlatformError, which are a distinct set of error
      numbers. But these work differently in the sense that negative values
      represent codes from <errno.h> and positive numbers are our own platform
      specific defines. NMPlatformError will also be merged into "nm-errno.h".
      
      "nm-errno.h" will unify the error handling of platform and netlink,
      making it more similar to what we are used to from systemd, and give
      room to extend it for our own purpose.
      943dcba5
  3. 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.
      281d2d9f
  4. 02 Nov, 2015 2 commits
  5. 15 Jul, 2014 1 commit
    • Dan Winship's avatar
      libnm-util, libnm-glib: standardize copyright/license headers · cb7e1893
      Dan Winship authored
      - Remove list of authors from files that had them; these serve no
        purpose except to quickly get out of date (and were only used in
        libnm-util and not libnm-glib anyway).
      
      - Just say "Copyright", not "(C) Copyright" or "Copyright (C)"
      
      - Put copyright statement after the license, not before
      
      - Remove "NetworkManager - Network link manager" from the few files
        that contained it, and "libnm_glib -- Access network status &
        information from glib applications" from the many files that
        contained it.
      
      - Remove vim modeline from nm-device-olpc-mesh.[ch], add emacs modeline
        to files that were missing it.
      cb7e1893
  6. 12 Mar, 2012 1 commit
  7. 07 Mar, 2012 1 commit
  8. 03 Feb, 2012 1 commit
    • Dan Winship's avatar
      libnm-glib: simplify handling of object and object array properties · cc90f101
      Dan Winship authored
      Add an "object_type" field to NMPropertiesInfo, and use that with
      DBUS_TYPE_G_OBJECT_PATH and DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH
      properties so that we don't need custom marshallers for each one.
      
      When creating an NMDevice or NMActiveConnection, we need to fetch an
      extra property first to figure out the exact subclass to use, so add a
      bit of infrastructure for that as well. Also, do that preprocessing
      asynchronously when processing a property change notification, so that
      it doesn't block the main loop.
      cc90f101
  9. 20 Dec, 2008 1 commit
  10. 16 Mar, 2007 1 commit
    • Tambet Ingo's avatar
      2007-03-16 Tambet Ingo <tambet@ximian.com> · e1c3b553
      Tambet Ingo authored
      	* libnm-glib/nm-device.c (nm_device_get_description): Implement.
      
      	* libnm-glib/nm-client.c (nm_client_manager_is_running): Implement. Also add a
      	"manager-running" signal that notifies the appearance/disappearance of NM.
      	(nm_client_sleep): Implement.
      
      	* libnm-glib/nm-device.c:
      	* libnm-glib/nm-device-802-11-wireless.c: 
      	* libnm-glib/nm-device-802-3-ethernet.c: 
      
      	Don't inherit from DBusGProxy, add a proxy to private
      	data. The reason is, classes inherited from NMDevice wouldn't get any dbus signals
      	for anything but their own dbus interface. DBusGProxy objects support only one
      	interfaces and to work around this, NMDevice has spearate proxy for each dbus
      	interface. The nice side effect of this change is that we do not create a new
      	DBusGProxy object for each property access.
      
      
      
      git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2479 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
      e1c3b553
  11. 12 Feb, 2007 1 commit
    • Tambet Ingo's avatar
      2007-02-12 Tambet Ingo <tambet@ximian.com> · 8a4c57f6
      Tambet Ingo authored
      	Totally break NetworkManager. Please use 0.6 branch until futher notice.
      
      	* src/:
      		- Remove old low-level dbus interface implementations and replace them
      		  with dbus-glib one.
      
      	* configure.in:
      		- Require dbus-glib >= 0.72.
      		- Plug in new sources to build.
      
      	* libnm-glib/:
      		- Implement GObject wrappers on top of DBUS glib auto-generated bindings
      		  to make it more convenient to use from GObject based programs.
      
      	* introspection/:
      		- Implement DBUS XML introspection files, used by both NM and libnm-glib.
      
      
      
      git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2309 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
      8a4c57f6