Commit Graph

25641 Commits

Author SHA1 Message Date
Beniamino Galvani
70916a1183 ifcfg-rh: add PKEY_ID to well-known keys
Fixes: 81e6fe963e ('ifcfg-rh: add functions to detect well-known ifcfg-rh keys')
2020-04-17 09:47:16 +02:00
Antonio Cardace
f957359421 clients: merge branch 'ac/cli_hide_if_default'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/470
2020-04-16 18:21:27 +02:00
Antonio Cardace
a5916de599 ethtool: refactor how options are hidden if default
Just use the new flag NMMetaPropertyInfo.
2020-04-16 10:52:46 +02:00
Antonio Cardace
3af07fd415 bridge: make some advanced options hidden if default
The options are:
  * group-address
  * multicast-querier
  * multicast-query-use-ifaddr
  * multicast-router
  * vlan-stats-enabled
  * vlan-protocol
2020-04-16 10:52:45 +02:00
Thomas Haller
69eca25391 cli: let _print_fill() hide option if NM_META_ACCESSOR_GET_OUT_FLAGS_HIDE is set
Regardless, whether the option is also currently the default.
2020-04-16 10:52:45 +02:00
Antonio Cardace
b94fcb2a94 clients: allow properties to be hidden if they have the default value 2020-04-16 10:52:42 +02:00
Thomas Haller
2cf31bfef0 keyfile: minor cleanup handling error in read_array_of_uint()
Why "if (length > G_MAXUINT)"? This is never going to hit. Also,
we probably should actual missing keys handle differently from
empty lists. If @error is set, return without setting the property.
2020-04-15 22:37:51 +02:00
Thomas Haller
8f46425b11 keyfile: avoid assertion failure in nm_keyfile_plugin_kf_get_{string,integer}_list()
g_key_file_get_integer_list() can return %NULL without setting an error.
That is the case if the key is set to an empty value.

For X sake, this API. Read the documentation and figure out whether
the function can return %NULL without reporting an error.

Anyway, avoid the assertion failure.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/412
2020-04-15 22:37:24 +02:00
Thomas Haller
216e97b7fa dbus: pretty format "org.freedesktop.NetworkManager.conf"
- indent by 4 spaces, not 8. We do that for the other 2 D-Bus
  configuration files. Also, since our lines here are rather long,
  save a bit in this regard.

- don't wrap lines for the XML elements. It makes it easier to visually
  parse.

- sort some lines asciibetically.

No changes otherwise.
2020-04-15 19:17:00 +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
12c2aacea7 keyfile: cleanup mac_address_parser() 2020-04-15 11:25:23 +02:00
Piotr Drąg
304fabf381 po: mark broken translations as fuzzy
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/468
2020-04-14 09:17:27 +02:00
Piotr Drąg
21a7e89061 po: update Polish (pl) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/467
2020-04-14 09:13:53 +02:00
David Drinn
4e73d71518 examples: fix copy/paste comment error from another script
https://github.com/NetworkManager/NetworkManager/pull/361
2020-04-11 15:38:46 +02:00
Beniamino Galvani
f2756b930e release: bump version to 1.25.0 (development) 2020-04-10 18:08:10 +02:00
Beniamino Galvani
f80826fbb2 release: bump version to 1.23.90 (1.24-rc1) 2020-04-10 17:55:22 +02:00
Antonio Cardace
f93d0ea3fd release: update NEWS 2020-04-10 17:52:44 +02:00
Antonio Cardace
bdcd15a62b bond: merge branch 'ac/bond_mode_fix'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/464
2020-04-10 17:49:01 +02:00
Antonio Cardace
2a5d9eb60b bond: small cleanups
* Use an enum instead of a string, is faster for comparisons.
* Add debug assertions
* Have NMBondMode enum correspond to Kernel numbering
2020-04-10 17:46:22 +02:00
Antonio Cardace
d73a98a3e8 nm-setting-bond: also accept bond mode as a numerical id
That corresponds to how the Kernel numbers the different modes.
2020-04-10 17:46:18 +02:00
Thomas Haller
2f20878dbf man: fix obsolete references to monitor-connection-files in manual pages
monitor-connection-files was deprecated and disabled by default for a long
time. In the meantime, it has no effect at all.

