Commit graph

436 commits

Author SHA1 Message Date
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
Dan Williams
c2ad294290 ifcfg-rh: fix error handing in some functions that expect error != NULL
A couple functions depended on the passed-in error being !NULL to
correctly report errors, and we can't depend on that because it might
not be true.  So fix up those functions' call chain to ensure that
errors get reported regardless of whether 'error' is !NULL.
2013-07-26 16:23:22 -05:00
Jiří Klimeš
d60dae2558 keyfile: ignore Emacs interlocking link named .#<file_name> (rh #987629)
https://bugzilla.redhat.com/show_bug.cgi?id=987629
http://stackoverflow.com/questions/5738170/why-does-emacs-create-temporary-symbolic-links-for-modified-files
2013-07-24 12:32:18 +02:00
Dan Williams
d687492d49 ifcfg-rh: add support for gateway ping timeout 2013-07-12 22:32:06 -05:00
Jiří Klimeš
3fc604ca79 keyfile: do not set GError over the top of a previous GError 2013-06-27 18:29:26 +02:00
Dan Williams
0eb97f3ad5 agents: change secrets request hints back to char **
Previously I didn't think they'd be used for anything other than connection secrets
which only have one hint, but in the future we'll want to pass more information.
2013-06-25 17:43:39 -05:00
Dan Williams
b34fdde19c agents: refactor agent secrets request tracking to be more generic
Split the agent secrets request tracking structure into a generic
structure for tracking any agent request, and a connection-specific
subclass.  We'll use the generic structure in the future for device
secrets and other stuff.
2013-06-25 17:43:39 -05:00
Jiří Klimeš
01585d2ebe keyfile: fix reading bonding options (bgo #701527)
Bonding options are written straight into [bond] group like:
[bond]
interface-name=bbb
mode-active-backup
miimon=300

So we have to handle them explicitly.
2013-06-25 18:03:19 +02:00
Pavel Šimerda
0b07a5301e settings: publish add_new_connection() as nm_settings_add_connection_internal() 2013-06-20 20:20:08 +02:00
Jiří Klimeš
eea23747ce ifcfg-rh: fix storing connections in the hash table
We have to copy the UUID (key) because otherwise the pointer can be invalidated
when the connection is destroyed and problems will start.

The issue showed up as an unability to delete a conenction via D-Bus.

Reproducer:
$ nmcli con add type eth con-name AAA ifname blah
$ nmcli con delete AAA
$ nmcli con add type eth con-name AAA ifname blah
$ nmcli con delete AAA
-- here the connection is not removed from NM
   (even though ifcfg- file) was removed --
2013-06-19 12:41:36 -05:00
Dan Winship
ac1692a17b keyfile: remove some debugging 2013-06-14 12:57:47 -03:00
Dan Winship
1f81851017 core: add monitor-connection-files=false and ReloadConnections
Add a "monitor-connection-files" config option, which can be set to
"false" to disable automatic reloading of connections on file change.

To go with this, add a new ReloadConnections method on
o.fd.NM.Settings that can be used to manually reload connections, and
add an nm-cli command to call it.
2013-06-14 12:57:47 -03:00
Dan Winship
4b74009b23 settings: don't connect to plugin signals until after initial load
Some plugins may emit :new-connection or :unmanaged-specs-changed
while reading connections, so don't connect to those signals until
after the initial load_connections() (and just unconditionally emit
:unmanaged-specs-changed at that point).

In ifcfg-rh's get_unmanaged_specs(), don't bother to try to read the
connections first; if they haven't been read yet, just return NULL;
NMSettings will call it again after the connections have been read.
2013-06-14 12:57:32 -03:00
Dan Winship
cb5606cf1c ifcfg-rh: add support for Infiniband partitions 2013-06-13 15:56:14 -03:00
Dan Winship
d575381c28 settings: fix unmanaging of InfiniBand devices
ifcfg-rh didn't let you unmanage an InfiniBand device by hardware
address because it was recording the hardware address with uppercase
letters, while nm_match_spec_hwaddr() required lowercase. Fix this by
making nm_match_spec_hwaddr() match case-insensitively (and remove the
manual lowercasing that several other places were doing to work around
this.)

keyfile didn't let you unmanage an InfiniBand device by hardware
address because it only accepted ARPHRD_ETHER hardware addresses. Fix
that by using nm_utils_hwaddr_valid() instead.
2013-06-13 15:52:51 -03:00
Dan Williams
2cb9bc9bda settings: let NMSettingsConnection unregister itself
Originally it was to keep logical balance, since NMSettings exports
the NMSettingsConnection to D-Bus, but it's kind of pointless to
spend some LoC just for that.
2013-06-11 12:48:15 -05:00
Jiří Klimeš
5875e17769 ifcfg-rh: ignore team connections until we support team devices (rh #968268)
https://fedorahosted.org/libteam/
team connections are marked by
DEVICETYPE="Team"
or
DEVICETYPE="TeamPort"
2013-06-04 13:21:04 +02:00
Dan Winship
43617d4c1d libnm-util: deprecate nm_utils_slist_free(), use g_slist_free_full() 2013-05-29 17:13:30 -03:00
Dan Williams
c7c8655832 settings: remove duplicated dbus_g_method_return()
Could cause a crash when updating a connection, since dbus-glib may
clear DBusGMethodInvocation resources during this method.  Since
update_complete() is actually our completion/cleanup handler for
this operation chain, we can remove the standalone call to
dbus_g_method_return().
2013-05-29 14:53:45 -05:00
Dan Williams
59222e562b settings: implement Save() function for connections 2013-05-28 12:26:56 -05:00
Dan Williams
8a79fb1d41 settings: implement ability to add connections without saving them to disk
We don't always want to immediately write new connections to disk, to
facilitate "runtime" or "temporary" connections where an interface's
runtime config isn't backed by on-disk config.  Also, just because
an interface's configuration is changed doesn't necessarily mean
that new configuration should be written to disk either.

Add D-Bus methods for adding new connections and for updating existing
connections that don't immediately save the connection to disk.

Also add infrastructure to indicate to plugins that the new connection
shouldn't be immediately saved if the connection was added with the
new method.
2013-05-28 12:26:56 -05:00
Dan Williams
f73d066382 ifnet: don't require a conn_name when creating an ifnet connection
If the connection doesn't yet have a conn_name, that means it's not
yet saved to disk.
2013-05-28 12:26:56 -05:00
Dan Williams
689dadaffb ifnet: track connections by UUID not conf.d net connection name
We'll need this for later with unsaved connections.  The ifnet
plugin previously tracked connections by the "conn_name" which
was derived from keys in the /etc/conf.d/net file.  These keys
take two forms:

1) interface name

config_eth0=(
"192.168.4.121/24"
"dhcp6"
)

2) wifi SSID, either text or hex-encoded:

config_myssid=("dhcp")
config_0xab3ace=("dhcp")

The conf.d net connection name is apparently usually an interface
name, so when writing to /etc/conf.d/net the NM connection name is
changed from eg "Ethernet connection 1" to the next available
interface name based on the type of connection, eg "eth0".

The ifnet plugin actively removed connections that were not present
in /etc/conf.d/net during the reload_connections() call, but in the
future we'll want to allow unsaved connections which in the case of
ifnet clearly won't yet be written to the file.  Since only
connections written to the file have a "conn_name", tracking
connections by conn_name no longer works.
2013-05-28 12:26:55 -05:00
Dan Williams
d35cdcc7d7 ifcfg-rh: don't require a path when creating an ifcfg-rh connection 2013-05-28 12:26:55 -05:00
Dan Williams
b225a9f53b ifcfg-rh: track connections by UUID not file path
We'll need this for later with unsaved connections.
2013-05-28 12:26:55 -05:00
Dan Williams
9d94000c69 keyfile: don't require a path when creating a keyfile connection 2013-05-28 12:26:55 -05:00