Commit graph

32163 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 07a7d4a004 rpm macros: add %sysusers_create_package
This is close to %sysusers_create_inline and %sysusers_create that we had
already, but expects a file name and uses --replace= to implement proper
priority.

This is used like:
  %sysusers_create_package %{name} %SOURCE1
where %SOURCE1 is a file with called %{name}.conf that will be installed
into /usr/lib/sysusers.d/.

The tough part is that the file needs to be available before %prep,
i.e. outside of the source tarball. This is because the spec file is
parsed (and any macros expanded), before the sources are unpackaged.

v2:
- disallow the case case when --config-name= is given but there are no
  positional args. Most likely this would be a user error, so at least for now
  forbid it.
v3:
- replace --config-name= with --target=
- drop quotes around %1 and %2 — if necessary, the caller should add
  those.
v4:
- replace --target with --replace
- add a big comment
2018-02-02 10:40:24 +01:00
Zbigniew Jędrzejewski-Szmek 4e9fe38dc0 test/TEST-21-SYSUSERS: add tests for new functionality 2018-02-02 10:40:24 +01:00
Zbigniew Jędrzejewski-Szmek d16a1c1bb6 sysusers: allow admin/runtime overrides to command-line config
When used in a package installation script, we want to invoke systemd-sysusers
before that package is installed (so it can contain files owned by the newly
created user), so the configuration to use is specified on the command
line. This should be a copy of the configuration that will be installed as
/usr/lib/sysusers.d/package.conf. We still want to obey any overrides in
/etc/sysusers.d or /run/sysusers.d in the usual fashion. Otherwise, we'd get a
different result when systemd-sysusers is run with a copy of the new config on
the command line and when systemd-sysusers is run at boot after package
instalation. In the second case any files in /etc or /run have higher priority,
so the same should happen when the configuration is given on the command line.
More generally, we want the behaviour in this special case to be as close to
the case where the file is finally on disk as possible, so we have to read all
configuration files, since they all might contain overrides and additional
configuration that matters. Even files that have lower priority might specify
additional groups for the user we are creating. Thus, we need to read all
configuration, but insert our new configuration somewhere with the right
priority.

If --target=/path/to/file.conf is given on the command line, we gather the list
of files, and pretend that the command-line config is read from
/path/to/file.conf (doesn't matter if the file on disk actually exists or
not). All package scripts should use this option to obtain consistent and
idempotent behaviour.

The corner case when --target= is specified and there are no positional
arguments is disallowed.

v1:
- version with --config-name=
v2:
- disallow --config-name= and no positional args
v3:
- remove --config-name=
v4:
- add --target= and rework the code completely
v5:
- fix argcounting bug and add example in man page
v6:
- rename --target to --replace
2018-02-02 10:40:22 +01:00
Zbigniew Jędrzejewski-Szmek 6e888894fc basic/strv: add function to insert items at position 2018-02-02 10:35:30 +01:00
Zbigniew Jędrzejewski-Szmek 7b1aaf6633 sysusers: allow the shell to be specified
This is necessary for some system users where the "login shell" is
set to a specific binary.
2018-02-02 10:35:30 +01:00
Zbigniew Jędrzejewski-Szmek 1b600bd522 sysusers: take configuration as positional arguments
If the configuration is included in a script, this is more convient.
I thought it would be possible to use this for rpm scriptlets with
'%pre -p systemd-sysuser "..."', but apparently there is no way to pass
arguments to the executable ($1 is used for the package installation count).
But this functionality seems generally useful, e.g. for testing and one-off
scripts, so let's keep it.

There's a slight change in behaviour when files are given on the command line:
if we cannot parse them, error out instead of ignoring the failure. When trying
to parse all configuration files, we don't want to fail even if some config
files are broken, but when parsing a list of items specified explicitly, we
should.

