Commit Graph

182 Commits

Author SHA1 Message Date
Jiří Klimeš
40e98f5d68 nmcli: add --order option for 'nmcli connection show'
The option allows you to specify custom sorting order.
Default order (when no --order is provided) corresponds to -o "active:name:path"

Examples:
nmcli con show -o name
nmcli con show -o +name
  - sort connections by name alphabetically
nmcli con show -o -name
  - sort connections by name alphabetically in reverse order
mmcli con show -o active:name
  - sort connections first by active status, then by name
mmcli con show -o -path
  - sort connections by D-Bus path in reverse order
2015-02-23 09:24:21 +01:00
Jiří Klimeš
b4d5296782 nmcli: sort connections in 'nmcli connection show' output 2015-02-23 09:24:21 +01:00
Jiří Klimeš
8f60081be9 nmcli: (trivial): use real parameter types in fill_output_connection() prototype
The generic pointers were remnants from the time the function was used as
a callback.
2015-02-23 09:24:21 +01:00
Jiří Klimeš
0ff9b75387 nmcli: allow adding 'generic' connections via nmcli connection add
'nmcli connection edit' already allows adding and editing generic connections
(added by 2a2af5825a).
2015-02-11 10:51:49 +01:00
Lubomir Rintel
1bc942b142 cli: fix client bond option count
Looks more like 5, not 7, unless a particular mode is selected:

There are 7 optional arguments for 'bond' connection type.
Do you want to provide them? (yes/no) [yes]
Bonding mode [balance-rr]:
Bonding monitoring mode (miimon/arp) [miimon]:
Bonding miimon [100]:
Bonding downdelay [0]:
Bonding updelay [0]:
2015-01-19 12:04:50 +01:00
Jiří Klimeš
ed088b0df7 cli: mute coverity for Error: DEADCODE (CWE-561)
It can't recognize that the variables are set when parsing arguments.
2014-12-12 22:43:33 +01:00
Jiří Klimeš
0e727062fc cli: g_strdup(NULL) returns NULL; simplify code for that 2014-12-03 16:03:19 +01:00
Jiří Klimeš
1a4259d23a cli: additional fix for nmcli connection down
nmcli crashed when a timeout was hit, because 'info' was used after freeing
in down_timeout_cb().

