Commit Graph

7740 Commits

Author SHA1 Message Date
Jiří Klimeš
831b7e2352 cli: move 'nmcli con status' under 'nmcli connection show' as 'active'
The static connection profiles are 'configured'.

So, now we have:
nmcli connection show configured [[id|uuid|path] <ID>]
  - shows configured connections
nmcli connection show active     [[id|uuid|path|apath] <ID>]
  - shows active connections

Without arguments the commands list all connections; with an argument, the details
of the requested connection is shown.
2013-04-08 16:09:23 -05:00
Jiří Klimeš
245d86bbcb cli: make id|uuid optional for 'nmcli connection down'
and also allow identifying connetions with 'path' and 'apath' that accepts either
the whole D-Dus path or just an index.

nmcli connection down [id|uuid|path|apath] <ID>

Example:
nmcli connection down con1
nmcli connection down con1 con2 apath 1 id my-wifi
2013-04-08 16:09:23 -05:00
Jiří Klimeš
6d5a88f02c cli: make id|uuid optional for 'nmcli connection up'
and also allow identifying connetions with 'path' that accepts either the whole
D-Dus path or just an index.

nmcli connection up [id|uuid|path] <ID>

Examples:
nmcli connection up "My Home Wi-Fi"
nmcli connection up id "My Home Wi-Fi"
nmcli connection up path /org/freedesktop/NetworkManager/Settings/18
nmcli connection up path 18

Note:
In order to be able to identify connections with just index number, the 'path'
keyword has to be provided.
2013-04-08 16:06:40 -05:00
Jiří Klimeš
4eef48d4aa cli: make id|uuid optional for 'nmcli connection delete'
and also allow identifying connetions with 'path' that accepts either the whole
D-Dus path or just an index.

nmcli connection delete [id|uuid|path] <ID>

Example:
nmcli connection delete "Wired 1" "Wired 2" "Wired 3"
nmcli connection delete id MyMain id "Quick Test 1" "Quick Test 2" path 23 path 47
2013-04-08 16:04:22 -05:00
Jiří Klimeš
1e106e31b8 cli: make id|uuid specifiers optional for 'connection list' and 'connection status'
And also allow:
 - identifying connetions with 'path'/'apath' accepting either the whole D-Dus path
   or just an index
 - multiple connections on cmdline at once

nmcli connection list   [[id|uuid|path] <ID>]
nmcli connection status [[id|uuid|path|apath] <ID>]

Examples:
nmcli c l
nmcli c l "My Wi-Fi 1" airpoirt1 cpath 23 id "My Wi-Fi 2"
nmcli c s
nmcli c s apath 1 ee19b893-e2a7-42cf-ac82-34506f07a05f
2013-04-08 15:52:15 -05:00
Jiří Klimeš
5e4d264917 cli: rename 'nm' object to 'general'
nmcli general

'nm' is kept for backward compatibility.
2013-04-08 15:52:15 -05:00
Dan Williams
a752a07875 todo: update item about proxy handling 2013-04-08 15:27:41 -05:00
Dan Williams
38d5770f3e cli: remove VPN state workaround from 191da673a8
This is no longer required, and state is signaled correctly.
2013-04-08 11:30:32 -05:00
Dan Williams
55cb1b74ee libnm-glib: ensure VpnStateChanged signals also notify VpnState property listeners
Both the VpnState property and the VpnStateChanged dbus signals update the
NMVPNConnection's 'vpn-state' GObject property, so we should ensure that
when either updates it due to a D-Bus event, GObject signals are sent
out for both too.
2013-04-08 11:30:32 -05:00
Dan Williams
a829c0439d cli: use nm_client_get_manager_running() instead of nmc_is_nm_running()
We now guarantee that NMClient won't dbus-activate NetworkManager so
there is no need for a custom function to prevent this.
2013-04-08 11:30:32 -05:00
Dan Williams
110a40358d libnm-glib: never call NM D-Bus methods if NM isn't running
Though the client shouldn't be calling anything when NM isn't running
(because clients have nm_client_get_manager_running()), make sure
that NMClient never calls a NetworkManager method when NM isn't
on the bus.

Next, ensure NMObject doesn't try to refresh properties when NM isn't
running.  Creating an NMClient may trigger a property refresh request,
but if NM isn't running, defer that until NM starts, to ensure that
we don't D-Bus autostart NM.

Third, ensure NMRemoteSettings doesn't attempt to list connections
unless NM is running.

This prevents service activation of NetworkManager in lieu of dbus-glib
learning about DBUS_HEADER_FLAG_NO_AUTO_START.
2013-04-08 11:30:32 -05:00
Dan Williams
4a21eb08db libnm-glib: clear and recheck permissions on NM restarts 2013-04-08 11:30:32 -05:00
Dan Williams
94ae8449c9 cli: let libnm-glib create our bus connection
libnm-glib handles connecting to the bus automatically if NULL
is passed for the bus object.  Do that; plus this lets us use
the private bus connection if present.
2013-04-08 11:30:32 -05:00
Dan Williams
a87b5a15df libnm-glib: use private connection before trying the system bus
Use the D-Bus connection helper whenever we need a connection to
NM, which by default tries to use a private connection instead of
the shared bus connection whenever the user is root.  Doing this
by default will not change the behavior of libnm-glib, and allows
tools like nmcli and libnm-glib-using clients to work in minimal
environments (those without a bus daemon) by default.
2013-04-08 11:30:32 -05:00
Dan Williams
661d09852d libnm-glib: use helpers to create dbus proxies
When using a private connection, we need to use dbus_g_proxy_new_for_peer()
because the bus isn't involved.  Since many parts of libnm-glib create a
proxy for their corresponding remote object, consolidate the proxy creation
logic.

A later patch will add logic to use a private connection versus a bus-based
one.
2013-04-08 11:30:32 -05:00
Dan Williams
44f350c99d libnm-glib: add helper to connect to NM's private D-Bus socket
A number of places in the code need to get a connection to NM through
D-Bus, and that connection could be either a shared bus connection or
a private connection.  Consolidate that logic.

Unfortunately only dbus-glib >= 0.100 correctly supports private
connections (commit 8b7e4a1c4ae055864e26db4addbcc2dc38ee6963 fixes
this problem) so the private connection functionality is not enabled
for older dbus-glib versions.
2013-04-08 11:30:31 -05: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
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