platform/upstream/systemd.git
6 years agodissect: update dissect tool to show image metadata
Lennart Poettering [Tue, 14 Nov 2017 22:24:13 +0000 (23:24 +0100)]
dissect: update dissect tool to show image metadata

Pretty straight-forward: just use the new metadata dissection API to
figure out what an image contains.

6 years agodissect: add an API that can read various metadata bits out of a dissected image
Lennart Poettering [Tue, 14 Nov 2017 22:22:46 +0000 (23:22 +0100)]
dissect: add an API that can read various metadata bits out of a dissected image

We focus on four kinds of metadata:

1. /etc/hostname
2. /etc/machine-id
3. /etc/machine-info
4. /etc/os-release or /usr/lib/os-release

This makes dissected images nicely self-contained as we can figure out
what they are just by dissecting them.

6 years agostrv: introduce strv_free_and_replace()
Lennart Poettering [Tue, 14 Nov 2017 22:21:57 +0000 (23:21 +0100)]
strv: introduce strv_free_and_replace()

it's like free_and_replace() but uses strv_free()

6 years agosignal-util: use a slightly less likely to conflict variable name instead of 't'
Lennart Poettering [Tue, 14 Nov 2017 22:21:43 +0000 (23:21 +0100)]
signal-util: use a slightly less likely to conflict variable name instead of 't'

6 years agohostname-util: rework read_hostname_config() a bit
Lennart Poettering [Tue, 14 Nov 2017 18:51:06 +0000 (19:51 +0100)]
hostname-util: rework read_hostname_config() a bit

First of all, let's rename it to read_etc_hostname(), to make clearer
what kind of configuration it actually reads: the file format defined in
/etc/hostname and nothing else.

Secondly: let's port this to use read_line(), i.e. the new way to read
lines from a file in a safe, bounded way.

Thirdly: let's strip leading/trailing whitespace from what we are
reading. Given that we are already pretty lenient what we read (comments
and empty lines), let's be permissive regarding whitespace too.

Fourthly: let's actually validate the hostname when reading it. So far
we tried to make it valid, but that's not always possible (for example,
we can't make an empty hostname valid, ever).

6 years agoMerge pull request #7375 from poettering/readme-updates
Zbigniew Jędrzejewski-Szmek [Mon, 20 Nov 2017 13:46:02 +0000 (14:46 +0100)]
Merge pull request #7375 from poettering/readme-updates

some README updates

