Commit graph

828 commits

Author SHA1 Message Date
Jiří Klimeš a751398785 libnm-glib: do not use deprecated Gtk-Doc Type: and Virtual: tags
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744250
2018-03-26 12:46:22 +02:00
Benjamin Berg 26c215e22d Add calls to g_simple_async_result_set_check_cancellable
If an operation is cancelled through the GCancellable, then the idiom is
that the operation is always cancelled, even if it has finished
successfully. To ensure this is the case, add calls to
g_simple_async_result_set_check_cancellable everywhere.

Without this, e.g. gnome-control-center will crash when switching away
from the power panel quickly, as the NMClient creation finishes
asynchronously and g-c-c assume that G_IO_ERROR_CANCELLED is returned to
ensure it doesn't access the now invalid user_data parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=794088
2018-03-08 14:52:45 +01:00
Lubomir Rintel ee916a1e9e all: fix -Wcast-function-type warnings
GCC 8.0's -Wcast-function-type objects casting function pointers to ones
with incompatible prototypes. Sometimes we do that on purpose though.

Notably, the g_source_set_callback()'s func argument can point to functions
of various prototypes. Also, libnm-glib/nm-remote-connection is perhaps
just not worth reworking, that would just be a waste of time.

A cast to void(*)(void) avoids the GCC warning, let's use it.
2018-02-08 17:11:46 +01:00
Lubomir Rintel 7f7207f36b libnm/vpn-plugin: avoid bad function pointer type casts
This makes GCC 8.0 unhappy and it is probably right about that -- it's more
difficult to get things wrong when the function prototypes actually match.
2018-02-08 17:11:46 +01:00
Thomas Haller 28da0154fc all: drop trailing spaces 2018-02-07 13:32:04 +01:00
Thomas Haller e4839accf5 all: replace non-leading tabs with spaces
We commonly only allow tabs at the beginning of a line, not
afterwards. The reason for this style is so that the code
looks formated right with tabstop=4 and tabstop=8.
2018-02-07 13:32:04 +01:00
Lubomir Rintel 8a46b25cfa all: require glib 2.40
RHEL 7.1 and Ubuntu 14.04 LTS both have this.

https://bugzilla.gnome.org/show_bug.cgi?id=792323
2018-01-18 11:45:36 +01:00
Lubomir Rintel bfff3ecfb0 build: don't install NetworkManager.pc when libnm-glib is disabled 2018-01-16 12:15:51 +01:00
Iñigo Martínez 54641388f8 meson: Fix missing symbols in libnm-glib
The following symbols are missing from the libnm-glib library:

* libnm_glib_get_network_state
* libnm_glib_init
* libnm_glib_register_callback
* libnm_glib_shutdown
* libnm_glib_unregister_callback

This has been changed by linking `libdeprecated_nm_glib` as a whole.

https://mail.gnome.org/archives/networkmanager-list/2018-January/msg00056.html
2018-01-12 09:37:55 +01:00
Thomas Haller 34cb6f9877 build/meson: use variables for ldflags and linker-script 2018-01-11 12:46:01 +01:00
Thomas Haller 349861ceec build/meson: unconditionally use linker version scripts
We also unconditionally use them with autotools.
Also, the detection for have_version_script does
not seem correct to me. At least, it didn't work
with clang.
2018-01-10 12:31:44 +01:00
Thomas Haller 3d7aa8483e build/meson: disable unit tests that are known to fail
I think it's because meson doesn't run the tests in their
own D-Bus session, hence the use the system service.

automake solves this running all tests via ./tools/run-nm-test.sh,
which knows how to prepare a suitable environment for the tests.
2018-01-10 12:30:48 +01:00
Iñigo Martínez 50930ed19a meson: Use string variables extensively
The strings holding the names used for libraries have also been
moved to different variables. This way they would be less error
as these variables can be reused easily and any typing error
would be quickly detected.
2018-01-10 12:22:55 +01:00
Iñigo Martínez 5e16bcf268 meson: Improve dependency system
Some targets are missing dependencies on some generated sources in
the meson port. These makes the build to fail due to missing source
files on a highly parallelized build.

These dependencies have been resolved by taking advantage of meson's
internal dependencies which can be used to pass source files,
include directories, libraries and compiler flags.

One of such internal dependencies called `core_dep` was already in
use. However, in order to avoid any confusion with another new
internal dependency called `nm_core_dep`, which is used to include
directories and source files from the `libnm-core` directory, the
`core_dep` dependency has been renamed to `nm_dep`.

