Commit Graph

9141 Commits

Author SHA1 Message Date
Dan Williams
12d96c30f2 core: capture DNS configuration from resolv.conf when generating connections
If the interface who's IP configuration is being captured has the default
route, then read DNS servers from resolv.conf into the NMIP[4|6]Config.

This allows NetworkManager to repopulate resolv.conf if anything changes.
For example, if the system does not define a persistent hostname, then
when a device which has generated a connection activates, a hostname
lookup will be performed.  The results of that lookup may change resolv.conf,
and thus NetworkManager must rewrite resolv.conf.  Without capturing
DNS information at startup when generating connections, an empty
resolv.conf would be written.
2013-11-22 15:01:10 -06:00
Dan Williams
fab6260bfa policy: ignore nameservers when starting lookup thread (rh #1031763)
When generating connections at startup for active interfaces, the
generation code may not always be able to read DNS information for
the connection.  Thus, the device's IP4Config won't have any
nameservers and the device won't be considered for reverse-address
lookup.  However, since any device that gets this far is already
the "best" device and has the default route, and thus should be the
one used for reverse-address lookup.

Second, reorganize the code better handle dual-stack in the
future by checking the IP configs directly, instead of the
devices.  Since 'best4' and 'best6' may be different devices,
we want to operate on the IP configs, not devices, to handle
situations where the best IP4Config may not be suitable for
reverse lookup, but the best IP6Config is.

https://bugzilla.redhat.com/show_bug.cgi?id=1031763
2013-11-22 14:37:37 -06:00
Thomas Haller
77c02f1802 core: fix crash in nm-manager-auth
When doing nm_auth_chain_unref(), the code iterated over the ->calls and
cancelled them. However, some of these calls might not have passed on to
polkit_authority_check_authorization(), but instead being scheduled with
g_idle_add(). These calls have to be canceled too because the NMAuthChain
will already be destroyed when auth_call_complete() calls.

Now, we g_source_remove() these calls and free them immediatly. Before
these calls leaked and led to use after free crash.

Also fix a memory leak by always get the results with
polkit_authority_check_authorization_finish(), even when being
cancelled.

This is the backtrace of the crash:

  #0  0x00007f166efda359 in g_slist_remove () from /lib64/libglib-2.0.so.0
  #1  0x00007f167311bcc1 in auth_call_complete ()
  #2  0x00007f166efbde06 in g_main_context_dispatch ()
     from /lib64/libglib-2.0.so.0
  #3  0x00007f166efbe158 in g_main_context_iterate.isra.22 ()
     from /lib64/libglib-2.0.so.0
  #4  0x00007f166efbe55a in g_main_loop_run () from /lib64/libglib-2.0.so.0
  #5  0x00007f16730d3c0d in main ()

Co-Authored-By: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-22 20:03:14 +01:00
Dan Winship
461920bb96 cli: add NMC_RESULT_ERROR_NOT_FOUND and use as appropriate
This will allow callers to distinguish "no such connection" from
"connection failed to activate", etc.

https://bugzilla.redhat.com/show_bug.cgi?id=1022256
2013-11-22 13:51:25 -05:00
Jiří Klimeš
472ee8104d cli: initialize interface-name for new team connections in editor 2013-11-22 14:28:08 +01:00
Thomas Haller
7698d5dfc0 cli: bash completion completes filenames for team "config" property
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-22 14:10:34 +01:00
Jiří Klimeš
cdec23d314 cli: complete file names for properties whose value is a file name
Note:
Tilde expansion is enabled, so ~/abc<TAB> expands the string to /home/joe/abc.
However, when user did not use the completion and typed "~/myfile" manually,
the path could not be opened.

nmcli 802-1x.ca-cert> set ~/newca.crt
Error: failed to set 'ca-cert' property: Failed to open file '~/newca.crt': No such file or directory
2013-11-22 14:09:10 +01:00
Jiří Klimeš
a3c06afc12 cli: support file names for 'config' argument when creating team connections
nmcli con add type team config /home/cimrman/team-config.json

libteam (and in turn NetworkManager) configures team devices via plain config
data in JSON format. However, it is useful and more user-friendly for nmcli to
accept also a file name that contains the config data, and read it. Thus the
user is not forced to type whole (possibly long) config on the command line.
2013-11-22 14:09:10 +01:00
Dan Williams
7994778723 core: ignore RA-provided default routes (rh #1029213)
The router has no idea what the local configuration or user preferences are,
so sending routes with a prefix length of 0 is at best misinformed and at
worst breaks things.  The kernel also ignores plen=0 routes in its in-kernel
RA processing code in net/ipv6/ndisc.c.

https://bugzilla.redhat.com/show_bug.cgi?id=1029213
2013-11-20 14:24:38 -06:00
Jiří Klimeš
46a7760ead core: do not generate a connection for loopback interface (rh #1032594)
Else loopback is managed, and could be easily disconnected, which causes various
issues with applications. So do not manage it for now, to be on the safer side.

https://bugzilla.redhat.com/show_bug.cgi?id=1032594
2013-11-20 19:07:48 +01:00
Thomas Haller
073cc01f52 dispatcher: fix crash while logging from signal handler
Bug rh#1017884 describes a crash, where dbus_init() failed, which causes
a g_warning(). While writing the warning, a SIGTERM hit, and the
signal_handler() tries to call again g_message().

The logging functions of glib are not reentrant and call abort() when
invoked recursivly. The solution, is to use g_unix_signal_add, which
will dispatch the handler on the mainloop asynchronously.

This bug is not that serious, because the dispatcher was about to
terminate anyway. However, it gets registered as a crash by the system
(ABRT).

https://bugzilla.redhat.com/show_bug.cgi?id=1017884

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-19 00:20:12 +01:00
Thomas Haller
fbcabeb7f7 libnm-glib: fix crash by taking additional ref in nm-remote-connection/result_cb
result_cb invokes a function pointer provided by the user. Nothing prevents
the user from destroying the NMRemoteConnection in the callback, which leads
to a crash. Take an additional ref of NMRemoteConnection to keep it
alive.

This probably caused a crash for nm-applet:
https://bugzilla.redhat.com/show_bug.cgi?id=1030403

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-18 23:01:35 +01:00
Jiří Klimeš
f93c154161 device: remove invalid assertion in slave_state_changed()
When activating a team slave and 'teamd' binary is not installed, the
priv->state of master device will be NM_DEVICE_STATE_FAILED, which is greater
than NM_DEVICE_STATE_ACTIVATED.

<info> Activation (nm-team) Stage 1 of 5 (Device Prepare) started...
<warn> Activation (nm-team) to start teamd: not found
<info> (nm-team): device state change: prepare -> failed (reason 'none') [40 120 0]
...
<debug> master_state_cb(): (0x81d6968): master ActiveConnection [0x91d69d0] 'team0' failed
<info> (eth1): device state change: config -> failed (reason 'dependency-failed') [50 120 50]
...
<debug> slave_state_changed(): (nm-team): slave eth1 state change 50 (config) -> 120 (failed)
--- ASSERTION ---
2013-11-18 14:24:10 -06:00
Thomas Haller
044cebade4 build: fix for make distcheck without enable-gtk-doc
Without this patch, the following fails with a rather obscure message
about missing make target.

  ./autogen.sh && make && make distcheck
  ...
  *** No rule to make target `NetworkManager.8', needed by `distdir'. Stop.

Swap the order of the subdirectories 'docs' and 'man' to build
'docs' earlier. This way, `make distcheck` fails in the directory 'docs'
with a better error message:
  *** gtk-doc must be installed and enabled in order to make dist

Also, add 'man/nmcli-examples.5' to the list of files, to determine
whether to use the pre generated doc files.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-18 19:19:13 +01:00
Dan Williams
63d486b4de trivial: fix some prototypes 2013-11-18 12:06:10 -06:00
Thomas Haller
32b67cd1be cli: bash completion must not suggest IP options for adding slave types
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-18 16:38:07 +01:00
Thomas Haller
6dc4065eb4 trivial: ifcfg-rh: remove unused code/variables 2013-11-18 16:38:07 +01:00
Jiří Klimeš
160d6f073e cli: add missing reason-to-string mappings for NMDeviceStateReason 2013-11-18 16:17:23 +01:00
Jiří Klimeš
0f02392123 doc: fix description of nm_setting_set_secret_flags() 2013-11-18 15:59:05 +01:00
Jiří Klimeš
1a74629a3f team: correct the message telling the teamd binary is missing 2013-11-18 13:18:17 +01:00
Thomas Haller
df7406fcf2 cli: add 'config' option to bash completion when adding team-slave connection
Like 'team', 'team-slave' also understands the property 'config'.
Add it to bash completion for the 'connection add' command.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-18 12:12:20 +01:00
Jiří Klimeš
3e7ad0c439 settings: fix return value in nm_system_config_interface_load_connection()
when g_return_val_if_fail fails.
2013-11-18 09:13:50 +01:00
Jiří Klimeš
de36db0af1 libnm-glib: fix return value in nm_remote_settings_load_connections()
when g_return_val_if_fail() fails.
2013-11-18 09:06:23 +01:00
Thomas Haller
6241366f30 cli: adjust bash completion for nmcli connection load <file>...
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-15 13:39:42 -05:00
Dan Winship
9a532db182 cli: add "nmcli con load file..."
https://bugzilla.gnome.org/show_bug.cgi?id=709830
2013-11-15 13:39:40 -05:00
Dan Winship
a52ebc74b5 libnm-glib: add nm_remote_settings_load_connections()
https://bugzilla.gnome.org/show_bug.cgi?id=709830
2013-11-15 13:38:48 -05:00
Dan Winship
51c6269d46 core: add o.fd.NM.Settings.LoadConnections
Add a D-Bus method to reload connection files specified by
filename, and implement it in the ifcfg-rh and keyfile backends.

https://bugzilla.gnome.org/show_bug.cgi?id=709830
2013-11-15 13:30:13 -05:00
Dan Winship
65737d9e48 devices: use disable_ipv6 as appropriate
Set and clear disable_ipv6 on devices as needed to ensure that:

  1) devices never get IPv6 link local addresses until they are
     actually activated

  2) devices always lose their IPv6 link local addresses when they are
     deactivated

  3) slaves never get IPv6 link local addresses at all

