Commit graph

1131 commits

Author SHA1 Message Date
Thomas Haller
b4e8ce876d core: add nm_settings_get() singleton getter for NMSettings 2016-05-24 12:35:57 +02:00
Thomas Haller
c35164a6a3 settings/trivial: rename nm_settings_get_connections() to nm_settings_get_connections_sorted()
nm_settings_get_connections() returns a sorted list. We have many users
of nm_connection_provider_get_connection(), which returns the same result,
but undefined order.

Next NMConnectionProvider will be dropped. Thus, we don't want to
seamlessly replace nm_connection_provider_get_connection() by a sorted
version nm_settings_get_connections().

Rename nm_settings_get_connections() to make clear it is sorted.
2016-05-24 12:35:57 +02:00
Thomas Haller
a2c843499c all/tests: split core part out of "nm-test-utils.h"
A large part of "nm-test-utils.h" is only relevant for tests inside "src/"
directory, as they are helpers related to NetworkManager core part.

Split this part out of "nm-test-utils.h" header.
2016-05-17 16:48:52 +02:00
Thomas Haller
2d428bda35 ifcfg-rh: remove unused define ERR_GET_MSG() 2016-05-17 12:26:02 +02:00
Thomas Haller
4dcb5e5ba5 ifcfg-rh: cleanup includes
- don't include "nm-default.h" from headers. All source files
  include this header as first.

- drop G_BEGIN_DECLS/G_END_DECLS. This is not C++ nor public
  API.

- drop unnecessary includes from header files. They are either
  not required, or already provided via "nm-default.h".

- include in source files the corresponding header file as first
  after "nm-default.h". This should ensure that header files are
  self-contained (appart from "nm-default.h").
2016-05-17 12:25:55 +02:00
Thomas Haller
b503b37636 ifcfg-rh: don't print warning in svGetValueInt64()
Having a simple accessor print warnings is not nice. At that point there
is no context as to why we are trying to read the value.

Note that the function already handles and expects invalid values, it's
just not clear that printing warnings from a utility function is the right
thing to do.

Just ignore such cases silently (at this point). It's up to the caller
to print a warning or whatever.
2016-05-17 12:22:42 +02:00
Thomas Haller
f3bd778d6d ifcfg-rh: use _NMLOG() macro in writer
This gives every logging line a proper "ifcfg-rh" prefix.
But drop the "    " prefixes.
2016-05-17 12:22:42 +02:00
Thomas Haller
a519cc57b8 ifcfg-rh: use _NMLOG() macro in reader
This gives every logging line a proper "ifcfg-rh" prefix.
2016-05-17 12:22:42 +02:00
Thomas Haller
c949e1c429 ifcfg-rh: reject vlan id of value 4096
Maybe we should also reject 0 and 4095, but for now leave it.
2016-05-17 12:22:42 +02:00
Thomas Haller
a85c3db2f0 ifcfg-rh: use _nm_utils_ascii_str_to_int64() instead of strtol() 2016-05-17 12:22:42 +02:00
Thomas Haller
4b538ea8f1 ifcfg-rh: replace uses of get_int() 2016-05-17 12:22:42 +02:00
Thomas Haller
7328613d7b ifcfg-rh: don't use get_int() to parse MTU value
And print a warning also if the value is out of range.
2016-05-17 12:22:41 +02:00
Thomas Haller
ec639b5c63 ifcfg-rh: cast variadic arguments to proper int type 2016-05-17 12:22:41 +02:00
Thomas Haller
8e6d619c46 ifcfg-rh: use _nm_utils_ascii_str_to_int64() in reader's get_uint()/get_int() functions 2016-05-17 12:22:41 +02:00
Thomas Haller
7961e1bb8a core: add nm_connection_provider_get_unmanaged_specs() 2016-05-17 11:54:08 +02:00
Beniamino Galvani
c5f17531b9 ifcfg-rh: add support for DNS priority 2016-05-12 17:13:50 +02:00
Joel Holdsworth
8606060121 settings: Follow symbolic link when installing file monitor
https://bugzilla.gnome.org/show_bug.cgi?id=765645
2016-05-12 15:24:11 +02:00
Thomas Haller
6c2130382a session-monitor: remove wrapper functions to connect/disconnect signal
We don't add such wrappers anywhere else, and I think they are not
desired style.

Also, keep the signal-id in a "gulong session_changed_id", instead of
guint.
2016-05-12 09:50:21 +02:00
Thomas Haller
c5ac691744 build: cleanup includes of <gmodule.h>
<gmodule.h> is implicitly included by <gio/gio.h> which is available
everywhere. For that reason, we would not have to include this header
at all. However, it is recommended to explicitly include <gmodule.h>
where needed.