These changes have allowed minimizing the build details which are
inherited by using those dependencies. The parallelized build has
also been improved.
2018-01-10 12:20:17 +01:00
Thomas Haller 22ef6a507a build: refine the NETWORKMANAGER_COMPILATION define
Note that:

 - we compile some source files multiple times. Most notably those
   under "shared/".

 - we include a default header "shared/nm-default.h" in every source
   file. This header is supposed to setup a common environment by defining
   and including parts that are commonly used. As we always include the
   same header, the header must behave differently depending
   one whether the compilation is for libnm-core, NetworkManager or
   libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h>
   depending on whether we compile a library or an application.

For that, the source files need the NETWORKMANAGER_COMPILATION #define
to behave accordingly.

Extend the define to be composed of flags. These flags are all named
NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the
build are available. E.g. when building libnm-core.la itself, then
WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE
are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE
is not available but the internal parts are still accessible. When
building nmcli, only WITH_LIBNM_CORE (the public part) is available.
This granularily controls the build.
2018-01-08 12:38:53 +01:00
Iñigo Martínez 03ba0f1b3a build: Remove default install directories
The install directories of those targets that match the default
install directories have been removed because they are redundant.

This also allows a simple meson build files and it is unnecessary
to create some paths.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00078.html
2018-01-02 10:44:05 +01:00
Iñigo Martínez 0735b35dd0 build: use template files for enum types' sources generation
Source files for enum types are generated by passing segments of the
source code of the files to the `glib-mkenums` command.

This patch removes those parameters where source code is used from
meson build files by moving those segmeents to template files.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00057.html
2017-12-18 11:25:06 +01:00
Iñigo Martínez d849366230 build: rename unit tests with the test- pattern
There are some tests located in different directories which are
using the same name. To avoid any confussion a prefix was used to
name the test and the target.

This patch uses the prefix just for the target, to avoid any
collision that may happen, and uses the `test-` pattern as the
name.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00051.html
2017-12-14 20:07:38 +01:00
Iñigo Martínez 03637ad8b5 build: add initial support for meson build system
meson is a build system focused on speed an ease of use, which
helps speeding up the software development. This patch adds meson
support along autotools.

[thaller@redhat.com: rebased patch and adjusted for iwd support]

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00022.html
2017-12-13 15:48:50 +01:00
Thomas Haller 7661ad64ba all: use cast macros instead of C cast
When building with assertions, they nm_assert() for the
type. Otherwise, they are identical to a C cast.

Also, where possible, don't cast at all, but adjust
the type instead.

Also, there were a few missing casts.
2017-12-06 10:34:28 +01:00
Colin Walters 3f6bef47f3 tree-wide: cast after g_object_ref() for proposed GLib patch
This fixes the build with related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00005.html
2017-12-06 10:34:28 +01:00
Thomas Haller b58481b31e all: don't use g_direct_equal() for hash table equality function
GHashTable optimizes a NULL equality function to use direct pointer
comparison. That saves the overhead of calling g_direct_equal().
This is also documented behavior for g_hash_table_new().

While at it, also don't pass g_direct_hash() but use the default
of %NULL. The behavior is the same, but consistently don't use
g_direct_hash().
2017-11-16 11:49:51 +01:00
Yuri Chornoivan 0050e8bd34 all: fix typos in documentation, translated strings and comments
https://bugzilla.gnome.org/show_bug.cgi?id=783173
2017-05-28 17:33:37 +02:00
Lubomir Rintel 55ad538cfb libnm-glib/secret-agent: don't error out on missing out_connection
It's perfectly valid to call the function with out_connection == NULL
when connection_hash == NULL too, as cancel_get_secrets() does.

Fixes: fbb1662269
(cherry picked from commit c4a0002f05)
2017-04-13 14:45:58 +02:00
Thomas Haller b11b603879 libnm: handle errors gracefully in nm_access_point_connection_valid()
Suppress warnings and avoid assertions in
nm_access_point_connection_valid().

