Commit graph

16647 commits

Author SHA1 Message Date
Lennart Poettering a4eaf3cf82 fs-util: change chase_symlinks() behaviour in regards to escaping the root dir
Previously, we'd generate an EINVAL error if it is attempted to escape a root
directory with relative ".." symlinks. With this commit this is changed so that
".." from the root directory is a NOP, following the kernel's own behaviour
where /.. is equivalent to /.

As suggested by @keszybz.
2016-12-01 00:25:51 +01:00
Zbigniew Jędrzejewski-Szmek df878e682d test-fs-util: add a test case with repeated ".." parts that would escape the root 2016-12-01 00:25:51 +01:00
Lennart Poettering 68cf43c315 nspawn: use chase_symlinks() on all paths specified via --tmpfs=, --bind= and so on
Fixes: #2860
2016-12-01 00:25:51 +01:00
Lennart Poettering fc4b68e557 fs-util: add chase_symlinks_prefix() and extend comments
chase_symlinks() currently expects a fully qualified, absolute path, relative
to the host's root as first argument. Which is useful in many ways, and similar
to the paths unlink(), rename(), open(), … expect. Sometimes it's however
useful to first prefix the specified path with the specified root directory.
Add a new call chase_symlinks_prefix() for this, that is a simple wrapper.
2016-12-01 00:25:51 +01:00
Lennart Poettering 4da92e5857 nspawn: coding style: don't mix variable declarations and function calls 2016-12-01 00:25:51 +01:00
Lennart Poettering 5639193139 nspawn: use realloc_multiply() where it makes sense 2016-12-01 00:25:51 +01:00
Lennart Poettering 8cd328d82e nspawn: accept --ephemeral --template= as alternative for --ephemeral --directory=
As suggested in PR #3667.

This PR simply ensures that --template= can be used as alternative to
--directory= when --ephemeral is used, following the logic that for ephemeral
options the source directory is actually a template.

This does not deprecate usage of --directory= with --ephemeral, as I am not
convinced the old logic wouldn't make sense.

Fixes: #3667
2016-12-01 00:25:51 +01:00
Lennart Poettering 3f342ec4b0 nspawn: properly handle image/directory paths that are symlinks
This resolves any paths specified on --directory=, --template=, and --image=
before using them. This makes sure nspawn can be used correctly on symlinked
images and directory trees.

Fixes: #2001
2016-12-01 00:25:51 +01:00
Lennart Poettering e187369587 tree-wide: stop using canonicalize_file_name(), use chase_symlinks() instead
Let's use chase_symlinks() everywhere, and stop using GNU
canonicalize_file_name() everywhere. For most cases this should not change
behaviour, however increase exposure of our function to get better tested. Most
importantly in a few cases (most notably nspawn) it can take the correct root
directory into account when chasing symlinks.
2016-12-01 00:25:51 +01:00
Lennart Poettering c9d5c9c0e1 core: make unit_free() accept NULL pointers
We generally try to make our destructors robust regarding NULL pointers, much
in the same way as glibc's free(). Do this also for unit_free().