Remove references from the manual pages.
2020-04-10 15:02:20 +02:00
Gennadij Latyshev
6cbbdb63fb po: update Russian (ru) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/348
2020-04-10 14:02:58 +02:00
Thomas Haller
f3ca61e6e4 shared/trivial: fix typo in code comment and reword 2020-04-10 10:55:22 +02:00
Thomas Haller
5f668ee389 cli: merge branch 'th/cli-command-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/460
2020-04-10 10:48:56 +02:00
Thomas Haller
3e1e63e57d cli/polkit: make parsing polkit-agent-helper-1 protocol more conforming
- in io_watch_have_data(), ensure that we handle incomplete lines
that don't yet have a newline by waiting for more data. That means,
if the current content of the in_buffer does not have a newline, we
wait longer.

- in io_watch_have_data(), implement (and ignore) certain commands
instead of failing the request.

- in io_watch_have_data(), no longer g_compress() the entire line.
"polkitagenthelper-pam.c" never backslash escapes the command, it
only escapes the arguments. Of course, there should be no difference
in practice, except that we don't want to handle escape sequences
in the commands.

- in io_watch_have_data(), compare SUCCESS/FAILURE literally.
"polkitagenthelper-pam.c" never appends any trailing garbage to these
commands, and we shouldn't handle that (although "polkitagentsession.c"
does).

- when io_watch_have_data() completes with success, we cannot destroy
AuthRequest right away. It probably still has data pending that we first
need to write to the polkit helper. Wait longer, and let io_watch_can_write()
complete the request.

- ensure we always answer the GDBusMethodInvocation. Otherwise, it gets
leaked.

- use NMStrBuf instead of GString.
2020-04-10 10:44:57 +02:00
Thomas Haller
277925c36a cli/polkit: suppress stderr from polkit-agent-helper when prompting for polkit authentication
Otherwise, we get an additional error message form the helper:

  $ nmcli --ask device wifi rescan
  System policy prevents Wi-Fi scans
  (action_id: org.freedesktop.NetworkManager.wifi.scan)
  password (user): •••••••
  polkit-agent-helper-1: pam_authenticate failed: Authentication failure
  Error: org.freedesktop.NetworkManager.wifi.scan request failed: not authorized.
2020-04-10 10:44:56 +02:00
Thomas Haller
d4a20fe360 cli/polkit: rework parsing identities for polkit request
The identities are in a nested dictionary of variants. We only want
to pick the "unix-user" values that we can handle.
2020-04-10 10:44:54 +02:00
Thomas Haller
b0759e9662 cli/polkit: reject unknown D-Bus methods 2020-04-10 10:44:53 +02:00
Thomas Haller
0dbb9c279e cli/polkit: rename NM_POLKIT_LISTENER_SIGNAL_REQUEST signal to "request-sync"
The response is blocking, which generally is rather ugly. Let's not fix
that now, but at least rename the signal so that it clearly points this
out.
2020-04-10 10:44:52 +02:00
Thomas Haller
7d91208218 cli/polkit: avoid G_DECLARE_FINAL_TYPE() in nm-polkit-listener.h
G_DECLARE_FINAL_TYPE() is glib 2.44, while we currently still only require glib 2.40.
2020-04-10 10:44:51 +02:00
Thomas Haller
2384033b05 shared: fix returning EAGAIN from nm_utils_fd_read()
We cannot just swallow EAGAIN and pretend that not bytes were read.

read() returning zero means end of file. The caller needs to distinguish
between end of file and EAGAIN.
2020-04-10 10:44:50 +02:00
Thomas Haller
8c637e693a shared/strbuf: fix signedness of integer comparison in nm_str_buf_append_printf() 2020-04-10 10:44:48 +02:00
Thomas Haller
741258a928 shared/strbuf: rename private, mutable fields in NMStrBuf structure
NMStrBuf is not an opaque structure, so that we can allocate it on the
stack or embed it in a struct.

But most of the fields should not be touched outside of the
implementation.

Also, "len" and "allocated" fields may be accessed directly, but
they should not be modified.

Rename the fields to make that clearer.
2020-04-10 10:44:47 +02:00
Thomas Haller
560b840a11 shared/strbuf: add nm_str_buf_is_initalized() helper 2020-04-10 10:44:46 +02:00
Thomas Haller
19fff8444e shared/strbuf: add nm_str_buf_erase() helper 2020-04-10 10:44:45 +02:00
Thomas Haller
f8efed528d shared/strbuf: add nm_str_buf_get_str_unsafe() helper function to give direct access to string buffer 2020-04-10 10:44:44 +02:00
Thomas Haller
7dc467bbbc shared/strbuf: add nm_str_buf_set_size() helper function 2020-04-10 10:44:43 +02:00
Thomas Haller
a2d52669aa shared/strbuf: add nm_str_buf_ensure_trailing_c() helper function 2020-04-10 10:44:42 +02:00
Thomas Haller
64894182ca shared/strbuf: expose read only value for "allocated" buffer size
We cannot actually mark the field as const, because then you could no
longer initialize a variable that contains a NMStrBuf with designated
initializers.

