chiark / gitweb /
Lennart Poettering [Wed, 7 Feb 2018 22:03:13 +0000 (23:03 +0100)]
update TODO
Lennart Poettering [Wed, 7 Feb 2018 21:52:52 +0000 (22:52 +0100)]
core: add new new bus call for migrating foreign processes to scope/service units
This adds a new bus call to service and scope units called
AttachProcesses() that moves arbitrary processes into the cgroup of the
unit. The primary user for this new API is systemd itself: the systemd
--user instance uses this call of the systemd --system instance to
migrate processes if itself gets the request to migrate processes and
the kernel refuses this due to access restrictions.
The primary use-case of this is to make "systemd-run --scope --user …"
invoked from user session scopes work correctly on pure cgroupsv2
environments. There, the kernel refuses to migrate processes between two
unprivileged-owned cgroups unless the requestor as well as the ownership
of the closest parent cgroup all match. This however is not the case
between the session-XYZ.scope unit of a login session and the
user@ABC.service of the systemd --user instance.
The new logic always tries to move the processes on its own, but if
that doesn't work when being the user manager, then the system manager
is asked to do it instead.
The new operation is relatively restrictive: it will only allow to move
the processes like this if the caller is root, or the UID of the target
unit, caller and process all match. Note that this means that
unprivileged users cannot attach processes to scope units, as those do
not have "owning" users (i.e. they have now User= field).
Fixes: #3388
Lennart Poettering [Wed, 7 Feb 2018 21:28:42 +0000 (22:28 +0100)]
sd-bus: synthesize a description for user/system bus if otherwise unset
Let's make debugging easier, by synthesizing a name when we have some
indication what kind of bus this is.
Lennart Poettering [Wed, 7 Feb 2018 17:11:18 +0000 (18:11 +0100)]
user-util: also consider /bin/false and /bin/true as non-shell
Lennart Poettering [Tue, 6 Feb 2018 14:59:55 +0000 (15:59 +0100)]
process-util: be more careful in is_kernel_thread()
This reworks is_kernel_thread() a bit. Instead of checking whether
/proc/$pid/cmdline is entirely empty we now parse the 'flags' field from
/proc/$pid/stat and check the PF_KTHREAD flag, which directly encodes
whether something is a kernel thread.
Why all this? With current kernels userspace processes can set their
command line to empty too (through PR_SET_MM_ARG_START and friends), and
could potentially confuse us. Hence, let's use a more reliable way to
detect kernels like this.
Lennart Poettering [Tue, 6 Feb 2018 10:57:35 +0000 (11:57 +0100)]
cgroup: add a new "can_delegate" flag to the unit vtable, and set it for scope and service units only
Currently we allowed delegation for alluntis with cgroup backing
except for slices. Let's make this a bit more strict for now, and only
allow this in service and scope units.
Let's also add a generic accessor unit_cgroup_delegate() for checking
whether a unit has delegation turned on that checks the new bool first.
Also, when doing transient units, let's explcitly refuse turning on
delegation for unit types that don#t support it. This is mostly
cosmetical as we wouldn't act on the delegation request anyway, but
certainly helpful for debugging.
Davide Cavalca [Wed, 14 Feb 2018 13:08:50 +0000 (05:08 -0800)]
meson: factor out daemon/event/id128 sources into variables (#8170)
Lennart Poettering [Fri, 9 Feb 2018 08:52:36 +0000 (09:52 +0100)]
rm-rf: make flags fields easier to read
Lennart Poettering [Fri, 9 Feb 2018 08:50:31 +0000 (09:50 +0100)]
fs-util: add new unlinkat_deallocate() helper
This new helper not only removes a file from a directory but also
ensures its space on disk is deallocated, by either punching a hole over
the full file or truncating the file afterwards if the file's link
counter is 0. This is useful in "vacuuming" algorithms to ensure that
client's can't keep the disk space the vacuuming is supposed to recover
pinned simply by keeping an fd open to it.
Lennart Poettering [Fri, 9 Feb 2018 08:50:13 +0000 (09:50 +0100)]
copy: wrap some unlink() calls in (void) casts
Lennart Poettering [Thu, 8 Feb 2018 17:58:35 +0000 (18:58 +0100)]
tree-wide: use path_hash_ops instead of string_hash_ops whenever we key by a path
Let's make use of our new hash_ops!
Lennart Poettering [Thu, 8 Feb 2018 17:31:15 +0000 (18:31 +0100)]
hash-func: add generic hash_ops implementation for hashing paths
This is similar to string_hash_ops but operates one file system paths
specifically. It will ensure that "/foo//bar" and "///foo/bar" are
considered to be the same path for hashmap purposes.
This makes use of the existing path_compare() API, and adds a matching
hashing function for it.
Note that relative and absolute paths will hash to different values,
however whether the path is suffixed with a slash or not is not
detected. This matches the existing path_compare() behaviour, and
follows the logic that on Linux there can't be two different objects at
path /foo/bar and /foo/bar/ either.
Lennart Poettering [Thu, 8 Feb 2018 16:37:56 +0000 (17:37 +0100)]
hash-funcs: remove redundant definition of devt_hash_ops
We should assign a value only in the .c file, not in both the .c and .h
file.
Lennart Poettering [Thu, 8 Feb 2018 16:14:37 +0000 (17:14 +0100)]
journal: move code that checks for network fs to stat-util.[ch]
We have similar code in stat-util.[ch] and managing this at a central
place almost definitely is the better choice.
Zbigniew Jędrzejewski-Szmek [Wed, 14 Feb 2018 08:34:46 +0000 (09:34 +0100)]
Yu Watanabe [Fri, 9 Feb 2018 08:52:05 +0000 (17:52 +0900)]
socket-util: drop getnameinfo_pretty()
Yu Watanabe [Fri, 9 Feb 2018 07:58:56 +0000 (16:58 +0900)]
fs-util: drop readlink_and_make_absolute_root()
Yu Watanabe [Fri, 9 Feb 2018 07:49:54 +0000 (16:49 +0900)]
fs-util: drop readlink_and_canonicalize()
Zbigniew Jędrzejewski-Szmek [Fri, 9 Feb 2018 12:31:37 +0000 (13:31 +0100)]
basic/socket-util: drop use of NI_IDN_USE_STD3_ASCII_RULES
The only use of socknameinfo_pretty() is in src/journal-remote/journal-remote.c,
to determine the output filename.
Replaces #8120.
Lennart Poettering [Fri, 9 Feb 2018 16:53:28 +0000 (17:53 +0100)]
fd-util: move certain fds above fd #2 (#8129)
This adds some paranoia code that moves some of the fds we allocate for
longer periods of times to fds > 2 if they are allocated below this
boundary. This is a paranoid safety thing, in order to avoid that
external code might end up erroneously use our fds under the assumption
they were valid stdin/stdout/stderr. Think: some app closes
stdin/stdout/stderr and then invokes 'fprintf(stderr, …' which causes
writes on our fds.
This both adds the helper to do the moving as well as ports over a
number of users to this new logic. Since we don't want to litter all our
code with invocations of this I tried to strictly focus on fds we keep
open for long periods of times only and only in code that is frequently
loaded into foreign programs (under the assumptions that in our own
codebase we are smart enough to always keep stdin/stdout/stderr
allocated to avoid this pitfall). Specifically this means all code used
by NSS and our sd-xyz API:
1. our logging APIs
2. sd-event
3. sd-bus
4. sd-resolve
5. sd-netlink
This changed was inspired by this:
https://github.com/systemd/systemd/issues/8075#issuecomment-
363689755
This shows that apparently IRL there are programs that do close
stdin/stdout/stderr, and we should accomodate for that.
Note that this won't fix any bugs, this just makes sure that buggy
programs are less likely to interfere with out own code.
Simon Fowler [Fri, 9 Feb 2018 16:37:39 +0000 (02:37 +1000)]
Suspend on lid close based on power status. (#8016)
This change adds support for controlling the suspend-on-lid-close
behaviour based on the power status as well as whether the machine is
docked or has an external monitor. For backwards compatibility the new
configuration file variable is ignored completely by default, and must
be set explicitly before being considered in any decisions.
Shawn Landden [Sat, 3 Feb 2018 18:16:33 +0000 (10:16 -0800)]
sd-bus: cleanup ssh sessions (Closes: #8076)
we still invoke ssh unnecessarily when there in incompatible or erreneous input
The fallow-up to finish that would make the code a bit more verbose,
as it would require repeating this bit:
```
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
log_error_errno(r, "Failed to create bus connection: %m");
goto finish;
}
sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
```
in every verb, after parsing.
v2: add waitpid() to avoid a zombie process, switch to SIGTERM from SIGKILL
v3: refactor, wait in bus_start_address()
Yu Watanabe [Fri, 9 Feb 2018 07:19:11 +0000 (16:19 +0900)]
sd-bus: explicitly convert int to bool
Yu Watanabe [Fri, 9 Feb 2018 07:21:51 +0000 (16:21 +0900)]
sd-bus: use free_and_replace()
Yu Watanabe [Fri, 9 Feb 2018 07:21:29 +0000 (16:21 +0900)]
sd-bus: avoid potential memory leaks
Zbigniew Jędrzejewski-Szmek [Mon, 5 Feb 2018 13:53:11 +0000 (14:53 +0100)]
tmpfiles: allow admin/runtime overrides to runtime config
This is very similar to
d16a1c1bb6. For tmpfiles this is much less useful
compared to sysusers, but let's add this anyway for consistency.
Lennart Poettering [Wed, 7 Feb 2018 02:10:09 +0000 (03:10 +0100)]
process-util: use raw_getpid() in getpid_cache() internally (#8115)
We have the raw_getpid() definition in place anyway, and it's certainly
beneficial to expose the same semantics on pre glibc 2.24 and after it
too, hence always bypass glibc for this, and always cache things on our
side.
Fixes: #8113
Yu Watanabe [Tue, 6 Feb 2018 03:17:50 +0000 (12:17 +0900)]
core/execute: make arguments constant if possible
Also make functions static if possible.
Zbigniew Jędrzejewski-Szmek [Mon, 5 Feb 2018 08:48:38 +0000 (09:48 +0100)]
test: add a simple smoke test for string_hashsum()
This is enough to show memory leakages pointed out by Stef Bon <stefbon@gmail.com>.
Zbigniew Jędrzejewski-Szmek [Wed, 31 Jan 2018 14:37:02 +0000 (15:37 +0100)]
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
Zbigniew Jędrzejewski-Szmek [Thu, 1 Feb 2018 11:50:18 +0000 (12:50 +0100)]
basic/strv: add function to insert items at position
Zbigniew Jędrzejewski-Szmek [Tue, 30 Jan 2018 13:28:10 +0000 (14:28 +0100)]
sysusers: allow the shell to be specified
This is necessary for some system users where the "login shell" is
set to a specific binary.
Zbigniew Jędrzejewski-Szmek [Mon, 29 Jan 2018 13:23:31 +0000 (14:23 +0100)]
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.
MilhouseVH [Mon, 5 Feb 2018 05:26:57 +0000 (05:26 +0000)]
kernel 3.10 compat: RTAX_QUICKACK not added until 3.11.0 (#8094)
Zbigniew Jędrzejewski-Szmek [Fri, 2 Feb 2018 13:34:00 +0000 (14:34 +0100)]
basic/hashmap: tweak code to avoid pointless gcc warning
gcc says:
[196/1142] Compiling C object 'src/basic/basic@sta/hashmap.c.o'.
../src/basic/hashmap.c: In function ‘cachemem_maintain’:
../src/basic/hashmap.c:1913:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
mem->active = r = true;
^~~
which conflates two things: the first is transitive assignent a = b = c = d;
the second is assignment of the value of an expression, which happens to be a
an assignment expression here, and boolean. While the second _should_ be
parenthesized, the first should _not_, and it's more natural to understand
our code as the first, and gcc should treat this as an exception and not emit
the warning. But since it's a while until this will be fixed, let's update
our code too.
tblume [Thu, 1 Feb 2018 21:46:15 +0000 (22:46 +0100)]
meson.build: make docdir configurable (#8068)
SUSE is using a different docdir, so the path should be configurable
Vito Caputo [Sat, 27 Jan 2018 21:10:39 +0000 (13:10 -0800)]
test-hashmap: test IteratedCache
Add some rudimentary testing of the new IteratedCache
Vito Caputo [Sat, 27 Jan 2018 00:38:01 +0000 (16:38 -0800)]
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.
Vito Caputo [Sun, 8 Oct 2017 23:28:04 +0000 (16:28 -0700)]
basic: track dirty state in HashmapBase
This only adds marking the HashmapBase as dirty, no clearing of
the dirty state happens yet.
No functional changes.
Lennart Poettering [Wed, 31 Jan 2018 18:53:16 +0000 (19:53 +0100)]
update TODO
Yu Watanabe [Thu, 1 Feb 2018 09:11:02 +0000 (18:11 +0900)]
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.
Sven Eden [Wed, 30 May 2018 05:54:20 +0000 (07:54 +0200)]
Save last mutual commit for migration of the v237-stable branch.
Zbigniew Jędrzejewski-Szmek [Wed, 21 Feb 2018 13:04:50 +0000 (14:04 +0100)]
missing_syscall: when adding syscall replacements, use different names (#8229)
In meson.build we check that functions are available using:
meson.get_compiler('c').has_function('foo')
which checks the following:
- if __stub_foo or __stub___foo are defined, return false
- if foo is declared (a pointer to the function can be taken), return true
- otherwise check for __builtin_memfd_create
_stub is documented by glibc as
It defines a symbol '__stub_FUNCTION' for each function
in the C library which is a stub, meaning it will fail
every time called, usually setting errno to ENOSYS.
So if __stub is defined, we know we don't want to use the glibc version, but
this doesn't tell us if the name itself is defined or not. If it _is_ defined,
and we define our replacement as an inline static function, we get an error:
In file included from ../src/basic/missing.h:1358:0,
from ../src/basic/util.h:47,
from ../src/basic/calendarspec.h:29,
from ../src/basic/calendarspec.c:34:
../src/basic/missing_syscall.h:65:19: error: static declaration of 'memfd_create' follows non-static declaration
static inline int memfd_create(const char *name, unsigned int flags) {
^~~~~~~~~~~~
.../usr/include/bits/mman-shared.h:46:5: note: previous declaration of 'memfd_create' was here
int memfd_create (const char *__name, unsigned int __flags) __THROW;
^~~~~~~~~~~~
To avoid this problem, call our inline functions different than glibc,
and use a #define to map the official name to our replacement.
Fixes #8099.
v2:
- use "missing_" as the prefix instead of "_"
v3:
- rebase and update for statx()
Unfortunately "statx" is also present in "struct statx", so the define
causes issues. Work around this by using a typedef.
I checked that systemd compiles with current glibc
(glibc-devel-2.26-24.fc27.x86_64) if HAVE_MEMFD_CREATE, HAVE_GETTID,
HAVE_PIVOT_ROOT, HAVE_SETNS, HAVE_RENAMEAT2, HAVE_KCMP, HAVE_KEYCTL,
HAVE_COPY_FILE_RANGE, HAVE_BPF, HAVE_STATX are forced to 0.
Setting HAVE_NAME_TO_HANDLE_AT to 0 causes an issue, but it's not because of
the define, but because of struct file_handle.
(cherry picked from commit
5187dd2c403caf92d09f3491e41f1ceb3f10491f)
Zbigniew Jędrzejewski-Szmek [Tue, 20 Feb 2018 16:13:41 +0000 (17:13 +0100)]
test-user-util: skip most tests for nobody if synthentization is off
When synthetisation is turned off, there's just too many ways those tests can
go wrong. We are not interested in verifying that the db on disk is correct,
let's just skip all checks.
In the first version of this patch, I recorded if we detected a mismatch during
configuration and only skipped tests in that case, but actually it is possible
to change the host configuration between our configuration phase and running
of the tests. It's just more robust to skip always. (This is particularly true
if tests are installed.)
(cherry picked from commit
7559b2da10b1513849f22312d09a2381569b4f06)
Zbigniew Jędrzejewski-Szmek [Tue, 20 Feb 2018 21:10:45 +0000 (22:10 +0100)]
test-user-util: print function delimiters
This makes it easier to see what is going on. Crashes may happen in a
nested test_{uid,gid}_to_name_one() function, and the default backtrace
doesn't show the actual string being tested.
(cherry picked from commit
52c6e6a8a0221530659c65090f18b16c45a9fc04)
Caio Marcelo de Oliveira Filho [Mon, 19 Feb 2018 02:33:16 +0000 (18:33 -0800)]
meson: apply defaults if /etc/login.defs doesn't exist
Apply defaults for system_{uid,gid}_max even if the /etc/login.defs file
doesn't exist (e.g. in Clear Linux with no changes).
awk returns an empty string in case the file doesn't exist, causing meson to
fail in to_int(). So set the default if output is empty. This makes the BEGIN{}
blocks unnecessary, so remove them.
(cherry picked from commit
2f62cf3552d48f518313bd6265bad6763e2b643b)
Caio Marcelo de Oliveira Filho [Mon, 19 Feb 2018 09:37:19 +0000 (01:37 -0800)]
meson: use multiline string syntax (#8214)
The single quote working with multiple lines is likely to be unintended. With
current versions of meson, it also causes error messages after it to report the
wrong line number. Use the documented syntax instead.
(cherry picked from commit
9e70f2f81821efa4797d89c06d1f04c11e86015e)
Lennart Poettering [Fri, 9 Feb 2018 08:50:31 +0000 (09:50 +0100)]
fs-util: add new unlinkat_deallocate() helper
This new helper not only removes a file from a directory but also
ensures its space on disk is deallocated, by either punching a hole over
the full file or truncating the file afterwards if the file's link
counter is 0. This is useful in "vacuuming" algorithms to ensure that
client's can't keep the disk space the vacuuming is supposed to recover
pinned simply by keeping an fd open to it.
(cherry picked from commit
43767d9d5e0ce8923828aebf9154da7af83916f7)
Lennart Poettering [Thu, 8 Feb 2018 17:31:15 +0000 (18:31 +0100)]
hash-func: add generic hash_ops implementation for hashing paths
This is similar to string_hash_ops but operates one file system paths
specifically. It will ensure that "/foo//bar" and "///foo/bar" are
considered to be the same path for hashmap purposes.
This makes use of the existing path_compare() API, and adds a matching
hashing function for it.
Note that relative and absolute paths will hash to different values,
however whether the path is suffixed with a slash or not is not
detected. This matches the existing path_compare() behaviour, and
follows the logic that on Linux there can't be two different objects at
path /foo/bar and /foo/bar/ either.
(cherry picked from commit
46e16b347f83d809ed3d34f26286f580dfd086ce)
Lennart Poettering [Thu, 8 Feb 2018 16:37:56 +0000 (17:37 +0100)]
hash-funcs: remove redundant definition of devt_hash_ops
We should assign a value only in the .c file, not in both the .c and .h
file.
(cherry picked from commit
9bac7d423f1d39737e2b7bc35c484ed0d79de73d)
Lennart Poettering [Thu, 8 Feb 2018 16:14:37 +0000 (17:14 +0100)]
journal: move code that checks for network fs to stat-util.[ch]
We have similar code in stat-util.[ch] and managing this at a central
place almost definitely is the better choice.
(cherry picked from commit
77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0)
Shawn Landden [Sat, 3 Feb 2018 18:16:33 +0000 (10:16 -0800)]
sd-bus: cleanup ssh sessions (Closes: #8076)
we still invoke ssh unnecessarily when there in incompatible or erreneous input
The fallow-up to finish that would make the code a bit more verbose,
as it would require repeating this bit:
```
r = bus_connect_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
log_error_errno(r, "Failed to create bus connection: %m");
goto finish;
}
sd_bus_set_allow_interactive_authorization(bus, arg_ask_password);
```
in every verb, after parsing.
v2: add waitpid() to avoid a zombie process, switch to SIGTERM from SIGKILL
v3: refactor, wait in bus_start_address()
(cherry picked from commit
392cf1d05dbfa1395f6d99102e5ea41debb58fec)
Yu Watanabe [Fri, 9 Feb 2018 07:21:29 +0000 (16:21 +0900)]
sd-bus: avoid potential memory leaks
(cherry picked from commit
b4ca3f45dc5742ad76e8feebd363c490f92b804f)
Lennart Poettering [Wed, 7 Feb 2018 02:10:09 +0000 (03:10 +0100)]
process-util: use raw_getpid() in getpid_cache() internally (#8115)
We have the raw_getpid() definition in place anyway, and it's certainly
beneficial to expose the same semantics on pre glibc 2.24 and after it
too, hence always bypass glibc for this, and always cache things on our
side.
Fixes: #8113
(cherry picked from commit
996def17f99bb3f41f82032860dfcb98ff19c3ae)
Zbigniew Jędrzejewski-Szmek [Mon, 5 Feb 2018 08:48:38 +0000 (09:48 +0100)]
test: add a simple smoke test for string_hashsum()
This is enough to show memory leakages pointed out by Stef Bon <stefbon@gmail.com>.
(cherry picked from commit
bd181f27d4d0c16c500c9f49394213d1fbad1f09)
MilhouseVH [Mon, 5 Feb 2018 05:26:57 +0000 (05:26 +0000)]
kernel 3.10 compat: RTAX_QUICKACK not added until 3.11.0 (#8094)
(cherry picked from commit
ec79af69a1d159a43deb68c9ec1c31fe89743b6f)
Vito Caputo [Sat, 3 Feb 2018 11:09:08 +0000 (03:09 -0800)]
socket-util: fix getpeergroups() assert(fd) (#8080)
Don't assert on zero-value fds.
Fixes #8075.
(cherry picked from commit
75f40779607ea79f20441c7fb46744d04ee2c7ae)
tblume [Thu, 1 Feb 2018 21:46:15 +0000 (22:46 +0100)]
meson.build: make docdir configurable (#8068)
SUSE is using a different docdir, so the path should be configurable
(cherry picked from commit
75aaade16b00ff519fbaedb4cc773b654c11a34a)
Sven Eden [Wed, 30 May 2018 05:51:02 +0000 (07:51 +0200)]
Save last mutual commit for migration to v237 tag.
Zbigniew Jędrzejewski-Szmek [Sun, 28 Jan 2018 15:54:18 +0000 (16:54 +0100)]
NEWS: add missing equal sign
Important!
Zbigniew Jędrzejewski-Szmek [Sun, 28 Jan 2018 15:52:47 +0000 (16:52 +0100)]
NEWS: reword one sentence
Lennart Poettering [Sun, 28 Jan 2018 15:36:03 +0000 (16:36 +0100)]
NEWS: let's get this thing done
Zbigniew Jędrzejewski-Szmek [Sun, 28 Jan 2018 14:52:06 +0000 (15:52 +0100)]
NEWS: mention --grep (#8029)
Zbigniew Jędrzejewski-Szmek [Sat, 27 Jan 2018 12:00:09 +0000 (13:00 +0100)]
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.
Zbigniew Jędrzejewski-Szmek [Fri, 12 Jan 2018 13:31:49 +0000 (14:31 +0100)]
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.
Zbigniew Jędrzejewski-Szmek [Fri, 12 Jan 2018 06:55:45 +0000 (07:55 +0100)]
journalctl: regexp matching
Zbigniew Jędrzejewski-Szmek [Fri, 12 Jan 2018 04:47:17 +0000 (05:47 +0100)]
meson: detect pcre2 dep
Lennart Poettering [Sun, 28 Jan 2018 12:28:58 +0000 (13:28 +0100)]
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
Alan Jenkins [Fri, 26 Jan 2018 13:42:53 +0000 (13:42 +0000)]
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.
Thomas Hindoe Paaboel Andersen [Sat, 27 Jan 2018 23:05:27 +0000 (00:05 +0100)]
NEWS: typo fix
bleep_blop [Sat, 27 Jan 2018 16:33:52 +0000 (22:03 +0530)]
Update NEWS to reflect changes made in #8020 (#8024)
Batuhan Osman Taşkaya [Sat, 27 Jan 2018 13:03:08 +0000 (16:03 +0300)]
String Formatting Update (#7819)
Changes: % changed as .format()
Lennart Poettering [Sat, 27 Jan 2018 12:52:09 +0000 (13:52 +0100)]
NEWS: get ready for release today (#8019)
Andrew Jeddeloh [Thu, 25 Jan 2018 21:17:17 +0000 (13:17 -0800)]
login/meson.build: require ACL for uaccess rules
Don't install udev rules that requires the uaccess builtin if systemd is
being built without the uaccess builtin.
Zbigniew Jędrzejewski-Szmek [Fri, 26 Jan 2018 15:15:17 +0000 (16:15 +0100)]
meson: use env object instead of string in tags targets
I used 'tags' before because this way we avoided a unnecessary
line about 'env' detection. But we cannot use 'env' in test(), so
previous commit added 'env' detection. We might just as well use
it in custom_target().
Zbigniew Jędrzejewski-Szmek [Fri, 19 Jan 2018 06:54:30 +0000 (17:54 +1100)]
Hook up oss-fuzz test cases as tests
This is a bit painful because a separate build of systemd is necessary. The
tests are guarded by tests!=false and slow-tests==true. Running them is not
slow, but compilation certainly is. If this proves unwieldy, we can add a
separate option controlling those builds later.
The build for each sanitizer has its own directory, and we build all fuzzer
tests there, and then pull them out one-by-one by linking into the target
position as necessary. It would be nicer to just build the desired fuzzer, but
we need to build the whole nested build as one unit.
[I also tried making systemd and nested meson subproject. This would work
nicely, but meson does not allow that because the nested target names are the
same as the outer project names. If that is ever fixed, that would be the way
to go.]
v2:
- make sure things still work if memory sanitizer is not available
v3:
- switch to syntax which works with meson 0.42.1 found in Ubuntu
Andrew Jeddeloh [Thu, 25 Jan 2018 21:17:17 +0000 (13:17 -0800)]
login/meson.build: require ACL for uaccess rules
Don't install udev rules that requires the uaccess builtin if systemd is
being built without the uaccess builtin.
Jason A. Donenfeld [Thu, 25 Jan 2018 20:16:38 +0000 (21:16 +0100)]
NEWS: add self to news file for this late commit
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Clinton Roy [Fri, 26 Jan 2018 10:44:11 +0000 (21:44 +1100)]
News: some fixes and improvements (#8010)
* missing whitespace.
* NEWS: some small fixes and improvements.
Björn Esser [Thu, 25 Jan 2018 14:30:15 +0000 (15:30 +0100)]
firstboot: Include <crypt.h> for declaration of crypt() if needed (#7944)
Not every target system may provide a crypt() function in its stdlibc
and may use an external or replacement library, like libxcrypt, for
providing such functions.
See https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt.
Lennart Poettering [Thu, 25 Jan 2018 13:18:14 +0000 (14:18 +0100)]
meson: bump so revision and systemd version in preparation for v237
Lennart Poettering [Thu, 25 Jan 2018 13:14:35 +0000 (14:14 +0100)]
update TODO
Lennart Poettering [Thu, 25 Jan 2018 12:18:28 +0000 (13:18 +0100)]
NEWS: start putting together an entry for v237
Björn Esser [Thu, 25 Jan 2018 14:30:15 +0000 (15:30 +0100)]
firstboot: Include <crypt.h> for declaration of crypt() if needed (#7944)
Not every target system may provide a crypt() function in its stdlibc
and may use an external or replacement library, like libxcrypt, for
providing such functions.
See https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt.
Yu Watanabe [Thu, 25 Jan 2018 08:45:53 +0000 (17:45 +0900)]
bus-util: fix format of NextElapseUSecRealtime= and LastTriggerUSec=
Before this, `systemctl show` for calendar type timer unit outputs
something like below.
```
NextElapseUSecRealtime=48y 3w 3d 15h
NextElapseUSecMonotonic=0
LastTriggerUSec=48y 3w 3d 3h 41min 44.093095s
LastTriggerUSecMonotonic=0
```
As both NextElapseUSecRealtime= and LastTriggerUSec= are not timespan
but timestamp, this makes format these values by `format_timestamp()`.
Lennart Poettering [Wed, 24 Jan 2018 10:09:29 +0000 (11:09 +0100)]
coccinelle: O_NDELAY → O_NONBLOCK
Apparently O_NONBLOCK is the modern name used in most documentation and
for most cases in our sources. Let's hence replace the old alias
O_NDELAY and stick to O_NONBLOCK everywhere.
Lennart Poettering [Wed, 24 Jan 2018 09:54:10 +0000 (10:54 +0100)]
tmpfiles: make "f" lines behaviour match what the documentation says
CHANGE OF BEHAVIOUR — with this commit "f" line's behaviour is altered
to match what the documentation says: if an "argument" string is
specified it is written to the file only when the file didn't exist
before. Previously, it would be appended to the file each time
systemd-tmpfiles was invoked — which is not a particularly useful
behaviour as the tool is not idempotent then and the indicated files
grow without bounds each time the tool is invoked.
I did some spelunking whether this change in behaviour would break
things, but afaics nothing relies on the previous O_APPEND behaviour of
this line type, hence I think it's relatively safe to make "f" lines
work the way the docs say, rather than adding a new modifier for it or
so.
Triggered by:
https://lists.freedesktop.org/archives/systemd-devel/2018-January/040171.html
Lennart Poettering [Wed, 17 Jan 2018 19:10:22 +0000 (20:10 +0100)]
update TODO
Lennart Poettering [Wed, 17 Jan 2018 17:50:27 +0000 (18:50 +0100)]
core: propagate TasksMax= on the root slice to sysctls
The cgroup "pids" controller is not supported on the root cgroup.
However we expose TasksMax= on it, but currently don't actually apply it
to anything. Let's correct this: if set, let's propagate things to the
right sysctls.
This way we can expose TasksMax= on all units in a somewhat sensible
way.
Lennart Poettering [Wed, 17 Jan 2018 14:39:39 +0000 (15:39 +0100)]
cgroup: when querying the number of tasks in the root slice use the pid_max sysctl
The root cgroup doesn't expose and properties in the "pids" cgroup
controller, hence we need to get the data from somewhere else.
Lennart Poettering [Wed, 17 Jan 2018 17:41:42 +0000 (18:41 +0100)]
cgroup: add proper API to determine whether our unit manags to root cgroup
Lennart Poettering [Wed, 17 Jan 2018 14:35:01 +0000 (15:35 +0100)]
util: rework system_tasks_max() to make use of procfs_tasks_max()
Let's use our new code.
Lennart Poettering [Wed, 17 Jan 2018 17:40:10 +0000 (18:40 +0100)]
util-lib: add new procfs-util.[ch] API for dealing with tasks limits
As it turns out the limit on concurrent tasks on Linux nasty to
determine, hence let's appropriate helpers for this.
Lennart Poettering [Wed, 17 Jan 2018 14:39:16 +0000 (15:39 +0100)]
cgroup: use CGROUP_LIMIT_MAX where appropriate
Lennart Poettering [Wed, 17 Jan 2018 14:31:23 +0000 (15:31 +0100)]
util: introduce more accurate definitions of TASKS_MAX
The maximum number of processes a tasks on the system is usually lower
than what pid_t would allow, and is compiled into the kernel (and
documented in proc(5)). Let's add proper defines for that, so that
we can adjust the pid_max sysctl without fearing invalid accesses.
Lennart Poettering [Wed, 24 Jan 2018 17:01:01 +0000 (18:01 +0100)]
log: remove LOG_TARGET_SAFE pseudo log target
This removes LOG_TARGET_SAFE. It's made redundant by the new
"prohibit-ipc" logging flag, as it used to have a similar effect: avoid
logging to the journal/syslog, i.e. any local services in order to avoid
deadlocks when we lock from PID 1 or its utility processes (such as
generators).
All previous users of LOG_TARGET_SAFE are switched over to the new
setting. This makes things a bit safer for all, as not even the
SYSTEMD_LOG_TARGET env var can be used to accidentally log to the
journal anymore in these programs.
Lennart Poettering [Wed, 24 Jan 2018 16:45:14 +0000 (17:45 +0100)]
log: add brief comment for log_set_open_when_needed() and log_set_always_reopen_console()
These two deserve some explanation...
Lennart Poettering [Wed, 24 Jan 2018 16:36:25 +0000 (17:36 +0100)]
log: add new "prohibit_ipc" flag to logging system
If set, we'll avoid logging to any IPC log targets, i.e. syslog or the
journal, but allow stderr, kmsg, console logging.
This is useful as PID 1 wants to turn this off explicitly as long as the
journal is not up.
Previously we'd open/close the log stream to these services whenever
needed but this is incompatible with the "open_when_needed" logic
introduced in #6915, which might open the log streams whenever it likes,
including possibly inside of the child process we fork off that'll
become journald later on. Hence, let's make this all explicit, and
instead of managing when we open/close log streams add a boolean that
clearly prohibits the IPC targets when needed, so that opening can be
done at any time, but will honour this.
See: #7985
Lennart Poettering [Wed, 24 Jan 2018 16:33:07 +0000 (17:33 +0100)]
log: make log_set_upgrade_syslog_to_journal() take effect immediately
This doesn't matter much, and we don't rely on it, but I think it's much
nicer if we log_set_target() and log_set_upgrade_syslog_to_journal() can
be called in either order and have the same effect.
Nathaniel McCallum [Wed, 24 Jan 2018 14:45:48 +0000 (09:45 -0500)]
Add fd close support to sd_event_source
It is often the case that a file descriptor and its corresponding IO
sd_event_source share a life span. When this is the case, developers will
have to unref the event source and close the file descriptor. Instead, we
can just have the event source take ownership of the file descriptor and
close it when the event source is freed. This is especially useful when
combined with cleanup attributes and sd_event_source_unrefp().
This patch adds two new public functions:
sd_event_source_get_io_fd_own()
sd_event_source_set_io_fd_own()