Commit Graph

405 Commits

Author SHA1 Message Date
Lubomir Rintel
84c484ed5b cli: make match() return boolean
Coccinelle semantic patch:

  @@
  @@
  -int
  +gboolean
          matches (...);

  @@
  expression pattern, cmd, len;
  @@
  -int
  +gboolean
          matches (...)
          {
                  ...
  -               return memcmp (pattern, cmd, len);
  +               return memcmp (pattern, cmd, len) == 0;
          }

  @@
  expression prefix, str;
  @@
  (
  -matches (prefix, str) != 0
  +!matches (prefix, str)
  |
  -matches (prefix, str) == 0
  +matches (prefix, str)
  )

  @@
  expression prefix, str;
  @@
  -(matches (prefix, str))
  +matches (prefix, str)

  @@
  expression prefix, str;
  @@
  -(!matches (prefix, str))
  +!matches (prefix, str)

spatch --smpl-spacing --sp-file match.cocci --dir clients/cli/ \
  --include-headers --macro-file shared/nm-utils/gsystem-local-alloc.h
2017-02-15 13:04:07 +01:00
Lubomir Rintel
8bd7bbba02 cli: add completion for "nmcli c edit" 2017-02-15 11:16:19 +01:00
Lubomir Rintel
1a0c779214 cli: complete VPN types 2017-02-15 11:16:19 +01:00
Lubomir Rintel
7399cf3b16 cli: add missing NULL-check
Only the connection down operation is cancellable, the other actions are not.

Fixes: 73b560c215
2017-01-29 12:56:31 +01:00
Lubomir Rintel
73b560c215 cli: avoid use-after free on connection deletion
If the connection spontaneously disappears (perhaps along with the whole
daemon on crash) while we're deleting it, then the removal callback
would free up the context structure the delete operation is using.

Let's cancel the in-flight delete operations so that they won't touch
the structure after it's gone.
2017-01-27 13:33:28 +01:00
Jiří Klimeš
283758dab3 cli: fix some TAB completions for nmcli -a con add
(cherry picked from commit 1cee85f556)
2017-01-21 21:32:31 +01:00
Jiří Klimeš
6397ce1fac cli: enable TAB-completion for proxy properties in interactive editor 2017-01-17 14:27:31 +01:00
Beniamino Galvani
d197c0626a cli: macsec support 2017-01-16 17:47:10 +01:00
Lubomir Rintel
260563a7d9 all: use nm_utils_is_valid_iface_name() 2017-01-06 15:11:56 +01:00
Jiří Klimeš
9a1a03b08c cli: (trivial) fix a typo 2016-12-15 15:31:51 +01:00
Jiří Klimeš
58a328aafc cli: add SLAVE field for 'nmcli con show' output
It helps listing or searching for slave connections. For example, one can do
$ nmcli -f name,uuid,type,slave connection show | awk '$NF == "bridge"'
to show all bridge slave connections.
2016-12-15 15:03:41 +01:00
Lubomir Rintel
01a20015e0 cli: use nmc_do_cmd to get the client and check if the daemon is running
The makes use of asynchronous client initialization, making things a bit
faster and reduces code duplication too.
2016-11-11 16:18:03 +01:00
Lubomir Rintel
3ee03afecc cli: make it possible to call sub-commands with client obtained asynchronously 2016-11-11 16:18:03 +01:00
Lubomir Rintel
6499bb893f cli: get rid of client-global connections list
Caching it in the NmCli object is unnecessary, ugly and would be cumbersome in
future when we'll be creating the client object only when needed.
2016-11-11 16:18:03 +01:00
Beniamino Galvani
984d4f0684 cli: properly set multiple addresses in questionnaire mode
Pass the '+' modifier to set_property() for IPv4 and IPv6 addresses to
append the new address to existing ones instead of overwriting them.

Fixes: 2f45665559

https://bugzilla.redhat.com/show_bug.cgi?id=1380165
2016-10-04 14:18:27 +02:00
Atul Anand
812b8774f6 proxy: remove unnecessary APIs
Unnecessary APIs have been removed from nm-setting-proxy, client like
nm-connection-editor are expected to create a PAC script snippet the load
the location of file in NM.
2016-10-04 11:44:44 +02:00
Atul Anand
2cb75e08d6 nmcli: Add Proxy support to nmcli
nmcli fixed to allow users edit proxy properties.
2016-10-04 11:44:44 +02:00
Beniamino Galvani
995229181c cli: remove editor thread
Currently the editor runs in a dedicated thread so that the blocking
call to readline() doesn't stop the processing of D-Bus events in the
main loop. The editor thread can access objects concurrently with the
main thread and this can cause races and crashes.

Remove the editor thread and use the non-blocking readline API.

