Commit Graph

370 Commits

Author SHA1 Message Date
Jiří Klimeš
b03518b817 cli: show details for active connection even if the profile is not visible
$ nmcli con show other_user_con
2014-10-20 09:11:57 +02:00
Jiří Klimeš
278ec17448 cli: fix errors and crash for invisible connections
* two users are logged in: user_a and user_b
* user_b creates a connection visible only to him 'user_b_private'
  (permissions: user:user_b)
* user_b activates the connection user_b_private
* user_a does not see the connection profile, but he does see the active
  connection

* user_a calls
  nmcli con
  nmcli con show user_b_private
2014-10-20 09:11:57 +02:00
Jiří Klimeš
88efa1c437 cli: fix 'nmcli connection up bond0' being stuck
It can happen on activating a master without slaves. Active connection will
not move past activating state.
2014-10-19 09:26:34 -04:00
Thomas Haller
cf26bb2dea cli: support connection.autoconnect-priority property
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
83e99c2227 cli: add nmc_property_set_int() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:17 +02:00
Thomas Haller
c9476a4242 cli: fix type when setting variadic argument in nmc_property_set_uint()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:17 +02:00
Dan Winship
677314c540 libnm: fix NMActiveConnection object-path-valued properties
NMActiveConnection:connection was an object path rather than an
NMRemoteConnection because in the past the NMObject property system
wasn't capable of handling NMRemoteConnection-valued properties.
NMActiveConnection:master was an object path rather than an NMDevice
entirely by accident. Fix both.

NMActiveConnection:specific-object can't currently be converted to an
object, because we don't know ahead of time what object type it is,
and NMObject can't deal with that. Instead, we rename it to
:specific-object-path (and likewise for its get function), both to
emphasize that it doesn't behave like other properties, and to leave
the old name open for an actual object-valued property later on.
2014-10-10 13:10:19 -04:00
Dan Winship
6f3d1f9526 libnm: merge NMRemoteSettings into NMClient
Make NMRemoteSettings internal and have NMClient wrap all of its APIs,
just like it does with NMManager.
2014-10-10 12:40:19 -04:00
Dan Winship
c1f1e96181 cli: (trivial) rename NmCli.system_connections to connections
Rename NmCli.system_connections to connections, since the "user
connections" have been gone forever.
2014-10-10 12:40:15 -04:00
Jiří Klimeš
f4cd7dec11 cli: fix setting secrets flags 2014-10-06 17:03:22 +02:00
Jiří Klimeš
0fa6e75b14 cli: fix setting SSID property in the editor
SSID is now GBytes, not GByteArray.
2014-10-06 15:43:37 +02:00
Dan Winship
a91e60902e libnm-core: make NMSettingSerial:parity an enum
NMSettingSerial:parity was defined as a char-typed property that could
have the (case-sensitive!) values 'n', 'E', or 'o'. This is zany. Add
an NMSettingSerialParity enum, and use that instead.
2014-10-03 09:36:28 -04:00
Thomas Haller
b662fbf450 cli: support new bond option 'lacp_rate'
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-02 16:36:11 +02:00
Jiří Klimeš
7e67fd2b24 libnm: return errors in nm_client_networking_set_enabled()
and do not print an error in the library. The caller can decide what to do
on an error.
2014-10-01 11:53:07 +02:00
Jiří Klimeš
8919a8572a cli: strip errors from D-Bus before presenting to a user 2014-10-01 11:53:07 +02:00
Jiří Klimeš
f585085907 cli: rename network-manager.[ch] to general.[ch] 2014-10-01 11:53:07 +02:00
Dan Winship
e684f36365 libnm-core: add nm_utils_wifi_strength_bars(), use it in nmcli and nmtui
Add nm_utils_wifi_strength_bars(), which figures out whether the
terminal can display graphical wifi strength bars, and converts a
numerical value to the appropriate Unicode or ASCII characters.

