Commit graph

829 commits

Author SHA1 Message Date
Lubomir Rintel
13cd646b9d ifcfg-rh: don't signal removal of the connection we didn't register
Removal of a NM_CONTROLLED=no connection and subsequent 'nmcli c reload' would
cause a crash.

(cherry picked from commit 3b853de2e9)
2015-07-02 15:19:46 +02:00
Lubomir Rintel
8c1e848401 ifcfg-rh,vlan: fall back to VLAN_ID if vlan id can't be determined from DEVICE
If the device begins with "vlan", but a VLAN ID does not follow, the reader
would fail and ignore the actual VLAN_ID.

(cherry picked from commit f23a46d4b7)
2015-06-24 18:27:06 +02:00
Thomas Haller
747af368da platform: pass object type with platform changed signal
(cherry picked from commit b88c309167)
2015-06-24 16:40:11 +02:00
Thomas Haller
6ac7a3c30e settings: print filename of loaded setting plugins
(cherry picked from commit 5ecfbf18c2)
2015-06-22 09:56:05 +02:00
Thomas Haller
e1283824ef settings: close module if loading of plugins fails
(cherry picked from commit 3be5e2908c)
2015-06-22 09:56:05 +02:00
Dan Winship
baacd13bd6 core, dispatcher: drop unnecessary setpgid() calls
There's no point in calling setpgid() on short-lived processes, so
remove the setpgid() calls when spawning dispatcher scripts, iptables,
iscsiadmin, and netconf.

(cherry picked from commit c22e3f327a)
2015-06-20 10:56:58 +02:00
Dan Winship
4213815d6b core: use GUnixSignalWatchSource to simplify signal handling
Replace the pthread_sigwait()-based signal handling with
g_unix_signal_add()-based handling, and get rid of all the
now-unnecessary calls to nm_unblock_posix_signals() when spawning
subprocesses.

As a bonus, this also fixes the "^C in gdb kills NM too" bug.

(cherry picked from commit c5b3e93792)
2015-06-20 10:48:21 +02:00
Thomas Haller
c933bacd4a ifcfg-rh: add svSetValueFull() to support writing empty values
svSetValue() treated the empty word like %NULL.
Handle empty differently from unset.

(cherry picked from commit 0348bc9195)
2015-06-19 13:08:55 +02:00
Thomas Haller
7a98e481d9 ifcfg-rh: fix svSetValue() to properly handle empty variables
svSetValue() called svGetValue() which would return %NULL
for empty variables. That is wrong, because it caused svSetValue()
to add the variable anew.

(cherry picked from commit 51255d8b64)
2015-06-19 13:08:46 +02:00
Thomas Haller
5ad85e17db ifcfg-rh: use svGetValueFull() in svGetValueInt64()
Previously, it would silently accept a value set to "empty".
This is however not a valid number and we should raise a
warning just like for any other invalid number.

(cherry picked from commit c6efbeccf3)
2015-06-19 13:08:37 +02:00
Thomas Haller
1cce24f346 ifcfg-rh: add svGetValueFull() function
(cherry picked from commit 33aaa730c5)
2015-06-19 13:08:30 +02:00
Thomas Haller
e3a76a4f3d ifcfg-rh: refactor svSetValue() and svEscape() not to clone string needlessly
In the most cases we don't expect that our values need
escaping. No need to do an additional copy of the unmodified
string.

(cherry picked from commit 32871deecc)
2015-06-19 13:07:45 +02:00
Thomas Haller
14e2e57acd ifcfg-rh: better detect alias files
Alias files have a ':' to separate the base name from their
alias. But we didn't always ensure not to write-out files without
colon, and also initscripts doesn't have that restriction.

We should detect alias files and handle them properly (e.g. by
reloading the base file).

This fixes an error that a `nmcli con load` would have tried to
load the alias file. Also extend load_connection() to support
passing filenames other then the base file.

We only have to handle this in plugin.c. Inside reader.c we always
have the normalized base filename.

Or detection of alias files only looks whether the filename has a ':'
and whether a corresponding base file exists.

(cherry picked from commit 0aed4e2388)
2015-06-19 13:02:00 +02:00
Thomas Haller
da112cc0cc ifcfg-rh: escape colon in generated filename
A colon indicates an alias file. It should be escaped.

(cherry picked from commit 2e87df8408)
2015-06-19 13:02:00 +02:00
Thomas Haller
9feb02d185 ifcfg-rh: refactor utils_should_ignore_file() to return early
(cherry picked from commit 8be9e832b5)
2015-06-19 13:02:00 +02:00
Thomas Haller
144093fa03 ifcfg-rh: also read alias file for dhcp connections
Previously, if the main ifcfg file doesn't define any
static ip addresses, any alias files would be ignored.

We should also allow alias files with (pure) 'dhcp' connections,
just like initscripts do.

