Commit Graph

17526 Commits

Author SHA1 Message Date
Thomas Haller
c5c48d4f5f cli: move global "loop" variable to nmcli.h header 2017-04-12 11:24:04 +02:00
Thomas Haller
03307e3dd6 cli: use nmc_print() to output nmcli general logging 2017-04-12 11:24:04 +02:00
Thomas Haller
16299e5ac0 cli: use nmc_print() to output nmcli general permissions
Add also colors for the output values.
2017-04-12 11:24:04 +02:00
Thomas Haller
3045daf127 cli: use nmc_print() to output setting data 2017-04-12 11:24:04 +02:00
Thomas Haller
fdd758112f cli: merge editor_show_secrets with NmcConfig.show_secrets
The show-secrets flag can be toggled in edit mode

  nmcli> nmcli show-secrets yes

There is no point in tracking two separate flags for it. Inside
edit mode, when the user toggles the show-secrets flag, it should
overwrite the command line option.

These two flags can be merged.
2017-04-12 11:24:04 +02:00
Thomas Haller
f0d91455ca cli: move show_secret field to NmcConfig
The show-secret property is basically a part of the current
configuration, relevant during printing. It will be passed
on to nmc_print(), and hence must be part of NmcConfig.
2017-04-12 11:24:04 +02:00
Thomas Haller
fdd40b6a68 cli: implement new nmc_print() command to generically output cli data
We already have
  - data sources (nm_cli, connections or settings)
  - meta data information how to access the data sources (NMMetaAbstractInfo,
    NmcMetaGenericInfo, NMMetaPropertyInfo)

Add now a generic way to output cli data using nmc_print(). It gets a
list of data-sources (@targets) and a list of available fields (meta
data). It also gets cli configuration (NmcConfig) and field selector
strings (@field_str).

Based on that, it should output the desired data.

This is intended to replaces the previous approach, where functions like
show_nm_status() have full knowledge about how to access the data and
create an intermediate output format (NmcOutputData, NmcOutputField)
that was printed via print_data().
show_nm_status() contained both knowledge about the data itself (how to
print a value) and intimate knoweledge about the output intermediate
format. Also, the intermediate format is hard to understand. For
example, sometimes we put the field prefix in NmcOutputField at index 0
and via the NmcOfFlags we control how to output the data.

Clearly separate the responsibilities.

  - The meta data (NmcMetaGenericInfo) is only concerned with converting
    a data source to a string (or a color format).
  - the field selection (@field_str) only cares about parsing the list
    of NMMetaAbstractInfo.
  - _print_fill() populates a table with output values and header
    entries.
  - _print_do() prints the previously prepared table.

The advantage is that if you want to change anything, you only need to
touch a particular part.

This is only a show-case for `nmcli general status`. Parts are still
un-implemented and will follow.

This changes behavior for --terse mode: the values are now no longer
translated:
  $ LANG=de_DE.utf8 nmcli -t --mode multiline general
