Commit Graph

23390 Commits

Author SHA1 Message Date
Lennart Poettering 63fdeeb7df update TODO 2015-11-12 22:04:49 +01:00
Lennart Poettering f6d6bad146 nspawn: add new --network-veth-extra= switch for defining additional veth links
The new switch operates like --network-veth, but may be specified
multiple times (to define multiple link pairs) and allows flexible
definition of the interface names.

This is an independent reimplementation of #1678, but defines different
semantics, keeping the behaviour completely independent of
--network-veth. It also comes will full hook-up for .nspawn files, and
the matching documentation.
2015-11-12 22:04:49 +01:00
Lennart Poettering 76e0779b5c Merge pull request #1870 from evverx/clarify_set_priority
core: use SD_EVENT_PRIORITY_NORMAL-n instead on -n
2015-11-12 22:01:41 +01:00
Evgeny Vereshchagin df0060346a core: use SD_EVENT_PRIORITY_NORMAL-n instead on -n 2015-11-12 19:54:34 +00:00
Lennart Poettering b0bcf47221 Merge pull request #1868 from teg/ndisc-fix
sd-ndisc: add missing parens
2015-11-12 20:27:51 +01:00
Daniel Mack f1637bd3a8 Merge pull request #1515 from poettering/install-symlink
install: follow unit file symlinks in /usr, but not /etc when looking for [Install] data and more
2015-11-12 18:18:45 +01:00
Lennart Poettering 79413b673b core: simplify handling of %u, %U, %s and %h unit file specifiers
Previously, the %u, %U, %s and %h specifiers would resolve to the user
name, numeric user ID, shell and home directory of the user configured
in the User= setting of a unit file, or the user of the manager instance
if no User= setting was configured. That at least was the theory. In
real-life this was not ever actually useful:

- For the systemd --user instance it made no sense to ever set User=,
  since the instance runs in user context after all, and hence the
  privileges to change user IDs don't even exist. The four specifiers
  were actually not useful at all in this case.

- For the systemd --system instance we did not allow any resolving that
  would require NSS. Hence, %s and %h were not supported, unless
  User=root was set, in which case they would be hardcoded to /bin/sh
  and /root, to avoid NSS. Then, %u would actually resolve to whatever
  was set with User=, but %U would only resolve to the numeric UID of
  that setting if the User= was specified in numeric form, or happened
  to be root (in which case 0 was hardcoded as mapping). Two of the
  specifiers are entirely useless in this case, one is realistically
  also useless, and one is pretty pointless.

- Resolving of these settings would only happen if User= was actually
  set *before* the specifiers where resolved. This behaviour was
  undocumented and is really ugly, as specifiers should actually be
  considered something that applies to the whole file equally,
  independently of order...

With this change, %u, %U, %s and %h are drastically simplified: they now
always refer to the user that is running the service instance, and the
user configured in the unit file is irrelevant. For the system instance
of systemd this means they always resolve to "root", "0", "/bin/sh" and
"/root", thus avoiding NSS. For the user instance, to the data for the
specific user.

The new behaviour is identical to the old behaviour in all --user cases
and for all units that have no User= set (or set to "0" or "root").
2015-11-12 17:57:04 +01:00
Lennart Poettering 485630813d man: improve the unit file enable state table a bit 2015-11-12 17:57:04 +01:00
Lennart Poettering 0ec0deaa30 install: follow unit file symlinks in /usr, but not /etc when looking for [Install] data
Some distributions use alias unit files via symlinks in /usr to cover
for legacy service names. With this change we'll allow "systemctl
enable" on such aliases.

Previously, our rule was that symlinks are user configuration that
"systemctl enable" + "systemctl disable" creates and removes, while unit
files is where the instructions to do so are store. As a result of the
rule we'd never read install information through symlinks, since that
would mix enablement state with installation instructions.

Now, the new rule is that only symlinks inside of /etc are
configuration. Unit files, and symlinks in /usr are now valid for
installation instructions.

This patch is quite a rework of the whole install logic, and makes the
following addional changes:

- Adds a complete test "test-instal-root" that tests the install logic
  pretty comprehensively.

- Never uses canonicalize_file_name(), because that's incompatible with
  operation relative to a specific root directory.

- unit_file_get_state() is reworked to return a proper error, and
  returns the state in a call-by-ref parameter. This cleans up confusion
  between the enum type and errno-like errors.

- The new logic puts a limit on how long to follow unit file symlinks:
  it will do so only for 64 steps at max.

