summaryrefslogtreecommitdiff
path: root/src/tests
Commit message (Collapse)AuthorAgeFilesLines
* device: support dynamic "connection.stable-id" in form of text-substitutionThomas Haller2017-01-091-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usecase: when connecting to a public Wi-Fi with MAC address randomization ("wifi.cloned-mac-address=random") you get on every re-connect a new IP address due to the changing MAC address. "wifi.cloned-mac-address=stable" is the solution for that. But that means, every time when reconnecting to this network, the same ID will be reused. We want an ID that is stable for a while, but at a later point a new ID should e generated when revisiting the Wi-Fi network. Extend the stable-id to become dynamic and support templates/substitutions. Currently supported is "${CONNECTION}", "${BOOT}" and "${RANDOM}". Any unrecognized pattern is treated verbaim/untranslated. "$$" is treated special to allow escaping the '$' character. This allows the user to still embed verbatim '$' characters with the guarantee that future versions of NetworkManager will still generate the same ID. Of course, a user could just avoid '$' in the stable-id unless using it for dynamic substitutions. Later we might want to add more recognized substitutions. For example, it could be useful to generate new IDs based on the current time. The ${} syntax is extendable to support arguments like "${PERIODIC:weekly}". Also allow "connection.stable-id" to be set as global default value. Previously that made no sense because the stable-id was static and is anyway strongly tied to the identity of the connection profile. Now, with dynamic stable-ids it gets much more useful to specify a global default. Note that pre-existing stable-ids don't change and still generate the same addresses -- unless they contain one of the new ${} patterns.
* core: add assertions for network_id/stable_typeThomas Haller2017-01-091-2/+2
| | | | | | | | | | | We require a network-id. Assert that it is set. Also, we encode the stable-id as uint8. Thus, add an assertion that we don't use more then 254 IDs. If we ever make use of stable-type 255, we must extend the encoding to allow for more values. The assertion is there to catch that.
* python: make test-secret-agent.py python3 readyThomas Haller2016-12-141-9/+8
| | | | Co-authored-by: Lubomir Rintel <lkundrak@v3.sk>
* all: use O_CLOEXEC for file descriptorsThomas Haller2016-12-131-1/+2
|
* ip6-config: add nm_ip6_config_set_privacy()Beniamino Galvani2016-12-051-3/+6
|
* config: drop nm_config_get_dhcp_client() and access config directlyThomas Haller2016-11-251-3/+14
| | | | | | | | | | | | Also, ifnet plugin would read the configuration value, which is just wrong because: - the configuration might not be set and ifnet would fail to fallback to the compile time default. - the configuration only is in effect if the plugin is also available. Otherwise, we fallback to the next plugin. Only the dhcp-manager knows which DHCP plugin is in use.
* config: optionally let nm_config_get_plugins() return compile time defaultThomas Haller2016-11-251-16/+9
| | | | | | | | | | | Instead of having the caller do the fallback to the compile time default plugins, let it be handled by nm_config_get_plugins(). The knowledge of fallback to a compile time default (and how to do that properly) should be inside NMConfig/NMConfigData alone. Also, as this function is only called once, let NMConfig not cache the string list but create it once as needed.
* build: don't add subdirectories to include search path but require qualified ↵Thomas Haller2016-11-218-10/+10
| | | | | | | | | | | | | | | include Keep the include paths clean and separate. We use directories to group source files together. That makes sense (I guess), but then we should use this grouping also when including files. Thus require to #include files with their path relative to "src/". Also, we build various artifacts from the "src/" tree. Instead of having individual CFLAGS for each artifact in Makefile.am, the CFLAGS should be unified. Previously, the CFLAGS for each artifact differ and are inconsistent in which paths they add to the search path. Fix the inconsistency by just don't add the paths at all.
* rdisc: rename to ndiscLubomir Rintel2016-11-092-3/+3
| | | | | | We'll soon not only do the router discovery, but announce ourselves as a reouter. "Neighbor discovery" sounds to be a more appropriate name for the class than "Router discovery".
* src/tests: relax assertion for test_nm_utils_monotonic_timestamp_as_boottime()Thomas Haller2016-10-241-1/+1
| | | | | | | | When running under load (e.g. with parallel make and valgrind enabled), the checked time interval might be too short. Relax the assertion NetworkManager:ERROR:src/tests/test-general-with-expect.c:65:test_nm_utils_monotonic_timestamp_as_boottime: assertion failed (now_boottime_2 - now_boottime <= NM_UTILS_NS_PER_SECOND / 1000): (15156494 <= 1000000)
* build: merge "src/tests/Makefile.am" into toplevel MakefileThomas Haller2016-10-212-182/+12
|
* build: merge "src/tests/config/Makefile.am" into toplevel MakefileThomas Haller2016-10-212-39/+0
|
* build: merge "src/platform/tests/Makefile.am" into toplevel MakefileThomas Haller2016-10-211-0/+2
|
* build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILERThomas Haller2016-10-192-2/+2
|
* device: make registration of internal device-factories more explicitThomas Haller2016-10-111-16/+0
| | | | | | | | | | | Internal device types are a static thing. Let's not do a constructor function to register the device factory. This gets rid of all attribute((constructor)) functions inside NetworkManager core. That is desired, because we don't want to run code before main(). For example, at that point logging is not yet initialized, but with code that runs before main() it is hard to ensure that we don't log anything yet.
* core: refactor private data in "src"Thomas Haller2016-10-042-21/+30
| | | | | | | | | | | | | | | | - use _NM_GET_PRIVATE() and _NM_GET_PRIVATE_PTR() everywhere. - reorder statements, to have GObject related functions (init, dispose, constructed) at the bottom of each file and in a consistent order w.r.t. each other. - unify whitespaces in signal and properties declarations. - use NM_GOBJECT_PROPERTIES_DEFINE() and _notify() - drop unused signal slots in class structures - drop unused header files for device factories
* all: modify line separator comments to be 80 chars wideThomas Haller2016-10-038-23/+23
| | | | sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
* build: don't add systemd path the include search pathThomas Haller2016-09-272-7/+2
| | | | | | | | | | | | | | | | | | | | Our internal copy of systemd should not be in the search path. Instead, let users only #include "systemd/nm-sd.h" which then includes everything from systemd that we need. We want to avoid to accidentally include anything from our systemd-copy. Any user of that should only include "nm-sd.h", which then includes everything that is needed further. For example, "src/devices/wwan/nm-modem-manager.c" has #include <systemd/nm-daemon.h> which in turn includes #include "_sd-common.h" This works all correctly before, because #include "" will first look in the directory where sd-daemon.h is. However, our mixing of external systemd library and internal copy is rather dangerous. Try to avoid it further by keeping the include paths clean.
* all: cleanup includes in header filesThomas Haller2016-08-171-5/+1
| | | | | | | | | | | | - don't include "nm-default.h" in header files. Every source file must include as first header "nm-default.h", thus our headers get the default include already implicitly. - we don't support compiling NetworkManager itself with a C++ compiler. Remove G_BEGIN_DECLS/G_END_DECLS from internal headers. We do however support users of libnm to use C++, thus they stay in public headers. (cherry picked from commit f19aff89095ca192b8b2e37534b7a899aecd82f9)
* systemd: merge branch systemd into masterThomas Haller2016-08-121-0/+6
|\ | | | | | | | | | | | | | | Conflicts: src/systemd/src/basic/fd-util.c src/systemd/src/basic/fileio.c src/systemd/src/libsystemd/sd-event/sd-event.c src/systemd/src/libsystemd/sd-id128/sd-id128.c
* | systemd/tests: don't link test-systemd against libNetworkManagerBaseThomas Haller2016-08-122-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | One point of test-systemd is to see whether our internal systemd code can fully link without external systemd library. In fact, we want all symbols from the internal systemd code to resolve, because when we link against an external libsystemd library, we may mix differing APIs, resulting in subtle bugs. Currently, it may well be that libNetworkManagerBase.la already links against libsystemd, which would result in test-systemd to wrongly succeed resolving all names. Fix that, by don't link libNetworkManagerBase.la into test-systemd.
* | build: rename libNetworkManager-base.la to libNetworkManagerBase.laThomas Haller2016-08-111-1/+1
| | | | | | | | it matches libNetworkManagerTest.la.
* | bulid: don't link NMFakePlatform into NetworkManager binaryThomas Haller2016-08-112-2/+2
| | | | | | | | | | It's only used for testing. Add a new object libNetworkManagerTest.la that contains libNetworkManager.la including the test stubs.
* | systemd: merge branch systemd into masterThomas Haller2016-06-301-2/+1
|\ \ | |/ | | | | | | | | | | Conflicts: src/systemd/src/basic/siphash24.c src/systemd/src/basic/time-util.c src/systemd/src/basic/util.c
* | all: make MAC address randomization algorithm configurableThomas Haller2016-06-301-10/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the per-connection settings "ethernet.cloned-mac-address" and "wifi.cloned-mac-address", and for the per-device setting "wifi.scan-rand-mac-address", we may generate MAC addresses using either the "random" or "stable" algorithm. Add new properties "generate-mac-address-mask" that allow to configure which bits of the MAC address will be scrambled. By default, the "random" and "stable" algorithms scamble all bits of the MAC address, including the OUI part and generate a locally- administered, unicast address. By specifying a MAC address mask, we can now configure to perserve parts of the current MAC address of the device. For example, setting "FF:FF:FF:00:00:00" will preserve the first 3 octects of the current MAC address. One can also explicitly specify a MAC address to use instead of the current MAC address. For example, "FF:FF:FF:00:00:00 68:F7:28:00:00:00" sets the OUI part of the MAC address to "68:F7:28" while scrambling the last 3 octects. Similarly, "02:00:00:00:00:00 00:00:00:00:00:00" will scamble all bits of the MAC address, except clearing the second-least significant bit. Thus, creating a burned-in address, globally administered. One can also supply a list of MAC addresses like "FF:FF:FF:00:00:00 68:F7:28:00:00:00 00:0C:29:00:00:00 ..." in which case a MAC address is choosen randomly. To fully scamble the MAC address one can configure "02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00". which also randomly creates either a locally or globally administered address. With this, the following macchanger options can be implemented: `macchanger --random` This is the default if no mask is configured. -> "" while is the same as: -> "00:00:00:00:00:00" -> "02:00:00:00:00:00 02:00:00:00:00:00" `macchanger --random --bia` -> "02:00:00:00:00:00 00:00:00:00:00:00" `macchanger --ending` This option cannot be fully implemented, because macchanger uses the current MAC address but also implies --bia. -> "FF:FF:FF:00:00:00" This would yields the same result only if the current MAC address is already a burned-in address too. Otherwise, it has not the same effect as --ending. -> "FF:FF:FF:00:00:00 <MAC_ADDR>" Alternatively, instead of using the current MAC address, spell the OUI part out. But again, that is not really the same as macchanger does because you explictly have to name the OUI part to use. `machanger --another` `machanger --another_any` -> "FF:FF:FF:00:00:00 <MAC_ADDR> <MAC_ADDR> ..." "$(printf "FF:FF:FF:00:00:00 %s\n" "$(sed -n 's/^\([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) .*/\1:\2:\3:00:00:00/p' /usr/share/macchanger/wireless.list | xargs)")"
* | device: extend MAC address handling including randomization for ethernet and ↵Thomas Haller2016-06-301-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wifi Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address" settings. Instead of specifying an explicit MAC address, the additional special values "permanent", "preserve", "random", "random-bia", "stable" and "stable-bia" are supported. "permanent" means to use the permanent hardware address. Previously that was the default if no explict cloned-mac-address was set. The default is thus still "permanent", but it can be overwritten by global configuration. "preserve" means not to configure the MAC address when activating the device. That was actually the default behavior before introducing MAC address handling with commit 1b49f941a69af910b0e68530be7339e8053068e5. "random" and "random-bia" use a randomized MAC address for each connection. "stable" and "stable-bia" use a generated, stable address based on some token. The "bia" suffix says to generate a burned-in address. The stable method by default uses as token the connection UUID, but the token can be explicitly choosen via "stable:<TOKEN>" and "stable-bia:<TOKEN>". On a D-Bus level, the "cloned-mac-address" is a bytestring and thus cannot express the new forms. It is replaced by the new "assigned-mac-address" field. For the GObject property, libnm's API, nmcli, keyfile, etc. the old name "cloned-mac-address" is still used. Deprecating the old field seems more complicated then just extending the use of the existing "cloned-mac-address" field, although the name doesn't match well with the extended meaning. There is some overlap with the "wifi.mac-address-randomization" setting. https://bugzilla.gnome.org/show_bug.cgi?id=705545 https://bugzilla.gnome.org/show_bug.cgi?id=708820 https://bugzilla.gnome.org/show_bug.cgi?id=758301
* | device: let device specs match on permanent MAC addressThomas Haller2016-06-301-1/+1
| | | | | | | | | | | | | | | | | | Using the current, possibly non-permanent MAC address doesn't really make sense. Also, NM_DEVICE_HW_ADDRESS used to be writable and was set by NMDeviceBt to the bdaddr. That is wrong, because bdaddr should not be the current address, but the permanent one.
* | device: initialize NMDevice's hw_addr at end of object constructionThomas Haller2016-06-301-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | hw-addr is a constuct-only property. We should not do complex stuff in the property setter before the object is sufficiently initialized. For example, the logging macros access nm_device_get_iface(), which might be unset at that early point. Instead, initialize hw_addr and hw_addr_len later, at the end of the constructor() function. Also, ensure that @hw_addr_len is zero iff @hw_addr is unset. Also, ensure that we always log a message when changing/setting the hardware address -- except when clearing it during unrealize. It's implicit that unrealize clears the hardware address. Also, give all related logging messages a "hw-addr:" prefix.
* | core: prefer connection.stable-id to generate IPv6 stable privacy addressesThomas Haller2016-06-301-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Network_ID for generating RFC 7217 stable privacy IPv6 addresses is by default the UUID of the connection. Alternatively, prefer "connection.stable-id" as Network_ID to generate the stable addresses. This allows to configure a set of connections that all use the same Network_ID for generating stable addresses. Note that the stable-id and the UUID do no overlap, that is two connections [connection] uuid=uuid1 stable-id= and [connection] uuid=uuid2 stable-id=uuid1 generate distinct addresses.
* | dns: add reverse DNS IPv6 entries to dnsmasqBeniamino Galvani2016-06-071-2/+55
| | | | | | | | https://bugzilla.gnome.org/show_bug.cgi?id=767174
* | dns: add CIDR reverse DNS IPv4 entries to dnsmasqBeniamino Galvani2016-06-071-0/+68
| | | | | | | | | | | | | | | | When a reverse DNS entry must be added to dnsmasq, instead of considering IP addresses as classful use the prefix to compute one or more "in-addr.arpa" according to CIDR rules. https://bugzilla.gnome.org/show_bug.cgi?id=767174
* | config: unify logging line when reloading configurationThomas Haller2016-06-011-3/+3
| | | | | | | | | | Also when config_data changes, the logging line should start with "config: signal" like it does in the other cases.
* | config: refactor change-flags to be a cause/reason which triggered the changeThomas Haller2016-06-011-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the most part, this patch just renames some change-flags, but doesn't change much about them. The new name should better express what they are. A config-change signal can be emitted for different reasons: when we receive a signal (SIGHUP, SIGUSR1, SIGUSR2) or for internal reasons like resetting of no-auto-default or setting internal values. Depending on the reason, we want to perform different actions. For example: - we reload the configuration from disk on SIGHUP, but not for SIGUSR1. - For SIGUSR1 and SIGHUP, we want to update-dns, but not for SIGUSR2. Another part of the change-flags encodes which part of the configuration actually changed. Often, these parts can only change when re-reading from disk (e.g. a SIGUSR1 will not change any configuration inside NMConfig). Later, we will have more causes, and accordingly more fine-grained effects of what should be done on reload.
* | device: use NMSettings directly instead of NMConnectionProvider in subclassesThomas Haller2016-05-241-4/+20
| | | | | | | | | | | | Instead of accessing the singleton getter nm_settings_get(), obtain the settings instance from the device instance itself via nm_device_get_settings().
* | all/tests: split core part out of "nm-test-utils.h"Thomas Haller2016-05-1710-10/+10
| | | | | | | | | | | | | | A large part of "nm-test-utils.h" is only relevant for tests inside "src/" directory, as they are helpers related to NetworkManager core part. Split this part out of "nm-test-utils.h" header.
* | config/tests: use absolute path for config testThomas Haller2016-05-121-2/+2
| | | | | | | | | | | | | | | | | | Otherwise, calling ./src/tests/config/test-config fails, and we must do: (cd ./src/tests/config && ./test-config) We can avoid that easily.
* | platform: extend NMIPConfigSource to preserve the rtm_protocol fieldThomas Haller2016-04-282-47/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For addresses (NMPlatformIPAddress) the @addr_source field is ignored on a platform level. That is, all addresses inside the platform cache have this value set to NM_IP_CONFIG_SOURCE_KERNEL. Maybe, for that reason, the source should not be a part of the NMPlatformIPAddress structure, but it is convenient for users to piggy back the source inside the platform address structure. For routes, the source is stored in NMPlatformIPRoute's @rt_source field. When adding a route to kernel, we set the @rtm_protocol of the route depending on the source. However, we want to map different source values to the same protocol value. On the other hand, when kernel sends us a route that gets put inside the cache, we must preserve the protocol value and must not map different protocol values to the same source. The reason is, that a user can add two routes that only differ by @rtm_protocol. In that sense, the @rtm_protocol fields is part of the unique ID of a kernel route, and thus different values must map to different sources. Fix this, by extending the range of NMIPConfigSource to contain a range of protocol fields.
* | core/trivial: rename "source" field of addresses and routesThomas Haller2016-04-283-81/+81
| | | | | | | | | | | | | | | | | | | | The "source" field of NMPlatformIPRoute (now "rt_source") maps to the protocol field of the route. The source of NMPlatformIPAddress (now "addr_source") has no direct equivalent in the kernel. As their use is different, they should have different names. Also, the name "source" is used all over the place. Hence give the fields a more distinct name.
* | core: add nm_utils_machine_id_read() and parse() utilThomas Haller2016-04-261-0/+1
| |
* | core: add nm_utils_get_secret_key() utilThomas Haller2016-04-261-3/+3
| |
* | platform/tests/trivial: rename init_tests() and setup_tests() functionThomas Haller2016-04-111-2/+2
| | | | | | | | | | Make it clear that they are nmtstp functions, i.e. they are found in the header "test-common.h".
* | core: add nm_utils_ip6_address_same_prefix() utilThomas Haller2016-04-111-0/+117
| |
* | ip-config/tests: refactor tests to use utilities from "nm-test-utils.h"Thomas Haller2016-04-111-63/+25
| |
* | config/tests: avoid test failure for valgrind due to g_file_copy()Thomas Haller2016-04-081-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Valgrind doesn't like it, so don't use g_file_copy(). ==10410== Syscall param ioctl(generic) points to unaddressable byte(s) ==10410== at 0x82E1707: ioctl (syscall-template.S:84) ==10410== by 0x7712E71: btrfs_reflink_with_progress (gfile.c:3012) ==10410== by 0x7712E71: file_copy_fallback (gfile.c:3186) ==10410== by 0x7712E71: g_file_copy (gfile.c:3394) ==10410== by 0x1350CA: test_config_state_file (test-config.c:948) ==10410== by 0x7D0845A: test_case_run (gtestutils.c:2158) ==10410== by 0x7D0845A: g_test_run_suite_internal (gtestutils.c:2241) ==10410== by 0x7D08622: g_test_run_suite_internal (gtestutils.c:2253) ==10410== by 0x7D0882D: g_test_run_suite (gtestutils.c:2328) ==10410== by 0x7D08850: g_test_run (gtestutils.c:1596) ==10410== by 0x12EFA4: main (test-config.c:1032) ==10410== Address 0x9 is not stack'd, malloc'd or (recently) free'd ==10410== Fixes: e3a30665d72e82cc8f9b67becfdd85c000235824
* | core: rename nm_config_run_state* to nm_config_state*Thomas Haller2016-04-071-8/+8
| | | | | | | | | | | | | | | | | | | | | | After all, this state is stored persistently to /var/lib/NetworkManager, and not to volatile storage in /var/run. Hence the name is better. It's also shorter, so rename it. The commit is mostly trivial, including update of code comments and logging messages. Fixes: 1b43c880ba43260fe551b0ac923826f16737484f
* | config: test reading and writing of state fileBeniamino Galvani2016-04-073-0/+68
| |
* | core: add code coverage support for files in src/Beniamino Galvani2016-04-071-1/+6
| |
* | build: disable deprecation checks for internal compilationThomas Haller2016-04-052-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | For internal compilation we want to be able to use deprecated API without warnings. Define the version min/max macros to effectively disable deprecation warnings. However, don't do it via CFLAGS option in the makefiles, instead hack it to "nm-default.h". After all, *every* source file that is for internal compilation needs to include this header as first.
* | systemd: split "nm-sd.h" out of "nm-sd-adapt.h"Thomas Haller2016-03-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now we have: "nm-sd.h" is a header file of NetworkManager with utilities related to systemd. It can be used anywhere freely. Also, systemd headers that are considered public API (like "sd-event.h") can be used without restrictions. When compiling the systemd sources, we always must include "nm-sd-adapt.h" as first. Similarly, systemd headers must not include "nm-sd-adapt.h", because they are either public (in which case the adapter is not needed) or they are internal (in which case they are themself included via a systemd source). Sometimes, we must internal API (like "dhcp-lease-internal.h"). In this case, we also must include "nm-sd-adapt.h".
* | systemd: integrate sd-event into glib main loopThomas Haller2016-03-112-0/+69
| | | | | | | | | | We should not try to reimplement sd-event based on glib, instead we should hook sd-event into the glib mainloop.