6 years agoman: fix description of --force in halt(8) (#7392)
Zbigniew Jędrzejewski-Szmek [Mon, 20 Nov 2017 13:27:46 +0000 (14:27 +0100)]
man: fix description of --force in halt(8) (#7392)

https://bugzilla.redhat.com/show_bug.cgi?id=1449751

6 years agoMerge pull request #7154 from keszybz/bootspec
Lennart Poettering [Mon, 20 Nov 2017 12:06:33 +0000 (13:06 +0100)]
Merge pull request #7154 from keszybz/bootspec

List bootspec entries in bootctl and use the default for kexec

6 years agoMerge pull request #7387 from yuwata/fix-7370
Lennart Poettering [Mon, 20 Nov 2017 11:51:40 +0000 (12:51 +0100)]
Merge pull request #7387 from yuwata/fix-7370

core: load() should fail when the corresponding unit file does not exist

6 years agoREADME,sysusers: complete and order list of default udev groups we need
Lennart Poettering [Mon, 20 Nov 2017 11:30:42 +0000 (12:30 +0100)]
README,sysusers: complete and order list of default udev groups we need

Let's make sure the list of default udev groups we need are ordered in
README and in the sysusers.d snippet, and both are complete.

6 years agoREADME: slightly update the section about split /usr
Lennart Poettering [Fri, 17 Nov 2017 10:39:48 +0000 (11:39 +0100)]
README: slightly update the section about split /usr

It's fine if /usr is actually on a separate fs. What matters is that it
is mounted early enough. Say so.

6 years agoREADME: document that prefix *must* be /usr and nss-systemd is not an option
Lennart Poettering [Fri, 17 Nov 2017 10:39:14 +0000 (11:39 +0100)]
README: document that prefix *must* be /usr and nss-systemd is not an option

See: #7374

6 years agomeson: add -Wimplicit-fallthrough=3 to compilation options (#7393)
Zbigniew Jędrzejewski-Szmek [Mon, 20 Nov 2017 11:14:47 +0000 (12:14 +0100)]
meson: add -Wimplicit-fallthrough=3 to compilation options (#7393)

At some point before gcc-7 was released, -Wimplicit-fallthrough=3 was included
in -Wextra. The documentation for gcc-7.2.1-2.fc27.x86_64 still says that, but
empirical testing shows that it's not. The documentation also misstates that
-Wimplicit-fallthrough is equivalent to -Wimplicit-fallthrough=3.

Let's add -Wimplicit-fallthrough=3 explicitly to get the warnings if we regress.

Prompted by #7389.

6 years agoMerge pull request #7373 from poettering/analyze-calendar
Zbigniew Jędrzejewski-Szmek [Mon, 20 Nov 2017 10:25:55 +0000 (11:25 +0100)]
Merge pull request #7373 from poettering/analyze-calendar

add nifty little "systemd-analyze calendar" command

6 years agosystemctl: elapsation → elapse
Lennart Poettering [Mon, 20 Nov 2017 09:54:21 +0000 (10:54 +0100)]
systemctl: elapsation → elapse

6 years agoupdate TODO
Lennart Poettering [Fri, 17 Nov 2017 09:34:52 +0000 (10:34 +0100)]
update TODO

6 years agoanalyze: add new "calendar" command
Lennart Poettering [Fri, 17 Nov 2017 09:33:22 +0000 (10:33 +0100)]
analyze: add new "calendar" command

This little new command can parse, validate, normalize calendar events,
and calculate when they will elapse next. This should be useful for
anyone writing calendar events and who'd like to validate the expression
before running them as timer units.

6 years agoman: Requires= stops this unit when dependencies get deactivated (#7391)
John Lin [Mon, 20 Nov 2017 09:55:52 +0000 (17:55 +0800)]
man: Requires= stops this unit when dependencies get deactivated (#7391)

Fixes: #7372

6 years agoutil: add new helper in_utc_timezone()
Lennart Poettering [Mon, 20 Nov 2017 09:52:20 +0000 (10:52 +0100)]
util: add new helper in_utc_timezone()

As the name suggests it checks whether we are running in an UTC
timezone.

6 years agocalendarspec: rework destructor to return its own type
Lennart Poettering [Fri, 17 Nov 2017 09:32:48 +0000 (10:32 +0100)]
calendarspec: rework destructor to return its own type

Let's make it more alike most of our other destructors.

6 years agomeson: bump required meson version to 0.41 (#7385)
Zbigniew Jędrzejewski-Szmek [Mon, 20 Nov 2017 07:08:43 +0000 (08:08 +0100)]
meson: bump required meson version to 0.41 (#7385)

We need data_dirs argument for i18n.merge_file, added in 0.40.1-11-g82492f5d76.

6 years agocore/swap: load() should fail when neither of corresponding unit file nor /proc/swap...
Yu Watanabe [Sun, 19 Nov 2017 16:00:34 +0000 (01:00 +0900)]
core/swap: load() should fail when neither of corresponding unit file nor /proc/swap entry does not exist

It is not necessary to label as loaded to a swap unit when neither of
corresponding unit file nor entry in /proc/swap does not exist.
This makes swap_load() to fail such a case.

Partially fixes #7370.

6 years agocore/automount: load() should fail when the unit file does not exist
Yu Watanabe [Sun, 19 Nov 2017 07:45:35 +0000 (16:45 +0900)]
core/automount: load() should fail when the unit file does not exist

It is not necessary to label as loaded to automount unit when its unit
file does not exist. So, let's make automount_load() to fail when the
unit file does not exist.

Partially fixes #7370.

6 years agoMerge pull request #7376 from keszybz/simplify-root-options
Lennart Poettering [Sun, 19 Nov 2017 18:50:03 +0000 (19:50 +0100)]
Merge pull request #7376 from keszybz/simplify-root-options

Simplify root configuration options

6 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

6 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

6 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

6 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.

6 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

6 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

6 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

6 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

6 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

6 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

6 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

6 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

6 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

6 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.

6 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

6 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

6 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.

6 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

6 years agotest: do not hardcode location of EFI partition
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 13:09:11 +0000 (14:09 +0100)]
test: do not hardcode location of EFI partition

6 years agobootctl: add a convenient way to print the path to EFI
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 12:55:05 +0000 (13:55 +0100)]
bootctl: add a convenient way to print the path to EFI

6 years agobootctl: rename r2 and r to r and k
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 12:50:08 +0000 (13:50 +0100)]
bootctl: rename r2 and r to r and k

r2 was assigned first despite the name. This scheme is different than
what is used elsewhere in the code. Rename to make it easier to read.

6 years agosystemctl: make sure the kernel is loaded before kexec'ing
Zbigniew Jędrzejewski-Szmek [Sat, 21 Oct 2017 08:55:32 +0000 (10:55 +0200)]
systemctl: make sure the kernel is loaded before kexec'ing

We just load the same kernel that would be loaded by default by sd-boot, with
the same options. Changing the kernel or initramfs or options is left for
later.

Now we will refuse to continue if loading fails. This makes 'systemctl kexec'
more predictable: it will not fall back to normal reboot if the kernel is
not loaded.

6 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

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

6 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.

6 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

6 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)

6 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

6 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

6 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

6 years agomeson: use absolute path for rpmmacrosdir
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 12:22:13 +0000 (13:22 +0100)]
meson: use absolute path for rpmmacrosdir

This only matter for the status display at the end of configure step.
Now it looks like:
         RPM macros dir:                    /usr/lib/rpm/macros.d

6 years agomeson: drop rootprefix option
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2017 12:07:46 +0000 (13:07 +0100)]
meson: drop rootprefix option

rootprefixdir is now always set to /usr or /, based on the split-usr setting.
Anything else does not work anyway.

C.f. #7375.

6 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

6 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

6 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.

6 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

6 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

6 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

6 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()

6 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

6 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.

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

6 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

6 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

6 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

6 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

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

6 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

6 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.

6 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.

6 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:

6 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.

6 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

6 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.

6 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.

6 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.

6 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.

6 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)

6 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=

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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

6 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.

6 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.

6 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

6 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

6 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.

6 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

6 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)

6 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

6 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.