- The InstallContext object's fields are renamed to will_process and
  has_processed (will_install and has_installed) since they are also
  used for deinstallation and all kinds of other operations.

- The root directory is always verified before use.

- install.c is reordered to place the exported functions together.

- Stricter rules are followed when traversing symlinks: the unit suffix
  must say identical, and it's not allowed to link between regular units
  and templated units.

- Various modernizations

- The "invalid" unit file state has been renamed to "bad", in order to
  avoid confusion between UNIT_FILE_INVALID and
  _UNIT_FILE_STATE_INVALID. Given that the state should normally not be
  seen and is not documented this should not be a problematic change.
  The new name is now documented however.

Fixes #1375, #1718, #1706
2015-11-12 17:57:04 +01:00
Lennart Poettering d073dea0a8 install: never log from install functions
Instead, let the caller do that. Fix this by moving masked unit messages
into the caller, by returning a clear error code (ESHUTDOWN) by which
this may be detected.
2015-11-12 17:56:49 +01:00
Lennart Poettering d25e100bd6 install: various simplifications 2015-11-12 17:56:49 +01:00
Tom Gundersen 133dd71fdd sd-ndisc: add missing parens
Reported by Thomas Andersen.
2015-11-12 16:37:18 +01:00
Lennart Poettering 05c450966a Merge pull request #1865 from msekletar/build-man-list
build-sys: fix dependencies
2015-11-12 14:28:53 +01:00
Michal Sekletar 100582b8cc build-sys: fix dependencies
update-man-list needs man/custom-entities.ent. Bug is nicely reproducible when
running make update-man-list.
2015-11-12 14:07:41 +01:00
Daniel Mack 1f920a3381 Merge pull request #1863 from poettering/network-man
man patch fix, and port journalctl --sync to use CLOCK_MONOTONIC timestamp files
2015-11-12 13:57:38 +01:00
Daniel Mack aafdda2238 Merge pull request #1864 from poettering/remove-smack-fs-root-label
core: remove SmackFileSystemRootLabel= again
2015-11-12 13:54:54 +01:00
Lennart Poettering a11c7ea52c NEWS: begin putting together a NEWS section for the next release 2015-11-12 13:40:25 +01:00
Lennart Poettering 2a2e1b36a0 core: remove SmackFileSystemRootLabel= again
Apparently, util-linux' mount command implicitly drops the smack-related
options anyway before passing them to the kernel, if the kernel doesn't
know SMACK, hence there's no point in duplicating this in systemd.

Fixes #1696
2015-11-12 12:50:59 +01:00
Lennart Poettering 4de2402b60 journald: fix accuracy of watchdog timer event
Adding 3/4th of the watchdog frequency as accuracy on top of 1/2 of the
watchdog frequency means we might end up at 5/4th of the frequency which
means we might miss the message from time to time.

Maybe fixes #1804
2015-11-12 12:33:10 +01:00
Lennart Poettering 33d52ab92f journald: rework --sync/--rotate logic to use CLOCK_MONOTONIC timestamp files
Previously, we'd rely on the mtime timestamps of the touch files to see
if our sync/rotation requests were already suppressed. This means we
rely on CLOCK_REALTIME timestamps. With this patch we instead store the
CLOCK_MONOTONIC timestamp *in* the touch files, and avoid relying on
mtime.

This should make things more reliable when the clock or underlying mtime
granularity is not very good.

This also adds warning messages if writing any of the flag files fails.
2015-11-12 11:17:01 +01:00
Lennart Poettering b97e7fabae man: add more (and simpler examples) to network.link(5) 2015-11-12 11:16:17 +01:00
Daniel Mack e87e7f5651 Merge pull request #1857 from evverx/fix-unstoppable
tests: fix unstoppable service
2015-11-12 10:15:51 +01:00
Daniel Mack 7fcaf31e39 Merge pull request #1862 from torstehu/fix-typo2
core: fix typo
2015-11-12 10:15:19 +01:00
Torstein Husebø 92bed4620a core: fix typo 2015-11-12 08:23:21 +01:00
Evgeny Vereshchagin b04b3e5803 tests: fix unstoppable service
[/etc/systemd/system/unstoppable.service:4] Unbalanced quoting,
ignoring: "/bin/echo 'I'm unstoppable!'"
2015-11-12 03:24:10 +00:00
Tom Gundersen fb5c8184a9 Merge pull request #1854 from poettering/unit-deps
Dependency engine improvements
2015-11-11 23:14:12 +01:00
Lennart Poettering ee735086f8 util-lib: use MODE_INVALID as invalid value for mode_t everywhere 2015-11-11 22:54:56 +01:00
Lennart Poettering c89f52ac69 core: fix dependency parsing
3d793d2905 broke parsing of unit file
names that include backslashes, as extract_first_word() strips those.
Fix this, by introducing a new EXTRACT_RETAIN_ESCAPE flag which disables
looking at any flags, thus being compatible with the classic
FOREACH_WORD() behaviour.
2015-11-11 22:53:05 +01:00
Lennart Poettering a9ae08421e Merge pull request #1806 from mbachry/ipv6-test-fix
test: fix failing test-socket-util when running with ipv6.disable=1 kernel param
2015-11-11 21:00:42 +01:00
Lennart Poettering c129bd5df3 man: document automatic dependencies
For all units ensure there's an "Automatic Dependencies" section in the
man page, and explain which dependencies are automatically added in all
cases, and which ones are added on top if DefaultDependencies=yes is
set.

