Commit graph

461 commits

Author SHA1 Message Date
Thomas Haller
c38be4ef4b core: keep nm_connection_provider_get_connections in private instead of static data
nm_connection_provider_get_connections returns an internally kept
constant list to simplify handling for the users. Do not cache this
list in a static variable, instead put it in a private field.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 18:45:22 +02:00
Yuri Chornoivan
61de24ba35 Fix typos
https://bugzilla.gnome.org/show_bug.cgi?id=710505
2013-10-19 11:49:18 -04:00
Thomas Haller
e46722b72b core: make callback argument in nm_settings_connection_commit_changes/_delete optional
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Dan Williams
de45e49eb8 settings: document nm_settings_add_connection() 2013-10-17 13:04:37 -05:00
Dan Williams
1fe5c197d2 settings: clarify ownership of objects returned from plugin's add_connection() hook
Plugin owns the object and callers must reference it if they wish to use it outside
of the function they called "add" from.  Likewise, callers of the ConnectionProvider's
add_connection method must also reference the returned object if they wish to
continue using it.
2013-10-17 13:03:39 -05:00
Dan Winship
79407f0c37 settings: normalize and verify connections on update
When a connection is updated (either by its plugin or via D-Bus), we
need to normalize and verify it before accepting the changes.
2013-10-16 13:27:23 -04:00
Dan Winship
0a77cf6320 ifcfg-rh: fix handling of minimal ifcfg files
ifcfg-rh had the rule that if an ifcfg file had no BOOTPROTO and no
IPv4 addresses, then it should be treated as method=auto for
compatibility. But in fact, current ifup treats it as method=disabled,
so we should too.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
2013-10-11 12:24:34 -04:00
Dan Winship
68f12b4e9c settings: make connections always have s_ip4 and s_ip6
Make sure that all connections returned from NMSettings or created via
AddAndActivateConnection have an NMSettingIP4Config and an
NMSettingIP6Config, with non-NULL methods, and get rid of
now-unnecessary checks for those.

Also move the slaves-can't-have-IP-config checks into the
platform-independent code as well. This also gets rid of spurious
"ignoring IP4/IP6 configuration" warnings in ifcfg-rh when reading a
slave ifcfg file.