v2:
- rename --direct to --inline
2018-02-02 10:18:13 +01:00
Zbigniew Jędrzejewski-Szmek d1e4b8fd96 sysusers: emit a bit more info at debug level when locking fails
This is the first error message when running unprivileged, and the message is
unspecific, so let's at least add some logging at debug level to make this less
confusing.
2018-02-02 09:09:24 +01:00
tblume 75aaade16b meson.build: make docdir configurable (#8068)
SUSE is using a different docdir, so the path should be configurable
2018-02-02 06:46:15 +09:00
Lennart Poettering 52dca0de99
Merge pull request #7042 from vcaputo/iteratedcache
RFC: Optionally cache hashmap iterated results
2018-02-01 18:08:50 +01:00
Lennart Poettering 05cdbb304d
Merge pull request #8045 from yuwata/dump-more
analyze: dump more settings
2018-02-01 10:16:50 +01:00
Lennart Poettering f6c7c39897
Merge pull request #8061 from poettering/selinux-mask-fix
never use /dev/null label when making selinux access decisions
2018-02-01 10:11:30 +01:00
Yu Watanabe e7b2ea7c97 strv: drop strv_join_quoted() (#8057)
The function `strv_join_quoted()` is now not used, and has a bug
in the buffer size calculation when the strings needs to escaped,
as reported in #8056.
So, let's remove the function.

Closes #8056.
2018-02-01 10:11:02 +01:00
Michael Vogt b9ee05c266 sysusers: allow force reusing existing user/group IDs (#8037)
On Debian/Ubuntu systems the default passwd/group files use a
slightly strange mapping. E.g. in passwd:
```
man6:12::/var/cache/man:/sbin/nologin
```
and in group:
```
disk6:
man12:
```

This is not supported in systemd-sysusers right now because
sysusers will not re-use an existing uid/gid in its normal
mode of operation. Unfortunately this reuse is needed to
replicate the default Debian/Ubuntu users/groups.

This commit enforces reuse when the "uid:gid" syntax is used
to fix this.

I also added a test that replicates the Debian base-passwd
passwd/group file to ensure things are ok.
2018-02-01 13:47:50 +09:00
Lennart Poettering 81e9871e87 selinux: make sure we never use /dev/null for making unit selinux access decisions 2018-01-31 19:54:25 +01:00
Lennart Poettering 0d5456556f update TODO 2018-01-31 19:54:25 +01:00
Alan Jenkins 5c19ff79de seccomp-util: fix alarming debug message (#8002, #8001)
Booting with `systemd.log_level=debug` and looking in `dmesg -u` showed
messages like this:

    systemd[433]: Failed to add rule for system call n/a() / 156, ignoring:
    Numerical argument out of domain

This commit fixes it to:

    systemd[449]: Failed to add rule for system call _sysctl() / 156,
    ignoring: Numerical argument out of domain

Some of the messages could be even more misleading, e.g. we were reporting
that utimensat() / 320 was skipped as non-existent on x86, when actually
the syscall number 320 is kexec_file_load() on x86 .

The problem was that syscall NRs are looked up (and correctly passed to
libseccomp) as native syscall NRs.  But we forgot that when we tried to
go back from the syscall NR to the name.

I think the natural way to write this would be
seccomp_syscall_resolve_num(nr), however there is no such function.
I couldn't work out a short comment that would make this clearer.  FWIW
I wrote it up as a ticket for libseccomp instead.
https://github.com/seccomp/libseccomp/issues/104
2018-01-31 17:20:14 +00:00
Alan Jenkins 62a0680bf2 man: systemd.exec: cleanup "only X will be permitted" ... "but X=X+1"
> Only system calls of the *specified* architectures will be permitted to
> processes of this unit.

(my emphasis)

> Note that setting this option to a non-empty list implies that
> native is included too.

Attempting to use "implies" in the later sentence, in a way that
contradicts the very clear meaning of the earlier sentence... it's too
much.
2018-01-31 15:39:13 +00:00
Evgeny Vereshchagin ce691f31aa test-lldp: use memcmp to compare bytes (#8054)
Technically, `data` is a sequence of bytes without a trailing zero,
so the use of `memcmp` seems to be logical here. Besides, this helps get
around a bug that makes `asan` report the false positive mentioned in
 #8052.

Closes #8052.
2018-01-31 09:54:37 +01:00
Yu Watanabe c9d4169919 core/service: dump more settings 2018-01-30 17:10:47 +09:00
Yu Watanabe 9bd0e1b814 core/swap: dump TimeoutSec= 2018-01-30 17:10:09 +09:00
Yu Watanabe 9189979213 core/mount: dump TimeoutSec= 2018-01-30 17:09:59 +09:00
Jason A. Donenfeld b55822c349 networkd: clean up link_get_type_string returns
It's cleaner and more consistent to actually return what we were
planning on returning.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 21:08:39 +01:00
Jason A. Donenfeld fdce7817b9 networkd: clean up link_get_type_string
The return value is always ignored, so get rid of it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 21:06:28 +01:00
Jason A. Donenfeld f119082e7a networkd: simplify and display all devtypes
Every place the kernel actually calls SET_NETDEV_DEVTYPE, it's adding a
piece of information that looks useful and relevant for us to use. So
let's use it when it's there.

The previous matching based on the corresponding ARPHRD didn't really
make much sense. The more sensible logic for getting a textual
representation of the link type is to see if the kernel supplies a
devtype. If it does, great. If not, then we can fall back on the ARPHRD,
as before.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 21:02:44 +01:00
Jason A. Donenfeld a18461bc7d networkd: display wireguard devtype
It's not useful to simply show "none", when we have more interesting
information to display.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 20:58:30 +01:00
Jason A. Donenfeld a8d6dbedca man: note handling of secret information with permissions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 20:43:30 +01:00
Jason A. Donenfeld 3209474fcb man: WireGuard is a proper noun
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 20:38:36 +01:00
Vito Caputo 302af1c250
Merge pull request #8031 from mrq1/MRQ1_20180128_typo_fix
journalctl: typo fix
2018-01-28 13:03:39 -08:00
Hermann Gausterer fabf4dae16 journalctl: typo fix 2018-01-28 20:49:55 +01:00
Lennart Poettering 46659f7deb
Merge pull request #8030 from keszybz/another-news-update
NEWS: reword one sentence
2018-01-28 16:58:17 +01:00
Zbigniew Jędrzejewski-Szmek 31751f7e2a NEWS: add missing equal sign
Important!
2018-01-28 16:54:18 +01:00
Zbigniew Jędrzejewski-Szmek 1a0cd2c74e NEWS: reword one sentence 2018-01-28 16:52:47 +01:00
Lennart Poettering 82c8e3e650 NEWS: let's get this thing done 2018-01-28 16:36:03 +01:00
Zbigniew Jędrzejewski-Szmek e6501af8b8 NEWS: mention --grep (#8029) 2018-01-28 23:52:06 +09:00
Lennart Poettering 7755083256
Merge pull request #7881 from keszybz/pcre
Add new --grep option to journalctl
2018-01-28 15:29:10 +01:00
Zbigniew Jędrzejewski-Szmek b4766d5f15 journalctl: add highlighting for matched substring
Red is used for highligting, the same as grep does. Except when the line is
highlighted red already, because it has high priority, in which case plain ansi
highlight is used for the matched substring.

Coloring is implemented for short and cat outputs, and not for other types.
I guess we could also add it for verbose output in the future.
2018-01-28 14:50:01 +01:00
Zbigniew Jędrzejewski-Szmek 61c5f8a1f0 journalctl: make matching optionally case sensitive
Case sensitive or case insensitive matching can be requested using
--case-sensitive[=yes|no].

Unless specified, matching is case sensitive if the pattern contains any
uppercase letters, and case insensitive otherwise. This matches what
forward-search does in emacs, and recently also --ignore-case in less.  This
works surprisingly well, because usually when one is wants to do case-sensitive
matching, the pattern is usually camel-cased. In the less frequent case when
case-sensitive matching is required with an all-lowercase pattern,
--case-sensitive can be used to override the automatic logic.
2018-01-28 14:50:01 +01:00
dana 992f51ea42 Slightly improve performance of startable/restartable unit completion (#7839) 2018-01-28 13:29:58 +01:00
Lennart Poettering 508058c9c5 NEWS: update NEWS again, we didn't release yesterday (#8027)
Fix tons of whitespace issues, also add a sysusers.d/ change and update
to contributors list again
2018-01-28 21:28:58 +09:00
Lennart Poettering dcfb4b6103
Merge pull request #8025 from sourcejedi/pid1_journal_or2
pid1: when we can't log to journal, remember our fallback log target
2018-01-28 11:02:24 +01:00
Martin Pitt 055a52575c hwdb: Fix bouncing brightness keys on MSI-PR200
Thanks to djfd for the patch!

Fixes #6972
2018-01-28 10:46:40 +01:00
Michael Biebl b4d7c66808
Merge pull request #8026 from phomes/NEWS-fix
NEWS: typo fix
2018-01-28 00:08:16 +01:00
Thomas Hindoe Paaboel Andersen caf2a2d8e6 NEWS: typo fix 2018-01-28 00:05:27 +01:00
Vito Caputo 647c7b7440 test-hashmap: test IteratedCache
Add some rudimentary testing of the new IteratedCache
2018-01-27 13:11:58 -08:00
Vito Caputo 5d4ba7f2b3 journal: use IteratedCache in sd-journal
This changes real_journal_next() to leverage the IteratedCache for
accelerating iteration across the open journal files.

journalctl timing comparisons with 100 journal files of 8MiB size
party to this boot:

Pre (~v235):
  # time ./journalctl -b --no-pager > /dev/null
  real    0m9.613s
  user    0m9.560s
  sys     0m0.053s

  # time ./journalctl -b --no-pager > /dev/null
  real    0m9.548s
  user    0m9.525s
  sys     0m0.023s

  # time ./journalctl -b --no-pager > /dev/null
  real    0m9.612s
  user    0m9.582s
  sys     0m0.030s

Post-IteratedCache:

  # time ./journalctl -b --no-pager > /dev/null
  real    0m8.449s
  user    0m8.425s
  sys     0m0.024s

  # time ./journalctl -b --no-pager > /dev/null
  real    0m8.409s
  user    0m8.382s
  sys     0m0.027s

  # time ./journalctl -b --no-pager > /dev/null
  real    0m8.410s
  user    0m8.350s
  sys     0m0.061s

~12.5% improvement, the benefit increases the more log files there are.
2018-01-27 13:11:58 -08:00
Vito Caputo 45ea84d8ed basic: implement the IteratedCache
Adds the basics of the IteratedCache and constructor support for the
Hashmap and OrderedHashmap types.

iterated_cache_get() is responsible for synchronizing the cache with
the associated Hashmap and making it available to the caller at the
supplied result pointers.  Since iterated_cache_get() may need to
allocate memory, it may fail, so callers must check the return value.

On success, pointer arrays containing pointers to the associated
Hashmap's keys and values, in as-iterated order, are returned in
res_keys and res_values, respectively.  Either may be supplied as NULL
to inhibit caching of the keys or values, respectively.

Note that if the cached Hashmap hasn't changed since the previous call
to iterated_cache_get(), and it's not a call activating caching of the
values or keys, the cost is effectively zero as the resulting pointers
will simply refer to the previously returned arrays as-is.

A cleanup function has also been added, iterated_cache_free().

This only frees the IteratedCache container and related arrays.  The
associated Hashmap, its keys, and values are not affected.  Also note
that the associated Hashmap does not automatically free its associated
IteratedCache when freed.

One could, in theory, safely access the arrays returned by a
successful iterated_cache_get() call after its associated Hashmap has
been freed, including the referenced values and keys.  Provided the
iterated_cache_get() was performed prior to the hashmap free, and that
the type of hashmap free performed didn't free keys and/or values as
well.
2018-01-27 13:11:50 -08:00
Alan Jenkins 8d5c7661a7 systemd-shutdown: use log_set_prohibit_ipc(true)
Now we have log_set_prohibit_ipc(), let's use it to clarify that
systemd-shutdown is not expected to try and log via journald (which it is
about to kill).  We avoided ever asking systemd-shutdown to do this, but
it's more convenient for the reader if they don't have to think about that.
In that sense, it's similar to using assert() to validate a function's
arguments.
2018-01-27 19:51:30 +00:00
Alan Jenkins cc2b9e6b20 rationalize interface for opening/closing logging
log_open_console() did not switch from stderr to /dev/console, when
"always_reopen_console" was set.  It was necessary to call
log_close_console() first.

By contrast, log_open() did switch between e.g. journald and kmsg according
to the value of "prohibit_ipc".

Let's fix log_open() to respect the values of all the log options, and we
can make log_close_*() private.

Also log_close_console() is changed.  There was some precaution, avoiding
closing the console fd if we are not PID 1.  I think commit 48a601fe made
a little mistake in leaving this in, and it only served to confuse
readers :).

Also I changed systemd-shutdown. Now we have log_set_prohibit_ipc(), let's
use it to clarify that systemd-shutdown is not expected to try and log via
journald (which it is about to kill).  We avoided ever asking it to, but
it's more convenient for the reader if they don't have to think about that.
In that sense, it's similar to using assert() to validate a function's
arguments.
2018-01-27 18:01:51 +00:00
bleep_blop 56a2911255 Update NEWS to reflect changes made in #8020 (#8024) 2018-01-28 01:33:52 +09:00
Batuhan Osman Taşkaya 7c4a807277 [gdb-sd_dump_hashmaps.py] String Formatting Update (#7819)
Changes: % changed as .format()
2018-01-27 14:03:08 +01:00