https://bugzilla.gnome.org/show_bug.cgi?id=700414
https://bugzilla.redhat.com/show_bug.cgi?id=1004255
2013-11-15 10:50:45 -05:00
Dan Winship
7496cc3db2 devices: enable/disable kernel IPv6 autoconf at the appropriate times
Set accept_ra and use_tempaddr to "0" when managing a device (and
restore them to their original values after unmanaging it) to ensure
that calling nm_device_bring_up() on a managed device won't ever cause
kernel IPv6 autoconf to happen. Remove some other redundant accept_ra
setting.

Fix up the deconfigure case of dispose() to clear the device's IP6
config as well as its IP4 config.

https://bugzilla.gnome.org/show_bug.cgi?id=700414
2013-11-15 10:49:43 -05:00
Dan Winship
29dc6d1ebe devices: clean up accept_ra/use_tempaddr handling
update_accept_ra_path() and update_ip6_privacy_save() were freeing
their path variables if they failed to read the existing values, but
if this ever actually happened it would cause problems later since
other code assumed that the variables were always set. Use
"priv->ip6_accept_ra_save = -1", etc, instead to indicate that the
value couldn't be read (and so shouldn't be restored later).

Merge the accept_ra and use_tempaddr code save/restore code together,
since they're always called together.

Fix the accept_ra-restoring code to correctly handle an original value
of "2".