Partly based on a patch from Pavel.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
2013-10-11 12:24:34 -04:00
Dan Williams
b5fa0fec1c trivial: remove unnecessary warning 2013-10-09 09:39:57 -05:00
Jiří Klimeš
2af8c08f65 ifcfg-rh: ignore default routes in route6 file (rh #991807)
Base on patch from Francesco Prelz <Francesco Prelz mi infn it>:
https://mail.gnome.org/archives/networkmanager-list/2013-January/msg00095.html

https://bugzilla.redhat.com/show_bug.cgi?id=991807
2013-10-07 18:10:27 +02:00
Dan Williams
87041545b4 ifcfg-rh: fix ignoring updates that don't change anything
connection_from_file() requires the 'error' parameter.  Not passing a
valid 'error' parameter causes the function to fail and return NULL,
which mean that commit_changes() would always re-write the connection
instead of ignoring commits where nothing has actually changed.

connection_from_file() no longer requires the unmanaged, keyfile,
or routefile parameters, so remove them.
2013-10-04 23:43:25 -05:00
Thomas Haller
98daf270ba core: add add_connection method to NMConnectionProvider
This exposes the functionality of nm_settings_add_connection to the users
of NMConnectionProvider.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-25 21:01:04 +02:00
Thomas Haller
3b12d9ae6e core: add has_connections_loaded method to NMConnectionProvider
This method returns true, if the connections are already loaded (and the
connection_loaded signal already emited).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-25 21:01:04 +02:00
Jiří Klimeš
5471a6c678 ifcfg-rh: if IPv4 is disabled put DNS domains (DOMAIN) into IPv6 (rh #1004866)
The problem is that there is only a single variable in ifcfg file holding dns
domains - DOMAIN. Thus NetworkManager writes both IPv4 and IPv6 dns-search into
it. While reading there is no way to distinguish between IPv4 and IPv6 values,
so the DOMAIN value is read and only put into IPv4 dns-search.

But, when IPv4 is disabled or invalid, the domains got lost. So in such case
we put DOMAIN variable into IPv6 instead.

https://bugzilla.redhat.com/show_bug.cgi?id=1004866
2013-09-23 09:57:37 +02:00
Jiří Klimeš
76c34d48ed core,settings: do not call functions with connection==NULL (rh #1008151)
check 'req' and 'connection' variables. Apparently, they can be NULL
on some circumstances.

NetworkManager[2830]: <info> (p6p1): device state change: secondaries -> disconnected (reason 'connection-removed') [90 30 38]
NetworkManager[2830]: <info> (p6p1): deactivating device (reason 'connection-removed') [38]
kernel: [ 2623.609111] NetworkManager[2830]: segfault at 50 ip 00007f1a309bf6a1 sp 00007fffc59e67e0 error 6 in NetworkManager[7f1a30915000+104000]
NetworkManager[2830]: (nm-device.c:5043):nm_device_state_changed: runtime check failed: (in_state_changed == FALSE)
NetworkManager[2830]: <info> (p6p1): device state change: disconnected -> failed (reason 'secondary-connection-failed') [30 120 54]
NetworkManager[2830]: nm_act_request_get_connection: assertion `NM_IS_ACT_REQUEST (req)' failed
NetworkManager[2830]: nm_connection_get_id: assertion `connection != NULL' failed
NetworkManager[2830]: <warn> Activation (p6p1) failed for connection '(null)'
NetworkManager[2830]: nm_settings_connection_get_timestamp: assertion `connection != NULL' failed
abrt[2882]: Saved core dump of pid 2830 (/usr/sbin/NetworkManager) to /var/tmp/abrt/ccpp-2013-09-15-11:38:39-2830 (18952192 bytes)
systemd[1]: NetworkManager.service: main process exited, code=dumped, status=11/SEGV
systemd[1]: Unit NetworkManager.service entered failed state.

https://bugzilla.redhat.com/show_bug.cgi?id=1008151
2013-09-17 19:14:39 +02:00
Jiří Klimeš
4255d72b21 build: fix distcheck - missing ifupdown test files in Makefile.am 2013-09-06 17:42:07 +02:00
Scott Shambarger
04f6e09d50 ifcfg-rh: fix handling of legacy IPv4 route files without gateway.
Routes without gateway are legal and should be treated as a device route
(direct route).

https://bugzilla.gnome.org/show_bug.cgi?id=697525

The original patch was written by Scott Shambarger <scott-gnome@shambarger.net>.
This is a modified version of the patch.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Reported-by: Scott Shambarger <scott-gnome@shambarger.net>
2013-09-05 21:13:15 +02:00
Thomas Haller
4e09b87d54 ifupdown: misc code cleanup for "add support for source stanza"
- make use of glib functions
- coding style

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-05 10:58:46 +02:00
Michael Wisheu
48ed1abca7 ifupdown: add support for source stanza
Since Debian 7 (Wheezy) / Ubuntu 11.04 (Natty Narwhal) ifupdown supports
the source stanza to source in other configuration files from
/etc/network/interfaces.

Add support to the ifupdown plugin to include configuration files via
source.

Patch did not apply cleanly and was slightly modified by Thomas Haller.

https://bugzilla.gnome.org/show_bug.cgi?id=707276

Signed-off-by: Thomas Haller <thaller@redhat.com>
Reviewed-by: Sebastian Harl <tokkee@debian.org>
2013-09-05 10:56:28 +02:00
Jiří Klimeš
ea78744555 settings: set deprecated 'security' for GetSettings() not to break old clients
Old clients might expect 802-11-wireless.security being set for secured Wi-Fi
connections. So to be on a safer side, we set the property in D-Bus GetSettings()
result.
2013-09-02 09:46:32 +02:00
Jiří Klimeš
284cce0405 test: remove deprecated 'security' property from tests
Adjust tests not to use deprecated 'security' property.
2013-09-02 09:46:31 +02:00
Jiří Klimeš
713755780f core: don't use deprecated 'security' property of wifi setting
That means replacing/removing
- nm_setting_wireless_get_security() function
- NM_SETTING_WIRELESS_SEC property
2013-09-02 09:46:31 +02:00
Dan Williams
0c15e1c2ce fix: glib assertion in nm-agent-manager, cancelling completed dbus call
This fixes a glib assertion:
"dbus_g_proxy_cancel_call: assertion `pending != NULL' failed"

Backtrace:
 #0  0x00007f962dad9e0d in g_logv () from /lib64/libglib-2.0.so.0
 #1  0x00007f962dad9ff2 in g_log () from /lib64/libglib-2.0.so.0
 #2  0x00000000004a84bd in nm_secret_agent_cancel_secrets (self=0x213b300, call=0x1) at settings/nm-secret-agent.c:331
 #3  0x00000000004a4068 in request_free (req=0x216a490) at settings/nm-agent-manager.c:479
 #4  0x00007f962dac25fa in g_hash_table_remove_internal () from /lib64/libglib-2.0.so.0

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-30 18:23:24 +02:00
Pavel Šimerda
2371ee6168 trivial: rename nm_settings_add_connection*() functions
It makes more sense to use basic name for the basic function and
suffixed name for the special one.

Acked-by: Dan Williams <dcbw@redhat.com>
2013-08-30 10:54:29 +02:00
Thomas Haller
2a0ec59dba ifcfg-rh: do not write IPV6_DEFAULTGW=:: for missing gateway
This also slighly changes the behaviour for writing IPV6_DEFAULTGW.
- IPV6_DEFAULTGW will be written after IPV6ADDR and
  IPV6ADDR_SECONDARY.
- Before, if there were no IPv6 addresse present, the IPV6_DEFAULTGW
  might not have been cleared. Now IPV6_DEFAULTGW is always written
  (or unset as in the case of gateway ::).

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-27 20:58:46 +02:00
Jiří Klimeš
bb72d2e4e2 ifcfg-rh: fix distcheck 2013-08-27 15:03:45 +02:00
Dan Winship
bfce3f7dc8 build: switch from $(INCLUDES) to $(AM_CPPFLAGS) to make automake happy
Unfortunately, $(AM_CPPFLAGS) gets overridden by per-target _CPPFLAGS
variables, which $(INCLUDES) did not, so this requires some additional
changes.

In most places, I have just gotten rid of the per-target _CPPFLAGS
variables; in directories with a single target, the per-target
variable is unnecessary, and in directories with multiple targets, the
per-target variable is often undesirable, since it forces some files
to be compiled twice, even though there ends up being no difference
between the two files.
2013-08-22 11:49:16 -04:00
Jiri Pirko
861e5148d8 ifcfg-rh writer: write DEVICETYPE for all team ports
even for that which does not have settings

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 09:38:11 -04:00
Dan Winship
f201a248c3 ifcfg-rh: minor tweaks to previous patch 2013-08-22 08:58:08 -04:00
Jiri Pirko
dbf9c42578 ifcfg-rh: add test for BOOTPROTO=none reader
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 08:51:51 -04:00
Jiri Pirko
886c760f8b ifcfg-rh: reader: allow device to not have ipv4 setting.
If BOOTPROTO is set to "none", user states that no ipv4 setting should
be set. So respect that.

Introduce helper is_any_ip4_address_defined() along the way to make the
code more readable.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 08:51:48 -04:00
Jiri Pirko
dcf5355810 ifcfg-rh: add write support for team devices
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Jiri Pirko
db65980328 ifcfg-rh: add read support for team devices
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Martin Pitt
5dc4be54e6 keyfile: Drop owner check
In nm_keyfile_plugin_connection_from_file(), disable the "bad owner"
check.
As root you can read all files anyway, or if necessary even chown them,
and for
other users the standard file permissions will do a fine job.

This fixes running "make check" as root.

https://bugzilla.gnome.org/show_bug.cgi?id=701112
2013-08-13 23:28:54 +02:00
Dan Williams
b5170903c0 settings: correctly handle connection deletion after unsaved and monitor-connection-files
Plugins that could save connections to disk previously depended on inotify
events from the kernel to know when to signal connection removal; that is
in response to a 'delete' request they would unlink the backing filesystem
resources, get the inotify signal, and cause NM_SETTINGS_CONNECTION_REMOVED
to be emitted.

Unsaved connections don't have any backing resources, so they would never
get the signal emitted, and NMSettings would never forget about them.

Also, when monitor-connection-files=false in the configuration, obviously
the inotify signals will never come in because they aren't set up.

Given that we can no longer rely on inotify, it's best to just explicitly
send out the NM_SETTINGS_CONNECTION_REMOVED signal whenever a connection
is deleted via the D-Bus interface or internally.
2013-08-09 00:54:58 -05:00
Dan Williams
1f084567f0 ifcfg-rh: don't require an error for read_mac_address()
No reason to; the caller knows success/failure from the return value
and might want to ignore the error.
2013-08-07 12:53:24 -05:00
Dan Williams
e9e84c19c9 ifcfg-rh: fix handling of VLAN parent PHYSDEV key
The initscripts do this:

    MATCH='^.+\.[0-9]{1,4}$'
    if [[ "${DEVICE}" =~ $MATCH ]]; then
	VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^.*\.\([0-9]\+\)/\1/')
	PHYSDEV=${DEVICE%.*}
    fi
    MATCH='^vlan[0-9]{1,4}?'
    if [[ "${DEVICE}" =~ $MATCH ]]; then
	VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^vlan0*//')
	# PHYSDEV should be set in ifcfg-vlan* file
	if test -z "$PHYSDEV"; then
		net_log $"PHYSDEV should be set for device ${DEVICE}"
		exit 1
	fi
    fi

which means that if the VLAN name starts with "vlan" then
PHYSDEV must be set, otherwise the parent interface cannot
be determined.

Since PHYSDEV, if set, reflects the explicit intentions of the
user instead of assuming the name from DEVICE, make PHYSDEV
take precedence over determining the parent interface from
heuristics.
2013-08-06 16:36:51 -05:00
Thomas Haller
4861161bd4 trivial: fix spelling errors in code comments and README file
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-06 13:48:02 -05:00
Pavel Šimerda
320a9d16a3 all: replace struct in_addr with guint32 2013-08-03 00:15:07 -05:00
Dan Winship
f9016e203a ifcfg-rh: update InfiniBand P_Key support to match latest initscripts 2013-08-02 13:54:13 -04:00
Dan Williams
802d4cdad2 agents: don't make method calls with a destroyed proxy
If the agent has dropped off the bus then its proxy may already
be destroyed, so we'll get warnings when trying to make method
calls using it.  Track proxy destruction and warn if we try to
use a destroyed proxy.
2013-07-31 08:16:41 -05:00
Dan Williams
724b9c045b agents: remove request_cancel()
Turns out this function is useless, because it's only called when the
agent has dropped off the bus or when the whole request is being
freed.  If the agent has dropped off the bus then there's no point
in asking it to cancel the request because there's nothing to ask.
So we can collapse request_cancel() into request_free().
2013-07-31 08:16:41 -05:00
Dan Williams
ab84a86678 vpn: handle interactive plugin secrets requests
If all agents can handle VPN hints, then we'll try to use
ConnectInteractive() to let the VPN plugin ask for secrets
interactively via the SecretsRequired signal.  These hints
are then passed to agents during the connection process if
the plugin needs more secrets or different secrets, and when
the new secrets are returned, they are passed back to the VPN
plugin.

If at least one agent does not have the VPN hints capability,
we can't use ConnectInteractive(), but fall back to the old
Connect call, because that agent won't be able to send the
hints to the VPN plugin's authentication dialog, and thus
we won't get back the secrets the VPN plugin is looking for.

So, for interactive secrets to work correctly, you need:

1) A VPN plugin updated for interactive secrets requests
2) NM updated for interactive secrets requests
3) all agents to set the VPN_HINTS capability when
    registering with NetworkManager and to pass hints
    along to the VPN authentication dialog