So, include it where needed -- if <gio/gio.h> wouldn't be there --
and drop it from where it is not needed.
2016-04-30 03:42:16 +02:00
Thomas Haller
c6a92224a4 settings: don't unload settings plugins on failure
Also, registering a weak-pointer to close the module that
was just made as resident is pointless.
2016-04-29 15:48:18 +02:00
Lubomir Rintel
76844c65d6 ifupdown: avoid calloc()
It can return NULL and makes Coverity upset:

CID 75369 (#1 of 1): Dereference null return value (NULL_RETURNS)
4.  dereference: Dereferencing a null pointer ret.
2016-04-29 12:47:34 +02:00
Lubomir Rintel
2e563d9c84 ifnet: fix error handling
CID 76722 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement:
g_set_error(error, nm_setti....
2016-04-29 12:47:34 +02:00
Beniamino Galvani
5b70254ea0 ifcfg-rh: emit a warning when DEFROUTE=no and GATEWAY is set 2016-04-27 17:15:49 +02:00
Thomas Haller
7f7e1eb60b settings: fix write_hostname for relative-symbolic links
g_file_read_link() "reads" the symbolic link. If it's a relative path,
we get a relative path which is anchored on @file. We must resolve that
to be absolute.
2016-04-27 15:03:50 +02:00
Thomas Haller
d6e7fa164b settings: remove unnecessary "file" field for hostname from NMSettingPrivate 2016-04-27 14:51:55 +02:00
Francesco Giudici
19350c8975 settings: add notification after connections load
The notification was missing from a long time. The issue has been exposed only
now due to the c57e5a6b66 fix which properly
implemented the "startup-complete" notification substituting out of place code
which masked the bug.
2016-04-27 11:10:58 +02:00
Thomas Haller
767fa0ed3d settings: disconnect connection_ready_changed() handler when reaching startup_complete
We connect to notify::startup-complete signal of each connection,
but after we signal startup-complete once, we don't need that
signal anymore. Disconnect.
2016-04-26 15:48:20 +02:00
Thomas Haller
89cf9429a7 device: generate stable UUID for default-wired-connection
Generate a stable connection UUID for the default-wired-connection.
Otherwise, on every reboot, the UUID changes although the generated
connection is the same.

But also hash into the UUID the machine-id, the device name and the
hardware address. So, the UUID is only the same if the connection is
identical in every aspect.

Also, the UUID is used as Network_ID for the stable-privacy address
generation mode. It is bad to re-create different UUIDs on every boot
as it causes different addresses.
2016-04-26 12:50:16 +02:00
Thomas Haller
316359d8b6 settings: refactor read_hostname_*() 2016-04-25 15:26:26 +02:00
Thomas Haller
79d85ca180 settings: cleanup #if blocks for HOSTNAME_PERSIST_* 2016-04-25 15:26:26 +02:00
Patrick J. Volkerding
1a714ee5e6 settings: fix Slackware hostname setting
https://mail.gnome.org/archives/networkmanager-list/2016-April/msg00075.html
2016-04-25 15:26:20 +02:00
Beniamino Galvani
34964273ee audit: log changed properties when updating a connection
The main purpose of audit logging is to understand who did what to the
system configuration, so it is useful to log also the list of changed
properties when a connection is updated:

 op="connection-update"
 uuid="2f3e48fc-5f47-41d9-9278-d2871378df43"
 name="pppoe1"
 args="pppoe.username,pppoe.password"         <========
 pid=9523
 uid=1001
 result="success"
2016-04-20 17:31:01 +02:00
Thomas Haller
3164c026a2 settings: merge "connection-updated" and "connection-updated-by-user" signals
This is mostly interesting of NMPolicy, which no longer needs to
subscribe to two almost identical signals (where the by-user signal
was always invoked together with the plain "updated" signal).
2016-04-14 12:25:41 +02:00
Thomas Haller
65c55e2a78 settings: combine "updated" and "updated-by-user" signal in NMSettingsConnection
Instead of connecting to two similar signals, combine them into one
and pass "by_user" argument.

We still need to keep the original NM_SETTINGS_CONNECTION_UPDATED signal,
because it is exposed on D-Bus.
2016-04-14 12:25:40 +02:00
Thomas Haller
a4f1a1794f settings: emit NM_SETTINGS_CONNECTION_UPDATED right away and not on an idle handler
I want to combine NM_SETTINGS_CONNECTION_UPDATED and NM_SETTINGS_CONNECTION_UPDATED_BY_USER
into one signal. Thus, they must have same behavior with respect as to whether they are
scheduled on idle.

Emit NM_SETTINGS_CONNECTION_UPDATED right away.

The "Updated" signal is exposed via D-Bus on the settings object.
Removing the idle handling has no bad consequences there.

Apart from that, the signal has only the listener NMSettings::connection_updated().
connection_updated() first emits NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, which only
has listener: NMPolicy::connection_updated(), which already delegates to
an idle handler.

Second, NMSettings::connection_updated() emits
NM_CP_SIGNAL_CONNECTION_UPDATED which has the following listeners:

  - NMBluezDevice::cp_connection_updated(), which can cause the
    connection to be tracked/untracked. Any further changes are
    already delayed on an idle handler (check_emit_usable_schedule()).

  - NMDevice::cp_connection_added_or_updated(), which causes the
    connection to be tracked by the device. It also emits
    "notify::available-connections", which however is only relevant
    for the D-Bus bindings.
    At last, it does available_connections_check_delete_unrealized()
    which also is on an idle handler already.
2016-04-14 12:24:38 +02:00
Thomas Haller
d571933505 settings: drop signal slots from NMSettings
NMSettings has no derived classes and obviously nobody is using
those slots. Just drop them.
2016-04-14 12:17:35 +02:00
Thomas Haller
f7e7df772d settings: refactor connection_changed()
Again, no functional change.
2016-04-14 12:17:35 +02:00
Thomas Haller
866df17e97 settings: refactor connection-changed handler
No change in behavior, just not pass on this GUINT_TO_POINTER (TRUE).
2016-04-14 12:17:35 +02:00
Thomas Haller
30b8842a48 settings: use NM_GOBJECT_PROPERTIES_DEFINE in NMSettings/NMSettingsConnection/NMActiveConnection 2016-04-14 12:17:35 +02:00
Thomas Haller
c57e5a6b66 manager: fix implementation of NMManager's "startup-complete
Due to a bug, NMManager would connect to "notify::connections"
and might miss an important notification when NMSettings declares
startup-complete.

Fixes: b067ca7034
2016-04-14 12:17:35 +02:00
Thomas Haller
a170320c35 ifcfg-rh: support zero prefix length for IP addresses in reader 2016-04-11 13:01:42 +02:00
Thomas Haller
9152dec99f build: disable deprecation checks for internal compilation
For internal compilation we want to be able to use deprecated
API without warnings.

Define the version min/max macros to effectively disable deprecation
warnings.

However, don't do it via CFLAGS option in the makefiles, instead hack it
to "nm-default.h". After all, *every* source file that is for internal
compilation needs to include this header as first.
2016-04-05 22:22:58 +02:00
Lubomir Rintel
a8e8e76641 dbus: fix up the XML formatting
The conversion script didn't do a very good job. It got fired.
2016-04-05 14:37:51 +02:00
Lubomir Rintel
6e2b188361 dbus: convert the annotations to gtk-doc blocks 2016-04-05 14:37:51 +02:00
Beniamino Galvani
1422ce0a6a ifcfg-rh: don't chain up after failure of replace_and_commit()
If replace_and_commit() found existing route files (and the callback
has potentially already been invoked), it is wrong to chain up to
parent class and continue the update.

Fixes: f79d62692e
2016-03-30 18:12:32 +02:00
Robby Workman
c0a506648f settings: add persistent hostname support for Slackware 2016-03-29 15:51:34 -05:00
Thomas Haller
7991298c51 core: be strict about connection argument in D-Bus methods
There is no excuse for clients to send connections to NetworkManager
that have invalid/unknown fields. Just reject them.

This is a dangerous change, because we might now reject connections
that we were accepting previously. Who know what clients were sending
and it used to work.
2016-03-29 11:56:26 +02:00
Thomas Haller
3d8776108c libnm-core: add _nm_simple_connection_new_from_dbus() function
Contary to nm_simple_connection_new_from_dbus(), this internal
function allows to specify parse-flags.
2016-03-26 12:10:54 +01:00
Lubomir Rintel
618373a14f dbus: use the annotations for documentation
gdbus only understands those (and gtk docstrings, which we should eventually
use) when generating the documentation.
2016-03-26 11:28:19 +01:00
Beniamino Galvani
a4b4e0bc5b ifcfg-rh: add support for domain-suffix-match properties 2016-03-16 17:32:17 +01:00