platform/upstream/systemd.git
7 years agoMerge pull request #7198 from poettering/stdin-stdout
Lennart Poettering [Sun, 19 Nov 2017 18:49:11 +0000 (19:49 +0100)]
Merge pull request #7198 from poettering/stdin-stdout

Add StandardInput=data, StandardInput=file:... and more

7 years agoMerge pull request #7379 from yuwata/follow-up-7309
Lennart Poettering [Sun, 19 Nov 2017 18:47:24 +0000 (19:47 +0100)]
Merge pull request #7379 from yuwata/follow-up-7309

networkd: small fixes

7 years agoMerge pull request #7386 from keszybz/spdx
Lennart Poettering [Sun, 19 Nov 2017 18:46:52 +0000 (19:46 +0100)]
Merge pull request #7386 from keszybz/spdx

Add some missing license headers and add SPDX identifiers

7 years agoAdd license headers and SPDX identifiers to meson.build files
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 17:32:01 +0000 (18:32 +0100)]
Add license headers and SPDX identifiers to meson.build files

So far I avoided adding license headers to meson files, but they are pretty
big and important and should carry license headers like everything else.
I added my own copyright, even though other people modified those files too.
But this is mostly symbolic, so I hope that's OK.

7 years agoAdd SPDX license headers to shell completion scripts
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 17:21:19 +0000 (18:21 +0100)]
Add SPDX license headers to shell completion scripts

7 years agoAdd SPDX license headers to various assorted files
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 17:18:16 +0000 (18:18 +0100)]
Add SPDX license headers to various assorted files

7 years agoAdd missing headers and SPDX identifiers to man pages
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:52:56 +0000 (17:52 +0100)]
Add missing headers and SPDX identifiers to man pages

7 years agoAdd SPDX license headers to unit files
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:35:03 +0000 (17:35 +0100)]
Add SPDX license headers to unit files

7 years agoAdd SPDX license headers to python scripts
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:32:46 +0000 (17:32 +0100)]
Add SPDX license headers to python scripts

7 years agoAdd SPDX indentifier to hwdb/parse_hwdb.py
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:26:32 +0000 (17:26 +0100)]
Add SPDX indentifier to hwdb/parse_hwdb.py

7 years agoAdd SPDX license identifiers to man pages
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:22:32 +0000 (17:22 +0100)]
Add SPDX license identifiers to man pages

7 years agoAdd SPDX license identifiers to catalog and po files
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:17:35 +0000 (17:17 +0100)]
Add SPDX license identifiers to catalog and po files

7 years agoAdd SPDX license identifiers to source files under the GPL
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:14:42 +0000 (17:14 +0100)]
Add SPDX license identifiers to source files under the GPL

7 years agoAdd SPDX license identifiers to source files under the LGPL
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:09:20 +0000 (17:09 +0100)]
Add SPDX license identifiers to source files under the LGPL

This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.

7 years agoMerge pull request #7388 from keszybz/doc-tweak
Lennart Poettering [Sun, 19 Nov 2017 16:50:35 +0000 (17:50 +0100)]
Merge pull request #7388 from keszybz/doc-tweak

Add link to kernel docs about no_new_privs and drop note about CPU controller

