Commit Graph

84 Commits

Author SHA1 Message Date
Thomas Haller
606612ea59 all: add "libnm/nm-default-client.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller
a9202a0f3d build/meson: cleanup dispatcher/meson.build 2021-02-09 12:38:16 +01:00
Thomas Haller
bd302341ef build/meson: rename "libnm_utils_base" to "libnm_glib_aux"
It's the better name.
2021-01-27 21:02:40 +01:00
Thomas Haller
977ea352a0 all: update deprecated SPDX license identifiers
These SPDX license identifiers are deprecated ([1]). Update them.

[1] https://spdx.org/licenses/

  sed \
     -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \
     -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \
     -i \
     $(git grep -l SPDX-License-Identifier -- \
         ':(exclude)shared/c-*/' \
         ':(exclude)shared/n-*/' \
         ':(exclude)shared/systemd/src' \
         ':(exclude)src/systemd/src')
2021-01-05 09:46:21 +01:00
Thomas Haller
595c5854ad introspection: avoid compiler warning in generated introspection files
Disable "-Wincompatible-pointer-types-discards-qualifiers" warning, as
this breaks build of the gdbus-codegen files.

With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, we
get a failure to build generated code:

    introspection/org.freedesktop.NetworkManager.AccessPoint.c:438:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_INTERFACE (NMDBusAccessPoint, nmdbus_access_point, G_TYPE_OBJECT)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1784:47: note: expanded from macro 'G_DEFINE_INTERFACE'
    #define G_DEFINE_INTERFACE(TN, t_n, T_P)                    G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;)
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1803:61: note: expanded from macro 'G_DEFINE_INTERFACE_WITH_CODE'
    #define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2042:7: note: expanded from macro '_G_DEFINE_INTERFACE_EXTENDED_BEGIN'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    introspection/org.freedesktop.NetworkManager.AccessPoint.c:944:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointProxy, nmdbus_access_point_proxy, G_TYPE_DBUS_PROXY,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
    #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
      _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    introspection/org.freedesktop.NetworkManager.AccessPoint.c:1729:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointSkeleton, nmdbus_access_point_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
    #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
      _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~