We also want to keep the "_allocated" alias, for the only places that
are allowed to mutate the field: inside "nm-str-buf.h". Add an alias
for that field, that is allowed to be read, provided that you don't
modify it!

The alternative would be a nm_str_buf_get_allocated() accessor, but
that seems unnecessarily verbose when you could just access the field.
2020-04-10 10:44:41 +02:00
Thomas Haller
7ff170a28f shared/strbuf: don't have const values in NMStrBuf
Before, if a struct had a field of type NMStrBuf (which is sensible to do),
then you could not longer initialize the entire struct with

  *ptr = (Type) { };

because NMStrBuf contained const fields.

The user should never set these fields directly and use nm_str_buf_*() to modify
them them. But no longer mark them as const, because that breaks valid
use cases.
2020-04-10 10:44:40 +02:00
Thomas Haller
43ba2cb933 shared/strbuf: allow forward declaring "struct _NMStrBuf" 2020-04-10 10:44:39 +02:00
Thomas Haller
abacc1e919 shared/strbuf: only clear the bytes that we actually wrote to
The allocated buffes are not known to be written. It is unnecessary to
clear them.

If the user writes sensitive data to those locations, without using
the NMStrBuf API, then it is up to the user to bzero the memory
accordingly.
2020-04-10 10:44:38 +02:00
Thomas Haller
d1c2572e11 shared: add NM_UTILS_GET_NEXT_REALLOC_SIZE_1000 define
When we have a buffer that we want to grow exponentially with
nm_utils_get_next_realloc_size(), then there are certain buffer
sizes that are better suited.

For example, if you have an empty NMStrBuf (len == 0), and you
want to allocate roughly one kilobyte, then 1024 is a bad choice,
because nm_utils_get_next_realloc_size() will give you 2024 bytes.

NM_UTILS_GET_NEXT_REALLOC_SIZE_1000 might be better in this case.
2020-04-10 10:44:37 +02:00
Thomas Haller
aede8fa554 cli: remove redundant return value from NMCCommand funcs
Many func implementations are asynchronous, that means, they
cannot return right away. Instead, they record the return value
in nmc->result_value.

The return value from the command functions was thus redundant.
In the best case, the return value agrees with the cached result
in nmc->result_value, in which it was unnecessary. In the worst case,
they disagree, and overwrite each other.

nmc->result_value is state. Tracking state is hard, and there should
be fewer places where the state gets mutated. Also, the rules how that
happened should be clearer. Drop the redundant, conflicting mechanism.
2020-04-10 10:44:37 +02:00
Thomas Haller
c5d45848dd cli: mark argv argument for command line parsing as const
It's bad style to pass the argv argument around and mutate it.
We shouldn't mutate it, and not assume that it stays around after
the function returns to the caller (meaning, we should clone the
array if we intend to use it later).

Add const specifier.
2020-04-10 10:27:27 +02:00
Thomas Haller
3a451141bd cli: merge implementations for do_networking_on_off() 2020-04-10 10:27:27 +02:00
Thomas Haller
d39f5c264b cli: pass cmd to NMCCommand.func()
It is useful from inside a function to know the command that it belongs to.
Currently we have do_networking_on() and do_networking_off() as separate
functions. However, these are basically the same with a minor difference.
If the func callback could know the "cmd" that it was called for, these
function can be combined.

Of course, without passing the NMCCommand instance, you still can
achieve the same results, especially as the NMCCommand instances are
static and known at compile time: just have separate func
implementations. But by passing the command to the function, they
*can* be combined, which is a useful thing to do.
2020-04-10 10:27:27 +02:00
Thomas Haller
e05f35f9f1 cli: cleanup NMCCommand and declarations of func implementations
- move the main func declarations to nmcli.h and give them a common
prefix "nmc_command_func_" prefix.

- remove some of the header files that are now empty. In fact, these
headers did not really declare some well separated module. While we
probably should structure the code in nmcli better with better layering,
it was not and still is not. Having these dummy headers don't mean that
the code is well structured and they serve little purpose.

- move the static NMCommand lists variables into the function scope
where they are used.
2020-04-10 10:27:27 +02:00
Thomas Haller
ef0c289104 shared/tests: avoid undefined behavior in test_nm_utils_get_next_realloc_size() test 2020-04-10 10:27:27 +02:00