Commit Graph

8762 Commits

Author SHA1 Message Date
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
Jiří Klimeš
654a79ba88 cli: update bash completion file for the new syntax 2013-04-09 10:31:13 +02:00
Jiří Klimeš
c84315fd12 cli: 'connection delete' - do not stop on invalid connection arguments
Rather report it and continue with the next one. This is the behaviour
e.g. 'rm' command uses.
2013-04-08 16:14:56 -05:00
Jiří Klimeš
b68dbf8e07 man: update nmcli manual page for recent changes 2013-04-08 16:14:11 -05:00
Jiří Klimeš
7dddead250 trivial: format nmcli usage help 2013-04-08 16:14:11 -05:00
Jiří Klimeš
15398f6fc3 trivial: fix some comments and error messages in devices.c 2013-04-08 16:14:11 -05:00
Jiří Klimeš
9ebe727d83 cli: add 'nmcli general logging'
nmcli general logging [level <log level>] [domains <log domains>]

Examples:
nmcli general logging    - print current level and domains values
nmcli general logging level ERR  - change logging level to ERR
nmcli general logging level DEBUG domains DNS  - change logging level to DEBUG and domains to DNS
nmcli g l domains DEFAULT  - set default log domains (the ones active when NM)
2013-04-08 16:14:11 -05:00
Jiří Klimeš
e2d8ca7924 cli: util function to parse command-line arguments
nmc_parse_args() - parse command-line arguments
2013-04-08 16:14:11 -05:00
Jiří Klimeš
9ddd7bc2dc cli: split 'nmcli switch' --> 'nmcli networking' and 'nmcli radio' 2013-04-08 16:14:11 -05:00
Jiří Klimeš
7e7335471c cli: rename HARDWARE -> HW in status/switch fields 2013-04-08 16:14:11 -05:00
Jiří Klimeš
2bafd7a707 cli: split 'general' into 'nmcli switch' and 'nmcli general' commands
They basically contain operations previously available via 'nmcli nm'.
'nmcli nm' is still kept for backward compatibility.

Usage:
nmcli switch  [all|networking|wifi|wwan|wimax [on/off]]
nmcli general [status|permissions]

Examples:
nmcli switch all         - show all switches
nmcli switch wifi off    - switch Wi-Fi off

nmcli g s    - show NM status
nmcli g p    - show NM permissions
2013-04-08 16:14:10 -05:00
Jiří Klimeš
7a8d654691 cli: rename 'device list' -> 'device show' and remove 'iface' keyword
Examples:
nmcli device show         - shows details for all available devices
nmcli device show eth0    - shows details for eth0
nmcli device show em1.25  - shows details for em1.25 VLAN device
2013-04-08 16:12:34 -05:00
Jiří Klimeš
51f055f74c cli: remove iface keyword for 'nmcli device disconnect'
'nmcli disconnect' allows specifying only one interface at a time.
2013-04-08 16:12:34 -05:00
Jiří Klimeš
60f54cd65d cli: 'device disconnect' - ask for interface when missing and '--ask' is present 2013-04-08 16:12:34 -05:00
Jiří Klimeš
0db4b4db90 cli: 'device wifi connect' - ask for SSID/BSSID and password if not provided
when '--ask' parameter is specified
2013-04-08 16:12:34 -05:00
Jiří Klimeš
9e8013314e cli: 'connection delete' - ask for a connection name if not provided
when '--ask' switch is used
2013-04-08 16:12:04 -05:00
Jiří Klimeš
786ba05bfa cli: 'connection down' - ask for a connection name if not provided
when '--ask' switch is used
2013-04-08 16:12:03 -05:00
Jiří Klimeš
97dbf98cdd cli: 'connection up' - ask for a connection name if not provided
when '--ask' switch is used
2013-04-08 16:09:23 -05:00
Jiří Klimeš
b0bee192e8 cli: add nmc_string_to_arg_array() to split a string to arguments array 2013-04-08 16:09:23 -05:00
Jiří Klimeš
7c629bf0f4 cli: nmc_get_user_input() util function for getting user input 2013-04-08 16:09:23 -05:00
Jiří Klimeš
981a687f77 cli: add '--ask' global option
It will be used to ask user for required but missing data/parameters.
2013-04-08 16:09:23 -05:00
Jiří Klimeš
abbde8d76f cli: add 'nmcli device wifi scan' command
This requests NetworkManager to perform scanning for Wi-Fi networks.
NetworkManager scans periodically, but this command can be used by impatient
users who don't want to wait for the next scan.

Direct D-Bus API call example:
gdbus call --system -d org.freedesktop.NetworkManager \
           -o /org/freedesktop/NetworkManager/Devices/2 \
           -m org.freedesktop.NetworkManager.Device.Wireless.RequestScan {}
2013-04-08 16:09:23 -05:00
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