Call update_ip6_properties_paths() from nm_device_set_ip_iface()
rather than act_stage3_ip6_config_start(), since set_ip_iface() is
when the paths actually change. Also, split the default-value-saving
code out into a separate function, since we only care about doing that
at construct time; if the IP6 property paths change later (because
iface != ip_iface), then we don't need to save and restore the values
on the ip_iface, since the interface will go away when we're done with
it.

https://bugzilla.gnome.org/show_bug.cgi?id=700414
2013-11-15 10:49:43 -05:00
Dan Winship
ee2b50fce8 devices: rename ip6_privacy_tempaddr_* vars to match sysctl
Rename ip6_privacy_tempaddr_path and ip6_privacy_tempaddr_save to
ip6_use_tempaddr_*, to match the sysctls, for consistency with the
accept_ra variables.
2013-11-15 10:49:43 -05:00
Dan Winship
46295e8fa1 devices: "deactivate" devices when going from UNMANAGED->UNAVAILABLE
We used to call nm_device_deactivate() when moving a device from
UNMANAGED to UNAVAILABLE (unless we were assuming the existing
connection), but this got lost when default-unmanaged was added. Fix
it to do this again, so the device will be in a known-clean state when
it is activated.
2013-11-15 10:49:43 -05:00
Dan Winship
7bc7da83ec core: remove redundant sysctl utilities
NMDevice was still using the old sysctl functions from
NetworkManagerUtils rather than the new NMPlatform ones. Fix it, and
remove the old functions.
2013-11-15 10:49:43 -05:00
Dan Winship
1981323b19 libnm-glib: fix a crash in NMObject
deferred_notify_cb() needs to take a ref on the object around emitting
its deferred signals, since otherwise if a notify:: handler drops the
last reference on an object, a following g_object_notify() call would
crash.
2013-11-14 13:01:55 -05:00
Dan Williams
6a75c9b8e8 core: allow default wired connections to stay up when quitting
Previously, the default wired connection was removed on quit when the
device was cleaned up.  This is inconsistent with other connections.
Leave the default wired connection up when quitting to fix this
inconsistency.