https://bugzilla.gnome.org/show_bug.cgi?id=773675
2017-03-24 12:08:03 +01:00
Thomas Haller 6808bf8195 udev: add and use nm_udev_utils_property_decode() function
DRY.
2017-03-22 12:41:06 +01:00
Thomas Haller e32839838e udev: drop libgudev in favor of libudev
libgudev is just a wrapper around libudev. We can
use libudev directly and drop the dependency for
libgudev.
2017-03-22 12:41:06 +01:00
Thomas Haller c033330c41 libnm: fix memleak of GUdevDevice in get_bus_name()
Fixes: f7b1b28202
2017-03-20 11:28:58 +01:00
Thomas Haller 831286df30 include: use double-quotes to include our own headers
In practice, this should only matter when there are multiple
header files with the same name. That is something we try
to avoid already, by giving headers a distinct name.

When building NetworkManager itself, we clearly want to use
double-quotes for including our own headers.
But we also want to do that in our public headers. For example:

  ./a.c
    #include <stdio.h>
    #include <nm-1.h>
    void main() {
        printf ("INCLUDED %s/nm-2.h\n", SYMB);
    }

  ./1/nm-1.h
    #include <nm-2.h>

  ./1/nm-2.h
    #define SYMB "1"

  ./2/nm-2.h
    #define SYMB "2"

$ cc -I./2 -I./1 ./a.c
$ ./a.out
INCLUDED 2/nm-2.h

Exceptions to this are
  - headers in "shared/nm-utils" that include <NetworkManager.h>. These
    headers are copied into projects and hence used like headers owned by
    those projects.
  - examples/C
2017-03-09 14:12:35 +01:00
Thomas Haller ab6e370195 all/trivial: unify construct-only property comments
Unify marking GObject properties that are G_PARAM_CONSTRUCT_ONLY
with a comment

    /* construct-only */
2017-03-08 13:47:00 +01:00
Philip Withnall 5a38b5c88b libnm-glib/nm-object: defer assignment of default D-Bus connection
If no D-Bus connection is provided to the constructor of an NMObject, a
default one will be assigned in set_property(). However, construction of
that default D-Bus connection might fail (if our connection to the
system bus is refused, for example), so priv->connection might still be
NULL. This will cause the constructor to fail construction of the
NMObject, which is correct, but hard to debug.

Instead, move the default D-Bus connection handling into the
constructor, so all the (priv->connection == NULL) handling is in the
same place. Print out any error message.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=778610
2017-02-15 16:30:16 +01:00
Philip Withnall 78058f7809 libnm-glib: add some missing precondition assertions
To validate the connection and path for NmObject subclass instances.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=778610
2017-02-15 16:30:13 +01:00
Lubomir Rintel 4fac787dfc libnm-glib: silence some build warnings
libnm-glib/nm-object-private.h:28: Warning: NMClient: symbol='PropertyMarshalFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:28: Warning: NMClient: symbol='PropertyMarshalFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:28: Warning: NMClient: symbol='PropertyMarshalFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:28: Warning: NMClient: symbol='PropertyMarshalFunc': missing parameter name; undocumentable

libnm-glib/nm-object-private.h:82: Warning: NMClient: symbol='NMObjectTypeFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:82: Warning: NMClient: symbol='NMObjectTypeFunc': missing parameter name; undocumentable

libnm-glib/nm-object-private.h:83: Warning: NMClient: symbol='NMObjectTypeCallbackFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:83: Warning: NMClient: symbol='NMObjectTypeCallbackFunc': missing parameter name; undocumentable

libnm-glib/nm-object-private.h:84: Warning: NMClient: symbol='NMObjectTypeAsyncFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:84: Warning: NMClient: symbol='NMObjectTypeAsyncFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:84: Warning: NMClient: symbol='NMObjectTypeAsyncFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:84: Warning: NMClient: symbol='NMObjectTypeAsyncFunc': missing parameter name; undocumentable
2016-11-21 13:53:03 +01:00
Lubomir Rintel 418e2a36b4 libnm-glib: drop some unneeded code
...so that we don't have to fix the following:

libnm-glib/nm-object-private.h:30: Warning: NMClient: symbol='NMObjectCreatorFunc': missing parameter name; undocumentable
libnm-glib/nm-object-private.h:30: Warning: NMClient: symbol='NMObjectCreatorFunc': missing parameter name; undocumentable

