Commit graph

549 commits

Author SHA1 Message Date
Thomas Haller
ba285e319e libnm: move _nm_utils_ascii_str_to_int64() from src/ to libnm-core/
(cherry picked from commit c5d23737fd)
2015-06-17 13:30:39 +02:00
Thomas Haller
a4d11bae29 trivial: rename nm_utils_ascii_str_to_int64() to _nm_utils_ascii_str_to_int64()
(cherry picked from commit 093f6d477b)
2015-06-17 13:30:38 +02:00
Beniamino Galvani
688183c96c ifnet/tests: fix GCC 5 warning about possible misuse of logical not
With GCC 5, -Wlogical-not-parentheses is enabled by -Wall and warns
about suspicious code like:

  int a;
  ...
  if (!a > 1) { ... }

Fix the following warning:

test_all.c: In function ‘test_is_static’:
test_all.c:114:32: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
  ASSERT (!is_static_ip6 ("eth0") == TRUE, "is static",
                                  ^

(cherry picked from commit fe765d30da)
2015-06-10 22:09:49 +02:00
Thomas Haller
2be628334c core: unify parsing of device specs using nm_match_spec_split()
There are three configuration options that contain device specs:
'main.ignore-carrier', 'main.no-auto-default', and
'keyfile.unmanaged-devices'.

Unify the parsing of them by splitting the device spec with
nm_match_spec_split(). This changes behavior for parsing of these
properties.

Also get rid of logging warnings when parsing 'keyfile.unmanaged-devices'.

(cherry picked from commit c6778ad1b7)
2015-06-10 18:33:07 +02:00
Thomas Haller
bd83000816 core/logging: downgrade some <info> loggings to <debug>
These logging statements are compile time dependent and
add little informational value.

(cherry picked from commit d8e1d9b469)
2015-05-13 18:43:57 +02:00
Thomas Haller
9809eb4da1 config: move keyfile values to NMConfigData
(cherry picked from commit ba74f9d242)
2015-05-05 16:51:33 +02:00
Thomas Haller
0ca82739d5 config: move main_file and description to NMConfigData
Every reload might change the main_file and description.
Move those properties to NMConfigData.

(cherry picked from commit 56f5fba723)
2015-05-05 16:51:21 +02:00
Thomas Haller
83edb5aee3 config/trivial: rename variables for configuration file
The name "nm_conf_path" and cli.config_path" were not consistent.
Rename them both to "config_main_file".

(cherry picked from commit 3714a6c7bd)
2015-05-05 16:50:25 +02:00
Thomas Haller
b3cae064d1 ibft/logging: don't localize logging stagements
We don't localize any other nm-logging messages either.

(cherry picked from commit b04c99da0b)
2015-04-29 15:13:50 +02:00
Lubomir Rintel
e951abe6d0 ifcfg-rh: don't try to read DEVTIMEOUT from file for in-memory connections
#0  0x00007ffff4a2c970 in g_logv (log_domain=0x7fffe9201115 "NetworkManager-ifcfg-rh", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd710) at gmessages.c:1046
  #1  0x00007ffff4a2cbaf in g_log (log_domain=log_domain@entry=0x7fffe9201115 "NetworkManager-ifcfg-rh", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff4a9bc1d "%s: assertion '%s' failed") at gmessages.c:1079
  #2  0x00007ffff4a2cbe9 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7fffe9201115 "NetworkManager-ifcfg-rh", pretty_function=pretty_function@entry=0x7fffe9204b70 <__FUNCTION__.30626> "devtimeout_from_file", expression=expression@entry=0x7fffe9202d97 "filename != NULL") at gmessages.c:1088
  #3  0x00007fffe91fbfa2 in devtimeout_from_file (filename=<optimized out>) at reader.c:4884
  #4  0x00007fffe91ef845 in nm_ifcfg_connection_new (self=0x8d2200 [NMIfcfgConnection]) at nm-ifcfg-connection.c:159
  #5  0x00007fffe91ef845 in nm_ifcfg_connection_new (source=source@entry=0x83ba40, full_path=full_path@entry=0x0, error=error@entry=0x7fffffffd980) at nm-ifcfg-connection.c:240
  #6  0x00007fffe91ec7e6 in update_connection (self=self@entry=0x80c2a0 [SCPluginIfcfg], source=source@entry=0x83ba40, full_path=0x0, connection=connection@entry=0x0, protect_existing_connection=protect_existing_connection@entry=0, protected_connections=protected_connections@entry=0x0, error=0x7fffffffd980) at plugin.c:225
  #7  0x00007fffe91eddf2 in add_connection (config=<optimized out>, connection=0x83ba40, save_to_disk=<optimized out>, error=0x7fffffffd980) at plugin.c:715
  #8  0x000000000048fc1d in nm_settings_add_connection (self=<optimized out>, connection=0x83ba40, save_to_disk=0, error=<optimized out>) at settings/nm-settings.c:1045
  #9  0x0000000000490858 in pk_add_cb (chain=0x8b1fc0, chain_error=<optimized out>, context=<optimized out>, user_data=<optimized out>) at settings/nm-settings.c:1151
  #10 0x00000000004ca98c in auth_chain_finish (user_data=0x8b1fc0) at nm-auth-utils.c:82
  #11 0x00007ffff4a257fb in g_main_context_dispatch (context=0x7cd3e0) at gmain.c:3111
  #12 0x00007ffff4a257fb in g_main_context_dispatch (context=context@entry=0x7cd3e0) at gmain.c:3710
  #13 0x00007ffff4a25b98 in g_main_context_iterate (context=0x7cd3e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
  #14 0x00007ffff4a25ec2 in g_main_loop_run (loop=0x7cd4a0) at gmain.c:3975
  #15 0x0000000000444c81 in main (argc=<optimized out>, argv=<optimized out>) at main.c:486

(cherry picked from commit 72f264ad9b)
2015-04-23 17:14:19 +02:00
Thomas Haller
643d412688 test: setup logging during nmtst_init_assert_logging()
Before, when having a test with nmtst_init_assert_logging(),
the caller was expected to setup logging separately according
to the log level that the test asserts against.

Since 5e74891b58, the logging
level can be reset via NMTST_DEBUG also for tests that
assert logging. In this case, it would be useful, if the test
would not overwrite the logging level that is set externally
via NMTST_DEBUG.

Instead, let the test pass the logging configuration to
nmtst_init_assert_logging(), and nmtst will setup logging
-- either according to NMTST_DEBUG or as passed in.

This way, setting the log level works also for no-expect-message
tests:

  NMTST_DEBUG="debug,no-expect-message,log-level=TRACE" $TEST

(cherry picked from commit b6d3b98655)
2015-04-09 08:22:28 +02:00
Thomas Haller
4cc06783ab libnm: accept unknown WEP key type in nm_utils_wep_key_valid()
libnm-core treated the UNKNOWN WEP key type as KEY. Relax that
and try to guess the correct type based on the key.

This is for example important if you have a valid connection with
  wep-key-type=0 (unknown)
If you request passwords for such a connection, the user cannot
enter them in password format -- but there is no UI indication
that the password must be KEY.

(cherry picked from commit 628f47285d)
2015-03-20 13:07:10 +01:00
Dan Williams
c505658815 ifcfg-rh: fix memleak in test-ifcfg-rh.c
(cherry picked from commit ad90f2f0ea)
2015-03-13 11:50:50 +01:00
Thomas Haller
b9a8f3c059 tests: enable valgrind tests for tests
(cherry picked from commit c50f30e79c)
2015-03-13 11:50:04 +01:00
Thomas Haller
e25d06cf71 ifcfg-rh/tests: fix memleaks in test code for valgrind
(cherry picked from commit 0750d934bf)
2015-03-13 11:50:04 +01:00
Thomas Haller
72666156e3 ibft/tests: fix memleaks in test code for valgrind
(cherry picked from commit fbe8c0ed87)
2015-03-13 11:50:04 +01:00
Thomas Haller
f334c4a7f1 keyfile/tests: fix memleaks in test code for valgrind
(cherry picked from commit 9a2f2ed7fd)
2015-03-13 11:50:04 +01:00
Thomas Haller
825eb5cb62 ifcfg-rh: fix memleak in write_ip4_aliases() and assert against overflow
(cherry picked from commit a9bfe9f4bb)
2015-03-13 11:50:04 +01:00
Thomas Haller
273576b01c ifcfg-rh: fix memleaks in reader
(cherry picked from commit 53796f0beb)
2015-03-13 11:50:04 +01:00
Thomas Haller
856962cea8 ifcfg-rh: fix memleak due to make_wpa_setting() returning both wsec and error
==10501== 353 (32 direct, 321 indirect) bytes in 1 blocks are definitely lost in loss record 1,579 of 1,641
    ==10501==    at 0x7EE3728: g_type_create_instance (gtype.c:1847)
    ==10501==    by 0x7EC75B4: g_object_new_internal (gobject.c:1746)
    ==10501==    by 0x7EC945C: g_object_newv (gobject.c:1890)
    ==10501==    by 0x7EC9C23: g_object_new (gobject.c:1556)
    ==10501==    by 0x1CD87C: nm_setting_wireless_security_new (nm-setting-wireless-security.c:122)
    ==10501==    by 0x16F70B: make_wpa_setting (reader.c:3010)
    ==10501==    by 0x16F33F: make_wireless_security_setting (reader.c:3188)
    ==10501==    by 0x161F4C: wireless_connection_from_ifcfg (reader.c:3464)
    ==10501==    by 0x16109A: connection_from_file_full (reader.c:4763)
    ==10501==    by 0x1614EE: connection_from_file_test (reader.c:4862)
    ==10501==    by 0x13D1D6: test_read_wifi_wpa_psk_unquoted2 (test-ifcfg-rh.c:4316)
    ==10501==    by 0x1281FD: main (test-ifcfg-rh.c:12513)
    ==10501==

(cherry picked from commit fcfd8f487a)
2015-03-13 11:50:04 +01:00
Thomas Haller
2ceea73dc3 ifcfg-rh: fix memleak in svSetValue()
(cherry picked from commit 98a0299265)
2015-03-13 11:50:04 +01:00
Thomas Haller
3e1055d141 ibft: fix memleak in read_ibft_blocks()
(cherry picked from commit 494c5c395d)
2015-03-13 11:50:04 +01:00
Thomas Haller
410a22b28f keyfile: fix memleak in parity_parser()
(cherry picked from commit 9d8f93384a)
2015-03-13 11:50:03 +01:00
Thomas Haller
06b3e3ae6b settings: update year in copyright text of plugin-info for keyfile and ifcfg-rh
(cherry picked from commit 4475f59bce)
2015-03-11 17:07:56 +01:00
Thomas Haller
76ee139107 ifcfg-rh: don't reload connection in connection_ifcfg_changed() if monitoring is not enabled
This was not really an error, because NMIfcfgConnection would not
watch the files if monitoring is not enabled. Still do it, because
it feels more correct.

(cherry picked from commit 236226a590)
2015-03-11 17:07:56 +01:00
Thomas Haller
581caca9f2 ifcfg-rh: refactor update_connection()
Make update_connection() analogous to keyfiles implementation.
Effectively merge _internal_new_connection() and update_connection()
-- previously connection_new_or_changed().

https://bugzilla.redhat.com/show_bug.cgi?id=1171751
(cherry picked from commit 0c6349c627)
2015-03-11 17:07:56 +01:00
Thomas Haller
4b5d3f160d ifcfg-rh: sort paths in read_connections()
Presort the files in read_connections() as we do it
for keyfile.

This alone has not much consequences. Do this patch first, to
keep the next patches more self-contained.

(cherry picked from commit 0cf00ff3aa)
2015-03-11 17:07:56 +01:00
Thomas Haller
d6bd8cc496 ifcfg-rh/trivial: rename connection_new_or_changed() and variable
The ifcfg-rh implementation should be similar to the one from keyfile.
Rename the variables and function that have the same meaning.
Do this trivial commit first, before starting refactoring.

(cherry picked from commit a609dd12d3)
2015-03-11 17:07:56 +01:00
Thomas Haller
0516b55de2 ifcfg-rh: add logging macros _LOGX() to plugin.c
(cherry picked from commit bbaa243e31)
2015-03-11 17:07:55 +01:00
Thomas Haller
7510e67f0a settings: avoid duplicate UUID in settings
When adding a connection to NMSettings we did not check for
duplicate connection UUIDs (which could for example happen
if two different plugins report a conflicting UUID).
Also, we would not check that an already added connection
changes it's UUID.

Both could lead to have duplicate connections (by UUID).

Avoid that two ways:
- when adding a connection to NMSettings, ensure that we don't add
  a conflicting UUID. Otherwise just bail out and do nothing.
- when modifying a connection that is already added to NMSettings,
  enforce that the UUID cannot change. Otherwise fail with error.

For ifcfg-rh plugin this situation still can happen during reload.
In this case error out and refuse to update the connection. After
all, the user configured invalid UUIDs.

https://bugzilla.redhat.com/show_bug.cgi?id=1171751
(cherry picked from commit 7b807b11cc)
2015-03-11 17:07:55 +01:00
Thomas Haller
6cd264b0d5 keyfile: ignore GFileMonitor change flags in dir_changed()
When writing a file (for example with `sed -i`) a temporary file
might be created and removed quickly. This causes spurious events
in dir_changed().

(cherry picked from commit 8ba8a55cfa)
2015-03-11 17:07:55 +01:00
Thomas Haller
8c97626918 keyfile: reuse duplicate check from update_connection() in add_connection()
Also during add_connection() we must take special care of not "adding" a
connection with a conflicting UUID. In that case we want to fallback to
"update".

update_connection() already does all the checks, so call
update_connection() from add_connection().

(cherry picked from commit db5c4ce64f)
2015-03-11 17:07:55 +01:00
Thomas Haller
84353078c1 keyfile: cleanup logging
Log lines with a "keyfile:" prefix and show more information about
the loaded connection. Especially printing the UUID is interesting.

(cherry picked from commit 5c2fa92099)
2015-03-11 17:07:55 +01:00
Thomas Haller
1b0fd9fae0 keyfile: read_connections() must skip duplicate connections
If there are keyfiles with duplicate UUIDs, read_connections()
would iterate over the files, loading them as they appear and
overwriting duplicate connections that were just loaded.

For example, have keyfiles 'A' and 'B' with the same UUID.
On start, NM might first load 'A', then 'B'. 'B' would replace the
content of 'A' which was just loaded.
On reload, NM would first overwrite 'B' with 'A', and then again
overwriting 'A' with 'B'.

Fix that by accept the first found connection and don't overwrite
it during the same read_connections() run.

Also sort the files by file modification timestamp so that we
get a reproducible and sensible behavior.

(cherry picked from commit 8a4e64c6aa)
2015-03-11 17:07:55 +01:00
Thomas Haller
b21d0b68fe keyfile: merge update_connection() and new_connection()
new_connection() and update_connection() are very similar as both
must anticipate collisions of UUIDs.

When reloading a connection (update_connection(), previously), the loaded
connection for a certain path might actually replace another existing
connection. In this case, the old connection must be removed, and
the existing one updated instead.
If reloading a connection changes the UUID to a new value, the old
connection must be removed likewise and a new connection added.

Merge both functions into update_connection().

(cherry picked from commit c2fcb680f8)
2015-03-11 17:07:55 +01:00
Thomas Haller
09e88d1d45 keyfile/trival: move code
(cherry picked from commit f41586f00c)
2015-03-11 17:07:55 +01:00
Thomas Haller
6f5c18f8fa keyfile: simplify g_return() checks for _internal_write_connection()
(cherry picked from commit fbd30c7dd2)
2015-03-11 17:07:55 +01:00
Thomas Haller
2e0293cc81 settings: log connection diffs in replace_settings only where appropriate
Only log connection diffs when we update a connection that we actually
care about.

Note that most plugin specific connections use
nm_settings_connection_replace_settings() in their constructor
to initialize themselves. These occurrences are not interesting
and spam the logfile.

(cherry picked from commit e14ea6818a)
2015-03-11 17:07:55 +01:00
Thomas Haller
d0283bc9e6 settings: fix wrong assertions for calling nm_settings_connection_replace_settings()
(cherry picked from commit c2dc5d3b0f)
2015-03-11 17:07:55 +01:00
Thomas Haller
7f8e486723 keyfile/writer: fix password_raw_writer() to write NMSetting8021x:password-raw
After refactoring libnm-core to use GBytes instead of
GByteArray/DBUS_TYPE_G_UCHAR_ARRAY, it was forgotten to update
keyfile writer.

This causes keyfile writer to skip the NMSetting8021x:password-raw setting
and raise a g_critical() warning.

Fixes: c43f88907b
(cherry picked from commit c651b27793)
2015-02-19 13:13:07 +01:00
Thomas Haller
f959cd404d ifcfg-rh: fix memleak in make_ip4_setting()
(cherry picked from commit d1a0229083)
2015-01-29 15:04:23 +01:00
Thomas Haller
d8ced83633 ifcfg-rh: fix memleak in make_ip4_setting()
(cherry picked from commit 9d04d62255)
2015-01-29 15:04:22 +01:00
Thomas Haller
cd5ba675ac ifcfg-rh: fix memleak in devtimeout_from_file()
(cherry picked from commit 9dddb4a918)
2015-01-29 15:04:22 +01:00
Thomas Haller
86382deed4 ifcfg-rh: fix memleak in connection_from_file_full()
(cherry picked from commit 93223112a1)
2015-01-29 15:04:22 +01:00
Thomas Haller
f791750cd8 ifcfg-rh/tests: remove test artifact 'route6-Test_Write_Wired_Static'
This left-over file breaks `make distcheck`.

Fixes: 1600ed9c68
(cherry picked from commit ce032e6e14)
2015-01-21 17:46:56 -06:00
Jiří Klimeš
966ac6a558 ifcfg-rh: add a testcase for numeric bonding mode values in BONDING_OPTS
(cherry picked from commit c743670251)
2015-01-21 12:18:15 -05:00
Jiří Klimeš
29e6b7628d ifcfg-rh: update test files not to use obsolete GATEWAY<n> variables
But add a dedicated test reading GATEWAY1 to ensure we are still backwards
compatible.
(cherry picked from commit 233498e0a4)
2015-01-15 13:24:18 +01:00
Jiří Klimeš
cc0f92db13 ifcfg-rh: read custom IP address for shared connections (rh #1174632)
Custom IP ranges for shared connection were implemeted in bgo #6759732
(commit 32a001f526). The first IP address
is used and a range is calculated.
However, the commit missed to update ifcfg-rh plugin to read the address.

Test case:
* use ifcfg-rh plugin for NetworkManager
$ nmcli con add type eth con-name shared-ip ifname eth0
$ nmcli con mod shared-ip ipv4.addresses 9.8.7.6/24 ipv4.method shared
$ nmcli con show shared-ip
$ nmcli con show shared-ip  <--- ip address 9.8.7.6 was missing

https://bugzilla.redhat.com/show_bug.cgi?id=1174632
(cherry picked from commit c8fe3bbabc)
2015-01-15 13:24:18 +01:00
Dan Winship
c9d4c3c110 ifcfg-rh: allow handling complex routing rules via dispatcher (rh #1160013)
If a connection has an associated "rule-NAME" or "rule6-NAME" file,
don't try to read in the routes, since NetworkManager won't be able to
parse them correctly. Instead, log a warning that they will need to be
applied via a dispatcher script, and provide a script that would do
that in examples/dispatcher/.

(cherry picked from commit f79d62692e)
2015-01-14 11:35:17 -05:00
Dan Winship
3572160f55 settings: add NMSettingsConnection:filename
Add a "filename" property to NMSettingsConnection, and set it from
keyfile and ifcfg-rh (replacing the existing priv->path variables in
those connection types). (The other plugins either don't use files, or
don't use per-connection files.)

(cherry picked from commits 24a464a7da
and c9002c041d)
2015-01-14 11:35:17 -05:00