Commit graph

32699 commits

Author SHA1 Message Date
Thomas Haller
442428dbbf
dispatcher: add cancellable for tracking SIGTERM 2021-08-04 09:41:10 +02:00
Thomas Haller
4dd517ca61
dispatcher: ignore SIGPIPE 2021-08-04 09:41:10 +02:00
Thomas Haller
e21db61b6d
dispatcher: setup signal handler as first
The very first and the very last thing we want to do is
register (unregister) the signal handler.
2021-08-04 09:41:10 +02:00
Thomas Haller
33b643414f
dispatcher: use GSource instead of source ids 2021-08-04 09:41:10 +02:00
Thomas Haller
7b4cb01366
dispatcher: replace GMainLoop by explicit context iteration
Explicitly iterating the context is more flexible, as we can control the
parameters how long we iterate. GMainLoop is essentially a (thread-safe)
iteration around one boolean flag (controlled by g_main_loop_run() and
g_main_loop_quit()). We can maintain that boolean flag ourselves.
2021-08-04 09:41:10 +02:00
Thomas Haller
82174a66c6
dispatcher: add comment about exit-on-idle race 2021-08-04 09:41:09 +02:00
Thomas Haller
dbd459ec92
nm-sudo: expect unknown interface in _bus_method_call()
GDBus will invoke the method_call callback also for the Get/Set
functions. Thus, we need to check the interface_name and handle
them (actually, there is nothing to handle, no properties exist).

Also, "Ping" method only exists for testing. It is usually not called
in production, so check for "GetFD" first.
2021-08-04 09:41:09 +02:00
Thomas Haller
1e71a00817
nm-sudo: return result from _bus_register_service()
Instead of adding a flag to global state.
2021-08-04 09:41:09 +02:00
Thomas Haller
5105995514
nm-sudo: use nm_dbus_connection_call_blocking() in _bus_register_service() 2021-08-04 09:41:09 +02:00
Thomas Haller
eeb01bcba9
nm-sudo: use nm_g_main_context_iterate_ready() helper 2021-08-04 09:41:09 +02:00
Thomas Haller
2b8add959f
nm-sudo: cancel quit_cancellable during shutdown 2021-08-04 09:41:09 +02:00
Thomas Haller
62a9a48cc2
nm-sudo: use nm_g_bus_get_blocking() to create GDBusConnection 2021-08-04 09:41:09 +02:00
Thomas Haller
a210e9a6f4
nm-sudo: fix race during exit-on-idle
nm-sudo is D-Bus activated and exits-on-idle. To do that race-free we
need:

  - sd_notify("STOPPING=1")
  - ReleaseName
  - keep processing pending requests
2021-08-04 09:41:09 +02:00
Thomas Haller
5d9a46ad34
nm-sudo: use nm_io_sockaddr_un_set() in nm_sudo_utils_open_fd() 2021-08-04 08:23:59 +02:00
Thomas Haller
292cf4c42f
nm-sudo: drop semicolon after _nm_log() macro 2021-08-04 08:23:59 +02:00
Thomas Haller
864bfb4052
glib-aux: add nm_dbus_connection_call_blocking() helper 2021-08-04 08:23:58 +02:00
Thomas Haller
dc2e0d30bb
glib-aux: add nm_dbus_connection_call_request_name() helper 2021-08-04 08:23:58 +02:00
Thomas Haller
68e049119a
glib-aux: add nm_g_main_context_iterate_ready() helper 2021-08-04 08:23:58 +02:00
Thomas Haller
133dc3d43c
glib-aux: add nm_g_bus_get_blocking() helper 2021-08-04 08:23:58 +02:00
Thomas Haller
b7c77d51eb
glib-aux: add nm_g_child_watch_source_new() and nm_g_child_watch_add_source() helpers 2021-08-04 08:23:58 +02:00
Thomas Haller
5d08d3a7ef
glib-aux: use GUnixFDSourceFunc for nm_g_unix_fd_source_new() signature 2021-08-04 08:23:58 +02:00
Thomas Haller
b87d7a8b40
glib-aux: add nm_sd_notify() helper
Reimplements systemd's sd_notify(). We want to notify, but we don't
want to link with libsystemd.
2021-08-04 08:23:58 +02:00
Thomas Haller
5e658530ab
glib-aux: add nm_io_sockaddr_un_set() helper 2021-08-04 08:23:50 +02:00
Thomas Haller
a29d8b712f
l3cfg: set NMIPConfigSource for NML3ConfigData at construct time
Each NML3ConfigData should have a source set, and in fact most callers
would call nm_l3_config_data_set_source() right after creating the
instance.

