Commit Graph

4279 Commits

Author SHA1 Message Date
Pavel Šimerda
0361b1ca8f trivial: ETHTOOL_GLINK usage explanation 2013-04-17 12:27:29 +02:00
Pavel Šimerda
5cc26c60ef trivial: use nl_cache_free instead of nl_cache_put
nl_cache_put is not present in older but still supported libnl releases.
2013-04-15 13:46:50 +02:00
Dan Williams
9f8b7ff51d keyfile: ensure all-default VLAN setting is read correctly
Settings with all-default values are not written to reduce
complexity of the keyfile (and be more human-readable friendly)
and that includes VLAN settings with a VLAN ID of zero.  So
when reading this file back, if there is no 'base type' setting
(eg, the setting specified by the connection::type property)
then just add that setting.  nm_connection_verify() will catch
cases where an empty 'base type' setting is invalid.
2013-04-11 14:55:37 -05:00
Dan Winship
f1d31e36da settings: consider :interface-name in default wired connection matching
The code to check if an ethernet device had a matching connection was
not taking NMSettingConnection:interface-name into account, meaning it
might think a device had a matching connection when that connection
actually only matched a different device.

Fix this by calling nm_setting_connection_get_interface_name() rather
than nm_connection_get_virtual_iface_name() (which would always be
NULL for ethernet connections anyway).

Also, simplify the code a bit.

