Commit Graph

454 Commits

Author SHA1 Message Date
Thomas Haller
d0f01aa2c2 clients,cli: show better error message when failing to load VPN plugin
VPN plugins are often not installed or they might be legacy-only.
In both cases we should show a better error message about the
failure reason.
2016-05-19 12:52:59 +02:00
Thomas Haller
41976e3069 clients,cli: for connection-add consider VPNs as loaded from the plugin
Instead of using (only) a hard-coded list of VPN types,
prefer lookup the VPN settings from the .name files.

Still, fallback to a hard-coded list if the plugin cannot
be found, because for connection-add we currently don't
actually need the plugin installed.
2016-05-19 12:52:59 +02:00
Thomas Haller
2b4b9d34e4 clients: don't assert against existance of plugin in nm_vpn_supports_ipv6()
Obviously, loading a plugin can fail easily.
2016-05-19 12:52:59 +02:00
Thomas Haller
0225c4567b clients: lookup VPN plugins either by "name" or "service"
... not constructing a "service" by prepending a D-Bus prefix to "name" (urgh).
2016-05-19 12:52:59 +02:00
Thomas Haller
09a015b23b nmcli-completion: complete filename for VPN import and passwd-file
Also hard-code the VPN types strongswan and fortisslvpn.

https://bugzilla.redhat.com/show_bug.cgi?id=1337300
2016-05-19 12:52:59 +02:00
Beniamino Galvani
dbd0634c84 cli: append newline to failure message
Fixes: a06487a6ae
2016-05-16 17:55:21 +02:00
Beniamino Galvani
c094ee5f90 cli: also hide phase2 private key unless --show-secrets is passed
Fixes: ca6f1e7f25
2016-05-13 13:48:43 +02:00
Beniamino Galvani
ca6f1e7f25 cli: hide secret certificate blobs unless --show-secrets is passed
Client certificate and private key blobs should be considered private
as other secrets and not shown unless the --show-secrets option is
passed.

https://bugzilla.redhat.com/show_bug.cgi?id=1184530
2016-05-13 11:49:58 +02:00
Beniamino Galvani
d5855ed807 cli: add support for DNS priority 2016-05-12 17:13:50 +02:00
Beniamino Galvani
f57c205051 clients: add missing openvpn secret types to secret agent
Add support for asking a certificate password and a HTTP proxy
password for openvpn connections to the built-in secret agent.

https://bugzilla.gnome.org/show_bug.cgi?id=765553
2016-05-05 14:22:32 +02:00
Thomas Haller
7752f390c2 cli: declare external variable nm_cli in <nmcli.h> header 2016-05-03 11:53:15 +02:00
Thomas Haller
a9908c012c cli: remove unused functions 2016-05-03 11:53:15 +02:00
Thomas Haller
d742ea7817 cli: don't allow multiple <ifname> arguments to device-reapply
Just like `nmcli device connect` only allows one argument, don't allow
multiple device arguments for reapply.

Allowing multiple device names makes it more complicated to add
additional options to the command. For example, it would be useful
to have a

    nmcli device reapply eth0 connection id other-connection

but when allowing multiple device names, it gets more complicated in
documentation, command line parsing and bash completion.

Note that the user can achieve a very similar outcome by using the
shell:

    for DEV in eth0 eth1 eth2; do
        nmcli device reapply $DEV &
    done
    wait

argubaly, this doesn't report the exit status properly. To properly
handle that would require more effort. Also, it is somewhat less
efficient, but well.

This is an API change, however it is very new API that probably nobody
is using much. Also, the documentation (man nmcli) didn't mention the
possibility to pass multiple device names.
2016-05-03 11:52:57 +02:00
Thomas Haller
b217b68b80 cli: refactor cleanup in do_device_reapply() 2016-05-03 11:52:40 +02:00
Thomas Haller
c5ac691744 build: cleanup includes of <gmodule.h>
<gmodule.h> is implicitly included by <gio/gio.h> which is available
everywhere. For that reason, we would not have to include this header
at all. However, it is recommended to explicitly include <gmodule.h>
where needed.

So, include it where needed -- if <gio/gio.h> wouldn't be there --
and drop it from where it is not needed.
2016-04-30 03:42:16 +02:00
Beniamino Galvani
a06487a6ae cli: handle device failure when activating
We might receive the update of the device state to FAILED when the
active connection is still in ACTIVATING. Handle this case properly.
2016-04-29 11:16:30 +02:00
Francesco Giudici
3c67a1ec5e cli: remove version check against NM
When performing NM package upgrade the new version of nmcli will be immediately
available while NM daemon will not, as it would not restart in order to avoid
to disrupt connectivity. This could create issues with tools leveraging
on nmcli output (till reboot). As apart from this case it is very unlikely
that a user can have this nmcli / NM daemon version mismatch situation,
the check could cause more harm than benefit in real user case
scenarios.

