summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2017-02-17test: re-drop assumption that /run is a mount point (#5377)Martin Pitt
Commit 436e916ea introduced the assumption into test-stat-util that /run is a tmpfs mount point. This is not the case in build chroots such as Fedora's mock or Debian's sbuild. So only assert that /run is a tmpfs and not a btrfs if /run is actually a mount point. This will then still be asserted with installed tests.
2017-02-17machined: when copying files from/to userns containers chown to rootLennart Poettering
This changes the file copy logic of machined to set the UID/GID of all copied files to 0 if the host and container do not share the same user namespace. Fixes: #4078
2017-02-17copy: change the various copy_xyz() calls to take a unified flags parameterLennart Poettering
This adds a unified "copy_flags" parameter to all copy_xyz() function calls, replacing the various boolean flags so far used. This should make many invocations more readable as it is clear what behaviour is precisely requested. This also prepares ground for adding support for more modes later on.
2017-02-16test: drop TEST_DATA_DIR, fold into get_testdata_dir()Martin Pitt
Drop the TEST_DATA_DIR macro as this was using alloca() within a function call which is allegedly unsafe. So add a "suffix" argument to get_testdata_dir() instead and call that directly.
2017-02-16test: show error message if $SYSTEMD_TEST_DATA does not existMartin Pitt
Rename get_exe_relative_testdata_dir() to get_testdata_dir() and move the env var check into that, so that everything interesting happens at the same place.
2017-02-16Rename $TEST_DIR to $SYSTEMD_TEST_DATA, document itZbigniew Jędrzejewski-Szmek
TEST_DIR is rather generic, and we prefix all variables used by installed executables with "SYSTEMD_".
2017-02-16test: setup test data dir before fake runtime dirMartin Pitt
That way, if the test directory does not exist we don't leave behind temporary files (as in that case or on test failure the cleanup actions don't run).
2017-02-16Merge pull request #4526 from keszybz/coredump-pythonLennart Poettering
Collect interpreter backtraces in systemd-coredump
2017-02-15test-ipcrm: use configured nobody user name (#5350)Zbigniew Jędrzejewski-Szmek
"nfsnobody" is now obsolete.
2017-02-15test-journal-importer: add a test case with broken inputZbigniew Jędrzejewski-Szmek
2017-02-15test-journal-importer: new test file to check the newly exported importer codeZbigniew Jędrzejewski-Szmek
Only one test case is added, but it is enough to check basic sanity of the code (single-line and binary fields and trusted fields, allocation and freeing).
2017-02-13test: make unit tests relocatableMartin Pitt
It is useful to package test-* binaries and run them as root under autopkgtest or manually on particular machines. They currently have a built-in hardcoded absolute path to their test data, which does not work when running the test programs from any other path than the original build directory. By default, make the tests look for their data in <test_exe_directory>/testdata/ so that they can be called from any directory (provided that the corresponding test data is installed correctly). As we don't have a fixed static path in the build tree (as build and source tree are independent), set $TEST_DIR with "make check" to point to <srcdir>/test/, as we previously did with an automake variable.
2017-02-13Merge pull request #5319 from keszybz/test-executeLennart Poettering
test-execute without capsh
2017-02-12core: skip ReadOnlyPaths= and other permission-related mounts on ↵Lennart Poettering
PermissionsStartOnly= (#5309) ReadOnlyPaths=, ProtectHome=, InaccessiblePaths= and ProtectSystem= are about restricting access and little more, hence they should be disabled if PermissionsStartOnly= is used or ExecStart= lines are prefixed with a "+". Do that. (Note that we will still create namespaces and stuff, since that's about a lot more than just permissions. We'll simply disable the effect of the four options mentioned above, but nothing else mount related.) This also adds a test for this, to ensure this works as intended. No documentation updates, as the documentation are already vague enough to support the new behaviour ("If true, the permission-related execution options…"). We could clarify this further, but I think we might want to extend the switches' behaviour a bit more in future, hence leave it at this for now. Fixes: #5308
2017-02-12calendarspec: fix duplicate detection (#5310)Doug Christman
a2eb5ea79c added a new field to `CalendarComponent`; update `normalize_chain` to compare all fields when dropping duplicates
2017-02-12test-execute: use __func__ to shorten messagesZbigniew Jędrzejewski-Szmek
2017-02-12test-execute: detect missing capsh in all testsZbigniew Jędrzejewski-Szmek
Fixes #5273.
2017-02-08Merge pull request #4962 from poettering/root-directory-2Zbigniew Jędrzejewski-Szmek
Add new MountAPIVFS= boolean unit file setting + RootImage=
2017-02-08seccomp: on s390 the clone() parameters are reversedLennart Poettering
Add a bit of code that tries to get the right parameter order in place for some of the better known architectures, and skips restrict_namespaces for other archs. This also bypasses the test on archs where we don't know the right order. In this case I didn't bother with testing the case where no filter is applied, since that is hopefully just an issue for now, as there's nothing stopping us from supporting more archs, we just need to know which order is right. Fixes: #5241
2017-02-08test: Fix a maybe-uninitialised compiler warning (#5269)Philip Withnall
The compiler warning is a false positive, since n_addresses is always initialised on the success path from parse_argv(), but the compiler obviously can’t work that out. Fixes: src/test/test-nss.c:426:9: warning: 'n_addresses' may be used uninitialized in this function [-Wmaybe-uninitialized]
2017-02-08seccomp: MemoryDenyWriteExecute= should affect both mmap() and mmap2() (#5254)Lennart Poettering
On i386 we block the old mmap() call entirely, since we cannot properly filter it. Thankfully it hasn't been used by glibc since quite some time. Fixes: #5240
2017-02-07install: when a template unit is instantiated via a /usr symlink, consider ↵Lennart Poettering
it enabled If a unit foobar@.service stored below /usr is instantiated via a symlink foobar@quux.service also below /usr, then we should consider the instance statically enabled, while the template itself should continue to be considered enabled/disabled/static depending on its [Install] section. In order to implement this we'll now look for enablement symlinks in all unit search paths, not just in the config and runtime dirs. Fixes: #5136
2017-02-07core: add RootImage= setting for using a specific image file as root ↵Lennart Poettering
directory for a service This is similar to RootDirectory= but mounts the root file system from a block device or loopback file instead of another directory. This reuses the image dissector code now used by nspawn and gpt-auto-discovery.
2017-02-06seccomp: RestrictAddressFamilies= is not supported on i386/s390/s390x, make ↵Lennart Poettering
it a NOP See: #5215
2017-02-05treewide: replace homegrown memory_erase with explicit_bzeroZbigniew Jędrzejewski-Szmek
explicit_bzero was added in glibc 2.25. Make use of it. explicit_bzero is hardcoded to zero the memory, so string erase now truncates the string, instead of overwriting it with 'x'. This causes a visible difference only in the journalctl case.
2017-02-04Silence two "unused function af_lookup" warnings (#5222)Zbigniew Jędrzejewski-Szmek
Gcc7 is smarter about detecting unused functions and detects those two functions which are unused in tests. But gperf generates them for us, so let's instead of removing tell gcc that we know they might be unused in the test code. In file included from ../src/test/test-af-list.c:29:0: ./src/basic/af-from-name.h:140:1: warning: ‘lookup_af’ defined but not used [-Wunused-function] lookup_af (register const char *str, register size_t len) ^~~~~~~~~ In file included from ../src/test/test-arphrd-list.c:29:0: ./src/basic/arphrd-from-name.h:125:1: warning: ‘lookup_arphrd’ defined but not used [-Wunused-function] lookup_arphrd (register const char *str, register size_t len) ^~~~~~~~~~~~~
2017-02-02time-util: refuse formatting/parsing times that we can't storeLennart Poettering
usec_t is always 64bit, which means it can cover quite a number of years. However, 4 digit year display and glibc limitations around time_t limit what we can actually parse and format. Let's make this explicit, so that we never end up formatting dates we can#t parse and vice versa. Note that this is really just about formatting/parsing. Internal calculations with times outside of the formattable range are not affected.
2017-02-02fs-util: unify code we use to check if dirent's d_name is "." or ".."Lennart Poettering
We use different idioms at different places. Let's replace this is the one true new idiom, that is even a bit faster...
2017-01-31Merge pull request #5146 from ssahani/ifname-aliasZbigniew Jędrzejewski-Szmek
networkd: Allow ':' in label This reverts a341dfe563 and takes a slightly different approach: anything is allowed in network interface labels, but network interface names are verified as before (i.e. amongst other things, no colons are allowed there).
2017-01-31util-lib: Fix chase_symlinks() with absolute symlinks (#5185)3chas3
If chase_symlinks() encouters an absolute symlink, it resets the todo buffer to just the newly discovered symlink and discards any of the remaining previous symlink path. Regardless of whether or not the symlink is absolute or relative, we need to preserve the remainder of the path that has not yet been resolved.
2017-01-24socket-utils: revert f1811313f42dc7ddaed3c47edc834c2bfd1309b2Susant Sahani
':' in not a a valid interface name.
2017-01-23network: accept colons in network interface names, normally used for alias ↵peoronoob
interfaces (#5117)
2017-01-17Merge pull request #4991 from poettering/seccomp-fixZbigniew Jędrzejewski-Szmek
2017-01-17seccomp: rework seccomp code, to improve compat with some archsLennart Poettering
This substantially reworks the seccomp code, to ensure better compatibility with some architectures, including i386. So far we relied on libseccomp's internal handling of the multiple syscall ABIs supported on Linux. This is problematic however, as it does not define clear semantics if an ABI is not able to support specific seccomp rules we install. This rework hence changes a couple of things: - We no longer use seccomp_rule_add(), but only seccomp_rule_add_exact(), and fail the installation of a filter if the architecture doesn't support it. - We no longer rely on adding multiple syscall architectures to a single filter, but instead install a separate filter for each syscall architecture supported. This way, we can install a strict filter for x86-64, while permitting a less strict filter for i386. - All high-level filter additions are now moved from execute.c to seccomp-util.c, so that we can test them independently of the service execution logic. - Tests have been added for all types of our seccomp filters. - SystemCallFilters= and SystemCallArchitectures= are now implemented in independent filters and installation logic, as they semantically are very much independent of each other. Fixes: #4575
2017-01-14Merge pull request #4879 from poettering/systemdZbigniew Jędrzejewski-Szmek
2017-01-11Merge pull request #5046 from stefanha/vsockLennart Poettering
Add AF_VSOCK socket activation support
2017-01-10socket-util: add AF_VSOCK address familyStefan Hajnoczi
The AF_VSOCK address family facilitates guest<->host communication on VMware and KVM (virtio-vsock). Adding support to systemd allows guest agents to be launched through .socket unit files. Today guest agents are stand-alone daemons running inside guests that do not take advantage of systemd socket activation.
2017-01-10build-sys: add check for gperf lookup function signature (#5055)Mike Gilbert
gperf-3.1 generates lookup functions that take a size_t length parameter instead of unsigned int. Test for this at configure time. Fixes: https://github.com/systemd/systemd/issues/5039
2016-12-25test-selinux: place %m after %[sf] (#4977)Evgeny Vereshchagin
"%d (%m) %s\n" crashes asan: https://github.com/google/sanitizers/issues/759 So, let's place %m after %s Fixes: ``` $ ./libtool --mode=execute ./test-selinux ... ============ test_misc ========== ASAN:DEADLYSIGNAL ================================================================= ==2981==ERROR: AddressSanitizer: SEGV on unknown address 0x000041b58ab3 (pc 0x7fd9c55a0eb2 bp 0x7fffdc2f9640 sp 0x7fffdc2f8d68 T0) #0 0x7fd9c55a0eb1 (/lib64/libasan.so.3+0xdeeb1) #1 0x7fd9c5550bbf (/lib64/libasan.so.3+0x8ebbf) #2 0x7fd9c5552cdd in __interceptor_vsnprintf (/lib64/libasan.so.3+0x90cdd) #3 0x7fd9c5063715 in log_internalv src/basic/log.c:680 #4 0x7fd9c506390a in log_internal src/basic/log.c:697 #5 0x561d398181a2 in test_misc src/test/test-selinux.c:81 #6 0x561d398185e8 in main src/test/test-selinux.c:117 #7 0x7fd9c493a400 in __libc_start_main (/lib64/libc.so.6+0x20400) #8 0x561d39817859 in _start (/home/vagrant/systemd-asan/.libs/lt-test-selinux+0x1859) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV (/lib64/libasan.so.3+0xdeeb1) ==2981==ABORTING ```
2016-12-21test: make sure test-execute can run in a read-only environmentLennart Poettering
This makes sure we can invoke it safely from out "mkosi.build" script when mkosi is invoked for a read-only image.
2016-12-21util-lib: rework path_check_fstype() and path_is_temporary_fs() to use O_PATHLennart Poettering
Also, add tests to make sure this actually works as intended.
2016-12-21util-lib: be stricter when decoding hex stringsLennart Poettering
If a hex string has an uneven length, generate an error instead of silently assuming a trailing '0' was in place.
2016-12-21dissect: make using a generic partition as root partition optionalLennart Poettering
In preparation for reusing the image dissector in the GPT auto-discovery logic, only optionally fail the dissection when we can't identify a root partition. In the GPT auto-discovery we are completely fine with any kind of root, given that we run when it is already mounted and all we do is find some additional auxiliary partitions on the same disk.
2016-12-21util-lib: various improvements to kernel command line parsingLennart Poettering
This improves kernel command line parsing in a number of ways: a) An kernel option "foo_bar=xyz" is now considered equivalent to "foo-bar-xyz", i.e. when comparing kernel command line option names "-" and "_" are now considered equivalent (this only applies to the option names though, not the option values!). Most of our kernel options used "-" as word separator in kernel command line options so far, but some used "_". With this change, which was a source of confusion for users (well, at least of one user: myself, I just couldn't remember that it's systemd.debug-shell, not systemd.debug_shell). Considering both as equivalent is inspired how modern kernel module loading normalizes all kernel module names to use underscores now too. b) All options previously using a dash for separating words in kernel command line options now use an underscore instead, in all documentation and in code. Since a) has been implemented this should not create any compatibility problems, but normalizes our documentation and our code. c) All kernel command line options which take booleans (or are boolean-like) have been reworked so that "foobar" (without argument) is now equivalent to "foobar=1" (but not "foobar=0"), thus normalizing the handling of our boolean arguments. Specifically this means systemd.debug-shell and systemd_debug_shell=1 are now entirely equivalent. d) All kernel command line options which take an argument, and where no argument is specified will now result in a log message. e.g. passing just "systemd.unit" will no result in a complain that it needs an argument. This is implemented in the proc_cmdline_missing_value() function. e) There's now a call proc_cmdline_get_bool() similar to proc_cmdline_get_key() that parses booleans (following the logic explained in c). f) The proc_cmdline_parse() call's boolean argument has been replaced by a new flags argument that takes a common set of bits with proc_cmdline_get_key(). g) All kernel command line APIs now begin with the same "proc_cmdline_" prefix. h) There are now tests for much of this. Yay!
2016-12-20calendarspec: improve overflow handlingDouglas Christman
Check if the parsed seconds value fits in an integer *after* multiplying by USEC_PER_SEC, otherwise a large value can trigger modulo by zero during normalization.
2016-12-20dissect: optionally, only look for GPT partition tables, nothing elseLennart Poettering
This is useful for reusing the dissector logic in the gpt-auto-discovery logic: there we really don't want to use MBR or naked file systems as root device.
2016-12-20util-lib: beef path_is_os_tree() up a bitLennart Poettering
Let's use chase_symlinks() when looking for /etc/os-release and /usr/lib/os-release as these files might be symlinks (and actually are IRL on some distros).
2016-12-20Merge pull request #4904 from dobyrch/calendar-range-stepLennart Poettering
calendarspec: allow repetition values with ranges
2016-12-17Use SPECIAL_DEFAULT_TARGET consistentlyZbigniew Jędrzejewski-Szmek
2016-12-17Modify mount_propagation_flags_from_string to return a normal int codeZbigniew Jędrzejewski-Szmek
This means that callers can distiguish an error from flags==0, and don't have to special-case the empty string.