Commit graph

841 commits

Author SHA1 Message Date
Thomas Haller
39a79b0ee7 ifcfg-rh: handle quotes of WPA_PSK key inside shvar.h
It is wrong to move the handling of quotes outside of shvar.h.
The ifcfg-rh core library (shvar.h) should handle quotation
transparently.

It is also wrong to encode meaning of the WPA_PSK depending on whether
the value is quoted or not. A psk that is 64 chars *must* be in hex
representation, and anything else is taken literal.

Also, the special handling of bash-syntax with $' was wrong. Including
the unit test "keys-test-wifi-wpa-psk-2" which contained invalid shell.
Support for $' must be done inside of shvar.h, for all properties alike
not just for WPA_PSK.
2016-11-09 12:07:34 +01:00
Thomas Haller
5a43b733b9 ifcfg-rh: change ESSID handling
Let shvar.h do the escaping/unescaping of the ESSID.
We should not treat a value differently whether it is quoted or not.

Also, cutting away double quotes and calling svUnescape() is just wrong.

Now, we write a value in hex if it contains non-printable characters
or if the reader would treat it like a hex value. Reader treats ESSID
now as hex if it starts with "0x" followed by pairs of hex digits.
2016-11-09 12:07:34 +01:00
Thomas Haller
912a866353 ifcfg-rh: read team key non-verbatim from ifcfg-rh
svUnescape() has no problem with extremely long strings.
It does not allocate any memory and has O(n) complexity.
No problem.

If somebody has a problem with extremely large files it's
shvarFile itself which caches the entire file in memory.

Also, libnm-core allows team configs to be 1 MB in size.
So, allow that here too.
2016-11-09 12:07:34 +01:00
Thomas Haller
22ef66e6bb ifcfg-rh: unescape ifcfg value for CIPHER_GROUP/CIPHER_PAIRWISE
It's not clear why we would read the CIPHER_GROUP/CIPHER_PAIRWISE
verbatim=TRUE (without shell unescaping). Especially since ifcfg-rh
writer does
  svSetValue (ifcfg, "CIPHER_PAIRWISE", str->str, FALSE);
2016-11-09 12:07:34 +01:00
Thomas Haller
8f9432327c ifcfg-rh/trivial: coding style/white-space 2016-11-09 12:07:33 +01:00
Thomas Haller
f950f7922e ifcfg-rh/tests: use cleanup macros in ifcfg-rh test 2016-11-09 12:07:33 +01:00
Thomas Haller
3bbc55fd9c core: don't use generated glib enum for platform types 2016-10-22 17:16:17 +02:00
Thomas Haller
548a5440e9 ifcfg-rh: fix signature of link_changed() callback
Depending on how arguments are passed to the called function,
this could lead to a crash.

Maybe not on 32 bit machines where the size of the pointer is
the size of an int.

Maybe not on x86_64, where the arguments are passed in registers.

Fixes: b88c309167
2016-10-22 16:12:58 +02:00
Thomas Haller
b48b56c499 build: merge "src/settings/plugins/ifnet/tests/Makefile.am" into toplevel Makefile 2016-10-21 17:04:05 +02:00
Thomas Haller
b2d4180787 build: merge "src/settings/plugins/ifnet/Makefile.am" into toplevel Makefile 2016-10-21 16:47:03 +02:00
Thomas Haller
b661b17687 build: merge "src/settings/plugins/ifupdown/tests/Makefile.am" into toplevel Makefile 2016-10-21 16:47:03 +02:00
Thomas Haller
4128d837ac build: merge "src/settings/plugins/ifupdown/Makefile.am" into toplevel Makefile 2016-10-21 16:47:03 +02:00
Thomas Haller
2169a09f07 build: merge "src/settings/plugins/ifcfg-rh/tests/Makefile.am" into toplevel Makefile 2016-10-21 16:47:02 +02:00
Thomas Haller
181dfe17d8 build: merge "src/settings/plugins/ifcfg-rh/Makefile.am" into toplevel Makefile 2016-10-19 17:16:08 +02:00
Thomas Haller
f87d153f8a build: merge "src/settings/plugins/ibft/Makefile.am" into toplevel Makefile 2016-10-19 17:16:08 +02:00
Thomas Haller
541f543451 build: merge "src/settings/plugins/keyfile/Makefile.am" into toplevel Makefile 2016-10-19 17:16:08 +02:00
Thomas Haller
274de2555b build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILER 2016-10-19 15:26:30 +02:00
Thomas Haller
5424e3a063 keyfile: disable permission checks of keyfile for tests
The tests were checking that the keyfiles had permission
0600 and there was a check-local target to prepare the permissons
of the tests.

