Commit Graph

558 Commits

Author SHA1 Message Date
Lubomir Rintel
717db4fe01 cli/connections: split connection name parsing
Reduces redundant code paths; will make it easier to implement
completion in a common one.
2016-08-01 13:52:36 +02:00
Lubomir Rintel
023791edb0 cli/connections: use nmc_do_cmd() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
0e298456ed cli/connections: add active connection completion
Start completing by the id if the filter type is not specified
2016-08-01 13:52:36 +02:00
Lubomir Rintel
2c24de5814 cli/device: add completion to wifi hotspot subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
1a0dfd31c4 cli/device: add completion to wifi connect subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
8679793f6b cli/device: add completion to wifi list subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
efd22c24e8 cli/device: add completion to wifi rescan subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
3068886043 cli/device: export some useful completion functions
Wi-Fi access point completion functionality and stuff useful for completing
"ifname" and "ap" for "nmcli c up".
2016-08-01 13:52:36 +02:00
Lubomir Rintel
4302e05b1a cli/device: make it possible to limit completion to wifis 2016-08-01 13:52:36 +02:00
Lubomir Rintel
d2842d16e3 cli/device: replace some duplicate code with find_wifi_device_by_iface() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
1d8ab4e276 cli/device: make devices_idx argument to find_wifi_device_by_iface() optional
Most callers don't use it.
2016-08-01 13:52:36 +02:00
Lubomir Rintel
f32285f03f cli/device: make find_wifi_device_by_iface use sorted device array
...as opposed to GPtrArray. The point is to be able to have a single device
list that could be later reused with complete_device().
2016-08-01 13:52:36 +02:00
Lubomir Rintel
58caeea846 cli/trivial: move find_ap_on_device() up 2016-08-01 13:52:36 +02:00
Lubomir Rintel
ed215dc372 cli/trivial: move find_wifi_device_by_iface() up 2016-08-01 13:52:36 +02:00
Lubomir Rintel
8c4b749355 cli/networking: add subcommand completion 2016-08-01 13:52:36 +02:00
Lubomir Rintel
1c2cabeda8 cli/agent: add subcommand completion 2016-08-01 13:52:36 +02:00
Lubomir Rintel
ac58146298 cli/agent: use nmc_do_cmd() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
b37c109ee4 cli/radio: add subcommand completion 2016-08-01 13:52:36 +02:00
Lubomir Rintel
5305dfdf19 cli/radio: use nmc_do_cmd() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
2b860e4e95 cli/general: add subcommand completion 2016-08-01 13:52:36 +02:00
Lubomir Rintel
7b6ded8cc4 cli/general: use nmc_do_cmd() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
d73c0e57d5 cli: add ability to indicate command completion expects a file name 2016-08-01 13:52:36 +02:00
Lubomir Rintel
9827725210 cli: get rid of the global command completion whitelist
We're going to implement most of the missing pieces; the rest is going
to handle inability to complete itself.
2016-08-01 13:52:36 +02:00
Lubomir Rintel
60f992c5d3 cli: handle global usage with nmc_do_cmd() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
33cd5149f8 cli: do not skip over a nonexistent argument in nmc_do_cmd()
If we're called without an argument, don't shift arguments of the
callback -- it would be called with argc==-1.
2016-08-01 13:52:36 +02:00
Lubomir Rintel
ba45b5ac6f cli: take a reference to the device when activating
It can go away before the activation finishes:

  (process:378): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

  Thread 1 "lt-nmcli" received signal SIGTRAP, Trace/breakpoint trap.
  0x00007ffff4fa919b in g_logv () from /lib64/libglib-2.0.so.0
  (gdb) bt
  #0  0x00007ffff4fa919b in g_logv () at /lib64/libglib-2.0.so.0
  #1  0x00007ffff4fa930f in g_log () at /lib64/libglib-2.0.so.0
  #2  0x00007ffff529b3ea in g_type_check_instance () at /lib64/libgobject-2.0.so.0
  #3  0x00007ffff528fa94 in g_signal_handlers_disconnect_matched () at /lib64/libgobject-2.0.so.0
  #4  0x000000000041ae4e in activate_connection_info_finish (info=0x7b5490) at connections.c:2197
  #5  0x00007ffff5279470 in g_cclosure_marshal_VOID__OBJECTv () at /lib64/libgobject-2.0.so.0
  #6  0x00007ffff5276617 in _g_closure_invoke_va () at /lib64/libgobject-2.0.so.0
  #7  0x00007ffff5290ea9 in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
  #8  0x00007ffff52914ff in g_signal_emit () at /lib64/libgobject-2.0.so.0
  #9  0x00007ffff52763e8 in g_closure_invoke () at /lib64/libgobject-2.0.so.0
  #10 0x00007ffff52884a2 in signal_emit_unlocked_R () at /lib64/libgobject-2.0.so.0
  #11 0x00007ffff529112d in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
  #12 0x00007ffff52919ab in g_signal_emit_by_name () at /lib64/libgobject-2.0.so.0
  #13 0x00007ffff78fc9b1 in deferred_notify_cb (data=<optimized out>) at nm-object.c:243
  #14 0x00007ffff4fa2703 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
  #15 0x00007ffff4fa2ab0 in g_main_context_iterate.isra () at /lib64/libglib-2.0.so.0
  #16 0x00007ffff4fa2dd2 in g_main_loop_run () at /lib64/libglib-2.0.so.0
  #17 0x00000000004146e3 in main (argc=<optimized out>, argv=<optimized out>) at nmcli.c:618
  (gdb) print info->device