https://bugzilla.redhat.com/show_bug.cgi?id=1291785
2016-04-28 09:35:20 +02:00
Beniamino Galvani
f4f9c9fa3c tui: quit from top-level form when exiting
The top-level form was left on screen after exit (this is visible only
on some types of terminal as vt100), breaking automated tests.

Fixes: b2fb80928e
2016-04-27 10:52:31 +02:00
Beniamino Galvani
b2fb80928e tui: return to initial menu after sub-forms exit
When the user runs nmtui and selects an operation (edit, connect or
set-hostname) from the initial menu, the expectation is that once the
operation terminates the initial menu is shown again, so that the user
can perform multiple operations (like creating a connection and
activating it) without quitting.

https://bugzilla.gnome.org/show_bug.cgi?id=763836
2016-04-15 13:27:42 +02:00
Thomas Haller
9152dec99f build: disable deprecation checks for internal compilation
For internal compilation we want to be able to use deprecated
API without warnings.

Define the version min/max macros to effectively disable deprecation
warnings.

However, don't do it via CFLAGS option in the makefiles, instead hack it
to "nm-default.h". After all, *every* source file that is for internal
compilation needs to include this header as first.
2016-04-05 22:22:58 +02:00
Thomas Haller
03fd18cde0 cli: fix setting 'slave-type' for nmcli connection add type *-slave
$ nmcli connection add type bond-slave ifname eth1 con-name bond0.0 master nm-bond
  Error: Failed to add 'bond0.0' connection: connection.slave-type: Cannot set 'master' without 'slave-type'

Fixes: 8ad218e71c
2016-03-30 18:36:07 +02:00
Thomas Haller
6fa521b384 cli/trivial: fix indention and whitespace 2016-03-30 18:15:03 +02:00
Beniamino Galvani
a9241773d7 cli: allow setting multiple IPs in bond 'arp_ip_target' option
The bond 'arp_ip_target' option contains a list of comma-separated IP
addresses; but comma is also used to separate options and so at the
moment it is not possible to specify multiple IPs as the command

 $ nmcli c m b1 bond.options \
   mode=0,arp_interval=1,arp_ip_target=1.1.1.1,2.2.2.2

interprets 2.2.2.2 as the next option.

Allows spaces to be used as separators for the IPs of the
'arp_ip_target':

 $ nmcli c m b1 bond.options \
   "mode=0,arp_interval=1,arp_ip_target=1.1.1.1 2.2.2.2"
2016-03-29 18:10:05 +02:00
Thomas Haller
31669329bb cli/trivial: fix TABs for indention 2016-03-29 14:59:01 +02:00
Lubomir Rintel
8ad218e71c nmcli: fix slave_type setting 2016-03-29 14:53:45 +02:00
Lubomir Rintel
e691f01e01 cli: make the *-slave type option parsing out of the common path
We actually don't want to understand these options unless the legacy
*-slave types are used. The properties should be used directly instead.

https://bugzilla.gnome.org/show_bug.cgi?id=748302

This basically undoes most of what has been done in  commit 00e0fffea2.
2016-03-29 14:20:09 +02:00
Beniamino Galvani
945c459f20 cli: add support for NMSetting8021x domain-suffix-match properties 2016-03-16 17:32:17 +01:00
Beniamino Galvani
ff97494e78 cli: fix memory leak in connection listing 2016-03-14 22:18:17 +01:00
Beniamino Galvani
f0c6a0315d cli: prefer 'modify' over 'monitor' when the command is abbreviated
In previous releases 'nmcli connection m' was interpreted as 'modify',
but recently the monitor command was introduced with a higher
priority, changing the behavior when the abbreviated form is
used.

Restore the old behavior.

https://bugzilla.redhat.com/show_bug.cgi?id=1316120
2016-03-10 11:12:02 +01:00
Francesco Giudici
fb8fe1d8cb nmcli: fix check on allowed parameters for slave connections
When editing a connection, check its slave-type parameter. If not null,
we will not have ip properties but possibly others, slave-type specific.
2016-03-04 19:14:26 +01:00
Dan Winship
6265398b6e all: use g_error_matches()
Use g_error_matches() where we're testing error codes. In particular,
use it rather than looking at only ->code and not also ->domain, which
is just wrong.

[thaller@redhat.com: rebase and modify original patch]
2016-03-03 18:54:20 +01:00
Thomas Haller
01b9b4104c all: clean-up usage of GError
Functions that take a GError** MUST fill it in on error. There is no
need to check whether error is NULL if the function it was passed to
had a failing return value.

Likewise, a proper GError must have a non-NULL message, so there's no
need to double-check that either.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +01:00
Beniamino Galvani
4ded98dd0f cli: fix use-after-free when adding ADSL connections
check_adsl_protocol() can free and assign a new string to
@protocol_ask, leaving @protocol dangling. Fix this.