This allows default wired connections to be assumed when NM starts.
2013-11-14 11:34:07 -06:00
Dan Williams
7a256b9a05 settings: simplify connection signal handling
No need to store the ID since we can use g_signal_handlers_disconnect_by_func()
2013-11-14 10:55:46 -06:00
Jiří Klimeš
9a019f1fb5 device: bind the generated loopback connection to 'lo' interface
It is useful to bind the loopack connection to the loopback interface,
and it also allows activating it.
$ nmcli con up lo

Else "Error: no device found for connection 'lo'" is returned, because
connection_compatible() in libnm-glib/nm-device-generic.c wants the
connection to have an interface-name set.
2013-11-14 13:53:44 +01:00
Jiří Klimeš
2a2af5825a cli: allow editing 'generic' connections 2013-11-14 13:53:44 +01:00
Jiří Klimeš
dbba05a3db cli: fix crash on editing 'lo' connection (rh #1030395)
https://bugzilla.redhat.com/show_bug.cgi?id=1030395
2013-11-14 13:53:21 +01:00
Dan Williams
2086cab127 platform: dump objects that fail to be added (rh #1029213)
Attempt to figure out why the objects fail.
2013-11-13 20:06:39 -06:00
Dan Winship
3c236c88eb core: fix re-activation of existing active connection
The change to allow an NMConnection to only be active on a single
device accidentally broke the case of re-activating a connection on
the same device. Fix that.
2013-11-13 13:35:41 -05:00
Dan Williams
49983db85e settings: convert NMDefaultWiredConnection into a plain NMSettingsConnection (rh #1029464) (bgo #712188)
Changing the default wired connection has always deleted the connection
(thus disconnecting the interface) and re-added it as a settings plugin
connection.  That was always sub-optimal, but until the 'unsaved' connection
stuff landed this summer, we couldn't do anything about that.  Clean
that all up, adding the connection as an unsaved connection right from
the start, which allows changes to the connection without having to
delete and recreate it, thus preventing disconnection of any interface
that is using the connection.

A new signal is added to NMSettingsConnection that is only emitted when
the connection is changed from D-Bus (thus indicating an explicit user-
requested change) since the connection may be modified internally by
NetworkManager.  NM-triggered changes should not result in the connection
no longer being a default-wired connection.

https://bugzilla.gnome.org/show_bug.cgi?id=712188
https://bugzilla.redhat.com/show_bug.cgi?id=1029464
2013-11-13 11:50:12 -06:00
Thomas Haller
709bc90b6b coverity: fix various warnings detected with Coverity (fixup)
I missed to implement the remarks from
https://bugzilla.redhat.com/show_bug.cgi?id=1025894#c4

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 18:43:18 +01:00
Thomas Haller
97935382f4 coverity: fix various warnings detected with Coverity
These are (most likely) only warnings and not severe bugs.
Some of these changes are mostly made to get a clean run of
Coverity without any warnings.

Error found by running Coverity scan

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
ab92a0d69c cli: fix reading IP config for *-slaves
Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
0139ad37f7 cli: fix potential crash in nmcli when using strcmp
Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
7fd4d35463 core: fix setting wifi quality
wifi_utils_get_qual returns -1 on error. Keeping it in an unsigned
variable is a bug.

Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
d0abf65004 gsystem: update libgsystem to current upstream master
This brings a fix for Coverity scan warning

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:14:52 +01:00
Thomas Haller
bbddc0e18a cli: fix bash completion for curser not at EOL (2)
Previous commit had an error in the following case:
  $ nmcli connection modify  '  <TAB>     id

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:02:23 +01:00
Thomas Haller
93f5687d7b cli: fix bash completion for curser not at EOL
If the curser is not at the end of the line, we want to complete
by ignoring everything right of the curser. However, the variable
$cur is set to the spaces since the last word, so we have to
get rid of them first

Without this, the following did not complete:
  $ nmcli connection modify id   <TAB>  lo
because $cur is set to '  '.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 14:42:59 +01:00