2016-07-28 11:22:31 +02:00
Beniamino Galvani
1fbdd4d008 cli: fix crash on connection delete/down timeout
connection_op_timeout_cb() passed a wrong object type to timeout_cb();
fix this.

Fixes: ac888de151

https://bugzilla.redhat.com/show_bug.cgi?id=1355740
2016-07-23 08:54:32 +02:00
Francesco Giudici
65771b80a6 cli: improve devices vs connection compatibility check
report error message on device compatibility failures
2016-07-22 19:36:23 +02:00
Beniamino Galvani
e7bd55afdd cli: fix typo in overview output
Fixes: f14845cc20
2016-07-20 09:31:11 +02:00
Lubomir Rintel
f14845cc20 cli: output a short summary of devices when called without arguments
This aims to be somewhat similar to what "ifconfig" does.

https://bugzilla.gnome.org/show_bug.cgi?id=766426
2016-07-19 14:29:05 +02:00
Lubomir Rintel
402828d2ed cli/devices: export device_state_to_color()
Also, get rid of the ColorInfo structure. It was not too nice anyway.
2016-07-19 14:29:05 +02:00
Lubomir Rintel
65c6eb5ce5 cli/connections: split out ac_state_to_color()
Going to be useful outside nmcli c.
2016-07-19 14:29:05 +02:00
Jiří Klimeš
2544f78858 nmcli: add missing commands to 'nmcli connection help' usage description 2016-07-15 12:26:24 +02:00
Jiří Klimeš
c875471430 nmcli: fix 'nmcli device modify' description
Fixes: 8b4494598d
2016-07-15 12:26:24 +02:00
Jiří Klimeš
887cdcc217 nmcli: remove the extra full stop from error messages
$ nmcli dev modify
Error: No interface specified..
$ nmcli dev modify bla
Error: Device 'bla' not found..
2016-07-15 11:43:32 +02:00
Lubomir Rintel
ac888de151 cli/connections: fail the activation when the active connection disappears
Relying solemnly on device or active connection state is unreliable.
2016-07-07 11:56:05 +02:00
Beniamino Galvani
938a4b35c6 cli: fix parsing of route metric on 32-bit archs
On 32-bit architectures long and int have the same size and thus it's
wrong to use nmc_string_to_int() since it uses strtol() and the @max
argument can't represent G_MAXUINT32. Use nmc_string_to_uint()
instead.

https://bugzilla.redhat.com/show_bug.cgi?id=1350201
2016-06-30 13:19:46 +02:00
Thomas Haller
96cabbcbb8 all: make MAC address randomization algorithm configurable
For the per-connection settings "ethernet.cloned-mac-address"
and "wifi.cloned-mac-address", and for the per-device setting
"wifi.scan-rand-mac-address", we may generate MAC addresses using
either the "random" or "stable" algorithm.

Add new properties "generate-mac-address-mask" that allow to configure
which bits of the MAC address will be scrambled.

By default, the "random" and "stable" algorithms scamble all bits
of the MAC address, including the OUI part and generate a locally-
administered, unicast address.

By specifying a MAC address mask, we can now configure to perserve
parts of the current MAC address of the device. For example, setting
"FF:FF:FF:00:00:00" will preserve the first 3 octects of the current
MAC address.

