Commit Graph

30872 Commits

Author SHA1 Message Date
Lennart Poettering 1e41242e11 core: shorten main() a bit, split out coredump initialization
No functional changes.
2017-11-17 11:28:17 +01:00
Lennart Poettering e839bafdf4 main: let's make main() shorter, let's split out clock initialization
no functional changes
2017-11-17 11:28:17 +01:00
Lennart Poettering 4a36297c41 main: let's make main() shorter, let's split out invocation of shutdown binary
No functional changes
2017-11-17 11:28:17 +01:00
Lennart Poettering 6808a0bc80 core: let's shorten main() a bit, let's split out telinit redirection into a separate function 2017-11-17 11:28:17 +01:00
Lennart Poettering 7b46fc6adc main: add set_manager_settings(), similar in style to set_manager_defaults() 2017-11-17 11:28:17 +01:00
Lennart Poettering fd1306121d 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
2017-11-17 11:28:17 +01:00
Lennart Poettering 85cb415124 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.
2017-11-17 11:28:17 +01:00
Lennart Poettering 3d80d4541b update TODO 2017-11-17 11:25:02 +01:00
Lennart Poettering 8adf53582c man: document that ExecStop= is executed during restarts
Fixes: #7126
2017-11-17 11:25:02 +01:00
Lennart Poettering 78a263f432 man: add missing suffixing "=" for setting name 2017-11-17 11:25:02 +01:00
Lennart Poettering ff946d8243 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: 6539dd7c42

See: #7126
2017-11-17 11:25:02 +01:00
Lennart Poettering c4f2aaa45b man: document the interaction of "systemctl restart" and the FD store
See: #7126
2017-11-17 11:25:02 +01:00
Lennart Poettering 370f9c21b9 update TODO 2017-11-17 11:13:44 +01:00
Lennart Poettering fc8d038130 man: document all the new options we acquired 2017-11-17 11:13:44 +01:00
Lennart Poettering 99be45a46f 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 5db9818772 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 666d787787 test: add basic test for StandardInput=file: 2017-11-17 11:13:44 +01:00
Lennart Poettering befc4a800e 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 2038c3f584 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
2017-11-17 11:13:44 +01:00
Lennart Poettering 0664775c84 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering e75a9ed176 execute: some extra asserts
In some cases we checked for fd validity already explicitly, let's do
this for all our fds.
2017-11-17 11:13:44 +01:00
Lennart Poettering 5073ff6bec 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 3a274a218d 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 9f617cd09f 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)
2017-11-17 11:13:44 +01:00
Lennart Poettering da543f6a77 test: add tests for StandardInputText= and StandardInputData= 2017-11-17 11:13:44 +01:00
Lennart Poettering 08f3be7a38 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 11f5d82507 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering a3ab8f2a99 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering ae6e414a61 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 6bbfdc672b 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering a548e14d69 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 9bd6a50e90 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 7fa0dcb6e3 core: drop config_parse_input() as it is unused 2017-11-17 11:13:44 +01:00
Lennart Poettering 1fb0682e78 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 046a82c1b2 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.
2017-11-17 11:13:44 +01:00
Lennart Poettering 3603efdea5 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
2017-11-17 11:12:33 +01:00
Lennart Poettering 14f8ccc755 nspawn: add missing #pragma once to header file 2017-11-17 11:12:33 +01:00
Lennart Poettering 57a4359ee0 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.
2017-11-17 11:12:33 +01:00
Lennart Poettering 994a6364d2 man: document how nspawn's --bind= and --private-users interact
Fixes: #5900
2017-11-17 11:12:33 +01:00
Zbigniew Jędrzejewski-Szmek 05d69e0294 test-cgroup-util: skip cg hierarchy tests when necessary (#7371) 2017-11-17 11:10:21 +01:00
Lennart Poettering bb84995789 nspawn: correctly document the relationship of --keep-unit and --register=no (#7364)
Fixes: #7228
2017-11-17 10:54:50 +01:00
Yu Watanabe 1bdfc7b951 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.
2017-11-17 10:04:25 +01:00
Lennart Poettering cefdf55b58
Merge pull request #7357 from yuwata/7314-mod
mount: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"
2017-11-17 09:49:07 +01:00
Evgeny Vereshchagin 5535d8f7a9 cgroup: assume the use of v1 when all the preceding checks fail (#7366)
This patch restores the default that was changed in 2977724b09,
making the tools depending on it work again.

Closes: #6477 and https://github.com/lxc/lxc/issues/1669
2017-11-17 09:47:49 +01:00
Yu Watanabe de345d3464 mount: show which argument is invalid 2017-11-17 16:43:38 +09:00
Yu Watanabe dc3364832c mount: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed" 2017-11-17 16:43:33 +09:00
Lennart Poettering 83123ab8fd
Merge pull request #7314 from poettering/gc-mode
add new CollectMode= unit file setting for tweaking the unit garbage collection logic
2017-11-16 16:32:36 +01:00
Lennart Poettering 2368e9748a update TODO 2017-11-16 14:38:36 +01:00
Lennart Poettering fe9d0be90b 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.
2017-11-16 14:38:36 +01:00
Lennart Poettering 5afe510c89 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.
2017-11-16 14:38:36 +01:00