summaryrefslogtreecommitdiff
path: root/libnm-util
Commit message (Collapse)AuthorAgeFilesLines
* all: drop unnecessary includes of <errno.h> and <string.h>Thomas Haller2019-02-122-2/+0
| | | | | "nm-macros-interal.h" already includes <errno.h> and <string.h>. No need to include it everywhere else too.
* all: don't use "static inline" in source filesThomas Haller2019-02-063-3/+3
| | | | | | | | For static functions inside a module, the compiler determines on its own whether to inline the function. Also, "inline" was used at some places that don't immediatly look like candidates for inlining. It was most likely a copy&paste error.
* build/meson: add intermediate shared/nm-utils base libraryThomas Haller2019-02-052-4/+3
| | | | | | | | | | Like also done for autotools, create and use intermediate libraries from "shared/nm-utils/". Also, replace "shared_dep" by "shared_nm_utils_base_dep". We don't need super fine-grained selection of what we link. We can always link in "shared/libnm-utils-base.a", and let the linker throw away unsed parts.
* build: meson: Add trailing commasIñigo Martínez2018-12-202-22/+22
| | | | | | | Add missing trailing commas that avoids getting noise when another file/parameter is added and eases reviewing changes[0]. [0] https://gitlab.gnome.org/GNOME/dconf/merge_requests/11#note_291585
* all: say Wi-Fi instead of "wifi" or "WiFi"Lubomir Rintel2018-11-291-3/+3
| | | | | | | | Correct the spelling across the *entire* tree, including translations, comments, etc. It's easier that way. Even the places where it's not exposed to the user, such as tests, so that we learn how is it spelled correctly.
* docs: misc. typos pt2luz.paz2018-09-1710-20/+20
| | | | | | | | | | | | | | | | | | | | | Remainder of typos found using `codespell -q 3 --skip="./shared,./src/systemd,*.po" -I ../NetworkManager-word-whitelist.txt` whereby whitelist consists of: ``` ans busses cace cna conexant crasher iff liftime creat nd sav technik uint ``` https://github.com/NetworkManager/NetworkManager/pull/205
* meson: Fix libnm-util buildJan Alexander Steffens (heftig)2018-09-131-4/+28
| | | | | | | This was broken by e01f7f2c6dccad7a950c1af4c31737a9628e809e. Port the commit's changes from libnm to libnm-util. (cherry picked from commit 4bfd0bab0d15d0b5d15f53c5b76e980a1aab1efd)
* libnm/crypto: rework endianness detection for crypto_verify_pkcs12()Thomas Haller2018-09-041-7/+8
| | | | | | | | At other places, we already use __BYTE_ORDER define to detect endianness. We don't need multiple mechanisms. Also note that meson did not do the correct thing as AC_C_BIGENDIAN, so meson + nss + big-endian was possibly broken.
* libnm-core: support private keys encrypted with AES-{192,256}-CBCBeniamino Galvani2018-08-281-2/+2
| | | | https://github.com/NetworkManager/NetworkManager/pull/189
* all: avoid useless cast of g_free() to GDestroyNotifyThomas Haller2018-08-222-2/+2
|
* libnm/trivial: cleanup variable names in settings' class-init functionsThomas Haller2018-08-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Don't use @parent_class name. This local variable (and @object_class) is the class instance up-cast to the pointer types of the parents. The point here is not that it is the direct parent. The point is, that it's the NMSettingClass type. Also, it can only be used inconsistently, in face of NMSettingIP4Config, who's parent type is NMSettingIPConfig. Clearly, inside nm-setting-ip4-config.c we wouldn't want to use the "parent_class" name. Consistently rename @parent_class to @setting_class. - Also rename the pointer to the own class to @klass. "setting_class" is also the wrong name for that, because the right name would be something like "setting_6lowpan_class". However, "klass" is preferred over the latter, because we commonly create new GObject implementations by copying an existing one. Generic names like "klass" and "self" inside a type implementation make that simpler. - drop useless comments like /* virtual functions */ /* Properties */ It's better to logically and visually structure the code, and avoid trival remarks about that. They only end up being used inconsistently. If you even need a stronger visual separator, then an 80 char /****/ line should be preferred.
* build: create "config-extra.h" header instead of passing directory variables ↵Thomas Haller2018-07-172-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | via CFLAGS 1) the command line gets shorter. I frequently run `make V=1` to see the command line arguments for the compiler, and there is a lot of noise. 2) define each of these variables at one place. This makes it easy to verify that for all compilation units, a particular define has the same value. Previously that was not obvious or even not the case (see commit e5d1a71396e107d1909744d26ad401f206c0c915 and commit d63cf1ef2faba57595112a82e962b9643cce4718). The point is to avoid redundancy. 3) not all compilation units need all defines. In fact, most modules would only need a few of these defines. We aimed to pass the necessary minium of defines to each compilation unit, but that was non-obvious to get right and often we set a define that wasn't used. See for example "src_settings_plugins_ibft_cppflags" which needlessly had "-DSYSCONFDIR". This question is now entirely avoided by just defining all variables in a header. We don't care to find the minimum, because every component gets anyway all defines from the header. 4) this also avoids the situation, where a module that previously did not use a particular define gets modified to require it. Previously, that would have required to identify the missing define, and add it to the CFLAGS of the complation unit. Since every compilation now includes "config-extra.h", all defines are available everywhere. 5) the fact that each define is now available in all compilation units could be perceived as a downside. But it isn't, because these defines should have a unique name and one specific value. Defining the same name with different values, or refer to the same value by different names is a bug, not a desirable feature. Since these defines should be unique accross the entire tree, there is no problem in providing them to every compilation unit. 6) the reason why we generate "config-extra.h" this way, instead of using AC_DEFINE() in configure.ac, is due to the particular handling of autoconf for directory variables. See [1]. With meson, it would be trivial to put them into "config.h.meson". While that is not easy with autoconf, the "config-extra.h" workaround seems still preferable to me. [1] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html
* all: don't use gchar/gshort/gint/glong but C typesThomas Haller2018-07-1110-62/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We commonly don't use the glib typedefs for char/short/int/long, but their C types directly. $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l 587 $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l 21114 One could argue that using the glib typedefs is preferable in public API (of our glib based libnm library) or where it clearly is related to glib, like during g_object_set (obj, PROPERTY, (gint) value, NULL); However, that argument does not seem strong, because in practice we don't follow that argument today, and seldomly use the glib typedefs. Also, the style guide for this would be hard to formalize, because "using them where clearly related to a glib" is a very loose suggestion. Also note that glib typedefs will always just be typedefs of the underlying C types. There is no danger of glib changing the meaning of these typedefs (because that would be a major API break of glib). A simple style guide is instead: don't use these typedefs. No manual actions, I only ran the bash script: FILES=($(git ls-files '*.[hc]')) sed -i \ -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \ -e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \ -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \ "${FILES[@]}"
* meson: run the check-export.sh in test phaseLubomir Rintel2018-06-281-3/+3
| | | | Targets not depended on by anything are not useful and likely never get run.
* build/meson: fix meson build for shared filesThomas Haller2018-05-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | The files in shared/nm-utils are not compiled as one static library, instead each subproject that needs (parts of) them, re-compiles the files individually. The major reason for that is, because we might have different compile flags, depending on whether we build libnm-core or libnm-util/libnm-glib. Actually, I think that is not really the case, and maybe this should be refactored, to indeed build them all as a static library first. Anyway, libnm-util, libnm-glib, clients' common lib, they all need a different set of shared files that they should compile. Refactor "shared/meson.build" to account for that and handle it like autotools does. Another change is, that "shared_c_siphash_dep" no longer advertises "include_directories: include_directories('c-siphash/src')". We don't put c-siphash.h into the include search path. Users who need it, should include it via "#include <c-siphash/src/c-siphash.h>". The only exception is when building shared_n_acd library, which is not under our control.
* build: use default NM_BUILD_* defines for testsThomas Haller2018-05-315-5/+9
| | | | | | | | | Use two common defines NM_BUILD_SRCDIR and NM_BUILD_BUILDDIR for specifying the location of srcdir and builddir. Note that this is only relevant for tests, as they expect a certain layout of the directories, to find files that concern them.
* build: unifiy specifying locale directory defineThomas Haller2018-05-312-2/+2
|
* libnm-util/crypto: fix harmless compiler warningThomas Haller2018-05-241-6/+3
| | | | | | | | | libnm-util/crypto_gnutls.c: In function crypto_encrypt: libnm-util/crypto_gnutls.c:245:8: error: variable salt_len set but not used [-Werror=unused-but-set-variable] gsize salt_len; ^~~~~~~~ See-also: 312c72f7617d974abd9de4218f1e9b920a6a999c
* all: use the elvis operator wherever possibleLubomir Rintel2018-05-104-5/+5
| | | | | | | | | | | | | | | | | | | | | Coccinelle: @@ expression a, b; @@ -a ? a : b +a ?: b Applied with: spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir . With some manual adjustments on spots that Cocci didn't catch for reasons unknown. Thanks to the marvelous effort of the GNU compiler developer we can now spare a couple of bits that could be used for more important things, like this commit message. Standards commitees yet have to catch up.
* all: remove consecutive empty linesBeniamino Galvani2018-04-3031-64/+0
| | | | | | | Normalize coding style by removing consecutive empty lines from C sources and headers. https://github.com/NetworkManager/NetworkManager/pull/108
* build: meson: add prefix to test namesBeniamino Galvani2018-04-121-1/+1
| | | | | | There are multiple tests with the same in different directories; add a unique prefix to test names so that it is clear from the output which one is running.
* build: meson: use run-nm-test.sh to run testsBeniamino Galvani2018-04-121-1/+5
| | | | | Like autotools, use the wrapper script 'run-nm-test.sh' that starts a separate D-Bus session when needed.
* libnm-util: Fix a minor type problem with GValuePhilip Withnall2018-02-081-1/+1
| | | | | | | | | | | | | | The code was passing the gpointer alias of the GValue, rather than the GValue* itself. This doesn’t matter normally, but broke an experimental patch in GLib to remove a cast from G_VALUE_TYPE. We’ve reverted the patch in GLib (see https://bugzilla.gnome.org/show_bug.cgi?id=793186), but this should be fixed in NetworkManager anyway. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://bugzilla.gnome.org/show_bug.cgi?id=793302
* all: replace non-leading tabs with spacesThomas Haller2018-02-072-35/+35
| | | | | | We commonly only allow tabs at the beginning of a line, not afterwards. The reason for this style is so that the code looks formated right with tabstop=4 and tabstop=8.
* version: rename macro NM_VERSION_CUR_STABLE to NM_API_VERSIONThomas Haller2018-01-231-4/+4
| | | | | | | | | | | | | | | | NM_API_VERSION is a better name. It's not the current stable version, but the version number of the API which the current NM_VERSION provides. In practice, NM_API_VERSION is either identical to NM_VERSION (in case of a release) or NM_VERSION is a development version leading up the the upcoming NM_API_VERSION. For example, with the new name the check #if NM_VERSION != NM_API_VERSION # warning this is an development version #endif makes more sense.
* version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLEThomas Haller2018-01-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to have two version defines "CUR" and "NEXT". The main purpose of these macros (if not their only), is to make NM_AVAILABLE_IN_* and NM_DEPRECATED_IN_* macros work. 1) At the precise commit of a release, "CUR" and "NEXT" must be identical, because whenever the user configures NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED, then they both compare against the current version, at which point "CUR" == "NEXT". 2) Every other commit aside the release, is a development version that leads up the the next coming release. But as far as versioning is concerned, such a development version should be treated like that future release. It's unstable API and it may or may not be close to later API of the release. But we shall treat it as that version. Hence, also in this case, we want to set both "NM_VERSION_CUR_STABLE" and again NEXT to the future version. This makes NM_VERSION_NEXT_STABLE redundant. Previously, the separation between current and next version would for example allow that NM_VERSION_CUR_STABLE is the previously release stable API, and NM_VERSION_NEXT_STABLE is the version of the next upcoming stable API. So, we could allow "examples" to make use of development API, but other(?) internal code still restrict to unstable API. But it's unclear which other code would want to avoid current development. Also, the points 1) and 2) were badly understood. Note that for our previousy releases, we usually didn't bump the macros at the stable release (and if we did, we didn't set them to be the same). While using two macros might be more powerful, it is hard to grok and easy to forget to bump the macros a the right time. One macro shall suffice. All this also means, that *immediately* after making a new release, we shall bump the version number in `configure.ac` and "NM_VERSION_CUR_STABLE".
* all: require glib 2.40lr/glib-2-40Lubomir Rintel2018-01-183-4/+1
| | | | | | RHEL 7.1 and Ubuntu 14.04 LTS both have this. https://bugzilla.gnome.org/show_bug.cgi?id=792323
* build/meson: use variables for ldflags and linker-scriptThomas Haller2018-01-111-8/+6
|
* build/meson: unconditionally use linker version scriptsThomas Haller2018-01-101-4/+3
| | | | | | | We also unconditionally use them with autotools. Also, the detection for have_version_script does not seem correct to me. At least, it didn't work with clang.
* meson: Use string variables extensivelyIñigo Martínez2018-01-101-5/+5
| | | | | | | The strings holding the names used for libraries have also been moved to different variables. This way they would be less error as these variables can be reused easily and any typing error would be quickly detected.
* meson: Improve dependency systemIñigo Martínez2018-01-102-25/+12
| | | | | | | | | | | | | | | | | | | | Some targets are missing dependencies on some generated sources in the meson port. These makes the build to fail due to missing source files on a highly parallelized build. These dependencies have been resolved by taking advantage of meson's internal dependencies which can be used to pass source files, include directories, libraries and compiler flags. One of such internal dependencies called `core_dep` was already in use. However, in order to avoid any confusion with another new internal dependency called `nm_core_dep`, which is used to include directories and source files from the `libnm-core` directory, the `core_dep` dependency has been renamed to `nm_dep`. These changes have allowed minimizing the build details which are inherited by using those dependencies. The parallelized build has also been improved.
* libnm: drop libnm-util/nm-setting-template.[hc]Thomas Haller2018-01-082-173/+0
| | | | | | | | | | | | | | | These files are a template how to add a new nm-setting-* implementation. We are not going to add new files to the deprecated libnm-util library, hence a template for libnm-util is pointless. libnm-core doesn't have a corresponding template file. Personally, I don't think such a template are a great idea either, because - People are not aware that it exists. Hence, it's unused, badly maintained and quite possibly does not follow current best practice. - Just copy an actual settings implementation and start from there. That seems better to me than having a template.
* tests: use NMTST_EXPECT*() macrosThomas Haller2018-01-082-56/+56
| | | | | | | | | | | | | | | | | | | | Tests are commonly created via copy&paste. Hence, it's better to express a certain concept explicitly via a function or macro. This way, the implementation of the concept can be adjusted at one place, without requiring to change all the callers. Also, the macro is shorter, and brevity is better for tests so it's easier to understand what the test does. Without being bothered by noise from the redundant information. Also, the macro knows better which message to expect. For example, messages inside "src" are prepended by nm-logging.c with a level and a timestamp. The expect macro is aware of that and tests for it #define NMTST_EXPECT_NM_ERROR(msg) NMTST_EXPECT_NM (G_LOG_LEVEL_MESSAGE, "*<error> [*] "msg) This again allows the caller to ignore this prefix, but still assert more strictly.
* build: refine the NETWORKMANAGER_COMPILATION defineThomas Haller2018-01-082-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Note that: - we compile some source files multiple times. Most notably those under "shared/". - we include a default header "shared/nm-default.h" in every source file. This header is supposed to setup a common environment by defining and including parts that are commonly used. As we always include the same header, the header must behave differently depending one whether the compilation is for libnm-core, NetworkManager or libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h> depending on whether we compile a library or an application. For that, the source files need the NETWORKMANAGER_COMPILATION #define to behave accordingly. Extend the define to be composed of flags. These flags are all named NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the build are available. E.g. when building libnm-core.la itself, then WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE is not available but the internal parts are still accessible. When building nmcli, only WITH_LIBNM_CORE (the public part) is available. This granularily controls the build.
* build: Remove default install directoriesIñigo Martínez2018-01-021-10/+3
| | | | | | | | | | The install directories of those targets that match the default install directories have been removed because they are redundant. This also allows a simple meson build files and it is unnecessary to create some paths. https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00078.html
* all: get rid of a handful of unused-but-set variablesLubomir Rintel2017-12-181-0/+1
|
* libnm/vpn: fix secret comparisonLubomir Rintel2017-12-181-6/+17
| | | | | One setting may contain a superset or subset of the another. Be sure not to ignore the presence of extra secret properties.
* build: use template files for enum types' sources generationIñigo Martínez2017-12-184-22/+95
| | | | | | | | | | Source files for enum types are generated by passing segments of the source code of the files to the `glib-mkenums` command. This patch removes those parameters where source code is used from meson build files by moving those segmeents to template files. https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00057.html
* build: rename unit tests with the `test-` patternIñigo Martínez2017-12-141-4/+2
| | | | | | | | | | | | There are some tests located in different directories which are using the same name. To avoid any confussion a prefix was used to name the test and the target. This patch uses the prefix just for the target, to avoid any collision that may happen, and uses the `test-` pattern as the name. https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00051.html
* build: fix libnm_linking testIñigo Martínez2017-12-141-1/+1
| | | | | | | | | | | | | | | The `libnm_linking` test that belongs to the libnm-util's general tests is failing because the test is not able to find the `test-libnm-linking` binary, which is executed as a child process. The problem lies to the `BUILD_DIR` macro definition which is used to set the place to find the binary, and is wrongly defined with the source directory. This patch changes its value to the build directory that fixes the problem. https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00049.html
* build: add initial support for meson build systemIñigo Martínez2017-12-132-0/+271
| | | | | | | | | | meson is a build system focused on speed an ease of use, which helps speeding up the software development. This patch adds meson support along autotools. [thaller@redhat.com: rebased patch and adjusted for iwd support] https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00022.html
* all: avoid coverity warnings about "Wrong Check of Return Value"Thomas Haller2017-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 30. NetworkManager-1.9.2/src/settings/plugins/keyfile/nms-keyfile-writer.c:218: check_return: Calling "g_mkdir_with_parents" without checking return value (as is done elsewhere 4 out of 5 times). 25. NetworkManager-1.9.2/src/platform/nm-linux-platform.c:3969: check_return: Calling "_nl_send_nlmsg" without checking return value (as is done elsewhere 4 out of 5 times). 34. NetworkManager-1.9.2/src/nm-core-utils.c:2843: negative_returns: "fd2" is passed to a parameter that cannot be negative. 26. NetworkManager-1.9.2/src/devices/wwan/nm-modem-broadband.c:897: check_return: Calling "nm_utils_parse_inaddr_bin" without checking return value (as is done elsewhere 4 out of 5 times). 3. NetworkManager-1.9.2/src/devices/bluetooth/nm-bluez5-manager.c:386: check_return: Calling "g_variant_lookup" without checking return value (as is done elsewhere 79 out of 83 times). 16. NetworkManager-1.9.2/libnm-util/nm-setting.c:405: check_return: Calling "nm_g_object_set_property" without checking return value (as is done elsewhere 4 out of 5 times).
* all: use _nm_utils_ip4_*() utils functionsThomas Haller2017-09-051-7/+2
|
* all: fix minor typos in settings docsYuri Chornoivan2017-07-033-5/+5
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=784440
* all: replace uses of inet_aton() and friendsThomas Haller2017-06-021-7/+22
| | | | | | | | | | | | | | | | | | | | rpmdiff complains about uses of inet_aton, inet_makeaddr, inet_netof, inet_ntoa under the IPv6 section: usr/sbin/NetworkManager on aarch64 i686 x86_64 ppc ppc64 ppc64le s390 s390x uses function inet_aton, which may impact IPv6 support I think the warning is bogus, but refactor our code to avoid it. Note that systemd code still uses them, so it don't avoid the rpmdiff warning. But let's not diverge our systemd import from upstream for this. - for NMSettingBond:validate_ip() also avoid g_strsplit_set() which allocates a full strv. Instead, we can do with one g_strdup(). - for test-resolvconf-capture.c, replace the functions with macros. Macros should be avoided usually, but for test asserts they are more convenient as they preserved the __FILE__:__LINE__ of where the assertion fails.
* all: fix typos in documentation, translated strings and commentsYuri Chornoivan2017-05-283-4/+4
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=783173
* all: fix typo 'entires' -> 'entries'Beniamino Galvani2017-05-052-4/+4
|
* release: bump version to 1.9.0 (development)1.9.0-devLubomir Rintel2017-03-281-0/+14
|
* build: don't link against libm.soThomas Haller2017-03-231-3/+6
| | | | | | | | | There are very few places where we actually use floating point or #include <math.h>. Drop that library, although we very likely still get it as indirect dependency (e.g. on my system it is still dragged in by libsystemd.so, libudev.so and libnl-3.so).
* all: fix typos in documentation and commentsYuri Chornoivan2017-03-172-6/+6
| | | | | | https://bugzilla.gnome.org/show_bug.cgi?id=780199 [thaller@redhat.com: reworded commit message]