One can also explicitly specify a MAC address to use instead of the
current MAC address. For example, "FF:FF:FF:00:00:00 68:F7:28:00:00:00"
sets the OUI part of the MAC address to "68:F7:28" while scrambling
the last 3 octects.
Similarly, "02:00:00:00:00:00 00:00:00:00:00:00" will scamble
all bits of the MAC address, except clearing the second-least
significant bit. Thus, creating a burned-in address, globally
administered.

One can also supply a list of MAC addresses like
"FF:FF:FF:00:00:00 68:F7:28:00:00:00 00:0C:29:00:00:00 ..." in which
case a MAC address is choosen randomly.

To fully scamble the MAC address one can configure
"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00".
which also randomly creates either a locally or globally administered
address.

With this, the following macchanger options can be implemented:

  `macchanger --random`
   This is the default if no mask is configured.
   -> ""
   while is the same as:
   -> "00:00:00:00:00:00"
   -> "02:00:00:00:00:00 02:00:00:00:00:00"

  `macchanger --random --bia`
   -> "02:00:00:00:00:00 00:00:00:00:00:00"

  `macchanger --ending`
   This option cannot be fully implemented, because macchanger
   uses the current MAC address but also implies --bia.
   -> "FF:FF:FF:00:00:00"
      This would yields the same result only if the current MAC address
      is already a burned-in address too. Otherwise, it has not the same
      effect as --ending.
   -> "FF:FF:FF:00:00:00 <MAC_ADDR>"
      Alternatively, instead of using the current MAC address,
      spell the OUI part out. But again, that is not really the
      same as macchanger does because you explictly have to name
      the OUI part to use.

  `machanger --another`
  `machanger --another_any`
  -> "FF:FF:FF:00:00:00 <MAC_ADDR> <MAC_ADDR> ..."
     "$(printf "FF:FF:FF:00:00:00 %s\n" "$(sed -n 's/^\([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) .*/\1:\2:\3:00:00:00/p' /usr/share/macchanger/wireless.list | xargs)")"
2016-06-30 08:32:50 +02:00
Thomas Haller
8eed67122c device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.

"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.

"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a6.

"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".

On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.

There is some overlap with the "wifi.mac-address-randomization" setting.

https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-06-30 08:29:56 +02:00
Thomas Haller
3f3ea1df21 libnm: add NMSettingConnection:stable-id property
This new property be used as token to generate stable-ids instead
of the connection's UUID.

Later, this will be used by ipv6.addr-gen-mode=stable-privacy,
ethernet.cloned-mac-address=stable, and wifi.cloned-mac-address=stable
setting. Those generate stable addresses based on the connection's
UUID, but allow to use the stable-id instead.

This allows multiple connections to generate the same addresses
-- on the same machine, because in the above cases a machine
dependant key is also hashed.
2016-06-30 08:29:54 +02:00
Lubomir Rintel
9dafcc8b26 cli/device: allow completion of the "wifi" command name
That's the "wifi" string itself. The subcommands need some work.
2016-06-29 20:49:34 +02:00
Lubomir Rintel
b8bc57c9d3 cli/device: add "lldp list" subcommand completion 2016-06-29 20:49:34 +02:00
Lubomir Rintel
08969b1789 cli: make subcommand dispatch do autocompletion 2016-06-29 20:49:34 +02:00
Lubomir Rintel
1e582f0172 cli: add boolean value completion helper 2016-06-29 20:49:34 +02:00
Lubomir Rintel
e2fe0eeb18 cli: add arbitrary string list completion helper 2016-06-29 20:49:34 +02:00
Lubomir Rintel
39f6d5a5ba cli/device: make "lldp list" subcommand use get_device() 2016-06-29 20:44:05 +02:00
Lubomir Rintel
95a13ef100 cli/device: make "set" subcommand use get_devices() 2016-06-29 20:39:09 +02:00
Lubomir Rintel
78c4038d8c cli/device: convert lldp subcommand to nmc_do_cmd() 2016-06-29 20:32:31 +02:00
Lubomir Rintel
05108ca975 cli/device: convert wifi subcommand to nmc_do_cmd() 2016-06-29 20:32:31 +02:00
Lubomir Rintel
8b4494598d cli/device: add modify command
It modifies the applied connection using the Reapply API.
2016-06-29 20:28:42 +02:00