Fixes: 290c1626b9
2016-02-29 13:47:47 +01:00
Thomas Haller
8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Lubomir Rintel
0aed7b5be6 cli: disable colors on dumb terminals
Nothing too sophisticated; just a simple way to get an color-less output on a
pty that wouldn't confuse the test suite.
2016-02-17 19:04:39 +01:00
Beniamino Galvani
1bb3b6a4c6 libnm-core: make ipvx.dhcp-timeout signed
Change the dhcp-timeout property in NMSettingIPConfig to int type for
consistency with the dad-timeout property. For dad-timeout -1 means
"use default value", while for dhcp-timeout probably we will never use
negative values, but it seems more correct to use the same type for
the two properties.
2016-02-16 11:37:26 +01:00
Beniamino Galvani
206e074863 libnm,core,cli: move dhcp-timeout property to generic NMSettingIPConfig
The property applies to both IPv4 and IPv6 and so it should not be in
NMSettingIP4Config but in the base class.
2016-02-16 11:37:26 +01:00
Thomas Haller
6898e2169e all: add version-id argument to device's Reapply method
This breaks API and ABI for the functions related to Reapply,
which got introduced in the current 1.1 development phase.

The version-id is here to allow users to error out if the connection
on the device was changed by a concurrent action.

https://bugzilla.gnome.org/show_bug.cgi?id=761714
2016-02-16 11:24:49 +01:00
Beniamino Galvani
10b222288e wifi: don't touch by default current powersave setting
Some drivers (or things outside NM like 'powertop') may turn powersave
on, so don't touch it unless explicitly configured by user.

To achieve this, add new 'default' and 'ignore' options; the former
can be used to fall back to a globally configured setting, while the
latter tells NM not to touch the current setting.

When 'default' is specified, a missing global default configuration is
equivalent to 'ignore'.

It is possible to enable Wi-Fi power saving for all connections by
dropping a file in /etc/NetworkManager/conf.d with the following
content:

 [connection]
 wifi.powersave=3

https://bugzilla.gnome.org/show_bug.cgi?id=760125
2016-02-16 00:18:06 +01:00
Thomas Haller
e663b88c59 all/trivial: rename STRLEN() macro to NM_STRLEN()
We should not have defines/macros in header files without a nm/NM
prefix. STRLEN() was one of the few offenders.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00048.html
2016-02-14 11:34:42 +01:00
Lubomir Rintel
868e1ddc07 cli: remove some dead code
Coverity points out.
2016-02-12 15:48:12 +01:00
Thomas Haller
2c2d9d2e4c build: cleanup default includes
- "gsystem-local-alloc.h" and <gio/gio.h> are already included via
  "nm-default.h". No need to include them separately.

- include "nm-macros-internal.h" via "nm-default.h" and drop all
  explict includes.

- in the modified files, ensure that we always include "config.h"
  and "nm-default.h" first. As second, include the header file
  for the current source file (if applicable). Then follow external
  includes and finally internal nm includes.

- include nm headers inside source code files with quotes

- internal header files don't need to include default headers.
  They can savely assume that "nm-default.h" is already included
  and with it glib, nm-glib.h, nm-macros-internal.h, etc.
2016-02-12 15:36:01 +01:00
Beniamino Galvani
0bfe70c574 cli: remove unused NMC_FIELDS_SETTING_*_COMMON defines 2016-02-12 13:46:12 +01:00
Beniamino Galvani
9e5c99465d cli: fix compile error
connections.c: In function ‘sort_connections’:
 connections.c:1536:3: error: ‘return’ with no value, in function returning non-void [-Werror=return-type]
    return;
    ^

Fixes: e8927c14ec
2016-02-11 17:14:35 +01:00
Lubomir Rintel
e8927c14ec client: fix NULL dereference with no connections
Coverity complains:

CID 59386 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking cons suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.
2016-02-11 17:01:03 +01:00
Lubomir Rintel
1783826856 cli: sort_access_points() doesn't take a NULL argument
The device never returns NULL access point list, it only deallocates it on
dispose(). Make this clear for Coverity:

CID 59387 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking aps suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.
2016-02-11 17:01:03 +01:00
Jiří Klimeš
1351b852f5 cli: fix nmcli help for 'monitor' command 2016-02-03 10:04:47 +01:00
Thomas Haller
bd74a9348f tui: disallow reserved vlan id 4095 2016-01-22 11:53:12 +01:00
Thomas Haller
7d67c533d1 cli: disallow reserved vlan id 4095 2016-01-22 11:50:52 +01:00
Dan Williams
0a12a1711c libnm-core,core,cli: fix spelling of NM_IP_TUNNEL_MODE_UNKNOWN
Fixes: b614a5ec61
Fixes: ae8c7a8967
Fixes: 570fdce93f
2016-01-20 11:27:22 -06:00