(cherry picked from commit 03d9ec27fa)
2020-11-23 15:26:47 +01:00
Thomas Haller
88071abb43 all: unify comment style for SPDX-License-Identifier tag
Our coding style recommends C style comments (/* */) instead of C++
(//). Also, systemd (which we partly fork) uses C style comments for
the SPDX-License-Identifier.

Unify the style.

  $ sed -i '1 s#// SPDX-License-Identifier: \([^ ]\+\)$#/* SPDX-License-Identifier: \1 */#' -- $(git ls-files -- '*.[hc]' '*.[hc]pp')
2020-09-29 16:50:53 +02:00
Thomas Haller
740b092fda format: replace tabs for indentation in code comments
sed -i \
     -e 's/^'$'\t'' \*/     */g' \
     -e 's/^'$'\t\t'' \*/         */g' \
     -e 's/^'$'\t\t\t'' \*/             */g' \
     -e 's/^'$'\t\t\t\t'' \*/                 */g' \
     -e 's/^'$'\t\t\t\t\t'' \*/                     */g' \
     -e 's/^'$'\t\t\t\t\t\t'' \*/                         */g' \
     -e 's/^'$'\t\t\t\t\t\t\t'' \*/                             */g' \
     $(git ls-files -- '*.[hc]')
2020-09-28 16:07:52 +02:00
Antonio Cardace
328fb90f3e all: reformat all with new clang-format style
Run:

    ./contrib/scripts/nm-code-format.sh -i
    ./contrib/scripts/nm-code-format.sh -i

Yes, it needs to run twice because the first run doesn't yet produce the
final result.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 16:07:51 +02:00
Thomas Haller
426a4c9d50 all: replace cleanup macro "gs_unref_keyfile" by "nm_auto_unref_keyfile" 2020-09-02 17:46:43 +02:00
Thomas Haller
259a07ae46 dispatcher: minor cleanup error paths in script_dispatch()
Handle the error case first and return early.
2020-04-30 21:50:28 +02:00
Thomas Haller
0b168f7b99 dispatcher: clarify documentation about first argument to dispatcher scripts for "connectivity-change"
The manual page claimed that for "connectivitiy-change" actions, the dispatcher
scripts would get as first argument (the device name) "none". That was not done,
only for "hostname" actions.

For consistency, maybe that should be adjusted to also pass "none" for connectivity
change events. However, "none" is really an odd value, if there is no device. Passing
an empty word is IMO nicer. So stick to that behavior, despite being inconsistent.
Also fix the documentation about that.
2020-04-30 21:50:28 +02:00
Thomas Haller
b681aec452 dbus: indent by 4 space in "nm-ifcfg-rh.conf" D-Bus configuration file 2020-04-15 18:48:32 +02:00
Thomas Haller
5450080932 dbus: don't use tabs in "nm-dispatcher.conf" D-Bus configuration file 2020-04-15 18:47:12 +02:00
Thomas Haller
46dd4d0fbf meson: merge branch 'inigomartinez/meson-license'
Add SPDX license headers for meson files.

As far as I can tell, according to RELICENSE.md file, almost everybody
who contributed to the meson files agreed to the LGPL-2.1+ licensing.
This entails the vast majority of code in question.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397
2020-03-28 12:45:19 +01:00
Thomas Haller
4fe46d9e20 build/meson: fix build by link nm-dispatcher with libnm-glib-aux.la
Fixes: a34b1f793e ('build: link nm-dispatcher with libnm-glib-aux.la')
2020-03-25 16:41:17 +01:00
Thomas Haller
380ecbc234 dispatcher: use nm_str_hash() for hash table in dispatcher
nm_str_hash() uses siphash24. We want to use that everywhere.
The only concern would be that it is slower. But if that's the concern,
then we would have many more performance critical places to care
about first.
2020-03-25 16:19:53 +01:00
Thomas Haller
52dbab7d07 all: use nm_clear_pointer() instead of g_clear_pointer()
g_clear_pointer() would always cast the destroy notify function
pointer to GDestroyNotify. That means, it lost some type safety, like

   GPtrArray *ptr_arr = ...

   g_clear_pointer (&ptr_arr, g_array_unref);

Since glib 2.58 ([1]), g_clear_pointer() is also more type safe. But
this is not used by NetworkManager, because we don't set
GLIB_VERSION_MIN_REQUIRED to 2.58.

[1] f9a9902aac

We have nm_clear_pointer() to avoid this issue for a long time (pre
1.12.0). Possibly we should redefine in our source tree g_clear_pointer()
as nm_clear_pointer(). However, I don't like to patch glib functions
with our own variant. Arguably, we do patch g_clear_error() in
such a manner. But there the point is to make the function inlinable.

Also, nm_clear_pointer() returns a boolean that indicates whether
anything was cleared. That is sometimes useful. I think we should
just consistently use nm_clear_pointer() instead, which does always
the preferable thing.

Replace:

   sed 's/\<g_clear_pointer *(\([^;]*\), *\([a-z_A-Z0-9]\+\) *)/nm_clear_pointer (\1, \2)/g' $(git grep -l g_clear_pointer) -i
2020-03-23 11:22:38 +01:00
Iñigo Martínez
648155e4a1 license: Add license using SPDX identifiers to meson build files
License is missing in meson build files. This has been added using
SPDX identifiers and licensed under LGPL-2.1+.
2020-02-17 13:16:57 +01:00
Thomas Haller
a0632c529b dispatcher: silently ignore empty files
There is already a way to hide/shadow scripts in "/usr/lib/NetworkManager/dispatcher.d":
by putting a file of the same name in "/etc/NetworkManager/dispatcher.d".

There is also the special case that if the file symlinks to "/dev/null", the
file is silently ignored. This is the proper way to hide a script.

I think we should also take a plain empty file as user indication to hide a script.
This way, one can simply hide a file with

  # touch /etc/NetworkManager/dispatcher.d/10-ifcfg-rh-routes.sh

It's an alternative to symlinking to /dev/null.
2019-11-28 13:44:57 +01:00
Thomas Haller
f5755259e4 dispatcher: cleanup loop in find_scripts() to avoid explicit free() 2019-11-28 13:44:43 +01:00
Thomas Haller
3ade6dacfc dispatcher: use free() to free memory allocated with malloc()
In practice, nowadays g_free() is the same as free(), so there is no
difference. However, we still should not mix the two and use free()
for data that was allocated with malloc() -- in this case, the memory
was allocated by libc's realpath().
2019-11-27 11:41:53 +01:00
Thomas Haller
1c2889faee dispatcher: fix detection of no-wait dispatcher scripts
While at it, use NM_STR_HAS_SUFFIX() with the string literal.

Fixes: 35a428f168 ('dispatcher: look for the scripts in /usr/lib as well')
2019-11-27 11:41:53 +01:00
Thomas Haller
6d7270e222 build/meson: cleanup configuration_data() for paths
We don't need such data duplicated. The build setup should
have only one configuration_data() for patching such values.

Now we only have one global, immutable data_conf dictionary with
configuration values. Note that none of the users of data_conf uses all
entries, but as the entries are basically only dependent on the
meson/configure option and valid for the entire project, this simplifies
to handling.
2019-11-22 15:59:31 +01:00
Iñigo Martínez
23b4dc5f77 meson: Rename variables related to pkg-config variables
Some variables belong to variables in their correspondent pkg-config
file.

These variables have been renamed to `dependency_variable` to
reflect the dependency and variables from pkg-config files they are
related to.

Some of these has also been fixed to use paths relative to
installation prefix.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
70da6993c8 meson: Improve dispatcher test build file
Different objects used in the `test-dispatcher-envp` target
have been grouped together.

The dependency over the `libnm` library has been removed as it is
unnecessary.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
4e85fdcdb7 meson: Avoid the creation of extra variables
Extra variables are used for sources of targets in the `dispatcher`
build file. These have been moved to the `source` parameter because
using them directly avoiding the creation of extra variablse doesn't
hurt readibility.

The compiler flags `cflags` variable has also been renamed to be
consistent with the rest of build files.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
c5e80a23fe meson: Remove extra new line 2019-10-01 09:49:33 +02:00
Iñigo Martínez
70a34c54fe meson: Use dependency for nm-default header
The `nm-default.h` header is used widely in the code by many
targets. This header includes different headers and needs different
libraries depending the compilation flags.

A new set of `*nm_default_dep` dependencies have been created to
ease the inclusion of different directorires and libraries.

This allows cleaner build files and avoiding linking unnecessary
libraries so this has been applied allowing the removal of some
dependencies involving the linking of unnecessary libraries.
2019-10-01 09:49:33 +02:00
Iñigo Martínez
bfbcf8f3fe meson: Use generators placeholders
Functions derived from generators as `configure_file`,
`custom_target` and `i18n.merge_file` can use placeholders like
`@BASENAME@` that removes the extension from the input filename
string.

The output string has been replaced by this placeholder that
allows in some cases the use of less variables.
2019-10-01 09:49:33 +02:00
Thomas Haller
abff46cacf all: manually drop code comments with file description 2019-10-01 07:50:52 +02:00
Lubomir Rintel
24028a2246 all: SPDX header conversion
$ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
2019-09-10 11:19:56 +02:00
Beniamino Galvani
7c2317a557 build: fix meson warning about 'install' arg in 'configure_file'
WARNING: Project targetting '>= 0.44.0' but tried to use feature
introduced in '0.50.0': install arg in configure_file

From the documentation:

 "install (added 0.50.0) When true, this generated file is installed
 during the install step, and install_dir must be set and not
 empty. When false, this generated file is not installed regardless of
 the value of install_dir. When omitted it defaults to true when
 install_dir is set and not empty, false otherwise."

The parameter can be omitted because install_dir is set.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/216
2019-08-05 16:05:30 +02:00
Lubomir Rintel
0c62445853 dispatcher: tolerate lack of connection path
If the dispatcher is being invoked because the connection was removed
(e.g. device going down), it doesn't have a path or a filename anymore.
Don't abort in such cases.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/205
2019-07-24 13:30:41 +02:00
Francesco Giudici
b3a5541111 dispatcher: add MS Azure endpoint env var expected by cloud-init
Some linux distros (e.g., RHEL, CentOS and Fedora) ship a dispatcher
script with their dhclient package in order to run user dhclient hook
scripts also when connections are run by NetworkManager.
The scripts convert the var names in the environment to the ones
expected in the dhclient hook scripts.
This feature is currently use by cloud-init to retrieve the MS Azure
server endpoint address, which is sent in the private dhcp option 245.
We just redefined the default dhclient var names for the private options
from "unknown_xyz" to "private_xyz". In order to let current cloud-init
version to be able to retrieve the Azure server endpoint address, add
the legacy var name "unknown_245" to the dispatcher script environment.
2019-07-05 15:17:04 +02:00
Francesco Giudici
b2915e20d1 dispatcher/trivial: fix typo in comment 2019-07-05 15:17:04 +02:00
Thomas Haller
c0e075c902 all: drop emacs file variables from source files
We no longer add these. If you use Emacs, configure it yourself.

Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.

No manual changes, just ran commands:

    F=($(git grep -l -e '-\*-'))
    sed '1 { /\/\* *-\*-  *[mM]ode.*\*\/$/d }'     -i "${F[@]}"
    sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"

Check remaining lines with:

    git grep -e '-\*-'

The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
2019-06-11 10:04:00 +02:00
Thomas Haller
f4222aff07 build/meson: depend test-dispatcher-envp on libnm
Otherwise we can get a build failiure:

  ../libnm/NetworkManager.h:61:27: fatal error: nm-enum-types.h: No such file or directory
2019-06-02 08:34:34 +02:00
Thomas Haller
7ea76c07e5 dispatcher: log warning when nm-dispatcher quits with requests pending 2019-05-27 12:43:06 +02:00
Thomas Haller
f809644866 build: don't link dispatcher with generated nmdbus-dispatcher bindings
We don't need it anymore.

Still, for tests let gdbus-codegen run and generate the sources and
compile them. We want to keep "dispatcher/nm-dispatcher.xml" and ensure
that it is still valid.
2019-05-27 12:39:25 +02:00
Thomas Haller
cdaedecaa7 dispatcher: unown dispatcher D-Bus name on exit 2019-05-27 12:10:26 +02:00
Thomas Haller
a01e760667 dispatcher: drop GDBusInterfaceSkeleton and generate GDBus bindings
Just hook into GDBusConnection directly. No need for this additional
layer that provides nothing. It doesn't even provide extra type-safety,
because you still need to get the arguments of the signal handler right.
That that point, it's as hard as getting the format string for
g_variant_get() right.

It still adds lines of code, because the "Action" method has such a
large argument list.
2019-05-27 12:10:26 +02:00
Thomas Haller
484194fa07 dispatcher: drop Handler GObject
"nm-dispatcher.c" does something rather simple. It is natural that it
has a bit of global data to keep track of that it's doing ("gl").

But this does not lend itself to pack the job of dispatcher into an
object. In fact, the Handler object was little more about packaging
the GDBus interface skeleton and a bit of state.

Global variables are often problematic because they makes unit testing hard.
But first of all, we have no test for this (we should). But it's not said
that you need an "object" to make testing easier. If we want to make
individual bits easier testable, we can just as well pass all required
parameters explicitly instead of accessing global variables. Since we
package global variables neatly in "gl", this is very simple to
refactor. Also, global variables can make code harder to understand. But
the problem is the amount of state that is accessible. This is not
alleviated by packaging the state in a Handler object.

As there is always only one handler instance, this provides very little
benefit.

I will drop the GDBus interface skeleton soon. So this Handler object
will have even less purpose. Drop it.
2019-05-27 12:10:26 +02:00
Thomas Haller
cdea5ca795 dispatcher: keep the GDBusConnection instance in the global variable
It's anyway a singleton that is still referenced by other components.
So unrefing it in the mainloop does not actually release any memory.

However, the GDBusConnection singleton is fundamental for the run of
the program. Keep it accessible in the global variables.

Note that soon I will drop the GDBusInterfaceSkeleton and only operate
on the GDBusConnection. Then it makes more sense to keep it around.

Note that usually we want to keep the amount of global state small.
But this connection is anyway a singleton (that we already implicitly
use). So, it doesn't change the amount of global state nor does it really
have much state (we either have a reference to the singleton or we don't).
2019-05-27 12:09:53 +02:00
Thomas Haller
3a3c807add dispatcher: parse command line arguments in a seprate function
Split command line parsing out of the main() function. For one, it's
an self-contained step, so we can make main() simpler.

Also, we don't need the GOptionEntry on the stack of the main() function
for the remainder of the program.
2019-05-27 12:07:52 +02:00
Thomas Haller
866189a001 dispatcher: don't just exit() but always shutdown before exiting
It's ugly to uncoordinated just call exit(). We should quit the mainloop
and clean up everything we had going.

Note that since Handler has no dispose() function, we also need to hack
a g_signal_handlers_disconnect_by_func(). This will change soon.
2019-05-27 12:07:52 +02:00
Thomas Haller
90e4ba15bc dispatcher: move global variable ever_aquired_name into "gl" struct 2019-05-27 12:07:52 +02:00
Thomas Haller
a454e418d4 dispatcher: unref main loop at exit and remove signal handler sources 2019-05-27 12:07:52 +02:00
Thomas Haller
bccf754347 dispatcher: namespace global variables in a struct "gl" 2019-05-27 12:07:52 +02:00
Thomas Haller
23286b2afa dispatcher: use logging macros instead of g_log() directly
Also cleanup the logging macros.
2019-05-27 12:01:09 +02:00
Thomas Haller
b4d678b314 dispatcher: silence message about non-existing dispatcher directory
Silence messages like

  find-scripts: Failed to open dispatcher directory '/usr/lib/NetworkManager/dispatcher.d': Error opening directory “/usr/lib/NetworkManager/dispatcher.d”: No such file or directory

  find-scripts: Failed to open dispatcher directory '/usr/lib/NetworkManager/dispatcher.d/pre-up.d': Error opening directory “/usr/lib/NetworkManager/dispatcher.d/pre-up.d”: No such file or directory
2019-05-27 12:01:09 +02:00