That is inconvenient, and it is unexpected to have a check-local
target for such a case.

Also, the tests were not testing that keyfile reader would
bail out on invalid permissions. So just skip the check for
testing.
2016-10-19 15:26:30 +02:00
Beniamino Galvani
f63e28b147 ifcfg-rh: support the autoconnect-retries property 2016-10-16 12:56:09 +02:00
Thomas Haller
e95090d303 settings/build: add linker version script for settings plugins 2016-10-13 21:33:33 +02:00
Thomas Haller
38d669d5ee build: move check_so_symbols for settings plugins to parent makefile
Like for the device plugins, check_so_symbols is called from the
Makefile of the plugin itself, not from tests/Makefile.am.

Just keep it consistent.
2016-10-13 21:33:33 +02:00
Beniamino Galvani
21358edc54 core: introduce and use nm_utils_file_set_contents()
In some places we use g_file_set_contents() after a umask() to limit
the permissions of the created file. Unfortunately if the containing
directory has a default ACL the umask will be ignored and the new file
will have a mode equal to the default ACL (since g_file_set_contents()
opens the file with mode 0666).

Calling a chmod() after the file gets created is insecure (see commit
60b7ed3bdc) and so the only solution seems to be to reimplement
g_file_set_contents() and accept a mode as parameter.

We already had similar functions in the tree, consolidate them into a
new generic utility function.

https://bugzilla.gnome.org/show_bug.cgi?id=769702
2016-10-12 14:54:57 +02:00
Thomas Haller
97d3b07753 ifcfg-rh/build: fix build error due to line-break in Makefile.am
Fixes: dd4ce10c92
2016-10-11 12:12:25 +02:00
Thomas Haller
051bcd9f1c ifcfg-rh: hide shvarFile struct 2016-10-11 11:37:46 +02:00
Thomas Haller
29f7688da5 ifcfg-rh: avoid copying and unescaping current line when unsetting value 2016-10-11 11:37:46 +02:00
Thomas Haller
b00ee52ab3 ifcfg-rh/trivial: move code in shvar.c 2016-10-11 11:37:46 +02:00
Thomas Haller
96846352de ifcfg-rh: minor cleanups in writer 2016-10-11 11:37:46 +02:00
Thomas Haller
0ed009f236 ifcfg-rh: use svUnsetValue()
sed 's/^\(\t\+\)svSetValue (\([a-z]\+\), \("[^"]*"\|[*a-z_0-9A-Z]\+\(\(->\|.\)[a-z0-9A-Z_]\+\)\), NULL, \(FALSE\|TRUE\));$/\1svUnsetValue (\2, \3);/g' src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c -i
2016-10-11 11:37:46 +02:00
Thomas Haller
491b6027ba ifcfg-rh: add svUnsetValue() 2016-10-11 11:37:46 +02:00
Thomas Haller
b3b0cb0b17 ifupdown: rename files to "nms-ifupdown-*" 2016-10-11 11:37:46 +02:00
Thomas Haller
1eac4f3e60 ifnet: rename files to "nms-ifnet-*" 2016-10-11 11:37:46 +02:00
Thomas Haller
dd4ce10c92 settings/build: build and use libnms-*-core.la library
Don't have the test recompile parts of the settings plugin.
Instead, build one core library that is used both by the test
and the settings plugin.

