Commit Graph

8762 Commits

Author SHA1 Message Date
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
8ba3e3da29 trivial: update .gitignore 2013-04-04 10:21:52 -04: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
08e7fda63d data: add a server.conf example file
Add a server.conf example file, and install it to $(docdir)/examples.
2013-04-03 10:23:49 -04: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
1ca4745394 man: update NetworkManager.conf.5
Mention that no-auto-default can take interface names now, and mention
$nmrundir/no-auto-default.state.
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
Dan Winship
57b0ed4154 settings: clarify that NMDefaultWiredConnection is ethernet-only
NMSettings would try to create an NMDefaultWiredConnection for any
NMDeviceWired subclass, and there was some code to deal with
InfiniBand in the code. But nm_default_wired_connection_new() required
the hwaddr length to be ETH_ALEN, so InfiniBand would never have
worked (and probably shouldn't have, since people generally don't want
the auto-default behavior on servers anyway). And we certainly never
intended for this code to apply to bridges and bonds. So fix it to
only apply to ethernet devices, and remove the vestigial
InfiniBand-related code.
2013-04-03 10:23:48 -04:00
Dan Winship
b3e8361f0f settings: don't pass config_path to NMSettings and settings plugins
They can just call nm_config_get() now to get the config, and
nm_config_get_path() to get its path.
2013-04-03 10:23:48 -04:00
Dan Winship
26de9db14b core: remove some can't-happen checks
Most of the various nm_foo_manager_get/new() calls never return NULL,
so just g_assert() that fact rather than logging a separate error
message for each one.
2013-04-03 10:23:48 -04:00
Dan Winship
213a3a4d2e core: don't pass config data to NMDHCPManager and NMDnsManager
Rather than passing specific bits of data to NMDHCPManager and
NMDnsManager, just let them call nm_config_get() and then get the data
themselves.

Also, remove the GError argument from nm_dhcp_manager_new(), since the
function never returned NULL. This in turn means there is no longer
any need for a distinction between nm_dhcp_manager_new() and
nm_dhcp_manager_get(), so remove the former.
2013-04-03 10:23:48 -04:00
Dan Winship
0b815ca166 config: add NMConfigDevice
Add NMConfigDevice, which is mostly just a wrapper around
nm_device_get_hw_address() and nm_device_spec_match_list(), and
implement it in NMDevice. This will be used for config options that
match devices. (We can't use NMDevice directly for dependency
reasons.)
2013-04-03 10:23:48 -04:00
Dan Winship
29ed892de7 config, man: hide connectivity-check command-line options
There is no reason to configure the connectivity-check options from
the command line rather than from the config file. Keep the options,
for backward-compatibility, but remove them from the man page and hide
them from --help.
2013-04-03 10:23:48 -04:00
Dan Winship
8bb9ee8d3b config: fix documentation of --log-domains
The list of log domains in the --log-domains documentation had gotten
out of date. Fix this by adding nm_logging_all_domain_to_string()
(and, for completeness, nm_logging_all_levels_to_string()), and use
those to fill in the help string.
2013-04-03 10:23:47 -04:00
Dan Winship
3407726758 config: move config-related command-line options into nm-config.c
Rather than having main.c parse them and then hand them all to
nm_config_new(), just let nm-config provide its own GOptionEntry
array to merge in with main's.
2013-04-03 10:23:47 -04:00
Dan Winship
4a7727d93a config: make NMConfig non-refcounted
It's a singleton that always exists. Callers shouldn't have to
refcount it.

Also, move its cleanup code from dispose() to finalize(), and remove
some unnecessary checks in it.
2013-04-03 10:23:47 -04:00
Dan Winship
53bd84feff config: move NMConfig into its own subdirectory/library
Also, remove the unused NMConfigError, and add a config-parsing test
program.
2013-04-03 10:23:47 -04:00
Jiří Klimeš
f17ab954f6 libnm-util: make nm_setting_vpn_remove_*() return gboolean instead of void
to match other property removal functions, like nm_setting_bond_remove_option()
or nm_setting_wired_remove_s390_option().

Note:
This is an API change, make sure to bump soname when releasing libnm-util.
2013-04-03 08:35:47 +02:00
Dan Winship
228f6459e1 dns-manager: remove an incorrect and unnecessary line
gcc 4.8.0 has a new warning that triggers on

    static void
    compute_hash (NMDnsManager *self, guint8 buffer[HASH_LEN])
    {
        ...
        memset (buffer, 0, sizeof (buffer));
        ...
    }

because "sizeof (buffer)" is *not* HASH_LEN, it's sizeof(guint8*). The
memset() was not necessary anyway since the g_checksum_get_digest()
after it will always end up filling in buffer, so just remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=697041
2013-04-02 16:15:06 -04:00
Pavel Šimerda
1680143558 libnm-glib: adapt example to python 3.x
It now works with sufficiently recent python 2.x or python 3.x, whatever
is the distribution default. This patch fixes 'make check' for
distributions where 'python' means python 3.x, like Gentoo.
2013-04-02 11:44:24 +02:00
Pavel Šimerda
eb2b990ddc trivial: rename rand to avoid -Wshadow 2013-04-02 11:03:47 +02:00
Dan Williams
afc7f17191 libnm-glib: convert DHCP option parsing to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
a492d29ceb libnm-util: convert remaining NMConnection users to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
6c7c2b874d libnm-util: convert nm_setting_new_from_hash() to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
a8d33c7e2c libnm-util: convert nm_connection_duplicate() to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
7a7ce3b8e2 libnm-util: convert nm_connection_dump() to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
df02e7324c libnm-util: convert nm_connection_compare() to GHashTableIter
And finally add some testcases for it too.
2013-04-01 17:18:54 -05:00
Dan Williams
66230eb2f6 libnm-util: reduce memory used by NMConnection
The setting names used when inserting a setting into the hash
table are const since they are derived from GObject internals,
so there's no need to strdup them.
2013-04-01 17:18:53 -05:00
Dan Williams
1699a93be3 libnm-glib: fix memory leak of GSimpleAsyncResult loading object properties 2013-04-01 17:18:53 -05:00
Dan Williams
faf376dad1 libnm-util: fix memory leaks of dhcp_hostname and dhcp_client_id 2013-04-01 17:18:53 -05:00
Dan Williams
b1fc88154b libnm-glib: fix memory leak of GSimpleAsyncResult getting connection settings 2013-04-01 17:18:53 -05:00
Dan Williams
c00e2f1d9d libnm-util: fix some memory leaks in testcases
Helps suppress valgrind false positives.
2013-04-01 17:18:53 -05:00
Dan Williams
bc921e35da valgrind: add common suppressions
Stuff for GObject and NSS that is allocated but never expected
to be freed.
2013-04-01 17:12:37 -05:00
Dan Williams
0ab00b895b libnm-util: make nm_setting_wired_add_s390_option() argument names consistent 2013-04-01 17:12:22 -05:00