https://bugzilla.gnome.org/show_bug.cgi?id=696722
2013-04-11 14:54:40 -04:00
Dan Williams
c36200a225 keyfile: use 'ethernet', 'wifi' and 'wifi-security' group names (bgo #696940)
Add these aliases for the setting names '802-3-ethernet',
'802-11-wireless', and '802-11-wireless-security' and write them by
default.  It's much friendlier for administrators to type, and a lot
less ugly.

Also works for:

[connection]
type=ethernet
2013-04-11 10:52:39 -05:00
Jiří Klimeš
fa20c80819 wifi: fix NM crash on mode == NULL
caused by 53d8f49bcd
2013-04-11 15:29:12 +02:00
Dan Williams
302e8ccab0 core: ensure new available connections generate a ProperiesChanged signal (bgo #697743)
The TRUE return got missed in the original commit of the AvailableConnections
code.  _try_add_available_connection() returns TRUE if the connection was
added and FALSE if it wasn't, to allow the caller to optionally emit the
PropertiesChanged signal.  Only TRUE was never returned...
2013-04-10 16:03:00 -05:00
Dan Williams
53d8f49bcd wifi: AP mode connections are always available
Just like adhoc, they don't need to be found in the scan list.
2013-04-10 16:02:35 -05:00
Dan Williams
6701181c35 ethernet: don't crash for PPPoE connections with no wired setting
PPPoE connections don't necessarily have a wired setting, so don't
require one here.
2013-04-10 13:37:22 -05:00
Jiří Klimeš
ac697a912e core: fix an assertion in nm_default_wired_connection_new()
nm_device_get_hw_address() has to be called with out_len
initialized to 0.
2013-04-10 18:58:21 +02:00
Dan Williams
caed13b3ef mobile: only clear dbus manager on quit
The private reference to the NMDBusManager is created at
NMModemManager init time, and should only be cleared when the
NMModemManager is disposed.  Instead it was getting cleared
whenever ModemManager1 was seen on the bus, and thus was unavailable
later when it was required to watch for the old ModemManager.
This caused NetworkManager to print warnings about NULL object
access to the console, and could prevent it from noticing when
ModemManager appeared on the system bus.
2013-04-10 10:06:38 -05:00
Pavel Šimerda
b636ea86b1 platform: link features (carrier-detect and vlans)
Thanks to Jiří Pírko for help with ethtool features.
2013-04-10 16:40:58 +02:00
Pavel Šimerda
3071cc6511 platform: route management
Extend nm-platform to support IPv4 and IPv6 route management.

Route features:

* Retrieve the list of IPv4 and IPv6 routes
* Add/delete/lookup IPv4 and IPv6 routes
* Flush all non-linklocal routes
2013-04-10 16:40:58 +02:00
Pavel Šimerda
0209db4111 platform: address management
Extend nm-platform to support IPv4 and IPv6 address management.

Address features:

* Retrieve the list of IPv4 and IPv6 addresses
* Add/delete/lookup IPv4 and IPv6 addresses
* Flush all non-linklocal addresses
2013-04-10 16:40:58 +02:00
Pavel Šimerda
c1e53dbf7c platform: link state, carrier and arp 2013-04-10 16:40:58 +02:00
Pavel Šimerda
15fd7cd75e platform: link management
Create the new nm-platform framework and implement link (or interface)
management. The nm-platform serves as the point of contact between
the rest of NetworkManager and the operating system.

There are two backends for nm-platform:

* NMFakePlatform: Fake kernel backend for testing purposes
* NMLinuxPlatform: Linux kernel backend for actual use

A comprehensive testsuite is included and will be extended with new
feature additions. To enable the Linux part of the testsuite, use
--enable-tests=root configure options and run 'make check' as root.
Use --enable-code-coverage for code coverage support.

  ./autogen.sh --enable-tests=root --enable-code-coverage
  make
  make -C src/platform check-code-coverage

Link features:

* Retrieve the list of links
* Translate between indexes and names
* Discover device type
* Add/remove dummy interfaces (for testing)

Thanks to Thomas Graf for helping with libnl3 synchronization issues.
2013-04-10 16:40:58 +02:00
Aleksander Morgado
82f8451c10 modem-manager: wait up to 120s for the connection result
We will very likely get the result of the connection attempt before the 2 mins,
either successful or error, but still we need to explicitly ask to keep the
DBus call open enough time.

This time should be enough to handle both the connection time (usually around
60s max), plus the time needed to register in the network and all the other
Simple.Connect() steps.
2013-04-09 15:48:16 -05:00
Jiří Klimeš
f1ec2aa320 dbus: fix compilation with dbus-glib < 100
private_server_get_connection_owner() is also used in
nm_dbus_manager_new_proxy(), thus it must be available.
2013-04-09 10:35:01 +02:00
Dan Williams
b69171061c dhcp: use private socket to return status if available
Allows DHCP to work when a bus daemon isn't running.  This also
fixes a race condition where when multiple interfaces are attempting
to get a DHCP lease at the same time, if one DHCP client instance
triggers the callout, that instance gets the bus name, and any
other client triggering the callout at that time will fail because
the bus name is already taken.  Since this commit allows using
a private socket, where no process has a bus name, this race is
avoided.

Also move the DHCP helper from callouts/ to src/dhcp-manager/ to
consolidate all the DHCP stuff and clean up some of the helper's
code.
2013-04-08 11:30:31 -05:00
Dan Williams
8e0b75eb0c settings: remove NM_SETTINGS_ERROR_NOT_PRIVILEGED
Pretty much the same thing as PERMISSION_DENIED.
2013-04-08 10:55:38 -05:00
Dan Williams
6326aea61b agents: create correct proxy for agents connecting via a private connection
We need to use dbus_g_proxy_new_for_peer() when talking to agents on a
private connection.
2013-04-08 10:55:38 -05:00
Dan Williams
b6b09a5f11 core: add DBus Proxy creation helper
We need to use dbus_g_proxy_new_for_peer() when creating a proxy
for private service connections.
2013-04-08 10:55:38 -05:00
Dan Williams
72bdb5707e auth: move common nm_dbus_manager_get_caller_info() functionality into nm_auth_chain_new()
Most callers of nm_auth_chain_new() call nm_dbus_manager_get_caller_info()
right before that, so just fold the get_caller_info() call into
nm_auth_chain_new() to reduce code complexity in callers.  Yes, this
means sometimes we call nm_dbus_manager_get_caller_info() twice,
but that's not really a problem.
2013-04-08 10:55:38 -05:00
Dan Williams
b389ad3141 core: remove unused argument to nm_auth_chain_new() 2013-04-08 10:55:38 -05:00
Dan Williams
10dc8e78ca agents: don't require root agents to be part of a login session
Which they won't always be in minimal environments.
2013-04-08 10:55:38 -05:00
Dan Williams
050f4b761e core: assume root always has a session for connection visibility
Normally, users which are not part of a login session can't access
connections.  Root won't always be part of a login session, so
allow root to bypass visibility checks.  The code already bypassed
the ACL checks for root, but in multiple places.  Consolidate those
checks into one function.
2013-04-08 10:55:38 -05:00
Dan Williams
5842342d91 agents: enforce one-agent-per-identifier-per-UID restriction
Has been documented from the beginning but was apparently not
enforced.
2013-04-08 10:55:38 -05:00
Dan Williams
edfaf2540d trivial: whitespace fixes 2013-04-08 10:55:38 -05:00
Dan Williams
18ddf20b38 core: route dbus_bus_get_unix_user() through NMDBusManager
Since dbus senders are faked for private connections, we can't just
call dbus_bus_get_unix_user() on fake senders.  They need to be
checked against the NMDBusManager's list of private connections
first.
2013-04-08 10:55:38 -05:00
Dan Williams
80f8fce675 core: remove unused auth functions
Functionality moved to NMDBusManager.
2013-04-08 10:55:37 -05:00
Dan Williams
a442d1ac42 core: use DBusManager caller info/auth functions
Only the DBusManager can get the sender for private connections.
2013-04-08 10:55:37 -05:00
Dan Williams
0621de7d48 core: use same codepaths for root and non-root during authentication
Instead of doing something like

<get caller UID>
if (root) {
   perform_operation()
   other boilerplate stuff
   return;
}

nm_auth_chain_new(perform_operation)
...

just have root also go through the auth chain, which is now
short circuited for root.  This ensures we always use the same
code paths for root and non-root, and that fixes made in one path
are also executed for the other.
2013-04-08 10:55:37 -05:00
Dan Williams
f7b720b047 core: simplify object set property filter
dbus-glib has had dbus_g_connection_lookup_g_object() since 0.72
(circa 2006) so instead of parsing the object paths ourselves, let
dbus-glib tell us what object it is, and rely on GObject property
permissions to block writes at the object level, and dbus-glib to
block writes at the D-Bus level based on the introspection XML.

Plus, we can use the various ways to get the caller UID that were
added in previous patches to simplify authentication.
2013-04-08 10:55:37 -05:00
Dan Williams
c4ac2f3279 core: add caller info functions to DBusManager
Because the DBusManager is the thing that knows about private
connections, it's the thing best positioned to get caller
details like sender and UID.
2013-04-08 10:55:37 -05:00
Dan Williams
c9335a497b core: add a root-only private D-Bus socket
For cases where NM may run without a bus daemon in root-only
environments, like an initramfs.  For disconnection, since private
connection just get a disconnect message instead of NameOwnerChanged
signals broadcast by a bus daemon, just synthesize the NameOwnerChanged
signals using our fake owner name.  It's just easier to do this rather
than modify any code that cares about disconnects.

Note that the new private socket is only enabled if built with
dbus-glib >= 0.100 as there are bugs in previous versions in the
implementation of dbus_g_proxy_new_for_peer() which clients must
use to talk to the private socket.
2013-04-08 10:55:37 -05:00
Dan Williams
496534b9f4 core: add nm_dbus_g_method_invocation_get_g_connection()
This method exists in dbus-glib >= 101, but if it doesn't, emulate it.

See https://bugs.freedesktop.org/show_bug.cgi?id=55729
2013-04-08 10:55:37 -05:00
Dan Williams
3c7f267fb9 core: use wrappers for DBus object registration/unregistration
When providing a service on the bus daemon and a private connection,
we'll need to track objects so we can register them with the
private connection too.  Thus all registration/unregistration
calls have to go through the NMDBusManager, not straight to
dbus-glib.
2013-04-08 10:55:37 -05:00
Dan Williams
1fec50cc1e core: push PolicyKit unavailable error to callers instead of logging it
The error is now pushed to things that request PK auth so that we don't
lose it, because we don't want to unconditionally log it from NM, but
still want things to know that their request couldn't be fulfilled
because PK wasn't running.
2013-04-08 10:55:37 -05:00
Dan Williams
da79a01b12 core: simplify auth chain early exit
Don't create a GError with a domain of 0, which causes a glib warning,
and make it clearer when we're early-finishing with an error and when
we're not.
2013-04-08 10:55:37 -05:00
Dan Williams
ef302981b4 core: silence warning about failure to read permanent MAC address (rh #907912)
Not all drivers support reporting their permanent MAC address, and some
don't have one at all (no EEPROM) so it's pointless to warn about it.
2013-04-05 13:06:22 -05:00
Dan Williams
1bcf3f6397 keyfile: fix testcase comparison
test-keyfile.c: In function 'test_read_string_ssid':
test-keyfile.c:1154:51: error: argument to 'sizeof' in 'memcmp' call is the
   same expression as the second source; did you mean to provide an explicit
   length? [-Werror=sizeof-pointer-memaccess]
ASSERT (memcmp (array->data, expected_ssid, sizeof (expected_ssid)) == 0,
2013-04-05 12:21:26 -05:00
Dan Winship
e58d86450d core: fix build with glib < 2.34
Using g_clear_pointer() didn't trigger G_UNAVAILABLE warnings because
it's a macro. Fix the build on older glibs by just pulling in the
definition.
2013-04-03 13:11:31 -04:00
Colin Walters
8b3d609404 build: Fix srcdir != builddir 2013-04-03 10:19:49 -05:00
Dan Winship
282a9720ab dns-manager: add dns=none
Add a new dns mode "none", meaning that NM should not modify
resolv.conf at all.

https://bugzilla.gnome.org/show_bug.cgi?id=690404
2013-04-03 10:23:49 -04:00
Dan Winship
df1f4bee0e dns-manager, config: make the dns config key single-valued
Make the main/dns config key be a single value rather than a list of
plugins. Since there is currently only one valid value for it
("dnsmasq"), this is backward-compatible.

In the future, it will be possible to specify custom DNS-configuring
scripts here, which is a more flexible way of handling complicated
behavior than trying to create chainable internal plugins.
2013-04-03 10:23:49 -04:00
Dan Winship
a15558daed dns-manager: minor cleanups
Remove the unused NMDnsPlugin::init method, some unused #includes, and
an out-of-date comment.

Use the correct macro for the default "/etc/resolv.conf" path.

Simplify NMDnsManager::dispose() a bit.

Make nm_dns_dnsmasq_new() return an NMDnsPlugin* rather than
NMDnsDnsmasq*.
2013-04-03 10:23:49 -04:00
Dan Winship
6d9aae3b47 core: add ignore-carrier config option
Add an ignore-carrier option to NetworkManager.conf, for specifying
devices where carrier state should be ignored for purposes of
activating/deactivating connections.
2013-04-03 10:23:49 -04:00
Dan Winship
5fec30d98e Revert :carrier-detect properties and associated code
Ignoring carrier is generally something you want at the machine level
(eg, for a server), not at the connection level.
2013-04-03 10:23:49 -04:00
Dan Winship
a2308fcab8 config: parse $nmconfdir/conf.d/*.conf
Add a new configuration directory ($nmconfdir/conf.d by default,
overridable via the --config-dir command-line option) that can contain
".conf" files that will be parsed in asciibetical order to override
the main NetworkManager.conf file.

In addition to simple overrides, the conf files also support appending
to the value of a previously-set list-valued key, by doing, eg,
"plugins+=foo"

https://bugzilla.gnome.org/show_bug.cgi?id=688857
2013-04-03 10:23:48 -04:00
Dan Winship
0186330a4b settings: use NMConfig directly rather than reparsing NetworkManager.conf
Add some new API to NMConfig so that NMSettings and its plugins can
use NMConfig to look up values rather than reparsing the config file
themselves.

Also, move the no-auto-default cache from NetworkManager.conf to
$NMSTATEDIR/no-auto-default.state, so NM isn't rewriting its own
config file at runtime.
2013-04-03 10:23:48 -04:00