This also now takes into consideration the fact that the console font
doesn't contain all of the necessary characters, so we can't display
the graphical bars there. (rh #1131491)
2014-09-27 11:49:15 -04:00
Dan Winship
1b74e77f9f cli: use g_print/g_printerr rather than printf/fprintf
Use g_print() and g_printerr(), which wrap printf() and
fprintf(stderr,...), but handle conversion from UTF-8 if the locale is
using a different character set.
2014-09-27 11:45:53 -04:00
Jiří Klimeš
9eabe9c5f6 cli: move "CONNECTIONS" group lower in the output 2014-09-25 19:09:06 +02:00
Jiří Klimeš
6c27af6385 cli: show capabilities for Bluetooth devices 2014-09-25 19:09:05 +02:00
Jiří Klimeš
0b6bd87848 cli: also show team and bridge specific details for devices
Now it is only SLAVES field, common for bond, team and bridge devices.
2014-09-25 19:09:05 +02:00
Dan Winship
2237ea3ddb libnm: make sync/async APIs more GLib-like
Make synchronous APIs take GCancellables, and make asynchronous APIs
use GAsyncReadyCallbacks and have names ending in "_async", with
"_finish" functions to retrieve the results.

Also, make nm_client_activate_connection_finish(),
nm_client_add_and_activate_finish(), and
nm_remote_settings_add_connection_finish() be (transfer full) rather
than (transfer none), because the refcounting semantics become
slightly confusing in some edge cases otherwise.
2014-09-25 09:29:20 -04:00
Dan Winship
6ca10677d6 libnm: merge saved and unsaved connection methods
Merge nm_remote_settings_add_connection() and
nm_remote_settings_add_connection_unsaved(), and likewise
nm_remote_connection_commit_changes() and
nm_remote_connection_commit_changes_unsaved(), by adding a boolean
flag to each saying whether to save to disk.
2014-09-25 09:29:20 -04:00
Jiří Klimeš
3784678177 cli: create a connection if none exist in 'nmcli dev connect' (rh #1113941)
https://bugzilla.redhat.com/show_bug.cgi?id=1113941
2014-09-22 13:10:43 +02:00
Jiří Klimeš
dc1c17fd30 cli: get NMClient early and remove duplicated code 2014-09-22 12:53:46 +02:00
Jiří Klimeš
f27a259ee6 cli: when NM is not running, give this error in 'nmcli connection'
Check whether NM is running before comparing nmcli and NM versions. Returning
NMC_RESULT_ERROR_NM_NOT_RUNNING is in accordance with other nmcli commands.
2014-09-22 12:53:46 +02:00
Lubomir Rintel
82947737b1 cli: return a failure status when the daemon is not running (bgo #698060)
Applies to status commands such as "nmcli radio" or "nmcli g status".
This is consistent with other commands.

The "RUNNING" field is now always "running", the tool will just return
an error instead of setting it to "not running". It never signalled
whether the daemon was actually running anyway, only whether the client
managed to connect to it.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2014-09-22 12:53:46 +02:00
Jiří Klimeš
8ee53b79f6 cli: fix crash by getting addresses and routes
Broken by commit 6793a32a8c that changed
return values from GSlist to GPtrArray.
2014-09-19 22:59:39 +02:00
Dan Winship
6793a32a8c libnm: port to GDBus
Port libnm-core/libnm to GDBus.

The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
2014-09-18 11:51:09 -04:00
Dan Winship
acf86f68b3 libnm-core: change connection hash tables to variants in API
In preparation for porting to GDBus, make nm_connection_to_dbus(),
etc, represent connections as GVariants of type 'a{sa{sv}}' rather
than as GHashTables-of-GHashTables-of-GValues.

This means we're constantly converting back and forth internally, but
this is just a stepping stone on the way to the full GDBus port, and
all of that code will go away again later.
2014-09-18 11:51:09 -04:00
Dan Winship
ad8b13091b libnm-core: fix up connection deserialize/copy/replace semantics
libnm-util's connection deserializing/copying/replacing functions have
odd semantics where sometimes they both modify a connection AND return
an error. libnm-core tried to improve things by guaranteeing that the
connection would not be modified if the new settings were invalid, but
this ended up breaking a bunch of places that needed to be able to
work with invalid connections. So re-fix the functions by reverting
back to the old semantics, but having return values that clearly
distinguish whether the connection was modified or not.

For comparison:

  - nm_connection_new_from_hash() / nm_simple_connection_new_from_dbus():

      - libnm-util: returns a valid connection or NULL.

      - OLD libnm-core: returned a valid connection or NULL.

      - NEW libnm-core: returns a valid connection or NULL.

  - nm_connection_duplicate() / nm_simple_connection_new_clone():

      - libnm-util: always succeeds, whether or not the connection is
        valid.

      - OLD libnm-core: returned a valid connection or NULL

      - NEW libnm-core: always succeeds, whether or not the connection
        is valid.

    - nm_connection_replace_settings_from_connection():

      - libnm-util: always replaces the settings, but returns FALSE if
        the connection is now invalid.

      - OLD libnm-core: either replaced the settings and returned TRUE
        (if the settings were valid), or else left the connection
        unchanged and returned FALSE (if not).

      - NEW libnm-core: always replaces the settings, and has no
        return value. (The modified connection is valid if and only if
        the replaced-from connection was valid; just like with the
        libnm-util version.)

    - nm_connection_replace_settings():

      - libnm-util: returns TRUE if the new settings are valid, or
        FALSE if either (a) the new settings could not be deserialized
        and the connection is unchanged, or (b) the new settings were
        deserialized, and the connection was updated, but is now not
        valid.

      - OLD libnm-core: either replaced the settings and returned TRUE
        (if the settings were valid), or else left the connection
        unchanged and returned FALSE (if not).

      - NEW libnm-core: returns TRUE if the connection was updated
        (whether or not it is valid), or FALSE if the new settings
        could not be deserialized and the connection is unchanged.
2014-09-17 08:21:21 -04:00
Jiří Klimeš
c6a932a2ce cli: fix ssid parameter processing in 'nmcli con add'
(broken by commit c43f88907b)
2014-09-09 16:54:32 +02:00
Dan Winship
730d096fe1 cli: fix MAC address validation (bgo #736275)
nm_utils_hwaddr_valid() accepts length while check_mac() mistakenly passes
type.

(broken by 3a54d05098)

https://bugzilla.gnome.org/show_bug.cgi?id=736275
2014-09-09 11:13:00 +02:00
Dan Winship
356fb7d77e libnm: drop libnm IP-address-array types, use G_TYPE_STRV
Make NMIP4Config:nameservers, NMIP4Config:wins-servers, and
NMIP6Config:nameservers be G_TYPE_STRV, with stringified IP addresses,
and update the APIs accordingly.
2014-09-04 09:21:05 -04:00
Dan Winship
3e5b3833aa libnm: change empty-GPtrArray-return semantics
libnm functions that return GPtrArrays of objects had a rule that if
the array was empty, they would return NULL rather than a 0-length
array. As it turns out, this is just a nuisance to clients, since in
most places the code for the non-empty case would end up doing the
right thing for the empty case as well (and where it doesn't, we can
check "array->len == 0" just as easily as "array == NULL"). So just
return the 0-length array instead.
2014-09-04 09:21:05 -04:00
Dan Winship
20dc44bda9 libnm: drop NM_TYPE_SSID, use G_TYPE_BYTES
Make NMAccessPoint:ssid be G_TYPE_BYTES and update the corresponding
APIs accordingly.
2014-09-04 09:21:04 -04:00
Dan Winship
4eb04dbcf8 libnm: drop NM_TYPE_STRING_ARRAY, use G_TYPE_STRV
Make NMIP4Config and NMIP6Config's array-of-string properties be
G_TYPE_STRV, and update the corresponding APIs accordingly.
2014-09-04 09:21:04 -04:00
Dan Winship
f71218d70a libnm: simplify NMDevice:state-reason
The NMDevice:state-reason property was awkward to work with since it
was a tuple of two values (state and reason), and likewise, although
we had nm_device_get_state() to return just the state, there was no
corresponding function to get just the reason.

Fix this; make the state-reason property contain just the
NMDeviceStateReason, and make nm_device_get_state_reason() return just
that.
2014-09-04 09:21:04 -04:00
Dan Winship
c43f88907b libnm-core: change DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES
Change all DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES, and
update corresponding APIs. Notably, this means they are now refcounted
rather than being copied.

Update the rest of NM for the changes. The daemon still converts SSIDs
to GByteArrays internally, because changing it to use GBytes has lots
of trickle-down effects. It can possibly be changed later.
2014-09-04 09:20:11 -04:00
Dan Winship
3fbabde4c3 libnm-core: replace GByteArray with pointer + length in some APIs
APIs that take arbitrary data should take it in the form of a pointer
and length, not a GByteArray, so that you can use them regardless of
what format you have the data in (GByteArray, GBytes, plain array,
etc).
2014-09-04 09:20:11 -04:00
Dan Winship
9837565789 libnm-core: improve NMSettingIP4Config / NMSettingIP6Config property types
Make the :addresses and :routes properties be GPtrArrays of
NMIP4Address, etc, rather than just reflecting the D-Bus data.

Make the :dns properties be arrays of strings rather than arrays of
binary IP addresses (and update the corresponding APIs as well).
2014-09-04 09:20:11 -04:00
Dan Winship
9ed6bd2be5 libnm-core: change map-of-string properties to G_TYPE_HASH_TABLE
Change all DBUS_TYPE_G_MAP_OF_STRING properties to G_TYPE_HASH_TABLE,
with annotations indicating they are string->string. Not much outside
libnm-core needs to changed for this, since DBUS_TYPE_G_MAP_OF_STRING
was already represented as a hash table.

(One change needed within libnm-core is that we now need to copy the
hash tables in get_property(), or else the caller will receive a
reffed copy of the object's own hash table, which we don't want.)
2014-09-04 09:20:11 -04:00
Dan Winship
6a4127cfa0 libnm-core: change list-of-string and array-of-string properties to G_TYPE_STRV
Change all DBUS_TYPE_G_LIST_OF_STRING and DBUS_TYPE_G_ARRAY_OF_STRING
properties to G_TYPE_STRV, and update everything accordingly.

(This doesn't actually require using
_nm_setting_class_transform_property(); dbus-glib is happy to transform
between 'as' and G_TYPE_STRV.)
2014-09-04 09:20:10 -04:00
Dan Winship
3a54d05098 libnm-core: change all mac-address properties to G_TYPE_STRING
Make all mac-address properties (including NMSettingBluetooth:bdaddr,
NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be
strings, using _nm_setting_class_transform_property() to handle
translating to/from binary form when dealing with D-Bus.

Update everything accordingly for the change, and also add a test for
transformed setting properties to test-general.
2014-09-04 09:20:10 -04:00
Dan Winship
ee3467e531 libnm-core: add nm_connection_is_virtual()
Add a method to determine if a connection applies to a virtual device.

Perhaps eventually the logic should be spread across the NMSetting
classes, but for now it's better off having it in NMConnection than
once in NMManager and once in nmcli.
2014-09-04 09:18:43 -04:00
Dan Winship
ab26964c56 all: stop using virtual interface-name properties
The virtual :interface-name properties (eg,
NMDeviceBond:interface-name) are deprecated in favor of
NMSettingConnection:interface-name, and nm_connection_verify() ensures
that their values are kept in sync. So (a) there is no need to set
those properties when we can just set
NMSettingConnection:interface-name instead, and (b) we can replace any
calls to the setting-specific get_interface_name() methods with
nm_connection_get_interface_name() or
nm_setting_connection_get_interface_name().
2014-09-04 09:18:43 -04:00
Dan Winship
7314256b77 libnm-core: drop nm_{setting,connection}_get_virtual_iface_name()
Since we enforce the fact that bond, bridge, team, and vlan
interface-name properties match NMSettingConnection:interface-name,
nm_connection_get_virtual_iface_name() can be replaced with
nm_connection_get_interface_name() basically everywhere.

The one place this doesn't work is with InfiniBand partitions (where
get_virtual_iface_name() was actually computing the name), but for the
most part we only need to care about the interface names of InfiniBand
partitions in places where we also already need to do some other
InfiniBand-specific handling as well, so we can use an
InfiniBand-specific method
(nm_setting_infiniband_get_virtual_interface_name()) to get it.

(Also, while updating nm_device_get_virtual_device_description(), fix
it to handle InfiniBand partitions too.)
2014-09-04 09:18:43 -04:00
Dan Winship
773d3f0ab6 libnm-core: rename NMConnection to/from_hash methods
Rename nm_connection_to_hash() to nm_connection_to_dbus(), and
nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In
addition to clarifying that this is specifically the D-Bus
serialization format, these names will also work better in the
GDBus-based future where the serialization format is GVariant, not
GHashTable.

Also, move NMSettingHashFlags to nm-connection.h, and rename it
NMConnectionSerializationFlags.
2014-09-04 09:17:36 -04:00
Dan Winship
1838db9e71 all: remove a bunch of unnecessary dbus/dbus-glib includes 2014-09-03 10:45:24 -04:00
Jiří Klimeš
a1907ec257 cli: simplify do_connections() now that we don't wait for "connection-read"
nm_remote_settings_list_connections() ensures the connections are loaded first.
We check "help" commands before getting connections, because it is time
intensive action.
2014-08-22 23:33:04 +02:00