4) a VPN authentication dialog updated to look for hints
    and only return secrets corresponding to the hints
    requested by the plugin
2013-07-31 08:16:40 -05:00
Dan Williams
16bb798861 agents: add agent capabilities
A new agent registration method enables agents to pass capabilities during
the registration process.
2013-07-31 08:16:34 -05:00
Dan Williams
d83c0722da ifcfg-rh: convert test_read_wired_static_no_prefix() to a GTest 2013-07-26 16:23:23 -05:00
Dan Williams
76c09fb729 ifcfg-rh: start converting tests to GTest framework 2013-07-26 16:23:23 -05:00
Dan Williams
06b0fc7b64 ifcfg-rh: clean up certificate/key verification tests
Kill the CKType enum since we can figure out what we want
from the property name.
2013-07-26 16:23:23 -05:00
Dan Williams
bad980ccfa ifcfg-rh: simplify testcases #1
Use g_assert() macros where we can, and don't bother passing stuff
into connection_from_file() that we don't even look at.
2013-07-26 16:23:23 -05:00
Dan Williams
01f172e99e ifcfg-rh: don't require all arguments to connection_from_file()
Lets eg testcases pass NULL instead of a bunch of variables they
just throw away.
2013-07-26 16:23:23 -05:00
Dan Williams
4920330ae5 ifcfg-rh: cleanup connection_from_file() error handling
Don't bother with local error variables, just pass 'error' around.
2013-07-26 16:23:22 -05:00