This is also done for systemd.exec(5), systemd.resource-control(5) and
systemd.unit(5) as these pages describe common behaviour of various unit
types.
2015-11-11 20:47:07 +01:00
Lennart Poettering ea0ec5cea7 core: simplify mount unit dependency generation a bit
Let's make the code a bit more explicit. Should not change execution
logic in any way.
2015-11-11 20:46:34 +01:00
Lennart Poettering 4c9ea260ae core: simplify things a bit by checking default_dependencies boolean in callee, not caller
It's nicer to hide the check away in the various
xyz_add_default_dependencies() calls, rather than making it explicit in
the caller, and thus require deeper nesing.
2015-11-11 20:42:39 +01:00
Lennart Poettering 45f06b3450 core: pull in dbus.socket from Type=dbus services
Do so only on non-kdbus systems. And on non-kdbus systems don't bother
with .busname units.
2015-11-11 20:40:57 +01:00
Lennart Poettering cb4c247d48 core: change default deps of services to require sysinit.target instead of basic.target
With this change services by default will no longer require
basic.target, but instead only after it it via After=basic.target.
However, they will still Require= on sysinit.target.

This has the benefit that when booting into emergency mode it is
relatively safe to actviate individual services, as this will not pull
the entirety of basic.target anymore, thus avoid everything listed in
sockets.target and suchlike. However, during the usual boot no change
should be noticed.
2015-11-11 20:40:57 +01:00
Lennart Poettering 2376020393 Merge pull request #1851 from teg/networkd-drop-foreign
networkd: link - drop foreign config when configuring link
2015-11-11 18:47:12 +01:00
Lennart Poettering a1350640ba Merge pull request #1852 from filbranden/passenv6
execute: Add new PassEnvironment= directive (v4)
2015-11-11 18:46:15 +01:00
Filipe Brandenburger e1abca2ee4 test-execute: Clarify interaction of PassEnvironment= and MANAGER_USER
@evverx brought up that test-execute runs under MANAGER_USER which
forwards all its environment variables to the services. It turns out it
only forwards those that were in the environment at the time of manager
creation, so this test was still working.

It was still possible to attack it by running something like:
  $ sudo VAR1=a VAR2=b VAR3=c ./test-execute

Prevent that attack by unsetting the three variables explicitly before
creating the manager for the test case.

Also add comments explaining the interactions with MANAGER_USER and,
while it has some caveats, this tests are still valid in that context.

Tested by checking that the test running with the variables set from the
external environment will still pass.
2015-11-11 09:24:34 -08:00
Filipe Brandenburger 4c80d201ac test-execute: Add tests for new PassEnvironment= directive
Check the base case, plus erasing the list, listing the same variable
name more than once and when variables are absent from the manager
execution environment.

Confirmed that `sudo ./test-execute` passes and that modifying the test
cases (or the values of the set variables in test-execute.c) is enough
to make the test cases fail.
2015-11-11 07:55:23 -08:00
Evgeny Vereshchagin 4ad4beec7f tests: add test for config_parse_pass_environ 2015-11-11 07:55:23 -08:00
Filipe Brandenburger b4c14404b3 execute: Add new PassEnvironment= directive
This directive allows passing environment variables from the system
manager to spawned services. Variables in the system manager can be set
inside a container by passing `--set-env=...` options to systemd-spawn.

Tested with an on-disk test.service unit. Tested using multiple variable
names on a single line, with an empty setting to clear the current list
of variables, with non-existing variables.

