summaryrefslogtreecommitdiff
path: root/src/shared
AgeCommit message (Collapse)Author
2017-02-17systemctl: show extra args if defined (#5379)Adrián López
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-16tests: look for tests relative to source dir when running from build dirZbigniew Jędrzejewski-Szmek
automake helpfully sets a few variables for during build. When our executable is in a directory underneath $(abs_top_builddir), we know that we're in the build environment $(abs_top_srcdir) contains the sources, and test data is under $(abs_top_srcdir)/test. This remains true no matter where the build directory is relative to the source directory. It also works if the test executable is invoked as ./test-whatever or .libs/test-whatever, since the relative path is not used at all. When running from outside of the build directory, we should be running from the installed location and we can look for ../testdata relative to the location of the exe file. Of course, $SYSTEMD_TEST_DATA always overrides this logic.
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: clarify error message if test data directory does not existMartin Pitt
When trying to directly run a test executable in the build tree without setting $TEST_DIR, some tests fail with a non-obvious error message. Print an useful one instead.
2017-02-14Define clone order on ppc (#5325)Zbigniew Jędrzejewski-Szmek
This was tested on ppc64le. Assume the same is true for ppc64.
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-12seccomp: disable RestrictAddressFamilies= for the ABI we shall block, not ↵Lennart Poettering
the one we are compiled for (#5272) It's a difference. Not a big one, but let's be correct here.
2017-02-12Merge pull request #5276 from poettering/resolved-cnameZbigniew Jędrzejewski-Szmek
a good number of resolved fixes
2017-02-12shared: pass *unsigned_long to namespace_flag_from_string_many (#5315)Evgeny Vereshchagin
Fixes: ``` src/shared/bus-unit-util.c: In function ‘bus_append_unit_property_assignment’: src/shared/bus-unit-util.c:570:65: warning: passing argument 2 of ‘namespace_flag_from_string_many’ from incompatible pointer type [-Wincompatible-pointer-types] r = namespace_flag_from_string_many(eq, &flags); ^ In file included from src/shared/bus-unit-util.c:31:0: src/shared/nsflags.h:41:5: note: expected ‘long unsigned int *’ but argument is of type ‘uint64_t * {aka long long unsigned int *}’ int namespace_flag_from_string_many(const char *name, unsigned long *ret); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Closes #5312
2017-02-12shared: convert unsigned long to uint64_t explicitly (#5314)Evgeny Vereshchagin
Closes #5313
2017-02-12Merge pull request #5303 from poettering/deleted-unitsZbigniew Jędrzejewski-Szmek
a small number of install and unit management related fixes
2017-02-10seccomp: order seccomp ABI list, so that our native ABI comes last (#5306)Lennart Poettering
this way, we can still call seccomp ourselves, even if seccomp() is blocked by the filter we are installing. Fixes: #5300
2017-02-10path-lookup: if $HOME can be determined but $XDG_RUNTIME_DIR can't, is itLennart Poettering
So far, if either $HOME or $XDG_RUNTIME_DIR is not set we wouldn't use either, and fail acquire_config_dirs() and acquire_control_dirs() in their entireties. With this change, let's make use of the variables we can acquire, and don't bother with the other. Specifically this means: in both acquire_config_dirs() and acquire_control_dirs() handle ENXIO from user_config_dir() and user_runtime_dir() directly, instead of propagating it up and handling it in the caller.
2017-02-10path-lookup: drop redundant strv_isempty() checkLennart Poettering
If the strv is empty, then strv_extend_strv_concat() is a NOP anyway, and hence there is no reason to guard for this explicitly.
2017-02-10path-lookup: try harder acquiring them $HOME of a userLennart Poettering
Let's use get_home_dir() for figuring out the home directory, so that there's a good chance we succeed figuring out unit locations even if $HOME isn't set. Fixes: #5260
2017-02-10install: never hit assert() when we can't figure out where to write ↵Lennart Poettering
configuration symlinks Under specific circumstances it might happen that we can't figure out where to place our symlinks, for example because we are supposed to create them in the runtime directory but $XDG_RUNTIME_DIR is not set. In this case, return -ENXIO instead of hitting an assert(). (Yeah, the error isn't very descriptive, but for now this should at least be good enough to remove the assert() being hit.)
2017-02-10install: when disabling units, do so even if the unit is missingLennart Poettering
In some cases there might be unit symlinks in .wants/ or .requires/ directories even though the unit is otherwise fully removed. In this case, don't fail removal, but still remove the symlinks. This reworks the symlink marking logic to always add unit files that we are missing to the changes list, but proceed with any symlink removal for them. This way we'll still generate useful hints that a unit is missing if you invoke "systemctl disable idontexist.service", but also still remove any link to it. Fixes: #4995
2017-02-09seccomp: add forgotten munmap() syscall to @file-system (#5291)Lennart Poettering
We added mmap() and mmap2(), but forgot munmap(). Fix that. Pointed out by @lucaswerkmeister: https://github.com/systemd/systemd/pull/4537#issuecomment-273275298
2017-02-09dropin: always initialize return parameters on successLennart Poettering
Just as a matter of coding style: whenever we return successfully, let's make sure all our return parameters are properly initialized to something.
2017-02-09dropin: let's reduce duplicate a bitLennart Poettering
After generating the template name we can shortcut things and just call unit_file_find_dirs() from inside itself, just with the new name and save a good number of duplicate lines.
2017-02-09dropin: let's prefer strjoina() over strjoin()Lennart Poettering
2017-02-09dropin: downgrade logging about paths we cannot canonicalizeLennart Poettering
After all, most units won't have drop-in dirs, hence there's no point in logging about that. Fixes: #5252
2017-02-09tree-wide: make bus_map_all_properties return a proper sd_bus_errorLennart Poettering
And then show it, to make things a bit friendlier to the user if we fail acquiring some props. In fact, this fixes a number of actual bugs, where we used an error structure for output that we actually never got an error in.
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-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-08Merge pull request #5231 from keszybz/mask-wantsLennart Poettering
Mask individual .wants/.requires symlinks
2017-02-07dissect: don't honour NOAUTO flags when looking for ESP (#5224)Lennart Poettering
The flag is originally defined for "basic data partitions", but not for the ESP. We reuse it for the various partitions defined by the Discoverable Partitions Spec, but it isn't defined for the ESP, hence don't check for it. Instead, do check for GPT_FLAG_NO_BLOCK_IO_PROTOCOL, as that flag actually is defined for all partition types, and recommended to use by the UEFI spec. Fixes: #5218
2017-02-07core: drop code that is now unusedZbigniew Jędrzejewski-Szmek
2017-02-07core: when loading .wants and .requires, follow the same logic as .d conf ↵Zbigniew Jędrzejewski-Szmek
dropins Essentially, instead of sequentially adding deps based on all symlinks encountered in .wants and .requires dirs for each name and each unit file load path, iteratate over the load paths and unit names gathering symlinks, then order them based on priority, and then iterate over the final list, adding dependencies. This patch doesn't change the logic too much, except that the order in which dependencies are applied might be different. It wasn't defined before, so that not really a change. Adding filtering on the symlinks is left for later patches.
2017-02-07install: remove some unused parameters from various functions in install.cLennart Poettering
No need to pass what we don't use.
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-07install: don't enter loop when traversing a template symlinksLennart Poettering
Before this patch, if we'd encounter an instance or template symlink while traversing a chain of symlinks we'd fill in the instance name and retry the iteration. This makes no sense if the resulting name is actually the same as we are coming from, as we'd just spin a couple of times in the loop, until the UNIT_FILE_FOLLOW_SYMLINK_MAX iteration limit is hit. Fix this, by accepted the symlink as it is, if it identical to what we filled in.
2017-02-07dissect: try to read roothash value off user.verity.roothash xattr of image fileLennart Poettering
This slightly extends the roothash loading logic to first check for a user.verity.roothash extended attribute on the image file. If it exists, it is used as Verity root hash and the ".roothash" file is not used. This should improve the chance that the roothash is retained when the file is moved around, as the data snippet is attached directly to the image file. The field is still detached from the file payload however, in order to make sure it may be trusted independently. This does not replace the ".roothash" file loading, it simply adds a second way to retrieve the data. Extended attributes are often a poor choice for storing metadata like this as it is usually difficult to discover for admins and users, and hard to fix if it ever gets out of sync. However, in this case I think it's safe as verity implies read-only access, and thus there's little chance of it to get out of sync.
2017-02-07core,nspawn,dissect: make nspawn's .roothash file search reusableLennart Poettering
This makes nspawn's logic of automatically discovering the root hash of an image file generic, and then reuses it in systemd-dissect and in PID1's RootImage= logic, so that verity is automatically set up whenever we can.
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-07dissect: make sure to manually follow symlinks when mounting dissected imageLennart Poettering
If the dissected image contains symlinks for the mount points we need we need to make sure to follow this with chase_symlinks() so that we don't leave the image.
2017-02-07core: actually make "+" prefix in ReadOnlyPaths=, InaccessiblePaths=, ↵Lennart Poettering
ReadWritablePaths= work 5327c910d2fc1ae91bd0b891be92b30379c7467b claimed to add support for "+" for prefixing paths with the configured RootDirectory=. But actually it only implemented it in the backend, it did not add support for it to the configuration file parsers. Fix that now.
2017-02-07core: add a per-unit setting MountAPIVFS= for mounting /dev, /proc, /sys in ↵Lennart Poettering
conjunction with RootDirectory= This adds a boolean unit file setting MountAPIVFS=. If set, the three main API VFS mounts will be mounted for the service. This only has an effect on RootDirectory=, which it makes a ton times more useful. (This is basically the /dev + /proc + /sys mounting code posted in the original #4727, but rebased on current git, and with the automatic logic replaced by explicit logic controlled by a unit file setting)
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-05seccomp: don't ever try to add an ABI before removing the default native ABI ↵Evgeny Vereshchagin
(#5230) https://github.com/systemd/systemd/issues/5215#issuecomment-277156262 libseccomp does not allow you to add architectures to a filter that doesn't match the byte ordering of the architectures already added to the filter (it would be a mess, not to mention largely pointless) and since systemd attempts to add an ABI before removing the default native ABI, you will always fail on Power (either due to ppc or ppc64le). The fix is to remove the native ABI before adding a new ABI so you don't run into problems with byte ordering. You would likely see the same failure on a MIPS system. Thanks @pcmoore!
2017-02-03Merge pull request #4973 from poettering/run-raceMartin Pitt
run: fix race for "systemd-run --wait"
2017-02-03run: exit early in --pty if service failedLennart Poettering
This reworks systemd-run so that in --pty mode we watch the unit state the way we do it in --wait mode. Whenever we notice that the service is in failed or inactive state finish right-away, but first write all unwritten characters we can read from the master TTY device. This makes sure that when the TTY service fails before it opens the slave PTY device we properly notice that and exit early, so that borked start parameters result in immediate systemd-run failure. Previously, we'd not notice this at all, as a PTY slave that never was opened won't result in POLLHUP events, and we'd hence simply keep reading from it forever. In essence, --pty now enables the same unit watching logic that --wait enables. However, unless --wait is specified we won#t show the final summary, hence the effective difference should be pretty minimal. Fixes: #3915
2017-02-03Merge pull request #5213 from keszybz/systemctl-root-catLennart Poettering
Two fixes to path lookup when --root is used
2017-02-02ptyfwd: set event source description strings for all event sources of a ↵Lennart Poettering
ptyfwd object
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.