https://bugzilla.gnome.org/show_bug.cgi?id=732097
https://bugzilla.redhat.com/show_bug.cgi?id=1368353
2016-09-23 09:46:28 +02:00
Beniamino Galvani
a2dac38174 cli: clear source when progress callback terminates 2016-09-23 09:46:28 +02:00
Beniamino Galvani
3ea5efd008 cli: fix wrong memory allocation size
Fixes: 8d9718bd0f
2016-09-23 09:46:28 +02:00
Jiří Klimeš
52723bd743 cli: fix yes/no completion in questionnaire mode 2016-09-19 16:58:18 +02:00
Jiří Klimeš
08a74c272b cli: tab-complete "Interface name [*]" in questionnaire mode 2016-09-19 16:58:18 +02:00
Jiří Klimeš
c2ef397867 cli: enable bash completion for some more properties of add/modify
connection.interface-name
mavclan.tap
mavclan.parent
ip-tunnel.parent
vxlan.parent
2016-09-19 16:58:18 +02:00
Jiří Klimeš
61a56aa3db cli: fix completion/add missing functions for '--complete-args' (rh #1375933)
This makes bash completion work again for 'nmcli connection add'.

Fixes: 8b39090597

https://bugzilla.redhat.com/show_bug.cgi?id=1375933
2016-09-19 16:55:40 +02:00
Jiří Klimeš
4b90b7b774 cli: (trivial): remove stray %s 2016-09-19 16:55:37 +02:00
Beniamino Galvani
b28b2ba8a9 clients: add define for NMSecretAgentSimple signal name 2016-09-14 23:32:52 +02:00
Beniamino Galvani
79a357b07a cli: connections: fail the activation if the ac deactivates
Since commit ac888de151 ("cli/connections: fail the activation when
the active connection disappears") we rely only on the disappearing of
the active-connection to determine the failure of an activation.

libnm can collapse a 'added' and a 'removed' signal if they are
received closer enough and thus we may miss the removal of the active
connection. Restore the detection of failure based on
active-connection state.
2016-09-09 16:40:53 +02:00
Lubomir Rintel
afab2b8112 cli: only connect handlers for property changes in interactive edit
Fixes: c5324ed285
(cherry picked from commit 79c81bbb8c)
2016-08-24 17:27:55 +02:00
Lubomir Rintel
2f45665559 cli: default to method=manual when adding an address
This restores accidentally changed behavior for
"nmcli c add ... ip[46] <address>"

Fixes: c5324ed285
(cherry picked from commit 195ad4ec97)
2016-08-24 17:27:55 +02:00
Beniamino Galvani
e9f96024ae cli: return sane error message for D-Bus policy permission errors
The error returned to users when a load_connection(s)/set_logging call
fails due to D-Bus policy denial is a bit obscure:

  $ nmcli general logging level debug
  Error: failed to set logging: Rejected send message, 4 matched rules;
  type="method_call", sender=":1.233" (uid=1001 pid=27225 comm="nmcli
  general logging level debug ")
  interface="org.freedesktop.NetworkManager" member="SetLogging" error
  name="(unset)" requested_reply="0" destination=":1.207" (uid=0
  pid=25793 comm="/usr/sbin/NetworkManager --no-daemon ")

Convert it to a more comprehensible:

  $ nmcli general logging level debug
  Error: failed to set logging: access denied

https://bugzilla.redhat.com/show_bug.cgi?id=1362542
(cherry picked from commit 805925f9ef)
2016-08-20 10:45:55 +02:00
Beniamino Galvani
482e506674 cli: fix error reporting for connection delete
get_connection() shifts to the next argument, so we need to cache the
old one.

Fixes: 717db4fe01
2016-08-02 17:21:12 +02:00
Beniamino Galvani
ec6a118f29 cli: fix connection delete/monitor
The two commands should apply to all available connections matching
the given name.

Fixes: 717db4fe01
2016-08-02 16:49:37 +02:00
Francesco Giudici
2adb5fc00f nmcli: fix connection clone/modify
remove extra "next_arg"s (get_connection already shifts argv).

Fixes: 717db4fe01
2016-08-02 15:44:47 +02:00
Lubomir Rintel
8cc6ce7e44 cli: add -f argument completion 2016-08-01 15:51:29 +02:00
Lubomir Rintel
8e7c94ed07 cli/connections: there's nothing to complete for reload 2016-08-01 13:52:36 +02:00
Lubomir Rintel
9e8a227813 cli/connections: add completion to show subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
a410e40655 cli/connections: add completion to down subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
af5c235f14 cli/connections: add completion to import subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
345291d6f1 cli/connections: add completion to load subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
680b53c96a cli/connections: add completion to up subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
c561fa34d2 cli/connections: add completion to export subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
075e705bc7 cli/connections: add completion to monitor subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
9d076a7a1a cli/connections: add completion to delete subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
18352340b6 cli/connections: add completion to clone subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
2895261c91 cli/connections: do connection completion in get_connection()
Start completing by the id if the filter type is not specified
2016-08-01 13:52:36 +02:00
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
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