Tested using `systemd-run -p PassEnvironment=VARNAME` to confirm it
works with transient units.

Confirmed that `systemctl show` will display the PassEnvironment
settings.

Checked that man pages are generated correctly.

No regressions in `make check`.
2015-11-11 07:55:23 -08:00
Marcin Bachry 4ebc62ec87 test: fix failing test-socket-util when running with ipv6.disable=1 kernel param
The ability to use inet_pton(AF_INET6, ...) doesn't depend on kernel
ipv6 support (inet_pton is a pure libc function), so make ipv6 address
parsing tests unconditional.
2015-11-11 16:54:11 +01:00
Lennart Poettering a020b3b332 journalctl: change repeated if checks into switch blocks
No functional changes.
2015-11-11 16:21:30 +01:00
Tom Gundersen 5e5b137acc networkd: link - drop foreign config when configuring link
This is a change in behavior:

Before we would never remove any state, only add to it, we now drop unwanted
state from any link the moment we start managing it.

Note however, that we still will not remove any foreign state added at runtime,
to avoid any feedback loops. However, we make no guarantees about coexisting
with third-party tools that change the state of the links we manage.
2015-11-11 16:16:47 +01:00
Lennart Poettering 176ee07b69 journalctl: refuse to --machine= in combination with --flush, --sync or --rotate 2015-11-11 16:04:29 +01:00
Lennart Poettering 85ae4be4f1 units: fix system.slice to require -.slice, instead of just want it 2015-11-11 16:04:16 +01:00
Daniel Mack 3116c225d2 Merge pull request #1843 from teg/ndisc
ndisc and dhcpv6
2015-11-11 16:03:05 +01:00
Tom Gundersen 4058d339f5 networkd: improve logging 2015-11-11 15:42:38 +01:00
Tom Gundersen e7ab854c6c networkd: link - track state of IPv6LL address
This is managed by the kernel, but we should track whether or not we have
a configured IPv6LL address. This fixes two issues:
 - we now wait for IPv6LL before considering the link ready
 - we now wait for IPv6LL before attempting to do NDisc or DHCPv6
   these protocols relies on an LL address being available.
2015-11-11 15:42:38 +01:00
Tom Gundersen 3b015d40c1 networkd: ndisc - handle router advertisement in userspace
Router Discovery is a core part of IPv6, which by default is handled by the kernel.
However, the kernel implementation is meant as a fall-back, and to fully support
the protocol a userspace implementation is desired.

The protocol essentially listens for Router Advertisement packets from routers
on the local link and use these to configure the client automatically. The four
main pieces of information are: what kind (if any) of DHCPv6 configuration should
be performed; a default gateway; the prefixes that should be considered to be on
the local link; and the prefixes with which we can preform SLAAC in order to pick
a global IPv6 address.

A lot of additional information is also available, which we do not yet fully
support, but which will eventually allow us to avoid the need for DHCPv6 in the
common case.

Short-term, the reason for wanting this is in userspace was the desire to fully
track all the addresses on links we manage, and that is not possible for addresses
managed by the kernel (as the kernel does not expose to us the fact that it
manages these addresses). Moreover, we would like to support stable privacy
addresses, which will soon be mandated and the legacy MAC-based global addresses
deprecated, to do this well we need to handle the generation in userspace. Lastly,
more long-term we wish to support more RA options than what the kernel exposes.
2015-11-11 15:42:38 +01:00
Tom Gundersen f5a8c43f39 networkd: IPv6 router discovery - follow IPv6AcceptRouterAdvertisemnt=
The previous behavior:
When DHCPv6 was enabled, router discover was performed first, and then DHCPv6 was
enabled only if the relevant flags were passed in the Router Advertisement message.
Moreover, router discovery was performed even if AcceptRouterAdvertisements=false,
moreover, even if router advertisements were accepted (by the kernel) the flags
indicating that DHCPv6 should be performed were ignored.

New behavior:
If RouterAdvertisements are accepted, and either no routers are found, or an
advertisement is received indicating DHCPv6 should be performed, the DHCPv6
client is started. Moreover, the DHCP option now truly enables the DHCPv6
client regardless of router discovery (though it will probably not be
very useful to get a lease withotu any routes, this seems the more consistent
approach).

The recommended default setting should be to set DHCP=ipv4 and to leave
IPv6AcceptRouterAdvertisements unset.
2015-11-11 15:42:38 +01:00