Move the source parameter to the new() constructor function. Also remove
the setter, making the source of an instance immutable.

As every l3cfg instance generally has a clear purpose, the source should
always be known from the start and doesn't need to change.
2021-08-03 20:36:08 +02:00
Thomas Haller
7a39f1f7e7
man: update URL for networkmanager.dev home page 2021-08-03 14:57:35 +02:00
Thomas Haller
b13dfcbc5b
libm: merge branch 'th/setting-update-one-secret'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/942
2021-08-02 14:16:14 +02:00
Thomas Haller
b06aed2d66
libnm/tests: check property meta data for secrets 2021-08-02 10:01:04 +02:00
Thomas Haller
675dd0edd7
libnm: minor cleanup of _nm_setting_clear_secrets() 2021-08-02 10:01:04 +02:00
Thomas Haller
d733df8f69
libnm: use from_dbus_fcn() property callback from update_one_secret()
Our handling of properties is relatively complicated. We should have
clear code paths and responsibilities who calls who.

There is from_dbus_fcn() callback to implement parsing a GVariant and
set the property in NMSetting. This is called via:

  - _nm_setting_new_from_dbus()
    - init_from_dbus()
      - _property_set_from_dbus()

Then, one of the from_dbus_fcn() implementations is
_nm_setting_property_from_dbus_fcn_gprop(), which calls
set_property_from_dbus(). That one sets the property using GObject
setter. That's good and a clear code path.

However, set_property_from_dbus() was also called via

  - _nm_setting_update_secrets()
    - klass->update_one_secret()
      - nm-setting.c:update_one_secret()
        - set_property_from_dbus()

Meaning, there is a different code path to set_property_from_dbus(),
which bypasses from_dbus_fcn(). That is highly undesirable, because
it should be clear how a property setter gets implemented, and this
way, potentially two different implementations were used.

Refactor nm-setting.c:update_one_secret() to use
_property_set_from_dbus() instead. This behaves potentially differently
for properties like NM_SETTING_ADSL_PASSWORD, which is implemented as
a "direct" property, where from_dbus_fcn() setter no longer uses g_object_set().
This should not make a difference in practice, and in any case, now the
code paths are unified.
2021-08-02 10:01:04 +02:00
Thomas Haller
f1fee9fe27
libnm: add out_is_modified argument to from_dbus_fcn() to detect modification
Note that most implementations use g_object_set(), and it's not
easy to detect modification. In those cases, we assume that modification
happened -- just like also the GObject setter will emit a notification
(as none of our properties use G_PARAM_EXPLICIT_NOTIFY).
2021-08-02 10:01:03 +02:00
Thomas Haller
c593980b2d
libnm: add helper function for init_from_dbus() to set property
There is one caller of property_type->from_dbus_fcn(). But we will
call it from multiple places, so move the code to a helper function.
2021-08-02 10:01:03 +02:00
Thomas Haller
77421ba1be
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.

Instead of repeatedly spelling out the function arguments, use a macro.

Advantages:

- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS  macro signals that this
  is an implementation of a property. You can now grep for these macros
  to find all implementation. That was previously rather imprecise, you
  could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
  implementations.
  As the goal is to keep properties "similar", there is a desire to
  reduce the number of similar implementations and to find them.

- changing the arguments now no longer will require you to go through
  all implementations. At least not, if you merely add an argument that
  has a reasonable default behavior and does not require explicit
  handling by most implementation.

- it's convenient to be able to patch the argument list to let the
  compiler help to reason about something. For example, the
  "connection_dict" argument to from_dbus_fcn() is usually unused.
  If you'd like to find who uses it, rename the parameter, and
  review the (few) compiler errors.