2017-04-12 11:24:04 +02:00
Thomas Haller
e79174ca89 cli: refactor enum-to-string function to have non-translating version
We need both translated and non-translated versions.
2017-04-12 11:24:04 +02:00
Thomas Haller
ce28918dbf cli/trivial: move code 2017-04-12 11:24:04 +02:00
Thomas Haller
01b1656f36 cli: cleanup print_required_fields()
Avoid explicit free() calls, but instead have a auto variable
own the string.
2017-04-12 11:24:04 +02:00
Thomas Haller
7861ce7560 shared: add NM_PTRARRAY_EMPTY() util 2017-04-12 11:24:03 +02:00
Thomas Haller
31d0d0ef83 shared: add NM_PTRARRAY_LEN() utility macro
I used to use g_strv_length ((char **) p) instead, but that feels
ugly because it g_strv_length() is not designed to operate on
arbitrary pointer arrays.
2017-04-12 11:24:03 +02:00
Beniamino Galvani
c9c029181e cli: do not show description of unsupported properties
Properties without meta data cannot be set or displayed: do
not show them.
2017-04-12 10:18:01 +02:00
Beniamino Galvani
3509af90c9 clients: avoid crash when property meta data do not exist
This happens for object properties we don't implement yet in NM and
nmcli, for example ipv6.dad-timeout or ipv6.dhcp-timeout.
2017-04-12 10:17:43 +02:00
Beniamino Galvani
69fd96118e manager: unexport VPN connections when the activation fails early
When a VPN connection can't be activated we have to unexport and
dispose it. Commit f2182fbf9b ("core: don't emit double
PropertiesChanged signal for new active connections") removed the call
to nm_exported_object_unexport() in case of failure because the active
connection already gets unreferenced on failure.

However, an exported object can't be disposed until it's explicitly
unexported because GDBus code keeps a reference to it. The result was
that the active connection was kept alive and exported, but without
explicit references to it. As soon as the connection was unexported,
it was also automatically disposed, causing issues like:

 (src/nm-exported-object.c:1025):dispose: code should not be reached

 #0   _g_log_abort () at /lib64/libglib-2.0.so.0
 #1   g_logv () at /lib64/libglib-2.0.so.0
 #2   g_log () at /lib64/libglib-2.0.so.0
 #3   g_warn_message () at /lib64/libglib-2.0.so.0
 #4   dispose (object=0xaaf110) at src/nm-exported-object.c:1025
 #5   dispose (object=0xaaf110) at src/nm-active-connection.c:1246
 #6   dispose (object=0xaaf110) at src/vpn/nm-vpn-connection.c:2642
 #7   g_object_unref () at /lib64/libgobject-2.0.so.0
 #8   registration_data_free () at /lib64/libgio-2.0.so.0
 #9   g_hash_table_remove_internal () at /lib64/libglib-2.0.so.0
 #10  g_dbus_object_manager_server_unexport_unlocked () at /lib64/libgio-2.0.so.0
 #11  g_dbus_object_manager_server_unexport () at /lib64/libgio-2.0.so.0
 #12  nm_bus_manager_unregister_object (self=0x9069e0, object=object@entry=0xaaf110) at src/nm-bus-manager.c:858
 #13  nm_exported_object_unexport (self=0xaaf110) at src/nm-exported-object.c:714
 #14  _settings_connection_removed (connection=<optimized out>, user_data=0xaaf110) at src/nm-active-connection.c:184
 #15  g_closure_invoke () at /lib64/libgobject-2.0.so.0
 #16  signal_emit_unlocked_R () at /lib64/libgobject-2.0.so.0
 #17  g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
 #18  g_signal_emit_by_name () at /lib64/libgobject-2.0.so.0
 #19  nm_settings_connection_signal_remove (self=self@entry=0x9e4a80, allow_reuse=allow_reuse@entry=0) at src/settings/nm-settings-connection.c:2085
 #20  do_delete (self=0x9e4a80, callback=0x58106a <con_delete_cb>, user_data=0xa84fa0) at src/settings/nm-settings-connection.c:768
 #21  do_delete (connection=0x9e4a80, callback=0x58106a <con_delete_cb>, user_data=0xa84fa0) at src/settings/plugins/keyfile/nms-keyfile-connection.c:127
 #22  nm_settings_connection_delete (self=self@entry=0x9e4a80, callback=callback@entry=0x58106a <con_delete_cb>, user_data=0xa84fa0) at src/settings/nm-settings-connection.c:694
 #23  delete_auth_cb (self=self@entry=0x9e4a80, context=context@entry=0x7fffd80131e0, subject=0x91fb40, error=<optimized out>, data=data@entry=0x0) at src/settings/nm-settings-connection.c:1879
 #24  pk_auth_cb (chain=0x7fffd00024a0, chain_error=<optimized out>, context=0x7fffd80131e0, user_data=<optimized out>) at src/settings/nm-settings-connection.c:1351
 #25  auth_chain_finish (user_data=0x7fffd00024a0) at src/nm-auth-utils.c:92
 #26  g_idle_dispatch () at /lib64/libglib-2.0.so.0

Restore the unexport upon failure to fix this.

Fixes: f2182fbf9b

https://bugzilla.redhat.com/show_bug.cgi?id=1440077
2017-04-11 20:27:48 +02:00
Lubomir Rintel
0234172923 wifi: only attempt to set the scan MAC address when it actually changes
The address change involves setting the link down which causes the supplicant
interface to change state and in turn another scan attempt. This could lead to
a loop in case of broken drivers that are not able to change the MAC address
iff the MAC address is attempted at each scan request.

https://bugzilla.redhat.com/show_bug.cgi?id=1382741
2017-04-11 16:39:31 +02:00
Francesco Giudici
2c4e991aba nmcli: fix "nmcli device monitor <dev>"
Call get_device_list() after next_arg(); call it only after checking
that there are other arguments after "monitor".

Fixes: 6a3d77fbe6
2017-04-11 15:49:30 +02:00
Lubomir Rintel
b35e10f0ed test: set 8021x private key password flags
Fixes: df0dc912cc
2017-04-10 14:07:03 +02:00
Beniamino Galvani
608ac31e87 wifi: merge branch 'th/wifi-ap-max-rate-bgo779771'
https://bugzilla.gnome.org/show_bug.cgi?id=779771
2017-04-10 13:38:12 +02:00
Beniamino Galvani
21c22f2f96 wifi: fix HT max rate calculation
The rates of MCSs are not monotonically increasing.
2017-04-10 13:37:24 +02:00
James Kalbfleisch
cd91b7e119 wifi: parse the first 77 bits of the supported mcs set 2017-04-10 13:37:24 +02:00
Thomas Haller
2b64961d05 wifi: avoid buffer overflow reading IEs 2017-04-10 13:37:24 +02:00
Thomas Haller
961d572472 wifi: rename ieee80211_eid capability defines
IEEE_80211_IE_VHT_CAP has zero hits searching the internet.
WLAN_EID_VHT_CAPABILITY is how the same define is called by
kernel's "include/linux/ieee80211.h".

Use the same name as kernel.

Also, collect the maximum of @max_rate.
2017-04-10 13:37:24 +02:00
Thomas Haller
0c6097ccbe wifi/trivial: rename get_max_rate*() functions 2017-04-10 13:37:24 +02:00
Thomas Haller
5bd7ff2ec0 wifi: collect maximum max-bitrate in nm_wifi_ap_update_from_properties() 2017-04-10 13:37:24 +02:00
Thomas Haller
b0016d47f1 wifi: fix unsigned error return value for get_max_rate()
Signal error via 0, not -1.

Also, if the length of the array is unexpected, error out.
2017-04-10 13:37:24 +02:00
Thomas Haller
3d8bc3bc01 wifi: replace "if" checks for rate with switch statement
Also, fix "if (mcs == (12 || 19 || 26))".
2017-04-10 13:37:24 +02:00
Thomas Haller
534a96d82a wifi: set changed flag for max-rate in nm_wifi_ap_update_from_properties() 2017-04-10 13:37:24 +02:00
Thomas Haller
6c534af4d7 wifi: fix compiler warnings 2017-04-10 13:37:24 +02:00
Thomas Haller
f27a0711e6 wifi/trivial: fix whitespace and style 2017-04-10 13:37:24 +02:00
James Kalbfleisch
f2b0092b5b wifi: parse BSS IEs for 80211n and 80211ac data rates
Currently, 'nmcli dev wifi list' does not show the user any rates above
54Mbps.  Now, we can check the IEs passed to NM from the wpa_supplicant,
pull the mcs rate and channel width information, and determine a maximum
possible data rate for 11n and 11ac APs.

https://bugzilla.gnome.org/show_bug.cgi?id=779771
2017-04-10 13:37:24 +02:00
Lubomir Rintel
583192d121 supplicant-config: correct the uri attribute/query separator 2017-04-10 10:33:24 +02:00
Lubomir Rintel
d4d6272fec ifcfg: don't complain if 8021x secrets are empty
The connection is still valid; and it's easily possible to create it. It would
be a shame if it couldn't be read back.
2017-04-10 10:33:24 +02:00
Lubomir Rintel
df0dc912cc 8021x: don't request secrets if they are empty and system owned
Empty secrets are fine. In particular, for PKCS#11 it means that protected
authentication path is used (the secrets are obtained on-demand from the
pinpad).
2017-04-10 10:33:23 +02:00
Lubomir Rintel
0812413c9d ifcfg-rh: fix loading the PKCS#11 client certificate
Contrary to the comment above, the reader would skip the client certificate
even if the key is on PKCS#11 token, not just in a PKCS#12 archive.
2017-04-10 10:33:22 +02:00
Dan Williams
f66de1dd0f device-bond: fix possible uninitialized variable
src/devices/nm-device-bond.c: In function 'check_changed_options':
src/devices/nm-device-bond.c:529:4: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    g_set_error (error,
    ^
src/devices/nm-device-bond.c:505:14: note: 'name' was declared here
  const char *name, *value_a, *value_b;
              ^
src/devices/nm-device-bond.c:528:8: error: 'value_a' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (!nm_streq0 (value_a, value_b)) {
        ^
src/devices/nm-device-bond.c:505:21: note: 'value_a' was declared here
  const char *name, *value_a, *value_b;
                     ^
2017-04-07 11:56:53 -05:00
Dan Williams
24ab2a4945 auth-utils: fix possibly uninitialized variables
src/nm-auth-utils.c:343:6: error: 'is_authorized' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (is_authorized) {
      ^
src/nm-auth-utils.c:320:11: note: 'is_authorized' was declared here
  gboolean is_authorized, is_challenge;
           ^
src/nm-auth-utils.c:346:13: error: 'is_challenge' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   } else if (is_challenge) {
             ^
src/nm-auth-utils.c:320:26: note: 'is_challenge' was declared here
  gboolean is_authorized, is_challenge;
                          ^
2017-04-07 11:52:16 -05:00
Dan Williams
857f26dd19 default-route-manager: fix possibly uninitialized variable
src/nm-default-route-manager.c: In function '_ipx_update_default_route':
src/nm-default-route-manager.c:769:23: error: 'is_assumed' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    if (!default_route && !is_assumed) {
                       ^
src/nm-default-route-manager.c:763:13: note: 'is_assumed' was declared here
    gboolean is_assumed;
             ^
2017-04-07 11:33:06 -05:00
Beniamino Galvani
ad6930f052 config: fix assertion in nm_config_device_state_write()
Fixes: 142ebb1037
2017-04-07 16:56:33 +02:00
Thomas Haller
142ebb1037 core: only persist explicit managed state in device's state file
For example, when starting without Wi-Fi plugin, a generic device
is created. On stop, we should not store the unmanaged state
on the state file, otherwise after restart the device is unmanaged.

Only store explicit user decisions.

https://bugzilla.redhat.com/show_bug.cgi?id=1440171
2017-04-07 15:27:04 +02:00
Beniamino Galvani
fad2cf0721 pacrunner: remove failed and pending items from configuration list
If a configuration does not have a path it is because we are still
sending it to pacrunner or because we failed to do so. In both cases,
we have to remove the configuration from the list.

Fixes: 3ad89223d0
2017-04-07 15:15:27 +02:00
Beniamino Galvani
3cada7722d device: fix removal of pacrunner configurations
Don't try to remove the configuration if we haven't added it in the
first place, for example when the connection gets deactivated before
it completes or for slave connections without IP configuration.

Fixes: 3ad89223d0
2017-04-07 15:15:27 +02:00
Thomas Haller
ab47a2d5fe build: fix broken line wraps in Makefile.am 2017-04-07 13:52:12 +02:00
Thomas Haller
9f7380e973 build: add missing build dependency for ifupdown
And reorder _OBJECTS dependencies of settings plugins after their
corresponding _LDADD declartion.

https://mail.gnome.org/archives/networkmanager-list/2017-April/msg00016.html
2017-04-07 12:37:56 +02:00
Thomas Haller
0b92c26bda cli: fix invalid assertion
Fixes: 19c70ace95
2017-04-06 15:41:27 +02:00
Lubomir Rintel
b7b0227935 linux-platform: fix link_get_unmanaged() return value
The function is supposed to set *unamanged to NM_UNMANAGED's and indicate
whether NM_UNMANAGED was present in the return value.

Fixes: e32839838e
2017-04-06 13:23:19 +02:00
Beniamino Galvani
bac864725b pacrunner: merge branch 'bg/pacrunner-domains-bgo780558'
https://bugzilla.gnome.org/show_bug.cgi?id=780558
2017-04-06 08:58:14 +02:00
Beniamino Galvani
b139552255 pacrunner: specify domains only for VPNs
If a VPN provides a proxy, we want to restrict the usage of that proxy
to URLs in the VPN domain. For all other connections, the proxy should
be used for all domains.
2017-04-06 08:57:35 +02:00
Beniamino Galvani
752e906aa4 pacrunner: don't log pacrunner-manager address
It's a singleton, the address is not meaningful.
2017-04-06 08:57:35 +02:00
Beniamino Galvani
3ad89223d0 pacrunner: rework processing of configuration entries
Fix some issues in nm-pacrunner-manager.c:

 - when adding a configuration through nm_pacrunner_manager_send(), we
   kept an association between the interface name and the pacrunner
   configuration object path, so that the configuration for that
   interface could be removed later. Unfortunately not all
   configurations have an interface associated, so we need a more
   generic way to identify configurations. Introduce a new @tag
   argument that serves as key to match configurations

 - the interface name of the last pushed configuration was stored in
   the manager private config and reused later; this could cause
   issues when there are multiple outstanding D-Bus calls. The
   interface is not needed anymore after the previous point.

 - remove() didn't actually remove the configuration from the list
2017-04-06 08:57:35 +02:00