Advantage: might save some compilation time, but more importantly: the
test use the same object code then NetworkManager itself, avoiding
different behavior due to compilation flags.
2016-10-11 11:37:46 +02:00
Thomas Haller
eab8b06d8b ifcfg-rh/tests: merge test-ifcfg-rh-utils into test-ifcfg-rh
We don't need need separate unit tests for basic tests that can
just run in the same test-run. If you really need to run only
a particular set of tests, try
  ./src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -p /settings/plugins/ifcfg-rh/utils

Results in less compilation (time), and less binaries to test during
`make check`.
2016-10-11 11:37:46 +02:00
Thomas Haller
254f892c9c ifcfg-rh: rename files 2016-10-11 11:37:46 +02:00
Thomas Haller
d18e71f35a ibft/build: cleanup Makefile.am to build one core library from ibft plugin
Instead of having the tests re-compile "nms-ibft-reader.c".
2016-10-11 11:37:46 +02:00
Thomas Haller
68f33a846e ibft: rename function names for ibft plugin 2016-10-11 11:37:46 +02:00
Thomas Haller
912526f543 ibft: rename files to "nms-ibft-*" 2016-10-11 11:37:46 +02:00
Thomas Haller
33d05f5295 keyfile/build: set LDFLAGS for buiding keyfile tests 2016-10-11 11:37:46 +02:00
Thomas Haller
1bea5d5048 keyfile: add logging macros to keyfile plugin 2016-10-06 20:41:20 +02:00
Thomas Haller
34f65e6ef8 keyfile: fix calling parent implementation in NMSKeyfilePlugin:constructed() 2016-10-06 20:41:20 +02:00
Thomas Haller
4d194c3833 keyfile/build: don't build keyfile settings plugin as library
We directly include keyfile sources in NetworkManager by compiling
them into "libNetworkManager.la".

Drop unused libraries from the Makefile.
2016-10-06 20:41:20 +02:00
Thomas Haller
8b1411712a keyfile: refactor GObject type creation 2016-10-06 20:41:20 +02:00
Thomas Haller
5d80a8a78b keyfile: rename public keyfile functions and names 2016-10-06 20:41:20 +02:00
Thomas Haller
93c8381965 keyfile: rename files
Setting plugins should have their own name prefix (nms) and
keyfile should have as prefix "nms-kf". As a first step, rename
the files.
2016-10-06 20:41:20 +02:00
Thomas Haller
a63867a40b build: use NetworkManager logging domain for device and settings plugins
First of all, G_LOG_DOMAIN only matters when using g_log() directly.
Inside core, we always want to log via nm-logging. Every call to a
g_log() is a bug in the first place (like a failed assertion that logs
a g_critical() during g_return_if_fail()).

So, for all practic purposes, the logging domain is not used.

For nm-logging, the G_LOG_DOMAIN has no effect. Unless we find a proper
use of this domain, G_LOG_DOMAIN should not differ from what the rest of
core.
2016-10-06 20:41:20 +02:00
Thomas Haller
8bc8d343ca ifcfg-rh/proxy: fix memleak in make_proxy_setting() 2016-10-05 14:58:03 +02:00
Thomas Haller
8b51e345af libnm/proxy: add proxy setting for non-slave connection during normalization
And reject slave settings with proxies.
2016-10-05 14:53:21 +02:00
Thomas Haller
29b576bd70 proxy: cleanup handling of proxy-method
The numeric value of NM_SETTING_PROXY_METHOD_NONE should be zero,
as that is the more natural default.

Also, cast all uses of the enum values in g_object_set() to
(int).
2016-10-05 14:46:18 +02:00
Thomas Haller
a93fee0844 keyfile/tests: refactor loading plain keyfile via glib API 2016-10-05 14:46:18 +02:00
Thomas Haller
cadeaf9c20 keyfile/tests: refactor uuid creation in test 2016-10-05 14:46:18 +02:00