Follow-up for #4748.
2016-12-01 00:25:51 +01:00
Franck Bui c5024cd05c systemctl: fix 'is-enabled' exit status on failure when executed in chroot (#4773) 2016-11-30 18:27:42 +01:00
Susant Sahani 730389b6dc As per use case we should allow ForwardDelaySec to be set as 0 (#4765)
So let's set ForwardDelaySec to USEC_INFINITY .

Reference:
https://wiki.linuxfoundation.org/networking/bridge#does-dhcp-work-overthrough-a-bridge
2016-11-30 11:54:42 +01:00
Evgeny Vereshchagin 97506e85e2 Merge pull request #4745 from joukewitteveen/notify
Improvements for notify services (including #4212)
2016-11-30 03:22:07 +03:00
Jouke Witteveen 6375bd2007 service: new NotifyAccess= value for control processes (#4212)
Setting NotifyAccess=exec allows notifications coming directly from any
control process.
2016-11-29 23:20:04 +01:00
Jouke Witteveen 7ed0a4c537 bus-util: add protocol error type explanation 2016-11-29 23:19:52 +01:00
Dongsu Park e7330dfe14 cgroup: support prefix "-" in cgroups whitelisting entries (#4687)
So far systemd-nspawn container has been creating files under
/run/systemd/inaccessible, no matter whether it's running in user
namespace or not. That's fine for regular files, dirs, socks, fifos.
However, it's not for block and character devices, because kernel
doesn't allow them to be created under user namespace. It results
in warnings at booting like that:

====
  Couldn't stat device /run/systemd/inaccessible/chr
  Couldn't stat device /run/systemd/inaccessible/blk
====

Thus we need to have the cgroups whitelisting handler to silently ignore
a file, when the device path is prefixed with "-". That's exactly the
same convention used in directives like ReadOnlyPaths=. Also insert the
prefix "-" to inaccessible entries.
2016-11-29 20:16:55 +01:00
Stefan Berger e8e42b31c5 ima: Write the policy filename into IMA's sysfs policy file (#4766)
IMA validates file signatures based on the security.ima xattr. As of
Linux-4.7, instead of copying the IMA policy into the securityfs policy,
the IMA policy pathname can be written, allowing the IMA policy file
signature to be validated.

This patch modifies the existing code to first attempt to write the
pathname, but on failure falls back to copying the IMA policy contents.
2016-11-29 10:47:20 -05:00
Jouke Witteveen 3c9512c71d service: prevent registering control pids as the main pid
We assume a process can be only one of the two in service_sigchld_event.
2016-11-29 10:34:33 +01:00
Jouke Witteveen 71e529fcf1 service: only fail notify services on empty cgroup during start
We stay in the SERVICE_START while no READY=1 notification message has
been received. When we are in the SERVICE_START_POST state, we have
already received a ready notification. Hence we should not fail when the
cgroup becomes empty in that state.
2016-11-29 10:34:33 +01:00
Martin Pitt 920ec31b5f Merge pull request #4761 from fsateler/python3
Explicitly use python3 everywhere
2016-11-28 21:10:57 +01:00
Tom Gundersen b76d99d9e6 networkd: move event loop handling out of the manager (#4723)
This will allow us to have several managers sharing an event loop
and running in parallel, as if they were running in separate processes.

The long term-aim is to allow networkd to be split into separate
processes, so restructure the code to make this simpler.

For now we drop the exit-on-idle logic, as this was anyway severely
restricted at the moment. Once split, we will revisit this as it may
then make more sense again.
2016-11-28 20:42:40 +01:00
Felipe Sateler b95f5528cc Use python3 explicitly in all python scripts 2016-11-28 15:00:20 -03:00
(GalaxyMaster) dc3b8afb93 socket-proxyd: Introduced dynamic connection limit via an option. (#4749) 2016-11-28 18:25:11 +01:00
Daniel Wagner a92cf7840f udevd: check correct return value of fcntl() (#4758)
This looks like a copy&paste error from the code block above.
2016-11-28 18:24:26 +01:00
Dave Reisner d112eae7da device: Avoid calling unit_free(NULL) in device setup logic (#4748)
Since a581e45ae8, there's a few function calls to
unit_new_for_name which will unit_free on failure. Prior to this commit,
a failure would result in calling unit_free with a NULL unit, and hit an
assertion failure, seen at least via device_setup_unit:

Assertion 'u' failed at src/core/unit.c:519, function unit_free().  Aborting.

Fixes #4747
https://bugs.archlinux.org/task/51950
2016-11-27 23:05:39 +01:00
Djalal Harouni a748a0169a Merge pull request #4736 from dobyrch/calendar-cleanup
calendarspec: miscellaneous parsing and formatting fixes
2016-11-27 11:43:26 +01:00
Douglas Christman 7c2503218e calendarspec: refactor format_chain()
Factor out repeated references to usec and remove nested ifs.
2016-11-25 11:21:21 -05:00
Waldemar Brodkorb 9bab3b65b0 fix journald startup problem when code is compiled with -DNDEBUG (#4735)
Similar to this patch from here:
http://systemd-devel.freedesktop.narkive.com/AvfCbi6c/patch-0-3-using-assert-se-on-actions-with-side-effects-on-test-cases

If the code is compiled with -DNDEBUG which is the default for
some embedded buildsystems, systemd-journald does not startup
and silently fails.
2016-11-25 11:24:58 +01:00
Douglas Christman c58b1b3abf calendarspec: rename "eom" to "end_of_month" 2016-11-24 18:40:14 -05:00
Douglas Christman 9904dc00e7 calendarspec: make specifications with ranges reversible
"*-*-01..03" is now formatted as "*-*-01..03" instead of "*-*-01,02,03"
2016-11-24 18:40:14 -05:00
Douglas Christman 36ff0c9792 calendarspec: allow whole second ranges
Previously a string like "00:00:01..03" would fail to parse due to the
ambiguity between a decimal point and the start of a range.
2016-11-24 18:22:08 -05:00
Douglas Christman 3215e35c40 calendarspec: make specifications with seconds wildcard reversible
"*:*:*" is now formatted as "*:*:*" instead of "*:*:00/1"
2016-11-24 18:22:08 -05:00
Douglas Christman 9dfa81a00a calendarspec: reject strings with spurious spaces and signs
strtoul() parses leading whitespace and an optional sign;
check that the first character is a digit to prevent odd
specifications like "00:  00:  00" and "-00:+00/-1".
2016-11-24 18:22:08 -05:00
Douglas Christman 6bae2fd4cd calendarspec: reject open weekday ranges
Forbid open ranges like "Tue.."; trailing commas are still OK.
2016-11-24 18:22:08 -05:00
Douglas Christman 04773cb50a calendarspec: reject strings that only contain a timezone
This makes " UTC" an illegal date specification.
2016-11-24 18:22:08 -05:00
Douglas Christman 408a51e156 calendarspec: always interpret a missing time as 00:00:00
"*-*-*" is now equivalent to "*-*-* 00:00:00" (daily)
rather than "*-*-* *:*:*" (every second).
2016-11-24 18:22:08 -05:00
Franck Bui acc28e2e30 core: make sure initrd-switch-root command survives PID1's killing spree (#4730)
This is a different way to implement the fix proposed by commit
a4021390fe suggested by Lennart Poettering.

In this patch we instruct PID1 to not kill "systemctl switch-root" command
started by initrd-switch-root service using the "argv[0][0]='@'" trick.

See: https://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/ for
more details.

We had to backup argv[0] because argv is modified by dispatch_verb().
2016-11-24 18:52:04 +01:00
Lennart Poettering bbe16abb61 Merge pull request #4710 from martinpitt/networkd-dbus
networkd: allow networkd to start in early boot
2016-11-24 01:58:33 +01:00
Susant Sahani d6fceaf1f7 networkd: handle MTU field in IPv6 RA (#4719)
This patch handles the custom MTU field in IPv6 RA.

fixes RFE #4464
2016-11-23 22:32:19 +01:00
Lennart Poettering 99245111ac Merge pull request #4703 from dobyrch/calendar-offset
calendarspec: add support for scheduling timers at the end of the month
2016-11-23 22:31:01 +01:00
Michael Biebl 331d6a201b hwdb: use systemd-hwdb instead of obsolete udevadm hwdb (#4722)
Fixes: #4721
2016-11-23 19:21:56 +01:00
Douglas Christman 8ea803516e calendarspec: add support for scheduling timers at the end of the month
"*-*~1"       => The last day of every month
"*-02~3..5"   => The third, fourth, and fifth last days in February
"Mon 05~07/1" => The last Monday in May

Resolves #3861
2016-11-23 12:37:43 -05:00
Douglas Christman f6e7d66b9f calendarspec: add upper bound on year
Stop looking for matches after MAX_YEAR so impossible dates like
"*-02-30" and "*-04-31" don't cause an infinite loop.
2016-11-23 12:28:00 -05:00
Martin Pitt 7901cea199 networkd: set DHCP-acquired timezone and hostname after connecting to D-Bus
If setting the received timezone or transient hostname fails because D-Bus is
not (yet) up, store the data in the Manager object and try again after
connecting to D-Bus.
2016-11-23 17:05:10 +01:00
Lennart Poettering fadc06bb81 Merge pull request #4259 from joukewitteveen/notify
service: fix main processes exit behavior for type notify services
2016-11-23 16:45:19 +01:00
Susant Sahani b8b40317d0 networkd: fix size of MTUBytes so that it does not overwrites ARP (#4707)
config_parse_iec_size overwrites the next varible that is ARP.
Now the mtu is unsigned . Make it size_t .

Fixes #4644
2016-11-23 16:33:01 +01:00
Martin Pitt 2c99aba726 networkd: allow networkd to set the timezone in timedated
systemd-networkd runs as user "systemd-network" and thus is not privileged to
set the timezone acquired from DHCP:

  systemd-networkd[4167]: test_eth42: Could not set timezone: Interactive authentication required.

Similarly to commit e8c0de912, add a polkit rule to grant
org.freedesktop.timedate1.set-timezone to the "systemd-network" system user.
Move the polkit rules from src/hostname/ to src/network/ to avoid too many
small distributed policy snippets (there might be more in the future), as it's
easier to specify the privileges for a particular subject in this case.

Add NetworkdClientTest.test_dhcp_timezone() test case to verify this (for
all people except those in Pacific/Honolulu, there the test doesn't prove
anything -- sorry ☺ ).
2016-11-23 16:32:06 +01:00
Martin Pitt 59eb33e0fe networkd: move setting hostname and timezone to Manager
Hostname and time zone are global settings, not link specific.  Move these
methods from Link into Manager.
2016-11-23 16:32:06 +01:00
Zbigniew Jędrzejewski-Szmek ee43050b40 Merge pull request #4692 from poettering/networkd-dhcp
Various networkd/DHCP fixes.
2016-11-22 23:22:04 -05:00
Jouke Witteveen 3d474ef7a6 service: fix main processes exit behavior for type notify services
Before this commit, when the main process of a Type=notify service exits the
service would enter a running state without passing through the startup post
state. This meant ExecStartPost= from being executed and allowed follow-up
units to start too early (before the ready notification).
Additionally, when RemainAfterExit=yes is used on a Type=notify service, the
exit status of the main process would be disregarded.

After this commit, an unsuccessful exit of the main process of a Type=notify
service puts the unit in a failed state. A successful exit is inconsequential
in case RemainAfterExit=yes. Otherwise, when no ready notification has been
received, the unit is put in a failed state because it has never been active.
When all processes in the cgroup of a Type=notify service are gone and no ready
notification has been received yet, the unit is also put in a failed state.
2016-11-22 17:54:27 +01:00