7 years agomachined: support "machinectl bind" on non-directories (#7349)
Lennart Poettering [Sun, 19 Nov 2017 13:23:29 +0000 (14:23 +0100)]
machined: support "machinectl bind" on non-directories (#7349)

Fixes: #7195

7 years agoman: remove note about CPU controller being unmerged
Zbigniew Jędrzejewski-Szmek [Sun, 19 Nov 2017 13:15:42 +0000 (14:15 +0100)]
man: remove note about CPU controller being unmerged

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0d5936344f30aba0f6ddb92b030cb6a05168efe6

In principle we shouldn't merge this until after 4.15 is released, but the
chances of a revert upstream are low, and in that unlikely scenario we can just
revert this patch, it's a trivial documentation update after all.

7 years agoMerge pull request #7365 from poettering/nspawn-bind-userns
Zbigniew Jędrzejewski-Szmek [Sun, 19 Nov 2017 13:01:39 +0000 (14:01 +0100)]
Merge pull request #7365 from poettering/nspawn-bind-userns

nspawn: document --bind= and --private-users relationship, and make recursive chown()ing safe

7 years agoman: add link to kernel docs about no_new_privs
Zbigniew Jędrzejewski-Szmek [Sun, 19 Nov 2017 10:58:45 +0000 (11:58 +0100)]
man: add link to kernel docs about no_new_privs

7 years agonetworkd: fix indentation
Yu Watanabe [Fri, 17 Nov 2017 16:24:07 +0000 (01:24 +0900)]
networkd: fix indentation

7 years agonetworkd: remove debug message and unref when error
Yu Watanabe [Fri, 17 Nov 2017 16:22:34 +0000 (01:22 +0900)]
networkd: remove debug message and unref when error

Follow-up for 8006aa32ee29538ef1d7978d60d6427a0bf31e80.

7 years agocore: be more defensive if we can't determine per-connection socket peer (#7329)
Lennart Poettering [Fri, 17 Nov 2017 14:22:11 +0000 (15:22 +0100)]
core: be more defensive if we can't determine per-connection socket peer (#7329)

Let's handle gracefully if a client disconnects very early on.

This builds on #4120, but relaxes the condition checks further, since we
getpeername() might already fail during ExecStartPre= and friends.

Fixes: #7172

7 years agoman: rescue.target could be seen as single-user.target (#7323)
John Lin [Fri, 17 Nov 2017 14:20:48 +0000 (22:20 +0800)]
man: rescue.target could be seen as single-user.target (#7323)

7 years agoman: document that start limiting of GC'ed units doesn't work (#7337)
Lennart Poettering [Fri, 17 Nov 2017 14:18:30 +0000 (15:18 +0100)]
man: document that start limiting of GC'ed units doesn't work (#7337)

Fixes: #7139

7 years agoMerge pull request #7360 from poettering/preset-fix
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 14:00:22 +0000 (15:00 +0100)]
Merge pull request #7360 from poettering/preset-fix

Some fixes for preset-all logic at boot, plus main.c reworking

7 years agoMerge pull request #7338 from poettering/doc-restart-fix
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 13:51:51 +0000 (14:51 +0100)]
Merge pull request #7338 from poettering/doc-restart-fix

improve unit restart documentation a bit

7 years agoinstall: when we encounter a transient/generated unit while presetting all, skip...
Lennart Poettering [Thu, 16 Nov 2017 11:30:33 +0000 (12:30 +0100)]
install: when we encounter a transient/generated unit while presetting all, skip over it silently

Fixes: #7100

7 years agomain: uid_to_name() might theoretically fail, handle that
Lennart Poettering [Thu, 16 Nov 2017 11:24:32 +0000 (12:24 +0100)]
main: uid_to_name() might theoretically fail, handle that

7 years agocore: shorten main() a bit, split out coredump initialization
Lennart Poettering [Thu, 16 Nov 2017 11:02:39 +0000 (12:02 +0100)]
core: shorten main() a bit, split out coredump initialization

No functional changes.

7 years agomain: let's make main() shorter, let's split out clock initialization
Lennart Poettering [Thu, 16 Nov 2017 10:58:08 +0000 (11:58 +0100)]
main: let's make main() shorter, let's split out clock initialization

no functional changes

7 years agomain: let's make main() shorter, let's split out invocation of shutdown binary
Lennart Poettering [Thu, 16 Nov 2017 10:54:53 +0000 (11:54 +0100)]
main: let's make main() shorter, let's split out invocation of shutdown binary

No functional changes

7 years agocore: let's shorten main() a bit, let's split out telinit redirection into a separate...
Lennart Poettering [Thu, 16 Nov 2017 10:48:45 +0000 (11:48 +0100)]
core: let's shorten main() a bit, let's split out telinit redirection into a separate function

7 years agomain: add set_manager_settings(), similar in style to set_manager_defaults()
Lennart Poettering [Thu, 16 Nov 2017 10:45:02 +0000 (11:45 +0100)]
main: add set_manager_settings(), similar in style to set_manager_defaults()

7 years agocore: never apply first boot presets in the initrd
Lennart Poettering [Wed, 15 Nov 2017 18:56:21 +0000 (19:56 +0100)]
core: never apply first boot presets in the initrd

Presets are useful to initialize uninitialized /etc, but that doesn't
apply to the initrd.

Also, let's rename etc_empty → first_boot. After all, the variable
doesn't actually reflect whether /etc is really empty, it just reflects
whether /etc/machine-id existed originally or not. Moreover, we later on
directly initialize manager_set_first_boot() from it, hence let's just
name it the same way all through the codepath, to make this all less
confusing.

See: #7100

7 years agomain: rename manager_set_defaults() → set_manager_defaults()
Lennart Poettering [Wed, 15 Nov 2017 19:15:01 +0000 (20:15 +0100)]
main: rename manager_set_defaults() → set_manager_defaults()

This function is really not a method of the Manager object (implemented
in manager.c), but just a helper in main.c. Hence let's not confusingly
name it the way methods are called.

7 years agoupdate TODO
Lennart Poettering [Wed, 15 Nov 2017 10:25:38 +0000 (11:25 +0100)]
update TODO

7 years agoman: document that ExecStop= is executed during restarts
Lennart Poettering [Wed, 15 Nov 2017 10:25:19 +0000 (11:25 +0100)]
man: document that ExecStop= is executed during restarts

Fixes: #7126

7 years agoman: add missing suffixing "=" for setting name
Lennart Poettering [Wed, 15 Nov 2017 10:24:51 +0000 (11:24 +0100)]
man: add missing suffixing "=" for setting name

7 years agoman: write "stop and start" instead of "restart" when explaining the reload fallback...
Lennart Poettering [Wed, 15 Nov 2017 10:23:00 +0000 (11:23 +0100)]
man: write "stop and start" instead of "restart" when explaining the reload fallback operations

We already made a similar change when talking about the "restart"
command, let's also do this for "systemctl reload" and friends.

Follow-up for: 6539dd7c42946d9ba5dc43028b8b5785eb2db3c5

See: #7126

7 years agoman: document the interaction of "systemctl restart" and the FD store
Lennart Poettering [Wed, 15 Nov 2017 10:22:25 +0000 (11:22 +0100)]
man: document the interaction of "systemctl restart" and the FD store

See: #7126

7 years agoupdate TODO
Lennart Poettering [Fri, 27 Oct 2017 17:01:21 +0000 (19:01 +0200)]
update TODO

7 years agoman: document all the new options we acquired
Lennart Poettering [Fri, 27 Oct 2017 16:10:34 +0000 (18:10 +0200)]
man: document all the new options we acquired

7 years agofs-util: rename path_is_safe() → path_is_normalized()
Lennart Poettering [Fri, 27 Oct 2017 14:28:15 +0000 (16:28 +0200)]
fs-util: rename path_is_safe() → path_is_normalized()

Already, path_is_safe() refused paths container the "." dir. Doing that
isn't strictly necessary to be "safe" by most definitions of the word.
But it is necessary in order to consider a path "normalized". Hence,
"path_is_safe()" is slightly misleading a name, but
"path_is_normalize()" is more descriptive, hence let's rename things
accordingly.

No functional changes.

7 years agocore: don't allow DefaultStandardOutput= be set to socket/fd:/file:
Lennart Poettering [Fri, 27 Oct 2017 14:22:38 +0000 (16:22 +0200)]
core: don't allow DefaultStandardOutput= be set to socket/fd:/file:

These three settings only make sense within the context of actual unit
files, hence filter this out when applied to the per-manager default,
and generate a log message about it.

7 years agotest: add basic test for StandardInput=file:
Lennart Poettering [Fri, 27 Oct 2017 14:16:19 +0000 (16:16 +0200)]
test: add basic test for StandardInput=file:

7 years agocore: add exec_context_dump() support for fd: and file: stdio settings
Lennart Poettering [Fri, 27 Oct 2017 14:13:59 +0000 (16:13 +0200)]
core: add exec_context_dump() support for fd: and file: stdio settings

This was missing for using fdnames as stdio, let's add support for
fdnames as well as file paths in one go.

7 years agocore: add support for StandardInputFile= and friends
Lennart Poettering [Fri, 27 Oct 2017 14:09:57 +0000 (16:09 +0200)]
core: add support for StandardInputFile= and friends

These new settings permit specifiying arbitrary paths as
stdin/stdout/stderr locations. We try to open/create them as necessary.
Some special magic is applied:

1) if the same path is specified for both input and output/stderr, we'll
   open it only once O_RDWR, and duplicate them fd instead.

2) If we an AF_UNIX socket path is specified, we'll connect() to it,
   rather than open() it. This allows invoking systemd services with
   stdin/stdout/stderr connected to arbitrary foreign service sockets.

Fixes: #3991

7 years agocore: fix handling of transient StandardOutputFileDescriptorName= and friends
Lennart Poettering [Fri, 27 Oct 2017 14:08:11 +0000 (16:08 +0200)]
core: fix handling of transient StandardOutputFileDescriptorName= and friends

Let's make sure to process the fdname first, before changing the actual
input/output setting, since the fdname part can fail due to OOM.

This way we don't leave half-initialized bits around.

7 years agoexecute: some extra asserts
Lennart Poettering [Fri, 27 Oct 2017 12:59:05 +0000 (14:59 +0200)]
execute: some extra asserts

In some cases we checked for fd validity already explicitly, let's do
this for all our fds.

7 years agocore: fold property_get_input_fdname() and property_get_output_fdname() into one
Lennart Poettering [Fri, 27 Oct 2017 12:57:12 +0000 (14:57 +0200)]
core: fold property_get_input_fdname() and property_get_output_fdname() into one

property_get_output_fdname() already had two different control flows for
stdout and stderr, it might as well handle stdin too, thus shortening
our code a bit.

7 years agoexecute: fix type of open_terminal_as() flags parameter
Lennart Poettering [Fri, 27 Oct 2017 12:32:22 +0000 (14:32 +0200)]
execute: fix type of open_terminal_as() flags parameter

It's the flags parameter we propagate here, not the mode parameter,
hence let's name it properly, and use the right type.

7 years agobus-unit-util: drop #ifdef HAVE_SECCOMP from bus client side
Lennart Poettering [Fri, 27 Oct 2017 09:40:53 +0000 (11:40 +0200)]
bus-unit-util: drop #ifdef HAVE_SECCOMP from bus client side

Whether seccomp is supported or not is a server implementation detail,
the client should not be altered by that, and clients should be able to talk
to servers configured differently than the client, hence drop the
HAVE_SECCOMP ifdeffery here.

(This would be different if we'd need libseccomp or so to implement the
client, but we don't)

7 years agotest: add tests for StandardInputText= and StandardInputData=
Lennart Poettering [Fri, 27 Oct 2017 09:38:59 +0000 (11:38 +0200)]
test: add tests for StandardInputText= and StandardInputData=

7 years agocore: add two new unit file settings: StandardInputData= + StandardInputText=
Lennart Poettering [Fri, 27 Oct 2017 09:33:05 +0000 (11:33 +0200)]
core: add two new unit file settings: StandardInputData= + StandardInputText=

Both permit configuring data to pass through STDIN to an invoked
process. StandardInputText= accepts a line of text (possibly with
embedded C-style escapes as well as unit specifiers), which is appended
to the buffer to pass as stdin, followed by a single newline.
StandardInputData= is similar, but accepts arbitrary base64 encoded
data, and will not resolve specifiers or C-style escapes, nor append
newlines.

This may be used to pass input/configuration data to services, directly
in-line from unit files, either in a cooked or in a more raw format.

7 years agoproc-cmdline: minor runlevel_to_target() coding style fixes
Lennart Poettering [Fri, 27 Oct 2017 09:15:20 +0000 (11:15 +0200)]
proc-cmdline: minor runlevel_to_target() coding style fixes

Let's not mix function calls and variable declarations, as well as
assignments and comparison in one expression.

7 years agohexdcoct: dump to stdout if FILE* is specified as NULL
Lennart Poettering [Fri, 27 Oct 2017 09:14:27 +0000 (11:14 +0200)]
hexdcoct: dump to stdout if FILE* is specified as NULL

We do a logic like that at various other places, let's do it here too,
to make this as little surprising as possible.

7 years agohexdecoct: slightly extend the unbase64mem() API and related
Lennart Poettering [Fri, 27 Oct 2017 09:06:19 +0000 (11:06 +0200)]
hexdecoct: slightly extend the unbase64mem() API and related

If the string length is specified as (size_t) -1, let's use that as
indicator for determining the length on our own. This makes it
slightlier shorter to invoke these APIs for a very common case.

Also, do some minor other coding style updates, and add assert()s here
and there.

7 years agobus-unit-util: propagate errors where it makes sense, don't make up EINVAL
Lennart Poettering [Fri, 27 Oct 2017 09:04:57 +0000 (11:04 +0200)]
bus-unit-util: propagate errors where it makes sense, don't make up EINVAL

This is not only more technically correct, but also shortens our code
quite a bit.

7 years agofd-util: add new acquire_data_fd() API helper
Lennart Poettering [Fri, 27 Oct 2017 08:56:42 +0000 (10:56 +0200)]
fd-util: add new acquire_data_fd() API helper

All this function does is place some data in an in-memory read-only fd,
that may be read back to get the original data back.

Doing this in a way that works everywhere, given the different kernels
we support as well as different privilege levels is surprisingly
complex.

7 years agocore: clean up config_parse_exec_input() a bit
Lennart Poettering [Thu, 26 Oct 2017 18:06:42 +0000 (20:06 +0200)]
core: clean up config_parse_exec_input() a bit

Mostly coding style fixes, but most importantly, initialize
c->std_input only after we know the free_and_strdup() invocation
succeeded, so that we don't leave half-initialized fields around on
failure.

7 years agocore: drop config_parse_input() as it is unused
Lennart Poettering [Thu, 26 Oct 2017 18:02:57 +0000 (20:02 +0200)]
core: drop config_parse_input() as it is unused

7 years agoexecute: check whether we are actually on a TTY before doing TIOCSCTTY
Lennart Poettering [Thu, 26 Oct 2017 16:47:34 +0000 (18:47 +0200)]
execute: check whether we are actually on a TTY before doing TIOCSCTTY

Given that Linux assigns the same ioctl numbers ot multiple subsystems,
we should be careful when invoking ioctls, so that we don't end up
calling something we wouldn't want to call.

7 years agofd-util: add new helper move_fd() and make use of it
Lennart Poettering [Thu, 26 Oct 2017 16:45:54 +0000 (18:45 +0200)]
fd-util: add new helper move_fd() and make use of it

We are using the same pattern at various places: call dup2() on an fd,
and close the old fd, usually in combination with some O_CLOEXEC
fiddling. Let's add a little helper for this, and port a few obvious
cases over.

7 years agonspawn: make recursive chown()ing logic safe for being aborted in the middle
Lennart Poettering [Thu, 16 Nov 2017 18:09:32 +0000 (19:09 +0100)]
nspawn: make recursive chown()ing logic safe for being aborted in the middle

We currently use the ownership of the top-level directory as a hint
whether we need to descent into the whole tree to chown() it recursively
or not. This is problematic with the previous chown()ing algorithm, as
when descending into the tree we'd first chown() and then descend
further down, which meant that the top-level directory would be chowned
first, and an aborted recursive chowning would appear on the next
invocation as successful, even though it was not. Let's reshuffle things
a bit, to make the re-chown()ing safe regarding interruptions:

a) We chown() the dir we are looking at last, and descent into all its
   children first. That way we know that if the top-level dir is
   properly owned everything inside of it is properly owned too.

b) Before starting a chown()ing operation, we mark the top-level
   directory as owned by a special "busy" UID range, which we can use to
   recognize whether a tree was fully chowned: if it is marked as busy,
   it's definitely not fully chowned, as the busy ownership will only be
   fixed as final step of the chowning.

Fixes: #6292

7 years agonspawn: add missing #pragma once to header file
Lennart Poettering [Thu, 16 Nov 2017 17:58:18 +0000 (18:58 +0100)]
nspawn: add missing #pragma once to header file

7 years agofs-util: add access_fd() which is like access() but for fds
Lennart Poettering [Thu, 16 Nov 2017 17:56:25 +0000 (18:56 +0100)]
fs-util: add access_fd() which is like access() but for fds

Linux doesn't have faccess(), hence let's emulate it. Linux has access()
and faccessat() but neither allows checking the access rights of an fd
passed in directly.

7 years agoman: document how nspawn's --bind= and --private-users interact
Lennart Poettering [Thu, 16 Nov 2017 17:05:42 +0000 (18:05 +0100)]
man: document how nspawn's --bind= and --private-users interact

Fixes: #5900

7 years agotest-cgroup-util: skip cg hierarchy tests when necessary (#7371)
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 10:10:21 +0000 (11:10 +0100)]
test-cgroup-util: skip cg hierarchy tests when necessary (#7371)

7 years agonspawn: correctly document the relationship of --keep-unit and --register=no (#7364)
Lennart Poettering [Fri, 17 Nov 2017 09:54:50 +0000 (10:54 +0100)]
nspawn: correctly document the relationship of --keep-unit and --register=no (#7364)

Fixes: #7228

7 years agocore/cgroup: assigning empty string to Delegate= resets list of controllers (#7336)
Yu Watanabe [Fri, 17 Nov 2017 09:04:25 +0000 (18:04 +0900)]
core/cgroup: assigning empty string to Delegate= resets list of controllers (#7336)

Before this, assigning empty string to Delegate= makes no change to the
controller list. This is inconsistent to the other options that take list
of strings. After this, when empty string is assigned to Delegate=, the
list of controllers is reset. Such behavior is consistent to other options
and useful for drop-in configs.

Closes #7334.

7 years agoMerge pull request #7357 from yuwata/7314-mod
Lennart Poettering [Fri, 17 Nov 2017 08:49:07 +0000 (09:49 +0100)]
Merge pull request #7357 from yuwata/7314-mod

mount: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"

7 years agocgroup: assume the use of v1 when all the preceding checks fail (#7366)
Evgeny Vereshchagin [Fri, 17 Nov 2017 08:47:49 +0000 (11:47 +0300)]
cgroup: assume the use of v1 when all the preceding checks fail (#7366)

This patch restores the default that was changed in 2977724b09eb997fc8,
making the tools depending on it work again.

Closes: #6477 and https://github.com/lxc/lxc/issues/1669

7 years agomount: show which argument is invalid
Yu Watanabe [Thu, 16 Nov 2017 06:55:42 +0000 (15:55 +0900)]
mount: show which argument is invalid

7 years agomount: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"
Yu Watanabe [Thu, 16 Nov 2017 06:40:25 +0000 (15:40 +0900)]
mount: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"

7 years agoMerge pull request #7314 from poettering/gc-mode
Lennart Poettering [Thu, 16 Nov 2017 15:32:36 +0000 (16:32 +0100)]
Merge pull request #7314 from poettering/gc-mode

add new CollectMode= unit file setting for tweaking the unit garbage collection logic

7 years agoupdate TODO
Lennart Poettering [Mon, 13 Nov 2017 16:21:27 +0000 (17:21 +0100)]
update TODO

7 years agorun: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"
Lennart Poettering [Mon, 13 Nov 2017 16:17:53 +0000 (17:17 +0100)]
run: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"

This option is likely to be very useful for systemd-run invocations,
hence let's add a shortcut for it.

With this new concepts it's now very easy to put together systemd-run
invocations that leave zero artifacts in the system, including when they
fail.

7 years agocore: add a new unit file setting CollectMode= for tweaking the GC logic
Lennart Poettering [Mon, 13 Nov 2017 16:14:07 +0000 (17:14 +0100)]
core: add a new unit file setting CollectMode= for tweaking the GC logic

Right now, the option only takes one of two possible values "inactive"
or "inactive-or-failed", the former being the default, and exposing same
behaviour as the status quo ante. If set to "inactive-or-failed" units
may be collected by the GC logic when in the "failed" state too.

This logic should be a nicer alternative to using the "-" modifier for
ExecStart= and friends, as the exit data is collected and logged about
and only removed when the GC comes along. This should be useful in
particular for per-connection socket-activated services, as well as
"systemd-run" command lines that shall leave no artifacts in the
system.

I was thinking about whether to expose this as a boolean, but opted for
an enum instead, as I have the suspicion other tweaks like this might be
a added later on, in which case we extend this setting instead of having
to add yet another one.

Also, let's add some documentation for the GC logic.

7 years agounit: rework a bit how we keep the service fdstore from being destroyed during servic...
Lennart Poettering [Mon, 13 Nov 2017 14:08:49 +0000 (15:08 +0100)]
unit: rework a bit how we keep the service fdstore from being destroyed during service restart

When preparing for a restart we quickly go through the DEAD/INACTIVE
service state before entering AUTO_RESTART. When doing this, we need to
make sure we don't destroy the FD store. Previously this was done by
checking the failure state of the unit, and keeping the FD store around
when the unit failed, under the assumption that the restart logic will
then get into action.

This is not entirely correct howver, as there might be failure states
that will no result in restarts.

With this commit we slightly alter the logic: a ref counter for the fd
store is added, that is increased right before we handle the restart
logic, and decreased again right-after.

This should ensure that the fdstore lives exactly as long as it needs.

Follow-up for f0bfbfac43b7faa68ef1bb2ad659c191b9ec85d2.

7 years agoMerge pull request #7246 from poettering/journal-extra-fields
Zbigniew Jędrzejewski-Szmek [Thu, 16 Nov 2017 13:24:53 +0000 (14:24 +0100)]
Merge pull request #7246 from poettering/journal-extra-fields

add new per-unit LogLevelMax= and LogExtraField= setting

7 years agoman: mention how to provision Ubuntu and Tanglu for nspawn (#7359)
Zbigniew Jędrzejewski-Szmek [Thu, 16 Nov 2017 12:40:35 +0000 (13:40 +0100)]
man: mention how to provision Ubuntu and Tanglu for nspawn (#7359)

Also add urls. Urls are nice.

7 years agotest-unit-file: add test for config_parse_log_extra_fields()
Zbigniew Jędrzejewski-Szmek [Tue, 14 Nov 2017 13:58:37 +0000 (14:58 +0100)]
test-unit-file: add test for config_parse_log_extra_fields()

7 years agoman: document LogFieldMax= and LogExtraFields=
Lennart Poettering [Thu, 2 Nov 2017 18:53:45 +0000 (21:53 +0300)]
man: document LogFieldMax= and LogExtraFields=

7 years agocore: implement /run/systemd/units/-based path for passing unit info from PID 1 to...
Lennart Poettering [Thu, 2 Nov 2017 18:43:32 +0000 (21:43 +0300)]
core: implement /run/systemd/units/-based path for passing unit info from PID 1 to journald

And let's make use of it to implement two new unit settings with it:

1. LogLevelMax= is a new per-unit setting that may be used to configure
   log priority filtering: set it to LogLevelMax=notice and only
   messages of level "notice" and lower (i.e. more important) will be
   processed, all others are dropped.

2. LogExtraFields= is a new per-unit setting for configuring per-unit
   journal fields, that are implicitly included in every log record
   generated by the unit's processes. It takes field/value pairs in the
   form of FOO=BAR.

Also, related to this, one exisiting unit setting is ported to this new
facility:

3. The invocation ID is now pulled from /run/systemd/units/ instead of
   cgroupfs xattrs. This substantially relaxes requirements of systemd
   on the kernel version and the privileges it runs with (specifically,
   cgroupfs xattrs are not available in containers, since they are
   stored in kernel memory, and hence are unsafe to permit to lesser
   privileged code).

/run/systemd/units/ is a new directory, which contains a number of files
and symlinks encoding the above information. PID 1 creates and manages
these files, and journald reads them from there.

Note that this is supposed to be a direct path between PID 1 and the
journal only, due to the special runtime environment the journal runs
in. Normally, today we shouldn't introduce new interfaces that (mis-)use
a file system as IPC framework, and instead just an IPC system, but this
is very hard to do between the journal and PID 1, as long as the IPC
system is a subject PID 1 manages, and itself a client to the journal.

This patch cleans up a couple of types used in journal code:
specifically we switch to size_t for a couple of memory-sizing values,
as size_t is the right choice for everything that is memory.

Fixes: #4089
Fixes: #3041
Fixes: #4441

7 years agoman: update SyslogXYZ= documentation a bit
Lennart Poettering [Thu, 2 Nov 2017 18:40:35 +0000 (21:40 +0300)]
man: update SyslogXYZ= documentation a bit

Let's clarify that these settings only apply to stdout/stderr logging.
Always mention the journal before syslog (as the latter is in most ways
just a legacy alias these days). Always mention the +console cases too.

7 years agoman: rework the discussion of Storage= a bit
Lennart Poettering [Thu, 2 Nov 2017 10:33:01 +0000 (11:33 +0100)]
man: rework the discussion of Storage= a bit

Most distributions default to persistent storage these days, hence don't
claim otherwise.

7 years agojournald: when logging about dropped messages, include more meta data
Lennart Poettering [Mon, 30 Oct 2017 19:01:50 +0000 (20:01 +0100)]
journald: when logging about dropped messages, include more meta data

When we drop messages of a unit, we log about. Let's add some structured
data to that. Let's include how many messages we dropped, but more
importantly, let's link up the message we generate to the unit we
dropped the messages from by using the "OBJECT" logic, i.e. by
generating OBJECT_SYSTEMD_UNIT= fields and suchlike, that "journalctl
-u" and friends already look for.

Fixes: #6494

7 years agojournal: reindent field mapping tables
Lennart Poettering [Mon, 30 Oct 2017 18:54:39 +0000 (19:54 +0100)]
journal: reindent field mapping tables

Let's fix up whitespace so that the tables look nicely aligned.

7 years agojournal: make use of IOVEC_MAKE() where it makes sense
Lennart Poettering [Mon, 30 Oct 2017 18:54:13 +0000 (19:54 +0100)]
journal: make use of IOVEC_MAKE() where it makes sense

7 years agojournal: move valid_user_field() to journal-util.[ch] and rename it → journal_field_v...
Lennart Poettering [Mon, 30 Oct 2017 18:53:01 +0000 (19:53 +0100)]
journal: move valid_user_field() to journal-util.[ch] and rename it → journal_field_valid()

Being able to validate journal field names is useful outside of the
journal itself.

7 years agoMerge pull request #7356 from keszybz/cgroup-and-manager-cleanups
Lennart Poettering [Thu, 16 Nov 2017 10:37:20 +0000 (11:37 +0100)]
Merge pull request #7356 from keszybz/cgroup-and-manager-cleanups

Cgroup and manager cleanups

7 years agoman: fix wrong tag (#7358)
Yu Watanabe [Thu, 16 Nov 2017 10:35:30 +0000 (19:35 +0900)]
man: fix wrong tag (#7358)

7 years agotmpfiles: when /etc is not fully initialized, some specifiers are expected to be...
Franck Bui [Thu, 16 Nov 2017 10:27:29 +0000 (11:27 +0100)]
tmpfiles: when /etc is not fully initialized, some specifiers are expected to be unresolvable (#6860)

In chroot environments, /etc might not be fully initialized: /etc/machine-id
can be missing for example. This makes the expansions of affected specifiers
impossible at that time.

These cases should not be considered as errors and such failures shouldn't be
logged at an error level therefore this patch downgrades the level used to
LOG_NOTICE in such cases.

Also this is logged at LOG_NOTICE only the first time and then downgrade to
LOG_DEBUG for the rest. That way, if debugging is enabled we get the full
output, but otherwise we only see only one message.

The expansion of specifiers is now self contained in a dedicated function
instead of being spread all over the place.

7 years agosystemctl: other wayland sessions should inhibit shutdown, like x11 sessions do ...
Alan Jenkins [Thu, 16 Nov 2017 10:02:34 +0000 (10:02 +0000)]
systemctl: other wayland sessions should inhibit shutdown, like x11 sessions do (#7353)

Update systemctl code to match the manpage for sd_session_get_type().

"wayland" sessions should be treated the same as "x11".  "mir" too, fwiw.

7 years agosd-dhcp6-client: Implement FQDN Option (#7309)
Stefan Agner [Thu, 16 Nov 2017 09:07:07 +0000 (10:07 +0100)]
sd-dhcp6-client: Implement FQDN Option (#7309)

Implement DHCPv6 option to exchange information about the Fully
Qualified Domain Name (FQDN) according to RFC 4704.

The RFC 4704 describes two models of operations in section 3,
currently only the second model is supported (DHCPv6 server
updates both the AAAA and the PTR RRs).

The existing DHCP Section Options SendHostname and Hostname are
sent as FQDN to the server. According to section 4.2 sending
only parts of its FQDN is allowed.

Fixes #4682.

7 years agosd-dhcp-client: validate hostnames stricter (#7308)
Stefan Agner [Thu, 16 Nov 2017 09:05:44 +0000 (10:05 +0100)]
sd-dhcp-client: validate hostnames stricter (#7308)

Technically DNS allows any ASCII character to be used in the
domain name. Also the DHCP specification for the FQDN option
(RFC 4702) does not put restriction on labels.

However, hostnames do have stricter requirements and typically
should only use characters from a-z (case insensitve), 0-9 and
minus.

Currently we require hostname/FQDN to be either a hostname or
a valid DNS name. Since dns_name_is_valid() allows any ASCII
characters this allows to specify hostnames which are typically
not valid.

Check hostname/FQDN more strictly and require them to pass both
tests. Specifically this requires the entire FQDN to be below 63.

7 years agoman: document that noauto doesn't affect automount units configured through /etc...
Lennart Poettering [Thu, 16 Nov 2017 03:05:15 +0000 (04:05 +0100)]
man: document that noauto doesn't affect automount units configured through /etc/fstab (#7350)

Fixes: #6937

7 years agoman: document interaction of --root= and the user/group databases (#7344)
Lennart Poettering [Thu, 16 Nov 2017 03:00:56 +0000 (04:00 +0100)]
man: document interaction of --root= and the user/group databases (#7344)

Fixes: #7032

7 years agoNEWS: document the systemd-logind IP firewalling incompatibility (#7343)
Lennart Poettering [Thu, 16 Nov 2017 02:57:32 +0000 (03:57 +0100)]
NEWS: document the systemd-logind IP firewalling incompatibility (#7343)

Fixes: #7074

7 years agoman: document that generators can generate instances+templates and regular unit files...
Lennart Poettering [Thu, 16 Nov 2017 02:37:25 +0000 (03:37 +0100)]
man: document that generators can generate instances+templates and regular unit files (#7342)

This addition is kept brief on purpose, since in order to write a good
generator users don't really need to grok templating/instantiation.

Fixes: #7257