Commit Graph

142 Commits

Author SHA1 Message Date
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
Thomas Haller
2a3d65f8b2 trivial: whitespace fix 2015-01-11 22:52:50 +01:00
Thomas Haller
3cbce6994a nmcli/bash-completion: don't allow specifying connection by apath for 'connection modify'
The following must not be allowed:

  $ nmcli connection modify apath /org/freedesktop/NetworkManager/ActiveConnection/0
2014-12-22 15:39:48 +01:00
Thomas Haller
5ef233936a nmcli/bash-completion: fix detecting connection for connection modify
Previously we would only complete connections given by ID.
The following would work:
  $ nmcli connection modify id <ID> <TAB>
  $ nmcli connection modify <ID> <TAB>
  $ nmcli connection modify uuid <UUID> <TAB>
but the following would not work:
  $ nmcli connection modify <UUID> <TAB>
2014-12-22 15:28:00 +01:00
Jiří Klimeš
bcd5b2cdc1 cli: fix DEADCODE (CWE-561) found by coverity
Error: DEADCODE (CWE-561): [#def3]
NetworkManager-0.9.11.0/clients/cli/utils.c:488: cond_notnull: Condition "input", taking true branch. Now the value of "input" is not "NULL".
NetworkManager-0.9.11.0/clients/cli/utils.c:517: notnull: At condition "input", the value of "input" cannot be "NULL".
NetworkManager-0.9.11.0/clients/cli/utils.c:517: dead_error_condition: The condition "input" must be true.
NetworkManager-0.9.11.0/clients/cli/utils.c:517: dead_error_line: Execution cannot reach the expression """" inside this statement: "g_set_error(error, 1U, 0, d...".
2014-12-12 22:43:33 +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
Lubomir Rintel
9a3cc60d9b cli: expose the vpn.persistent property 2014-12-11 11:15:53 +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
Thomas Haller
c3246d962d nmcli/bash-completion: complete [+-] modifier for connection modify property
Fixes
  nmcli connection modify CONNECTION +conn<TAB>
2014-12-01 15:22:10 +01:00
Jiří Klimeš
72156ba1c5 cli: fix setting ethernet.s390-subchannels
It was not properly updated in a7c4d53d03 (when
updating stuff to ne libnm).

And allow 2 subchannels (libnm and ifcfg-rh allow it too).
2014-11-28 14:27:31 +01:00
Jiří Klimeš
fda5a4703d cli: add parent device information for VLAN devices 2014-11-24 10:33:22 +01:00
Dan Winship
71b4c05fca libnm: rename NMSecretAgent to NMSecretAgentOld
As with NMVpnPluginOld, rename NMSecretAgent to NMSecretAgentOld, to
leave the name "NMSecretAgent" open for a new-and-improved version in
NM 1.2.
2014-11-21 12:17:41 -05: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
224acba8f6 cli,vpn: merge branch 'lr/nm-1-0-fixes'
Fixes for various issues identified during 1.0 testing.

https://bugzilla.gnome.org/show_bug.cgi?id=740135
2014-11-20 16:12:21 +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
Thomas Haller
943db815ee translations: avoid preprocessor strings inside translation macro
https://bugzilla.gnome.org/show_bug.cgi?id=740381

Reported-by: Yuri Chornoivan <yurchor@ukr.net>
2014-11-20 12:42:15 +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
Lubomir Rintel
653b7e4805 cli: Watch for device as well as AC state changes when activating
The signals might be delivered in no particular order and we need to wait for
the device to reach stable state (whether it's successfully conntected or not)
as well as the active connection to leave ACTIVATING state.

https://bugzilla.gnome.org/show_bug.cgi?id=740320
2014-11-19 17:06:33 +01:00
Dan Winship
e43ba45f2f cli, libnm: don't use D-Bus-specific documentation in nmcli
Now that nm-setting-docs.xml is more D-Bus-specific, it's less
appropriate for nmcli's internal documentation. So generate a second
copy of the docs without using the overrides file, and use that one
for nmcli's documentation.
2014-11-19 09:24:10 -05:00
Dan Winship
c14486984e libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.

With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).

The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...

(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-11-19 09:24:09 -05: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
Lubomir Rintel
7d80a17631 cli: Finish waiting for the device activation when it disconnects
The device status alone is uninteresting as its changes can be due to
deactivation of previously active connection. We should monitor the
active connection changes instead of device state changes.

However the device state changes is still interesting, as it contains the
reason for the change, let's just ignore them while the connection is
activating.

Lastly, we need to handle failures as well. It should be noted that it's
not sufficient to deal with NM_DEVICE_STATE_FAILED as the device will
quickly draverse to NM_DEVICE_STATE_DISCONNECTED. This happens in case of
a failure due to NM_DEVICE_STATE_REASON_NO_SECRETS as soon as the server
makes sure it won't reconnect automatically.
2014-11-14 16:46:40 -06:00
Dan Winship
16a9fc49dd docs: make the settings docs work from tarball builds
docs/api/settings-spec.xml was accidentally not getting disted,
because gtk-doc.make explicitly removes all DISTCLEANFILES from
distdir. However, it doesn't actually make sense for the settings docs
files to be in DISTCLEANFILES anyway; they were put there rather than
CLEANFILES (IIRC) so that "make clean" in a tarball build wouldn't
delete them and break things. But the right fix is to just make them
only be in CLEANFILES when BUILD_SETTING_DOCS is true, and not ever
get deleted otherwise.

Also adjust the build rules to ensure that the generated docs don't
get rebuilt in tarball builds, since that can cause problems when
building from a read-only source tree, etc.

Meanwhile, in an unrelated but also fatal bug, configure.ac's check
for if the generated docs were already present never got updated for
the cli/src -> clients/cli move, and so even if we had been disting
settings-spec.xml, configure would still think that the tarball didn't
have all of the generated docs in it, so SETTING_DOCS_AVAILABLE would
be set false and none of the generated docs would get used.

https://bugzilla.gnome.org/show_bug.cgi?id=740035
2014-11-14 17:14:18 -05:00
Lubomir Rintel
529092f035 Revert "cli: Finish waiting for device activation when they disconnect"
In case there's already a connection on the device, it traverses to
DISCONNECTED. We shouldn't cease waiting then.

This reverts commit 94a57d5e07.
2014-11-14 13:54:13 +01:00
Lubomir Rintel
94a57d5e07 cli: Finish waiting for device activation when they disconnect
When wifi secrets are missing, NM_DEVICE_STATE_FAILED due to
NM_DEVICE_STATE_REASON_NO_SECRETS is immediately followed by traversal to
NM_DEVICE_STATE_DISCONNECTED as soon as the server makes sure it won't
reconnect automatically. We sometimes aren't quick to handle the first signal
and only get the latter one.

Let's treat all states that aren't ordinarily reached upon activation as bad.
2014-11-13 18:55:37 +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
Jiří Klimeš
142dbf213e cli: show gateway as a separate item in active connection data (bgo #739958)
Example (for active connection ethernet-13)
$ nmcli -f active con show ethernet-13
...
IP4.ADDRESS[1]:                         10.34.25.205/23
IP4.GATEWAY:                            10.34.25.254
IP4.ROUTE[1]:                           dst = 10.38.5.26/32, nh = 0.0.0.0, mt = 20
...

https://bugzilla.gnome.org/show_bug.cgi?id=739958
2014-11-11 17:15:03 +01:00
Jiří Klimeš
b75dfc62e8 cli: fix nmcli timeout when disconnecting a device
$ nmcli dev disconnect nm-bond
Error: Timeout 10 sec expired.

When a software device is disconnected, it will be removed. And it may not go
to NM_DEVICE_STATE_DISCONNECTED state before that. So we need to listen to
"device-removed" signal.

Fixes:Beaker:test_log-NetworkManager_Test189_bond_activate
2014-11-10 17:22:52 +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
Dan Williams
22762324e8 libnm,core: enhance nm_utils_hexstr2bin()
Make the type return GBytes since most in-tree users want that.

Allow the function to accept many more formats as valid hex, including
bytes delimited by ':' and a leading '0x'.
2014-11-07 12:18:32 -06:00
Thomas Haller
36d99dbed5 cli: support new property NM_SETTING_IP_CONFIG_ROUTE_METRIC
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
7a55191079 cli: add utility methods for gint64 types
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01: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
e374923bbe all: allow route metrics to be "0"
Change NMIPRoute to use "-1" for "default", so that "0" is a valid
metric. Update everything for that.
2014-11-07 07:49:41 -05: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
35f6264745 core, clients: implement dhcp-send-hostname for IPv6
Now that NMSettingIP6Config inherits the dhcp-send-hostname property
from NMSettingIPConfig, fix things up so that it actually gets used.

(Note that this changes behavior: previously if ip6.dhcp-hostname was
unset, no hostname would be sent. Now, the system hostname will be
set. Also, ifcfg-rh does not currently support this property, so there
is no way to disable this...)
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š
e517061203 cli: add a polkit agent support for nmcli
Example: nmcli --ask general hostname computer007
2014-11-07 11:37:42 +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