- it does save 573 LOC of boilerplate with no actual logic or useful
  information. I argue, that this simplifies the code and review, by
  increasing the relative amount of actually meaningful code.

Disadvantages:

- the user no longer directly sees the argument list. They would need
  cscope/ctags or an IDE to jump to the macro definition and conveniently
  see all arguments.

Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-08-02 10:01:03 +02:00
Thomas Haller
2f5543b3ed
libnm: cleanup _nm_setting_use_legacy_property() by using cleanup attribute 2021-08-02 10:01:03 +02:00
Thomas Haller
17f0acfdb3
std-aux: add _nm_nil macro
This is only useful to hack the clang-formatting.
2021-08-02 10:01:03 +02:00
Thomas Haller
41937748d8
contrib: add "makerepo.sh" script
"makerepo.sh" script is a helper script for handling dist-git
repositories. It was so far part of "automation" branch. It seems
useful enough to officially add it to "main" branch.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/944
2021-08-02 09:56:44 +02:00
Thomas Haller
13a5c38d58
cli: merge branch 'vbubela:add-gateway-nmcli'
https://bugzilla.redhat.com/show_bug.cgi?id=1870059

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/943
2021-08-02 09:44:08 +02:00
Vojtech Bubela
9d40226b00
nmcli: edit output of nmcli so it shows more inormation about routes
Edit nmcli command to show additional information about the routes
(both route4 and route6).

If there is information about next hop or metric in the route
structure it will be shown in addition to destination and prefix.
2021-08-02 09:37:02 +02:00
Vojtech Bubela
30b8c71198
libnm-core-aux: add function which prints information about route
Add function which will take route passed as argument and
print available information about the route into buffer.

The information are destination, prefix and then depending on route
next hop and metric.
2021-08-02 09:37:01 +02:00
Thomas Haller
d196e4962b
all: merge branch 'th/utils-api-rename'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/947
2021-08-02 09:27:31 +02:00
Thomas Haller
593cb57eb6
all: rename nm_utils_strdict_*() to nm_strdict_*() 2021-08-02 09:26:48 +02:00
Thomas Haller
3587cbd827
all: rename nm_utils_strsplit_set*() to nm_strsplit_set*() 2021-08-02 09:26:47 +02:00
Thomas Haller
4ac66a4215
all: rename nm_utils_strdup_reset*() to nm_strdup_reset*() 2021-08-02 09:26:47 +02:00
Thomas Haller
d0ba87a1ad
all: rename nm_utils_strbuf_*() API to nm_strbuf_*()
The "utils" part does not seem useful in the name.

Note that we also have NMStrBuf, which is named nm_str_buf_*().
There is an unfortunate similarity between the two, but it's still
distinct enough (in particular, because one takes an NMStrBuf and
the other not).
2021-08-02 09:26:42 +02:00
Thomas Haller
ce3069b01e
systemd: merge branch systemd into main
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/945
2021-08-02 09:25:02 +02:00
Thomas Haller
1e76fef4d1
std-aux: merge branch 'th/move-macros-to-std-aux'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/948
2021-08-02 09:15:54 +02:00
Thomas Haller
3a6eb5920e
all: use _NM_ENSURE_POINTER() macro 2021-07-30 11:03:29 +02:00
Thomas Haller
4484363df0
std-aux: add _NM_ENSURE_POINTER() macro 2021-07-30 11:02:33 +02:00
Thomas Haller
387d5ded93
std-aux: move _NM_ENSURE_TYPE(), _NM_ENSURE_TYPE_CONST(), NM_STRUCT_OFFSET_ENSURE_TYPE() 2021-07-30 10:51:02 +02:00
Thomas Haller
194e29d0dc
std-aux: move nm_offsetof_end() to std-aux and add nm_offsetof()
In std-aux, we cannot use G_STRUCT_OFFSET(). I guess, we could use
offsetof() directly. Instead, add an nm_offsetof() macro. This requires
<stddef.h>.
2021-07-30 10:51:01 +02:00
Thomas Haller
91a36478f6
std-aux: move _NM_CC_SUPPORT_AUTO_TYPE, _NM_CC_SUPPORT_GENERIC to "nm-std-aux.h" 2021-07-30 10:50:56 +02:00