Fixes: ad5daa098c
2016-11-21 13:53:03 +01:00
Thomas Haller 0f09b1d1cc build: merge "libnm-glib/tests/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Thomas Haller 8027e09be4 build: merge "libnm-glib/Makefile.am" into toplevel Makefile 2016-10-21 17:37:57 +02:00
Thomas Haller 7aefbcb622 build: merge "libnm/tests/Makefile.am" into toplevel Makefile 2016-10-19 17:16:08 +02:00
Thomas Haller cd98705d21 tests: combine "run-test-valgrind.sh" and "run-test-dbus-session.sh" in "run-nm-test.sh"
No need to have two test-runners. Combine them, and call tests always
via "tools/run-nm-test.sh".

Yes, this brings an overhead, that we now always invoke the test with
a test wrapper script, also --without-vagrind. Previously, that was only
necessary for libnm tests that require their own D-Bus session.

Later we will do non-recursive Makefiles, thus all tests should have the
same LOG_COMPILER.
2016-10-19 15:26:30 +02:00
Thomas Haller 274de2555b build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILER 2016-10-19 15:26:30 +02:00
Thomas Haller 9f5b80d215 build: don't guard check-local with "if ENABLE_TESTS"
We should enable tests by default, probably we even should drop
the configure flags to enable tests and just always build them.

Anyway, at this point there is no use in guarding check-local
with a check for ENABLE_TESTS. A user who does't want to run
the tests, should just not call `make check`.
2016-10-13 21:33:33 +02:00
Thomas Haller a83eb773ce all: modify line separator comments to be 80 chars wide
sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
2016-10-03 12:01:15 +02:00
Thomas Haller 0bdcab100c all: cleanup includes in header files
- don't include "nm-default.h" in header files. Every source file must
  include as first header "nm-default.h", thus our headers get the
  default include already implicitly.

- we don't support compiling NetworkManager itself with a C++ compiler. Remove
  G_BEGIN_DECLS/G_END_DECLS from internal headers. We do however support
  users of libnm to use C++, thus they stay in public headers.

(cherry picked from commit f19aff8909)
2016-08-17 19:51:17 +02:00
Alfonso Sanchez-Beato 6fb0de0a8b auth: check when setting statistics refresh rate 2016-08-17 16:08:20 +02:00
Thomas Haller 2cb18efaea permissions: properly add checkpoint-rollback permission
Fixes: a52d4654ec
2016-08-17 15:50:20 +02:00
Dan Williams fdf5b6941a libnm/libnm-glib: use Bluetooth device name as description (bgo #592819)
Abuse the 'name' property for this, for now, so we don't have to grab
a free slot from NMDeviceClass.

https://bugzilla.gnome.org/show_bug.cgi?id=592819
2016-06-21 10:35:53 -05:00
Beniamino Galvani 01540cf1d3 build: add options to compile with address/undefined sanitizers
This adds two new options to the configure scripts to compile NM,
clients and libraries with the address and undefined-behavior
sanitizers available in recent GCC versions. Clang is not supported at
moment.
2016-06-03 22:19:38 +02:00
Thomas Haller 8e54cfdb27 all: move NM_AUTH_PERMISSION_* defines to "nm-common-macros.h" header 2016-06-01 19:06:35 +02:00
Thomas Haller 1d0e0eeffd manager: add Reload() D-Bus command
Add new Reload D-Bus command to reload NetworkManager configuration.

For now, this is like sending SIGHUP to the process. There are several
advantages here:

  - it is guarded via PolicyKit authentication while signals
    can only be sent by root.

  - the user can wait for the reload to be complete instead of sending
    an asynchronous signal. For now, we operation completes after
    nm_config_reload() returns, but later we could delay the response
    further until specific parts are fully reloaded.

  - SIGHUP reloads everything including re-reading configuration from
    disk while SIGUSR1 reloads just certain parts such as writing out DNS
    configuration anew.
    Now, the Reload command has a flags argument which is more granular
    in selecting parts which are to be reloaded. For example, via
    signals the user can:

      1) send SIGUSR1: this writes out the DNS configuration to
         resolv.conf and possibly reloads other parts without
         re-reading configuration and without restarting the DNS plugin.
      2) send SIGHUP: this reloads configuration from disk,
         writes out resolv.conf and restarts the DNS plugin.

    There is no way, to only restart the DNS plugin without also reloading
    everything else.
2016-06-01 19:06:34 +02:00
Thomas Haller 8913585397 libnm: implement missing NM_AUTH_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS 2016-06-01 19:06:34 +02:00
Lubomir Rintel e96f0e6349 all: trivial: use g_value_dup_string () 2016-05-30 16:13:48 +02:00