Commit graph

2509 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 825fd3cd41 Merge (¾ of) pull request #5596 from matijaskala/master 2017-03-16 08:42:22 -04:00
Djalal Harouni d1d59eeb47 base-filesystem: skip fchownat() if the previous mkdirat() on same path failed (#5548)
If we are working on a path that was marked to be ignored on errors, and
the mkdirat() fails then add a continue statement and skip fchownat() call.
This avoids the case where UID/GID are valid and we run fchownat() on
non existent path which will fail hard even on paths that we want to
ignore in case of errors.
2017-03-15 22:30:15 -04:00
Matija Skala e5276995ae assigning stdout and stderr is not allowed 2017-03-16 03:24:49 +01:00
Michael Biebl dcce98a4bd Avoid strict DM interface version dependencies (#5519)
Compiling against the dm-ioctl.h header as provided by the Linux kernel
will embed the DM interface version number. Running an older kernel can
result in an error like this on shutdown:

Could not detach DM dm-11: ioctl mismatch, kernel(4.34.4), user(4.35.4)

Work around this by shipping a local copy of dm-ioctl.h. We need at
least the version from 3.13 for DM_DEFERRED_REMOVE [1], so bump the
requirements in README accordingly.

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2c140a246dc0bc085b98eddde978060fcec1080c

Fixes: #5492
2017-03-02 19:11:37 +01:00
Zbigniew Jędrzejewski-Szmek 4f37cbd911 journalctl: move access_check() to shared/
The only functional change is that log_notice("No journal files were found.")
is not printed any more with --quiet. log_error("No journal files were opened
due to insufficient permissions.") is still printed.

I wasn't quite sure where to put this function, but shared/ seems to be the
right place and none of the existing files seem to fit too well.

v2: rename journal_access_check to journal_access_check_and_warn.
2017-02-28 21:37:35 -05:00
Martin Pitt 4059584718 Merge pull request #5449 from keszybz/blkd-error-handling
blkid error handling
2017-02-25 12:25:27 +01:00
AsciiWolf 13e785f7a0 Fix missing space in comments (#5439) 2017-02-24 18:14:02 +01:00
Zbigniew Jędrzejewski-Szmek b382db9f3b tree-wide: simplify handling of blkid errors 2017-02-21 16:41:33 -05:00
Lennart Poettering a4dde27d73 Merge pull request #5131 from keszybz/environment-generators
Environment generators
2017-02-21 11:11:44 +01:00
Zbigniew Jędrzejewski-Szmek f63c4aabb2 environment-generator: new generator to peruse environment.d
Why the strange name: the prefix is necessary to follow our own advice that
environment generators should have numerical prefixes. I also put -d- in the
name because otherwise the name was very easy to mistake with
systemd.environment-generator. This additional letter clarifies that this
on special generator that supports environment.d files.
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek 0357fa0dce shared/pager: abort if we cannot set environment variables
This most likely means oom, it's better to exit than to run less with
incomplete settings.

CID #714383.
2017-02-20 16:02:18 -05:00
Zbigniew Jędrzejewski-Szmek f28501279d firewall-util: add an assert that we're not overwriting a buffer
Check for CID #1368267.
2017-02-20 16:02:15 -05:00
Adrián López ef6e596ff0 systemctl: show extra args if defined (#5379) 2017-02-17 15:27:45 -05:00
Lennart Poettering 1c876927e4 copy: change the various copy_xyz() calls to take a unified flags parameter
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-17 10:22:28 +01:00
Martin Pitt cc100a5a9b test: drop TEST_DATA_DIR, fold into get_testdata_dir()
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-16 21:45:57 +01:00
Martin Pitt c60b6ddafb test: show error message if $SYSTEMD_TEST_DATA does not exist
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-16 21:36:31 +01:00
Zbigniew Jędrzejewski-Szmek 1f35a3b2a4 tests: look for tests relative to source dir when running from build dir
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-16 21:36:31 +01:00
Zbigniew Jędrzejewski-Szmek 94fa1497ba Rename $TEST_DIR to $SYSTEMD_TEST_DATA, document it
TEST_DIR is rather generic, and we prefix all variables used by installed
executables with "SYSTEMD_".
2017-02-16 21:36:31 +01:00
Martin Pitt 31f8b331c7 test: clarify error message if test data directory does not exist
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-16 21:36:30 +01:00
Zbigniew Jędrzejewski-Szmek 290f0ff9aa Define clone order on ppc (#5325)
This was tested on ppc64le. Assume the same is true for ppc64.
2017-02-14 11:27:40 +01:00
Martin Pitt f853c6efb5 test: make unit tests relocatable
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-13 22:31:13 +01:00
Lennart Poettering 9606bc4b4b seccomp: disable RestrictAddressFamilies= for the ABI we shall block, not the one we are compiled for (#5272)
It's a difference. Not a big one, but let's be correct here.
2017-02-12 15:25:40 -05:00
Zbigniew Jędrzejewski-Szmek 179e679edd Merge pull request #5276 from poettering/resolved-cname
a good number of resolved fixes
2017-02-12 15:08:19 -05:00
Evgeny Vereshchagin 0d7578dc30 shared: pass *unsigned_long to namespace_flag_from_string_many (#5315)
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-12 00:38:16 -05:00
Evgeny Vereshchagin b9e2d822d0 shared: convert unsigned long to uint64_t explicitly (#5314)
Closes #5313
2017-02-12 00:36:34 -05:00
Zbigniew Jędrzejewski-Szmek e0686b73ac Merge pull request #5303 from poettering/deleted-units
a small number of install and unit management related fixes
2017-02-12 00:31:39 -05:00
Lennart Poettering f2d9751c59 seccomp: order seccomp ABI list, so that our native ABI comes last (#5306)
this way, we can still call seccomp ourselves, even if seccomp() is
blocked by the filter we are installing.

Fixes: #5300
2017-02-10 23:47:50 +01:00
Lennart Poettering c3c7eb7d7d path-lookup: if $HOME can be determined but $XDG_RUNTIME_DIR can't, is it
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-10 15:18:23 +01:00
Lennart Poettering b9418b053a path-lookup: drop redundant strv_isempty() check
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-10 15:17:18 +01:00
Lennart Poettering c49970743e path-lookup: try harder acquiring them $HOME of a user
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-10 15:16:11 +01:00
Lennart Poettering d0fd66a379 install: never hit assert() when we can't figure out where to write 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-10 15:14:18 +01:00
Lennart Poettering 637d6e5b9c install: when disabling units, do so even if the unit is missing
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-10 14:36:17 +01:00
Lennart Poettering 7961116e2c seccomp: add forgotten munmap() syscall to @file-system (#5291)
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-09 21:29:33 -05:00
Lennart Poettering 058db92528 dropin: always initialize return parameters on success
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-09 20:10:03 +01:00
Lennart Poettering a09d3eafac dropin: let's reduce duplicate a bit
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-09 20:08:58 +01:00
Lennart Poettering 96bb2fd8bd dropin: let's prefer strjoina() over strjoin() 2017-02-09 20:08:44 +01:00
Lennart Poettering 09c624878a dropin: downgrade logging about paths we cannot canonicalize
After all, most units won't have drop-in dirs, hence there's no point in
logging about that.

Fixes: #5252
2017-02-09 20:08:24 +01:00
Lennart Poettering f9e0eefc7c tree-wide: make bus_map_all_properties return a proper sd_bus_error
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-09 16:13:07 +01:00
Zbigniew Jędrzejewski-Szmek fc6149a6ce Merge pull request #4962 from poettering/root-directory-2
Add new MountAPIVFS= boolean unit file setting + RootImage=
2017-02-08 23:05:05 -05:00
Lennart Poettering ae9d60ce4e seccomp: on s390 the clone() parameters are reversed
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-08 22:21:27 +01:00
Lennart Poettering 8a50cf6957 seccomp: MemoryDenyWriteExecute= should affect both mmap() and mmap2() (#5254)
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-08 15:14:02 +01:00
Lennart Poettering b6f08ecda9 Merge pull request #5231 from keszybz/mask-wants
Mask individual .wants/.requires symlinks
2017-02-08 14:50:56 +01:00
Lennart Poettering a48dd3475b dissect: don't honour NOAUTO flags when looking for ESP (#5224)
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-07 22:10:48 -05:00
Zbigniew Jędrzejewski-Szmek dcc4f30ecc core: drop code that is now unused 2017-02-07 21:31:59 -05:00
Zbigniew Jędrzejewski-Szmek 9577878210 core: when loading .wants and .requires, follow the same logic as .d conf 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-07 21:31:22 -05:00
Lennart Poettering 80cb9da358 install: remove some unused parameters from various functions in install.c
No need to pass what we don't use.
2017-02-07 20:22:09 +01:00
Lennart Poettering dfead90d93 install: when a template unit is instantiated via a /usr symlink, consider 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-07 20:16:12 +01:00
Lennart Poettering 9f6cbcf53c install: don't enter loop when traversing a template symlinks
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-07 16:22:49 +01:00
Lennart Poettering 41488e1f7a dissect: try to read roothash value off user.verity.roothash xattr of image file
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-07 12:21:29 +01:00
Lennart Poettering 78ebe98061 core,nspawn,dissect: make nspawn's .roothash file search reusable
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-07 12:21:28 +01:00