Reported-by: Marek Hulan <mhulan@redhat.com>
(cherry picked from commit 4ef8c0c90c)
2015-06-19 13:02:00 +02:00
Thomas Haller
99eb598c34 ifcfg-rh: log warning when loading of connection fails
connection_from_file() used to log a warning about failure,
but only when an @error argument was given.

update_connection() didn't ensure that in several cases,
so we would not log any failure reason when an ifcfg file
failed to read.

This behavior of controlling logging by passing @error (or not)
is unexpected. Instead, refactor the code so that the caller
can do appropriate logging.
Another reason for this refactoring is that PARSE_WARNING() does
not mention the file for which the failure is and uses some extra
indention that looks wrong. IOW, connection_from_file() doesn't
have the context to give the logging line a proper formatting.

(cherry picked from commit 900aa016b1)
2015-06-19 13:02:00 +02:00
Thomas Haller
fd80b02405 ifcfg: refactor utils_get_ifcfg_name()
No need to allocate a temporary "base" variable. Just
search for the last '/' ourselves.
All the special handling that g_path_get_basename() does,
for example handling empty filenames and removing trailing
slashes, is not needed.

Thereby fix not to return empty names such as from "ifcfg-".

(cherry picked from commit 2ef8f6edfe)
2015-06-19 13:02:00 +02:00
Jiří Klimeš
8aa0b5b17d ifcfg-rh: read/write autoconnect-slaves property as AUTOCONNECT_SLAVES
AUTOCONNECT_SLAVES is an NetworkManager extension. initscripts always activate
slaves with the master connection for bond and team, and doesn't activate
automatically slaves for bridge.
NetworkManager behaviour is controlled by this variable. If the variable is
missing the default value from configuration file is used.

(cherry picked from commit 2a497eeadc)
2015-06-19 12:18:52 +02:00
Thomas Haller
517e9fa0f0 ibft: avoid logging multiple lines when ibft fails
In case of error, ibft prints an error message to stderr
with two trailing newlines. This causes multiple lines
in our logfile. Replace newlines in the error message
by whitespaces.

(cherry picked from commit 205c109741)
2015-06-19 12:05:50 +02:00
Lubomir Rintel
0f95b5c345 builds: only enable TAP driver for glib >= 2.37.6
No TAP support for previous versions and --tap argument is silently ignored,
confusing the TAP driver.

(cherry picked from commit c47c06470a)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
fe3e32c034 tests: use the TAP formatter
The test results in standard format are easily integrated into CI systems.

(cherry picked from commit 6463ce5dd9)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
62172a9a9e tests: move all asserts into tests
Otherwise the TAP formatter would produce a plan-less output.

(cherry picked from commit f627d6db8e)
2015-06-19 11:52:49 +02:00
Dan Williams
cf044faf13 settings: ignore incompatible connections when looking for existing ones
beb18050 made this code run for all devices instead of just ethernet
devices, which means any kind of connection gets compared to any
device.  But only compatible connections should be considered.

(cherry picked from commit 77d01c9094)
2015-06-17 16:11:55 +02:00
Thomas Haller
3a30ccacc7 platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.

While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.

With this change, NMPlatform instances can be used individually, not
only as a singleton instance.

Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.

Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.

Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.

This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".

(cherry picked from commit c6529a9d74)
2015-06-17 14:32:30 +02:00
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
3d17c73576 core/logging: adjust log line about loading setting plugins
We have different kinds of plugins (settings, dhcp, dns).
Clearify, that we are about to load "settings" plugins.

(cherry picked from commit e9b9d9b627)
2015-05-13 18:44:02 +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
41598c1f1a config: move no-auto-default to NMConfigData
With this change, NMConfig is really immutable and all
modifyable parts migrated to NMConfigData.

Another advantage is that components can now subscribe to
NMConfig changes to pickup changes to no-auto-default.

(cherry picked from commit 13c7f6a56d)
2015-05-05 16:51:43 +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
Dan Williams
1d8a2a2662 settings: remove 'do_export' argument from claim_connection()
It was always TRUE, and unused anyway.

(cherry picked from commit bbcf5444fd)
2015-05-05 16:37:06 +02:00
Dan Williams
de9a34cc42 settings/dbus: harden connection removal and object unexport
None of these functions was checking if the same operation had already
been performed, or if the object being removed/unexported was known.

(cherry picked from commit fe96dbc0ee)
2015-05-05 16:37:06 +02:00
Lubomir Rintel
a4369ef841 nm-settings: add nm_settings_has_connection()
Useful for checking if a connection is already deleted.

https://bugzilla.gnome.org/show_bug.cgi?id=744812
https://bugzilla.redhat.com/show_bug.cgi?id=1174164
(cherry picked from commit 8a00bb36ec)
2015-05-05 16:37:06 +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
Thomas Haller
62bff65e14 core/trivial: rename singleton variables according to default name
(cherry picked from commit 822cb293ef)
2015-03-13 11:50:50 +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