Commit Graph

477 Commits

Author SHA1 Message Date
Jiří Klimeš
8d9718bd0f cli: add 'activate' menu command for interactive editor (rh #1004883)
This command allows activating the edited connection.

Monitoring the progress of the activation is a bit complicated by the fact
that the callback activate_connection_editor_cb() is invoked in main loop
thread, and not in the editor thread itself.

https://bugzilla.redhat.com/show_bug.cgi?id=1004883
2013-10-31 08:53:56 +01:00
Jiří Klimeš
26dca13c7e cli: fix VLAN egress priority mapping for 'nmcli connection add'
Found with Coverity.
2013-10-30 17:25:45 +01:00
Thomas Haller
623f8a2be1 cli: fix bash completion for nmcli connection modify
Only complete the setting name if it is at the very first
position after the connection.

e.g. complete the settings name in the case
  $ nmcli connection modify em1 connec<TAB>
but not at
  $ nmcli connection modify em1 connection.autoconnect <TAB>

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-30 13:33:47 +01:00
Jiří Klimeš
a4004fd2e9 cli: fix new connection initialization in the editor
This fixes a regression caused by ecd49fb435

In addition, initialize Wi-Fi mode to "infrastructure".
2013-10-25 14:26:00 +02:00
Thomas Haller
2a7c976539 cli: show property names in bash completion for nmcli connection modify
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-24 14:52:08 +02:00
Jiří Klimeš
9ca6fa71f1 cli: do not pass con_type to callbacks, get the type from device
This simplifies the code.

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
2013-10-23 22:22:35 -04:00
Dan Winship
0221971da5 nmcli: fix some leaks found by valgrind
https://bugzilla.gnome.org/show_bug.cgi?id=709369
2013-10-23 22:22:35 -04:00
jvoisin
00ffb78c8d core: add support for EAP-PWD authentication 2013-10-23 21:07:30 -05:00
Jiří Klimeš
ecd49fb435 cli: add IPv{4,6} setting for all new non-slave connections in editor 2013-10-23 16:22:18 +02:00
Jiří Klimeš
3d14d52325 cli: copy remote connection to local one on 'save' (rh #997958)
Plugins may have problems with preserving some properties on write/read cycle,
may add ipv{4,6} settings when they are not present in the connection, etc.
That makes local and remote connection differ.
So we copy remote connection into the local to get rid of such problems.

Note:
68f12b4e9c and
f03635e5ac
commits ensure that all connection (except slaves) have IPv{4,6} settings.

https://bugzilla.redhat.com/show_bug.cgi?id=997958
2013-10-23 16:22:18 +02:00
Thomas Haller
3eb1d5e902 core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.

The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Jiří Klimeš
6a8fd3f469 cli: properly initialize new team-slave connections in editor 2013-10-21 16:30:04 +02:00
Yuri Chornoivan
61de24ba35 Fix typos
https://bugzilla.gnome.org/show_bug.cgi?id=710505
2013-10-19 11:49:18 -04:00
Jiří Klimeš
b2ff06fc12 cli: fix a possible crash when casting NULL using NM_CONNECTION (rh #1011942)
https://bugzilla.redhat.com/show_bug.cgi?id=1011942
2013-10-03 19:14:16 +02:00
Jiří Klimeš
8695410d86 cli: enhance TAB-completion in nmcli editor
- completion now works for command shortcuts too
  nmcli> g ethe<TAB>
- completion now allows leading spaces
  nmcli>   desc wifi.ss<TAB>
- fix completion of settings when property is already there
  nmcli> set con<TAB>.id
- fix completion of properties in setting.property
  nmcli> des con.inter<TAB> bla
2013-10-03 16:39:30 +02:00
Thomas Haller
78a8df37d8 cli: fix bash completion to show general options
This fixes an error in the following example:
  $ nmcli con add type bridge con-name test-bridge <TAB>

Before, general options such as 'autoconnect' and 'ifname' were
wrongly not suggested.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-03 16:05:44 +02:00
Thomas Haller
f37686fba7 cli: add primary bonding option in bash completion
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-02 14:19:12 +02:00
Jiří Klimeš
e6fa711088 trivial: remove stray ')' from nmcli prompts in questions 2013-10-02 11:48:07 +02:00
Jiří Klimeš
62d113f6c2 cli: accept 'primary' bonding option 2013-10-02 11:48:07 +02:00
Jiří Klimeš
1bb78f6ecf cli: enhance questionnaire for bond connections (rh #1007355)
The session now looks like this:

There are optional arguments for 'bond' connection type.
Do you want to provide them? (yes/no) [yes]
Bonding mode [balance-rr]:
Bonding monitoring mode (miimon or arp) [miimon]: miimon
Bonding miimon [100]:
Bonding downdelay [0]:
Bonding updelay [0]:

...when answered arp...
Bonding arp-interval [0]:
Bonding arp-ip-target [none]:

https://bugzilla.redhat.com/show_bug.cgi?id=1007355
2013-10-02 11:48:07 +02:00
Jiří Klimeš
9e9afdb25b cli: fix memory leaks on questionnaires 2013-10-02 11:48:07 +02:00
Thomas Haller
ed08a3fe04 cli: fix missing type option 'team' in mcli completion
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-30 19:07:18 +02:00
Jiří Klimeš
a74d3678d1 cli: use a generic function asking for both IPv4/IPv6 in questionnaire 2013-09-30 13:42:13 +02:00
Jiří Klimeš
5ba3e42b1e cli: be more verbose when adding IP addresses in questionnaire (rh #1006450)
Now the session looks like this:
Do you want to add IP addresses? (yes/no) [yes]
Press <Enter> to finish adding addresses.
IPv4 address (IP[/plen] [gateway]) [none]: 10.0.0.22/24 10.0.0.1
  Address successfully added: 10.0.0.22/24 10.0.0.1
IPv4 address (IP[/plen] [gateway]) [none]: 10.0.0.22/24 10.0.0.1
  Warning: address already present: 10.0.0.22/24 10.0.0.1
IPv4 address (IP[/plen] [gateway]) [none]: 192.168.1.1 abc
Error: invalid gateway 'abc'
IPv4 address (IP[/plen] [gateway]) [none]:
IPv6 address (IP[/plen] [gateway]) [none]: abcd::1234 ::2 blabla
  Address successfully added: abcd::1234 ::2
  Warning: ignoring garbage at the end: 'blabla'
IPv6 address (IP[/plen] [gateway]) [none]:
2013-09-30 13:39:44 +02:00
Dan Winship
e1e4740648 cli: recognize InfiniBand partitions as virtual
We don't need to hardcode the kinds of devices that are virtual here;
NMConnection already knows.
2013-09-24 11:54:34 -04:00
Jiří Klimeš
f8c23077cc cli: fix bond questionnaire to be able to set miimon (rh #1007355)
Bonding options are related and some combinations don't make sense. Basically,
MIIMON and ARP monitoring mode (and related options) are mutually exclusive.
When nmcli set arp_interval of "0" (the default value),
nm_setting_bond_add_option() cleared the MIIMON options (miimon, updelay and
downdelay).

This commit works around libnm-util's nm_setting_bond_add_option() that clears
miimon options when arp_interval is being set and vice versa, but doesn't
take into account the value of "0" that should be regarded as 'disable'.

https://bugzilla.redhat.com/show_bug.cgi?id=1007355
2013-09-19 16:56:37 +02:00
Jiří Klimeš
9dacfd0a39 cli: always print success message (not only in --pretty mode) (rh #1006444)
The commands performing actions without an output only printed a successfull
message for --pretty mode. Some users don't like this silent operation.
This commit makes nmcli print operation success unconditionally. I think that
doesn't hurt; scripts/users can ignore the message if not interested.

https://bugzilla.redhat.com/show_bug.cgi?id=1006444
2013-09-19 15:24:13 +02:00
Jiří Klimeš
05980f9045 cli: fix the error message for valid IPv6 prefix range to <1-128> 2013-09-19 14:06:36 +02:00
Jiří Klimeš
295df3405c cli: accept gateway in the IP questionnaire of 'nmcli -a con add' (rh #1007368)
Also allow leading/trailing white spaces, and more white spaces between IP and
gateway. (Spaces in values and around / are not allowed).
 All of these are accepted:
'  1.2.3.4/11     1.2.3.254 '
' 1.2.3.4 '
'   fe80::215:ff:fe93:ffff/128  ::1 '
...

https://bugzilla.redhat.com/show_bug.cgi?id=1007368
2013-09-19 12:07:22 +02:00
Jiří Klimeš
1f6e1fbc62 cli: editor 'change' command: output -> input format conversion (rh #998929)
The format of property values that nmcli prints is not the same (for some
properties) as the format nmcli editor accepts as input from user. The reasons
are that (a) output format is more descriptive and not much suitable to be
typed, (b) it comes in most cases from libnm-util.
'change' command displays current property value and allows users to edit it.
So we convert the output into input format, before presenting it to the user.

https://bugzilla.redhat.com/show_bug.cgi?id=998929
2013-09-13 10:56:20 +02:00
Dan Williams
e4b92acdf7 cli: clarify 'startup' property when NM is not running
Wouldn't make a ton of sense to print "started" for the STARTING
property if NM wasn't running.
2013-09-12 13:15:50 -05:00
Dan Williams
15ddc6dce3 cli: fix build error due to possibly uninitialized variable 2013-09-12 13:13:09 -05:00
Jiří Klimeš
1df9948199 cli: add STARTUP field for 'nmcli -f all general status'
It says 'starting' when NM is in the process of startup (still activating
connections); 'started' when NM finished the startup.
2013-09-12 16:29:26 +02:00
Thomas Haller
8548d68381 nmcli: extend bash completion for 'nmcli networking connectivity'
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-12 16:19:42 +02:00
Jiří Klimeš
fa36216787 cli: consolidate a code for connectivity check a bit 2013-09-12 14:45:08 +02:00
Jiří Klimeš
449a0933ce cli: don't call g_strstrip() on NULL arguments
GLib-CRITICAL **: g_strchug: assertion `string != NULL' failed
GLib-CRITICAL **: g_strchomp: assertion `string != NULL' failed
2013-09-12 10:03:23 +02:00
Jiří Klimeš
6014e3fa04 cli: fix an 'nmcli con edit' crash
nmcli> desc   AAA
2013-09-11 18:12:51 +02:00
Jiří Klimeš
b62856a0bb cli: set wep-key-type properly in nmcli con edit (rh #1003945)
Accept both [0,1,2] and [unknown,key,passphrase] as wep-key-type values and
set the property value correctly.

https://bugzilla.redhat.com/show_bug.cgi?id=1003945
2013-09-10 16:23:25 +02:00
Jiří Klimeš
555e5b401c cli: reset terminal using libreadline when quitting on signal (bgo #706118)
readline() makes changes to terminal and when it doesn't receive unix signals,
it has no chance to perform cleanups on exit. So we have to call its cleanup
functions manually on exit.

https://bugzilla.gnome.org/show_bug.cgi?id=706118
2013-09-10 11:45:21 +02:00
Jiří Klimeš
663014ed62 cli: handle POSIX signals in a dedicated thread
For a multihreaded application the safest way to handle unix signals is using
a dedicated thread that processes the signals by sigwait() function. All other
threads have these signals (processed by the thread) blocked.

A few useful links:
http://pubs.opengroup.org/onlinepubs/007904975/functions/sigwait.html
http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.genprogc%2Fdoc%2Fgenprogc%2Fsignal_mgmt.htm
http://www.linuxjournal.com/article/2121?page=0,2
http://www.redwoodsoft.com/~dru/unixbook/book.chinaunix.net/special/ebook/addisonWesley/APUE2/0201433079/ch12lev1sec8.html
https://www.securecoding.cert.org/confluence/display/seccode/CON37-C.+Do+not+call+signal%28%29+in+a+multithreaded+program
2013-09-10 11:41:00 +02:00
Thomas Haller
7ad5c79441 nmcli: minor fixes in bash completion
- the ifname argument for "connection add" is not mandatory
- support the long names for connection types ("802-*")

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-06 17:47:57 +02:00
Jiří Klimeš
9f09ebd582 cli: forbid removing connection.uuid in editor
We expect that UUID is set, else there are various errors. Anyway, users should
not modify connection UUID.
2013-09-06 15:14:30 +02:00
Jiří Klimeš
2eede80108 cli: deny removing values of nmcli-unchangable properties
nmc_setting_reset_property() function checks whether we allow changing the property
(set_func != NULL) and if so, the property value is reset to default.
2013-09-06 15:00:34 +02:00
Jiří Klimeš
70cc30cb73 cli: add missing connection:type to nmc_add_prop_funcs() in editor 2013-09-06 14:12:26 +02:00
Jiří Klimeš
242bebfb3d cli: add 'remove' command to the interactive editor
remove <setting>[.property] | <property>

It entirely removes given setting from edited connection. If a property is given,
the command instead resets the property to its default value.

https://bugzilla.gnome.org/show_bug.cgi?id=707576
2013-09-06 10:10:37 +02:00
Jiří Klimeš
c2faf32b88 cli: 'connection add' - questionnaire mode (rh #953291)
Synopsis: nmcli --ask connection add

When '--ask' is used, nmcli will ask not only for mandatory arguments but also
for the optional ones, with a series of questions.
2013-09-06 09:16:46 +02:00
Thomas Haller
f6703f540c nmcli: reword error message for a wrong user input in edit mode
Before, when specifying a setting.property with missing property name,
the following happened:

  nmcli> set connection.
  Error: invalid property: '' not among [...

Reword this special error case of a missing property to make it more
clear.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-05 20:02:12 +02:00
Thomas Haller
1111dbf812 nmcli: fix segfault in edit mode when parsing user prompt
readline_x returns NULL for empty input, so it is wrong
to call g_strstrip without checking for NULL first.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-05 13:59:54 +02:00
Thomas Haller
fc7468131c nmcli: major rework of bash completion
Bash completion does now parse the command line from left to right and
only suggests options that make sense at the current cursor position.

If the cursor is not at the end of the line, the words right from the
cursor are ignored for completion. The reason is, that it would be much
more difficult to figure out the valid options when also looking at
options right from the cursor. However, it should still work nicely
even in this case.

There is still an unsolved issue when completing words with space or
other special characters. However, this issue was present before.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-05 10:47:41 +02:00
Jiří Klimeš
50bec85f98 cli: allow editing team and team-port settings in interactive editor 2013-09-04 12:43:11 +02:00