Fixes 4a7c88621d.
2014-12-03 13:22:29 +01:00
Jiří Klimeš
4a7c88621d cli: fix deactivation for multiple connections (bgo #740775) (rh #1168383)
$ nmcli connection down aa bb cc

It has been broken by commit 20566c76de.

Fixups by dcbw.

https://bugzilla.gnome.org/show_bug.cgi?id=740775
https://bugzilla.redhat.com/show_bug.cgi?id=1168383
2014-12-03 10:54:49 +01:00
Dan Williams
20566c76de cli: wait for "con down" to deactivate the connection (bgo #740775) (rh #1168383)
nmcli currently does not wait for the connection to fully deactivate, which
can take some time due to dispatcher scripts or cleanup operations like
DCB.  Change it to wait until the connection is deactivated, or until
a short timeout has expired.  The user can adjust the timeout with
"--wait" if they want.

https://bugzilla.gnome.org/show_bug.cgi?id=740775
https://bugzilla.redhat.com/show_bug.cgi?id=1168383
2014-12-01 10:04:50 -06:00
Dan Williams
88c9c6a6ac clients: merge nm_secret_agent_simple_set_connection_path() into nm_secret_agent_simple_enable()
set_connection_path() is almost always called right before enable(),
and it's unclear why it would be called anywhere else.  So just
merge the two methods.
2014-11-21 12:14:48 -05:00
Dan Winship
a1f746351a clients: NMSecretAgentSimple API fixups
nm_secret_agent_simple_*() functions should take an
NMSecretAgentSimple, not an NMSecretAgent.

The type macros were incorrectly validating against
NM_TYPE_SECRET_AGENT rather than NM_TYPE_SECRET_AGENT_SIMPLE.
2014-11-21 12:08:35 -05:00
Jiří Klimeš
4b799db1d3 cli: add support for secret agent to 'nmcli dev connect' too
And move secrets getting code to common.c (without changes).
2014-11-20 16:36:29 +01:00
Lubomir Rintel
991df80408 cli: Process secret agent request for a connection only if we know its path
If we're activating the device without knowing the connection in advance, defer
servicing the requests for the secrets until we set the path.

[lkundrak@fedora20-2 ~]$ nmcli --ask c ifname wlan0

(process:18405): libnm-CRITICAL **: nm_object_get_path: assertion 'NM_IS_OBJECT (object)' failed
Error: Connection activation failed: The device has no connections available.
[lkundrak@fedora20-2 ~]$
2014-11-20 16:00:58 +01:00
Lubomir Rintel
d4240ad04c cli: Abort when given name of a non-existent connection for nmcli up
Even when ifname is present: nmcli c up name Nonexistent ifname wlan0
2014-11-19 19:51:44 +01:00
Lubomir Rintel
51974196f9 cli: Only escape VPN banner if it's present
If the connection is in ACTIVATING state, the banner is still NULL.
2014-11-19 19:51:44 +01:00
Jiří Klimeš
6fd8afd39f cli: fix showing secrets in nmcli editor (bgo #737415)
Put secrets into the local connection.

https://bugzilla.gnome.org/show_bug.cgi?id=737415
2014-11-19 11:47:58 +01:00
Jiří Klimeš
265b827ddd cli: ignore timestamp when comparing connections in the editor 2014-11-19 10:58:58 +01:00
Jiří Klimeš
a928ce89ef clients: only handle secret requests for connection being explicitly activated
When a connection is being activated, nmcli could ask for secrets for another
connection, which might confuse users. We check the request now and only ask
for secrets of connection being activated.

Test case:
$ nmcli con up my-ethernet0
Passwords or encryption keys are required to access the wireless network 'Red Hat'.
Warning: password for '802-1x.identity' not given in 'passwd-file' and nmcli cannot ask without '--ask' option.
2014-11-12 13:41:49 +01:00
Dan Winship
3e3e54a56c cli: fix an activation bug
Add a missing g_clear_error() that, for circuitous reasons, made
trying to activate a virtual connection fail silently.
2014-11-07 13:58:01 -05:00
Lubomir Rintel
5aa93e5518 connections: Don't give up if we've not seen an active connection yet
It will appear later on.

https://bugzilla.redhat.com/show_bug.cgi?id=1149200
2014-11-07 14:26:41 +01:00
Dan Winship
ca18b2d442 libnm: create NMDhcpConfig as parent of NMDhcp4Config and NMDhcp6Config
As with NMIP4Config and NMIP6Config, merge the two DHCP config classes
into one in the public API.
2014-11-07 07:49:40 -05:00
Dan Winship
d34910b128 libnm: create NMIPConfig as parent of NMIP4Config and NMIP6Config
Create NMIPConfig as the parent of NMIP4Config and NMIP6Config, and
remove the two subclasses from the public API; while it's convenient
to still have both internally, they are now identical to the outside
world.
2014-11-07 07:49:40 -05:00
Dan Winship
f17699f4e3 libnm-core: add NMSettingIPConfig:gateway, drop NMIPAddress:gateway
The gateway is a global property of the IPv4/IPv6 configuration, not
an attribute of any particular address. So represent it as such in the
API; remove the gateway from NMIPAddress, and add it to
NMSettingIPConfig.

Behind the scenes, the gateway is still serialized along with the
first address in NMSettingIPConfig:addresses, and is deserialized from
that if the settings dictionary doesn't contain a 'gateway' key.

Adjust nmcli's interactive mode to prompt for IP addresses and gateway
separately. (Patch partly from Jirka Klimeš.)
2014-11-07 07:49:40 -05:00
Dan Winship
3f30c6f1c2 libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classes
Split a base NMSettingIPConfig class out of NMSettingIP4Config and
NMSettingIP6Config, and update things accordingly.

Further simplifications of now-redundant IPv4-vs-IPv6 code are
possible, and should happen in the future.
2014-11-07 07:49:40 -05:00
Dan Winship
21c8a6b20e libnm-core, all: merge IPv4 and IPv6 address/route types
Merge NMIP4Address and NMIP6Address into NMIPAddress, and NMIP4Route
and NMIP6Route into NMIPRoute. The new types represent IP addresses as
strings, rather than in binary, and so are address-family agnostic.
2014-11-07 07:49:40 -05:00
Jiří Klimeš
3a551664df cli: add 'nmcli agent' command (bgo #739568)
Synopsis:
nmcli agent { secret | polkit | all }

The command runs separate NetworkManager secret agent or session polkit agent, or both.
It is useful when
- no other secret agent is available (such as GUI nm-applet, gnome-shell, KDE applet)
- no other polkit agent is available (such as polkit-gnome-authentication-agent-1,
  polkit-kde-authentication-agent-1 or lxpolkit)

https://bugzilla.gnome.org/show_bug.cgi?id=739568
2014-11-07 11:58:25 +01:00
Jiří Klimeš
3c9b8671fa cli: add 'passwd-file' option for 'nmcli connection up' to provide passwords
It is useful for running nmcli without --ask option, i.e. non-interactively.

Example contents of the file:
wifi.psk: s e c r e t 12345
802-1x.password:kili manjaro
802-1x.pin:987654321
2014-11-07 09:32:32 +01:00
Jiří Klimeš
de7f85bdec cli: use secret agent for getting passwords from user
--ask option has to be used, so that nmcli can be interactive.
2014-11-07 09:32:32 +01:00
Jiří Klimeš
098d655ef1 cli: fix an error path in second level 'set' command of nmcli editor
Test case:
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> set 1.1.1.1
Do you also want to set 'ipv4.method' to 'manual'? [yes]: no
nmcli ipv4.addresses> set 3.3.3.3/99
Error: failed to set 'addresses' property: invalid prefix '99'; <1-32> allowed
Do you also want to set 'ipv4.method' to 'manual'? [yes]:

The second question (after failed 'set') should not be asked.
2014-11-06 16:44:41 +01:00
Jiří Klimeš
32600a9035 cli: fix a regression in monitoring addresses vs. method changes
while editing an existing commention.
It was broken by commit 45590f809a that called
nm_connection_replace_settings_from_connection() which replaces settings with
connected signal handlers.
2014-11-06 12:47:17 +01:00
Lubomir Rintel
0276945fd3 cli: Activating an already activated connection fails
The new ActiveConnection starts in UNKNOWN state and we immediately assume
it failed. We should wait for DEACTIVATED or ACTIVATED instead.

https://bugzilla.gnome.org/show_bug.cgi?id=739339
2014-11-03 15:40:52 +01:00
Lubomir Rintel
1f275a980a Merge branch 'lr/ap'
https://bugzilla.gnome.org/show_bug.cgi?id=738439
2014-10-31 15:35:20 +01:00
Jiří Klimeš
45590f809a cli: allow showing secrets in the editor 2014-10-30 09:18:01 +01:00
Jiří Klimeš
b4e013abed cli: display '<hidden>' string for secret properties
unless the user explicitly say to show them.
2014-10-30 09:18:01 +01:00
Jiří Klimeš
1a64683802 cli: add '--show-secrets' option for 'nmcli connection show'
It can be used to display connection secrets (passwords).  When used, it will
get secrets for the connection profile and merge it into the connection's
settings before displaying it.

Example:
nmcli con show -s hotel-wifi
2014-10-30 09:11:43 +01:00
Jiří Klimeš
f558c8a51e cli: add 'verify fix' command for nmcli connection editor
Some connection verification errors are normalizable by NetworkManager. So we
can allow users to normalize the connection using one command.
2014-10-30 08:31:54 +01:00
Jiří Klimeš
d31c456033 cli: check IP configuration when setting connection.master in editor
If IPv4 and/or IPv6 are present on setting connection.master, offer their
removal.
2014-10-30 08:30:48 +01:00
Jiří Klimeš
afde052445 trivial: fix a typo in comments 2014-10-30 08:25:11 +01:00
Dan Winship
6ae4224850 libnm: change GSList to GPtrArray in libnm methods
libnm mostly used GPtrArrays in its APIs, except that arrays of
connections were usually GSLists. Fix this and make them GPtrArrays
too (and rename nm_client_list_connections() to
nm_client_get_connections() to match everything else).
2014-10-28 17:17:17 -04:00
Lubomir Rintel
1c9b16b2f2 cli: Add mode option for wifi connecitons
Only default (infrastructure) mode connections can be created and as it's not
possible to write mode=ap connections with ifcfg-rh plugins, they can't be
switched to mode=ap.
2014-10-23 18:34:39 +02:00
Dan Winship
2ff4a7d4b0 libnm: strip GDBus gunk from GErrors
Call g_dbus_error_strip_remote_error() on all errors returned from
gdbus calls. (Blah!)
2014-10-22 08:29:10 -04:00
Jiří Klimeš
e130415f2b cli: show active connection even if the connection profile is not visible
$ nmcli con show
2014-10-20 09:11:57 +02:00
Jiří Klimeš
b03518b817 cli: show details for active connection even if the profile is not visible
$ nmcli con show other_user_con
2014-10-20 09:11:57 +02:00
Jiří Klimeš
278ec17448 cli: fix errors and crash for invisible connections
* two users are logged in: user_a and user_b
* user_b creates a connection visible only to him 'user_b_private'
  (permissions: user:user_b)
* user_b activates the connection user_b_private
* user_a does not see the connection profile, but he does see the active
  connection

* user_a calls
  nmcli con
  nmcli con show user_b_private
2014-10-20 09:11:57 +02:00
Jiří Klimeš
88efa1c437 cli: fix 'nmcli connection up bond0' being stuck
It can happen on activating a master without slaves. Active connection will
not move past activating state.
2014-10-19 09:26:34 -04:00
Thomas Haller
cf26bb2dea cli: support connection.autoconnect-priority property
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Dan Winship
677314c540 libnm: fix NMActiveConnection object-path-valued properties
NMActiveConnection:connection was an object path rather than an
NMRemoteConnection because in the past the NMObject property system
wasn't capable of handling NMRemoteConnection-valued properties.
NMActiveConnection:master was an object path rather than an NMDevice
entirely by accident. Fix both.

NMActiveConnection:specific-object can't currently be converted to an
object, because we don't know ahead of time what object type it is,
and NMObject can't deal with that. Instead, we rename it to
:specific-object-path (and likewise for its get function), both to
emphasize that it doesn't behave like other properties, and to leave
the old name open for an actual object-valued property later on.
2014-10-10 13:10:19 -04:00
Dan Winship
6f3d1f9526 libnm: merge NMRemoteSettings into NMClient
Make NMRemoteSettings internal and have NMClient wrap all of its APIs,
just like it does with NMManager.
2014-10-10 12:40:19 -04:00
Dan Winship
c1f1e96181 cli: (trivial) rename NmCli.system_connections to connections
Rename NmCli.system_connections to connections, since the "user
connections" have been gone forever.
2014-10-10 12:40:15 -04:00