chiark / gitweb /
Lennart Poettering [Sat, 2 Dec 2017 12:07:18 +0000 (13:07 +0100)]
nss-elogind: tweak checks when we consult PID 1 for dynamic UID/GID lookups
Instead of contacting PID 1 for dynamic UID/GID lookups for all
UIDs/GIDs that do not qualify as "system" do the more precise check
instead: check if they actually qualify for the "dynamic" range.
Lennart Poettering [Sat, 2 Dec 2017 11:59:21 +0000 (12:59 +0100)]
user-util: add new uid_is_system() helper
This adds uid_is_system() and gid_is_system(), similar in style to
uid_is_dynamic(). That a helper like this is useful is illustrated by
the fact that test-condition.c didn't get the check right so far, which
this patch fixes.
Lennart Poettering [Sat, 2 Dec 2017 11:48:31 +0000 (12:48 +0100)]
build-sys: make the dynamic UID range, and the container UID range configurable
Also, export these ranges in our pkg-config files.
Zbigniew Jędrzejewski-Szmek [Thu, 23 Nov 2017 12:02:21 +0000 (13:02 +0100)]
util-lib: kill duplicate slashes in lookup paths
Since we're munging the array anyway, we can make the output a bit
nicer too.
Lennart Poettering [Tue, 5 Dec 2017 15:42:58 +0000 (16:42 +0100)]
hexdecoct: fix comment typo (#7548)
Lennart Poettering [Tue, 28 Nov 2017 15:37:53 +0000 (16:37 +0100)]
string-util: rework strextend() to optionally inset separators between each appended string
This adds a new flavour of strextend(), called
strextend_with_separator(), which takes an optional separator string. If
specified, the separator is inserted between each appended string, as
well as before the first one, but only if the original string was
non-empty.
This new call is particularly useful when appending new options to mount
option strings and suchlike, which need to be comma-separated, and
initially start out from an empty string.
Yu Watanabe [Tue, 5 Dec 2017 05:01:39 +0000 (14:01 +0900)]
meson: fix indentation
Lennart Poettering [Sun, 3 Dec 2017 19:57:24 +0000 (20:57 +0100)]
util-lib,tests: rework unbase64 so that we skip over whitespace automatically (#7522)
Let's optimize things a bit, and instead of having to strip whitespace
first before decoding base64, let's do that implicitly while doing so.
Given that base64 was designed the way it was designed specifically to
be tolerant to whitespace changes, it's a good idea to do this
automatically and implicitly.
Ikey Doherty [Sun, 3 Dec 2017 12:28:23 +0000 (12:28 +0000)]
sysusers: Provide meson argument to set gid for 'users' group (#7533)
To allow better integration with distributions requiring an explicitly
set gid for the `users` group, provide the new `-Dusers-gid` option to
set to a new numeric value.
In the absence of a specified gid, we'll fallback to the default existing
behaviour of `-` as the gid value, to automatically assign the next available
gid on the system.
Yu Watanabe [Thu, 30 Nov 2017 16:15:42 +0000 (01:15 +0900)]
fs-util: remove comment about non-existing function
Yu Watanabe [Thu, 30 Nov 2017 17:19:44 +0000 (02:19 +0900)]
fs-util: chase_symlinks(): remove unnecessary slash at the head
Before this, chase_symlinks("/../../foo/bar",...) returns //foo/bar.
This removes the unnecessary slash at the head.
Vito Caputo [Sat, 2 Dec 2017 00:49:52 +0000 (16:49 -0800)]
*: fix some inconsistent control statement style
Zbigniew Jędrzejewski-Szmek [Fri, 1 Dec 2017 15:25:19 +0000 (16:25 +0100)]
NEWS: update the text a bit (#7524)
This fixes various typos, removes some duplications, and adds a bit more
detail in the few places which are potential pitfalls for users.
Also change the way the paragraphs about new options begin, because having
a paragraph saying "Two new options have been added", and then bit lower
again "Two new options have been added" is confusing.
Zbigniew Jędrzejewski-Szmek [Wed, 29 Nov 2017 19:02:11 +0000 (20:02 +0100)]
Add x-elogind.growfs option for fstab
Zbigniew Jędrzejewski-Szmek [Tue, 21 Nov 2017 22:18:05 +0000 (23:18 +0100)]
Add x-elogind.makefs option for fstab
I opted to completely generate a unit for both mount points and swaps. For
swaps, it would be possible to use fixed template unit like elogind-mkswap@.service,
because there's no information passed except the device name. For mount points,
that's not possible because both the device name and file system type need to
be passed. Nevertheless, I expect that options will need to passed to both mkfs
and mkswap, in which case it'll be necessary to create units of both types
anyway.
Zbigniew Jędrzejewski-Szmek [Sun, 26 Nov 2017 21:51:29 +0000 (22:51 +0100)]
Add mkfs wrapper which first checks if the partition is empty
Zbigniew Jędrzejewski-Szmek [Tue, 21 Nov 2017 17:56:52 +0000 (18:56 +0100)]
growfs: add support for resizing encrypted partitions
Zbigniew Jędrzejewski-Szmek [Mon, 23 Oct 2017 11:40:38 +0000 (13:40 +0200)]
Add elogind-growfs tool
Zbigniew Jędrzejewski-Szmek [Tue, 31 Oct 2017 09:52:30 +0000 (10:52 +0100)]
test-mount-util: move test_path_is_mount_point here
path-util.c and mount-util.c are intertwined, but path_is_mount_point() is
defined in mount-util.c.
No functional difference.
Krzysztof Nowicki [Thu, 30 Nov 2017 10:59:29 +0000 (11:59 +0100)]
Fix SELinux labels in cgroup filesystem root directory (#7496)
When using SELinux with legacy cgroups the tmpfs on /sys/fs/cgroup is by
default labelled as tmpfs_t. This label is also inherited by the "cpu"
and "cpuacct" symbolic links. Unfortunately the policy expects them to
be labelled as cgroup_t, which is used for all the actual cgroup
filesystems. Failure to do so results in a stream of denials.
This state cannot be fixed reliably when the cgroup filesystem structure
is set-up as the SELinux policy is not yet loaded at this
moment. It also cannot be fixed later as the root of the cgroup
filesystem is remounted read-only. In order to fix it the root of the
cgroup filesystem needs to be temporary remounted read-write, relabelled
and remounted back read-only.
Zbigniew Jędrzejewski-Szmek [Tue, 28 Nov 2017 20:46:53 +0000 (21:46 +0100)]
meson: emit a warning if rootprefix is set
It's printed at the end because it's the easiest to spot there.
When meson is upgraded to 0.43.1, we'll be able to use warning() instead.
Lennart Poettering [Mon, 27 Nov 2017 15:06:39 +0000 (16:06 +0100)]
fileio: document why fileio-label.c and fileio.c are two different modules
Lennart Poettering [Wed, 22 Nov 2017 11:10:39 +0000 (12:10 +0100)]
logind: fix sysfs change trigger code
We can't create files in sysfs, hence don't bother. Also if we ignore
the return value, do so explicitly by casting to void.
Lennart Poettering [Tue, 21 Nov 2017 16:52:31 +0000 (17:52 +0100)]
specifier: add helper for escaping '%' characters to avoid making them subject for expansion
This is ultimately just a wrapper around strreplace(), but it makes
things a bit more self-descriptive.
Lennart Poettering [Tue, 21 Nov 2017 18:38:49 +0000 (19:38 +0100)]
string-util: update strreplace() a bit, use GREEDY_REALLOC()
Zbigniew Jędrzejewski-Szmek [Tue, 28 Nov 2017 11:35:49 +0000 (12:35 +0100)]
Add set/hashmap helpers for non-trivial freeing and use where straighforward
A macro is needed because otherwise we couldn't ensure type safety.
Some simple tests are included.
No functional change intended.
Zbigniew Jędrzejewski-Szmek [Tue, 28 Nov 2017 19:00:10 +0000 (20:00 +0100)]
Revert "meson: drop rootprefix option"
This reverts commit
ee4bfa21f62dbf4d8f2be27d3c763c3c16743bfd.
Also add comment so that this doesn't get deleted again by mistake.
Replaces #7461.
Yu Watanabe [Tue, 28 Nov 2017 13:06:34 +0000 (22:06 +0900)]
cap-list: check range of numeric value
Yu Watanabe [Tue, 28 Nov 2017 09:11:58 +0000 (18:11 +0900)]
alloc-util: coding style fix
Zbigniew Jędrzejewski-Szmek [Mon, 27 Nov 2017 21:52:32 +0000 (21:52 +0000)]
test-process-util: add (void) cast to make coverity happy
The intent is for the call to succeed only when privileged, so make
that clear.
Lennart Poettering [Mon, 27 Nov 2017 15:28:53 +0000 (16:28 +0100)]
sd-resolve: propagate timeouts in sd_resolve_wait() the same way as in sd_bus_wait(): ETIMEDOUT
Thankfully this is an internal API still, so we can mkae changes like
this.
Lennart Poettering [Mon, 13 Nov 2017 18:06:11 +0000 (19:06 +0100)]
logind: use the new FDSTOREREMOVE=1 sd_notify() message
Let's explicitly tell PID 1 that we don't need an fd anymore, instead of
relying exclusively on POLLERR/POLLHUP for it to be removed.
Fixes: #6908
Lennart Poettering [Mon, 13 Nov 2017 17:26:04 +0000 (18:26 +0100)]
core: add a new sd_notify() message for removing fds from the FD store again
Currenly the only way to remove fds from the fdstore is to fully
stop the service, or to somehow trigger POLLERR/POLLHUP on the fd, in
which case elogind will remove the fd automatically.
Let's add another way: a new message that can be sent to remove fds
explicitly, given their name.
Lennart Poettering [Mon, 13 Nov 2017 17:19:53 +0000 (18:19 +0100)]
man: slightly improve the sd_notify() documentation regarding READY=1
READY=1 may be used to signal when a service finished startup, but also
when it finished reloading. Say so.
Lennart Poettering [Mon, 13 Nov 2017 17:14:20 +0000 (18:14 +0100)]
core: only process one of READY=1, STOPPING=1 or RELOADING=1 in sd_notify() handling
Of course, it's not really a valid sd_notify() message if multiple of
these fields are used in one, but let's handle this somewhat gracefully,
by only processing one of them, and ignoring the rest.
Lennart Poettering [Mon, 13 Nov 2017 17:06:09 +0000 (18:06 +0100)]
service: reorder sd_notify() handling a bit
Let's keep handling of WATCHDOG= and WATCHDOG_USEC= together. No
functional changes.
Lennart Poettering [Mon, 27 Nov 2017 07:15:07 +0000 (08:15 +0100)]
logind: make sure we don't acces m->action_what if it's not initialized (#7475)
Fixes: #7466
Evgeny Vereshchagin [Sun, 26 Nov 2017 11:46:56 +0000 (14:46 +0300)]
exec-util: initialize `new` before using it (#7471)
CID #
1383004
Yu Watanabe [Sat, 25 Nov 2017 17:40:23 +0000 (02:40 +0900)]
fileio: include sys/mman.h
Yu Watanabe [Sat, 25 Nov 2017 17:17:06 +0000 (02:17 +0900)]
meson: update header file to detect memfd_create()
Lennart Poettering [Fri, 24 Nov 2017 21:02:22 +0000 (22:02 +0100)]
core: warn about left-over processes in cgroup on unit start
Now that we don't kill control processes anymore, let's at least warn
about any processes left-over in the unit cgroup at the moment of
starting the unit.
Lennart Poettering [Fri, 24 Nov 2017 18:51:36 +0000 (19:51 +0100)]
unit: initialize bpf cgroup realization state properly
Before this patch, the bpf cgroup realization state was implicitly set
to "NO", meaning that the bpf configuration was realized but was turned
off. That means invalidation requests for the bpf stuff (which we issue
in blanket fashion when doing a daemon reload) would actually later
result in a us re-realizing the unit, under the assumption it was
already realized once, even though in reality it never was realized
before.
This had the effect that after each daemon-reload we'd end up realizing
*all* defined units, even the unloaded ones, populating cgroupfs with
lots of unneeded empty cgroups.
With this fix we properly set the realiazation state to "INVALIDATED",
i.e. indicating the bpf stuff was never set up for the unit, and hence
when we try to invalidate it later we won't do anything.
Lennart Poettering [Fri, 24 Nov 2017 18:48:38 +0000 (19:48 +0100)]
cgroup: when dispatching the cgroup realization queue, check again if we shall actually realize
We add units to the cgroup realization queue when propagating realizing
requests to sibling units, and when invalidating cgroup settings because
some cgroup setting changed. In the time between where we add the unit
to the queue until the cgroup is actually dispatched the unit's state
might have changed however, so that the unit doesn't actually need to be
realized anymore, for example because the unit went down. To handle
that, check the unit state again, if realization makes sense.
Redundant realization is usually not a problem, except when the unit is
not actually running, hence check exactly for that.
Lennart Poettering [Fri, 24 Nov 2017 18:37:01 +0000 (19:37 +0100)]
cgroup: drop unused parameter from function
Yu Watanabe [Sat, 25 Nov 2017 15:01:55 +0000 (00:01 +0900)]
test: set log_level to info in test-hwdb and check-help-*
These tests check the stderr. So, if the elogind.log_level=debug
is set in the kernel command line, then these tests fail.
This set log_level to info in hwdb-test.sh and meson-check-help.sh,
the kernel command line not to change the output of the target
programs.
Fixes #7362.
Yu Watanabe [Sat, 25 Nov 2017 11:35:24 +0000 (20:35 +0900)]
meson: remove abbreviations in status
Zbigniew Jędrzejewski-Szmek [Fri, 24 Nov 2017 13:00:29 +0000 (14:00 +0100)]
meson: restore building of man pages on demand even if -Dman=false
I want to configure -Dman=false for speed, but be able to build a specific
man page sometimes to check my edits. Commit
5b316b9ea6c broke this by mistake.
Let's adjust the condition to better match the logic of disabling tests only
if xsltproc is really not found.
Daniel Lockyer [Fri, 24 Nov 2017 10:36:04 +0000 (10:36 +0000)]
Replace use of snprintf with xsprintf
Daniel Lockyer [Fri, 24 Nov 2017 10:33:41 +0000 (10:33 +0000)]
Replace free and reassignment with free_and_replace
Daniel Lockyer [Fri, 24 Nov 2017 10:31:49 +0000 (10:31 +0000)]
Replace free and return NULL with return mfree
Daniel Lockyer [Fri, 24 Nov 2017 09:37:50 +0000 (09:37 +0000)]
Replace free and nullify by mfree
Shawn Landden [Fri, 24 Nov 2017 09:08:12 +0000 (01:08 -0800)]
__attribute__((fallthrough)) only when -Wimplicit-fallthrough (#7448)
That is version 7 or greater
https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Fix regression of https://github.com/elogind/elogind/pull/7389
82a27ba8217d09e4fef4c9550f8b733d174c5705
on older gccs
bumping to re-run CI
upstream FAIL timed out
boot-smoke FAIL non-zero exit status 1
Yu Watanabe [Thu, 23 Nov 2017 13:20:22 +0000 (22:20 +0900)]
meson: do not install RPM macros if rpmmacrosdir is set to no (#7430)
Fixes #7427.
Lennart Poettering [Thu, 23 Nov 2017 11:44:17 +0000 (12:44 +0100)]
mount-util: fix error propagation in fd_fdinfo_mnt_id()
Evgeny Vereshchagin [Thu, 23 Nov 2017 10:07:20 +0000 (13:07 +0300)]
cgroup: downgrade the log level of "invocation id" messages to debug (#7422)
Now that
d3070fbdf6077d7d has been merged, these errors are not as
critical as they used to be.
Zbigniew Jędrzejewski-Szmek [Wed, 22 Nov 2017 11:42:28 +0000 (12:42 +0100)]
meson: re-attach rule-syntax-check.py test
39/248 rule-syntax-check OK 0.07 s
Simon Peeters [Sun, 6 Nov 2016 15:09:32 +0000 (16:09 +0100)]
udevd: use list.h instead of udev_list_node
Susant Sahani [Wed, 22 Nov 2017 07:23:22 +0000 (12:53 +0530)]
networkd: introduce vxcan netdev. (#7150)
Similar to the virtual ethernet driver veth, vxcan implements a
local CAN traffic tunnel between two virtual CAN network devices.
When creating a vxcan, two vxcan devices are created as pair
When one end receives the packet it appears on its pair and vice
versa. The vxcan can be used for cross namespace communication.
Zbigniew Jędrzejewski-Szmek [Mon, 20 Nov 2017 13:23:40 +0000 (14:23 +0100)]
meson: "upgrade" -Wimplicit-fallthrough to 5
5 means that only the explicit attribute introduced in previous commit
is accepted. We don't want the comments anymore.
Lennart Poettering [Fri, 17 Nov 2017 18:25:18 +0000 (19:25 +0100)]
cgroup: fix delegation on the unified hierarchy
Make sure to add the delegation mask to the mask of controllers we have
to enable on our own unit. Do not claim it was a members mask, as such
a logic would mean we'd collide with cgroupv2's "no processes on inner
nodes policy".
This change does the right thing: it means any controller enabled
through Controllers= will be made available to subcrgoups of our unit,
but the unit itself has to still enable it through
cgroup.subtree_control (which it can since that file is delegated too)
to be inherited further down.
Or to say this differently: we only should manipulate
cgroup.subtree_control ourselves for inner nodes (i.e. slices), and
for leaves we need to provide a way to enable controllers in the slices
above, but stay away from the cgroup's own cgroup.subtree_control —
which is what this patch ensures.
Fixes: #7355
Lennart Poettering [Fri, 17 Nov 2017 18:24:06 +0000 (19:24 +0100)]
cgroup: properly determine cgroups zombie processes belong to
When a process becomes a zombie its cgroup might be deleted. Let's add
some minimal code to detect cases like this, so that we can still
attribute this back to the original cgroup.
Shawn Landden [Sun, 19 Nov 2017 18:06:10 +0000 (10:06 -0800)]
tree-wide: adjust fall through comments so that gcc is happy
Distcc removes comments, making the comment silencing
not work.
I know there was a decision against a macro in commit
ec251fe7d5bc24b5d38b0853bc5969f3a0ba06e2
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'
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.
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.
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.
Zbigniew Jędrzejewski-Szmek [Sat, 18 Nov 2017 16:52:56 +0000 (17:52 +0100)]
Add missing headers and SPDX identifiers to man pages
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
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.
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.
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.
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.
Lennart Poettering [Thu, 2 Nov 2017 18:43:32 +0000 (21:43 +0300)]
core: implement /run/elogind/units/-based path for passing unit info from PID 1 to journald
And let's make use of it to implement two new unit settings with it:
1. LogLevelMax= is a new per-unit setting that may be used to configure
log priority filtering: set it to LogLevelMax=notice and only
messages of level "notice" and lower (i.e. more important) will be
processed, all others are dropped.
2. LogExtraFields= is a new per-unit setting for configuring per-unit
journal fields, that are implicitly included in every log record
generated by the unit's processes. It takes field/value pairs in the
form of FOO=BAR.
Also, related to this, one exisiting unit setting is ported to this new
facility:
3. The invocation ID is now pulled from /run/elogind/units/ instead of
cgroupfs xattrs. This substantially relaxes requirements of elogind
on the kernel version and the privileges it runs with (specifically,
cgroupfs xattrs are not available in containers, since they are
stored in kernel memory, and hence are unsafe to permit to lesser
privileged code).
/run/elogind/units/ is a new directory, which contains a number of files
and symlinks encoding the above information. PID 1 creates and manages
these files, and journald reads them from there.
Note that this is supposed to be a direct path between PID 1 and the
journal only, due to the special runtime environment the journal runs
in. Normally, today we shouldn't introduce new interfaces that (mis-)use
a file system as IPC framework, and instead just an IPC system, but this
is very hard to do between the journal and PID 1, as long as the IPC
system is a subject PID 1 manages, and itself a client to the journal.
This patch cleans up a couple of types used in journal code:
specifically we switch to size_t for a couple of memory-sizing values,
as size_t is the right choice for everything that is memory.
Fixes: #4089
Fixes: #3041
Fixes: #4441
Zbigniew Jędrzejewski-Szmek [Wed, 15 Nov 2017 09:19:45 +0000 (10:19 +0100)]
core: fix message about detected memory hierarchy
Just the error check and message were wrong, otherwise the logic was OK.
Zbigniew Jędrzejewski-Szmek [Tue, 14 Nov 2017 20:29:40 +0000 (21:29 +0100)]
Use plural DelegateControllers= consistently
Alan Jenkins [Fri, 15 Sep 2017 16:35:02 +0000 (17:35 +0100)]
logind: fix SetLinger to authorize by client's effective User ID
SetLinger is authorized by the PolicyKit action "set-self-linger", if it is
not passed an explicit UID.
According to comments we were determining the default UID from the client's
session. However, user processes e.g. which are run from a terminal
emulator do not necessarily belong to a session scope unit. They may
equally be started from the elogind user manager [1][2]. Actually the
comment was wrong, and it would also have worked for processes
started from the elogind user manager.
Nevertheless it seems to involve fetching "augmented credentials" i.e.
it's using a racy method, so we shouldn't have been authenticating based
on it.
We could change the default UID, but that raises issues especially for
consistency between the methods. Instead we can just use the clients
effective UID for authorization.
This commit also fixes `loginctl enable-linger $USER` to match the docs
that say it was equivalent to `loginctl enable-linger` (given that $USER
matches the callers user and owner_uid). Previously, the former would not
have suceeded for unpriviliged users in the default configuration.
[1] It seems the main meaning of per-session scopes is tracking the PAM
login process. Killing that provokes logind to revoke device access. Less
circularly, killing it provokes getty to hangup the TTY.
[2] User units may be started with an environment which includes
XDG_SESSION_ID (presuambly GNOME does this?). Or not.
Alan Jenkins [Mon, 18 Sep 2017 17:04:59 +0000 (18:04 +0100)]
loginctl: enable-linger does not need fallback to XDG_SESSION_ID
To maintain consistency with `loginctl user-status`, drop the fallback to
XDG_SESSION_ID for `loginctl enable-linger`. The fallback was unnecessary
and also incorrect: it passed the numeric value of the session identifier
as a UID value.
Alan Jenkins [Sat, 14 Oct 2017 08:25:56 +0000 (09:25 +0100)]
logind: "self" objects which do not apply - return specific error messages
It's confusing that the bus API has aliases like "session/self" that return
an error based on ENXIO, when it also has methods that return e.g.
NO_SESSION_FOR_PID for the same problem. The latter kind of error includes
more specifically helpful messages.
"user/self" is the odd one out; it returns a generic UnknownObject error
when it is not applicable to the caller. It's not clear whether this was
intentional, but at first I thought it was more correct. More
specifically, user_object_find() was returning 0 for "user/self", in the
same situations (more or less) where user_node_enumerator() was omitting
"user/self". I thought that was a good idea, because returning e.g. -ENXIO instead
suggested that there _is_ something specific on that path. And it could be
confused with errors of the method being called.
Therefore I suggested changing the enumerator, always admitting that there
is a handler for the path "foo/self", but returning a specific error when
queried. However this interacts poorly with tools like D-Feet or `busctl`.
In either tool, looking at logind would show an error message, and then go
on to omit "user/self" in the normal listing. These tools are very useful,
so we don't want to interfere with them.
I think we can change the error codes without causing problems. The self
objects were not listed in the documentation. They have been suggested to
other projects - but without reference to error reporting. "seat/self" is
used by various Wayland compositors for VT switching, but they don't appear
to reference specific errors.
We _could_ insist on the link between enumeration and UnknownObject, and
standardize on that as the error for the aliases. But I'm not aware of any
practical complaints, that we returned an error from an object that didn't
exist.
Instead, let's unify the codepaths for "user/self" vs GetUserByPid(0) etc.
We will return the most helpful error message we can think of, if the
object does not exist. E.g. for "session/self", we might return an error
that the caller does not belong to a session. If one of the compositors is
ever simplified to use "session/self" in initialization, users would be
able to trigger such errors (e.g. run `gnome-shell` inside gnome-terminal).
The message text will most likely be logged. The user might not know what
the "session" is, but at least we'll be pointing towards the right
questions. I think it should also be clearer for development / debugging.
Unifying the code paths is also slightly helpful for auditing / marking
calls to sd_bus_creds_get_session() in subsequent commits.
Topi Miettinen [Mon, 13 Nov 2017 21:00:03 +0000 (21:00 +0000)]
basic: remove redundant check (#7320)
The check is redundant as the whole block is only evaluated if
__IGNORE_pkey_mprotect is not defined. Change to #else.
Lennart Poettering [Thu, 9 Nov 2017 14:29:34 +0000 (15:29 +0100)]
core: rework the Delegate= unit file setting to take a list of controller names
Previously it was not possible to select which controllers to enable for
a unit where Delegate=yes was set, as all controllers were enabled. With
this change, this is made configurable, and thus delegation units can
pick specifically what they want to manage themselves, and what they
don't care about.
Lennart Poettering [Wed, 8 Nov 2017 20:38:51 +0000 (21:38 +0100)]
conf-parser: simplify things a bit by using strextend()
Lennart Poettering [Wed, 8 Nov 2017 18:16:03 +0000 (19:16 +0100)]
cgroup: make use of unit_get_subtree_mask() where appropriate
subtree_mask is own_mask | members_mask, let's make use of that to
shorten a few things
Lennart Poettering [Wed, 8 Nov 2017 17:39:28 +0000 (18:39 +0100)]
cgroup-util: add brief comments clarifying which controllers are v2-only and which v1-only
Zbigniew Jędrzejewski-Szmek [Mon, 13 Nov 2017 08:27:53 +0000 (09:27 +0100)]
basic/missing: add numbers for pkey_mprotect
Follow-up for
b835eeb4ec1dd122b6feff2b70881265c529fcdd.
Lennart Poettering [Fri, 10 Nov 2017 20:41:53 +0000 (21:41 +0100)]
string-util: when ellipsizing to a length if (size_t) -1, become a NOP
Let's say that (size_t) -1 (i.e. SIZE_T_MAX) is equivalent to
"unbounded" ellipsation, i.e. ellipsation as NOP. In which case the
relevant functions become little more than strdup()/strndup().
This is useful to simplify caller code in case we want to turn off
ellipsation in certain code paths with minimal caller-side handling for
this.
Lennart Poettering [Fri, 10 Nov 2017 20:10:17 +0000 (21:10 +0100)]
pager: cache not only number of columns but also of lines before we open pager
Not that we need it, but let's do this as matter of completeness.
Lennart Poettering [Wed, 25 Oct 2017 18:46:01 +0000 (20:46 +0200)]
core: track why unit dependencies came to be
This replaces the dependencies Set* objects by Hashmap* objects, where
the key is the depending Unit, and the value is a bitmask encoding why
the specific dependency was created.
The bitmask contains a number of different, defined bits, that indicate
why dependencies exist, for example whether they are created due to
explicitly configured deps in files, by udev rules or implicitly.
Note that memory usage is not increased by this change, even though we
store more information, as we manage to encode the bit mask inside the
value pointer each Hashmap entry contains.
Why this all? When we know how a dependency came to be, we can update
dependencies correctly when a configuration source changes but others
are left unaltered. Specifically:
1. We can fix UDEV_WANTS dependency generation: so far we kept adding
dependencies configured that way, but if a device lost such a
dependency we couldn't them again as there was no scheme for removing
of dependencies in place.
2. We can implement "pin-pointed" reload of unit files. If we know what
dependencies were created as result of configuration in a unit file,
then we know what to flush out when we want to reload it.
3. It's useful for debugging: "elogind-analyze dump" now shows
this information, helping substantially with understanding how
elogind's dependency tree came to be the way it came to be.
Lennart Poettering [Tue, 24 Oct 2017 10:18:27 +0000 (12:18 +0200)]
virt: trivial whitespace fixes
Zbigniew Jędrzejewski-Szmek [Fri, 10 Nov 2017 14:44:58 +0000 (15:44 +0100)]
basic/hashmap: add cleanup of memory pools (#7164)
It was dropped in
89439d4fc0d29f04ac68432fd06ab84bc4e36e20. As a result, every
process that uses a hashmap allocates and then leaks the hashmap mempools.
The mempools are only allocated in the main thread, but we don't know where
the memory is used.
So let's check if we are the last thread and free the mempools then. This is
fairly heavy, because /proc/self/status has to be opened and parsed, but we do
it only when compiled for valgrind, i.e. not by default, and compared to running
under valgrind or asan, the extra cost is acceptable. The big advantage is that
we don't have to think or filter out this false positive.
As a micro-opt, cleanup is attempted only in the main thread. We could allow
any thread to check if it is the last one and perform cleanup, but that'd mean
that we'd have to _do_ the check in every thread. We don't use threads like
that, our non-main threads are always short-lived, so let's just accept the
possibility that we'll leak memory if a thread survives. The check is also
non-atomic, but it's called in a destructor of the main thread _and_ we do
cleanup only when there are no other threads, so the risk of some library
suddenly spawning another thread is very low. All in all, this is not perfect,
but should work in 999‰ of cases.
Fixes the following valgrind warning:
==22564== HEAP SUMMARY:
==22564== in use at exit: 8,192 bytes in 2 blocks
==22564== total heap usage: 243 allocs, 241 frees, 151,905 bytes allocated
==22564==
==22564== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 2
==22564== at 0x4C2FB6B: malloc (vg_replace_malloc.c:299)
==22564== by 0x4F08A8C: mempool_alloc_tile (mempool.c:62)
==22564== by 0x4F08B16: mempool_alloc0_tile (mempool.c:81)
==22564== by 0x4EF8DE0: hashmap_base_new (hashmap.c:748)
==22564== by 0x4EF8ED9: internal_hashmap_new (hashmap.c:782)
==22564== by 0x11045D: test_hashmap_copy (test-hashmap-plain.c:87)
==22564== by 0x115722: test_hashmap_funcs (test-hashmap-plain.c:914)
==22564== by 0x10FC9D: main (test-hashmap.c:60)
==22564==
==22564== 4,096 bytes in 1 blocks are still reachable in loss record 2 of 2
==22564== at 0x4C2FB6B: malloc (vg_replace_malloc.c:299)
==22564== by 0x4F08A8C: mempool_alloc_tile (mempool.c:62)
==22564== by 0x4F08B16: mempool_alloc0_tile (mempool.c:81)
==22564== by 0x4EF8DE0: hashmap_base_new (hashmap.c:748)
==22564== by 0x4EF8EF8: internal_ordered_hashmap_new (hashmap.c:786)
==22564== by 0x10A2A0: test_ordered_hashmap_copy (test-hashmap-ordered.c:89)
==22564== by 0x10F70F: test_ordered_hashmap_funcs (test-hashmap-ordered.c:916)
==22564== by 0x10FCA2: main (test-hashmap.c:61)
==22564==
==22564== LEAK SUMMARY:
==22564== definitely lost: 0 bytes in 0 blocks
==22564== indirectly lost: 0 bytes in 0 blocks
==22564== possibly lost: 0 bytes in 0 blocks
==22564== still reachable: 8,192 bytes in 2 blocks
==22564== suppressed: 0 bytes in 0 blocks
v2:
- check if we are the main thread
v3:
- check if there are no other threads
tblume [Fri, 10 Nov 2017 09:31:44 +0000 (10:31 +0100)]
elogind-firstboot: add vconsole keymap support (#7035)
Enable elogind-firstboot to set the keymap.
RFE:
https://github.com/elogind/elogind/issues/6346
Yu Watanabe [Thu, 9 Nov 2017 09:38:02 +0000 (18:38 +0900)]
tree-wide: do not work in assert()
Follow-up for
85e55d14dea66f5fe412ca8128487d5ea828b7b1.
Tom Stellard [Tue, 31 Oct 2017 15:46:24 +0000 (08:46 -0700)]
udev-rules: Permission changes for /dev/dri/renderD*
- Remove the uaccess tag from /dev/dri/renderD*.
- Change the owning group from video to render.
- Change default mode to 0666.
- Add an option to allow users to set the access mode for these devices at
compile time.
Tom Stellard [Tue, 31 Oct 2017 15:41:53 +0000 (08:41 -0700)]
udev-rules: Permission changes for /dev/kvm
- Remove uaccess tag from /dev/kvm.
- Change the default mode for /dev/kvm to 0666.
Yu Watanabe [Tue, 7 Nov 2017 13:04:20 +0000 (22:04 +0900)]
tree-wide: do not work in assert() (#7271)
Fixes #7270.
Zbigniew Jędrzejewski-Szmek [Wed, 1 Nov 2017 22:06:27 +0000 (23:06 +0100)]
test-util: silence clang warning about unaligned access
Zbigniew Jędrzejewski-Szmek [Wed, 1 Nov 2017 22:01:24 +0000 (23:01 +0100)]
util-lib: mark variable with _unused_ to silence clang warning
_unused_ means "the variable is meant to be possible unused and gcc
will not generate a warning about it", which is exactly what we need here,
since we're only declaring it for the side effect of _cleanup_.
Zbigniew Jędrzejewski-Szmek [Wed, 1 Nov 2017 21:32:22 +0000 (22:32 +0100)]
Remove a bunch of unused variables
gcc does not warn about those, because of the _cleanup_ usage.
clang is smarter here.
Yu Watanabe [Tue, 31 Oct 2017 08:12:13 +0000 (17:12 +0900)]
meson: do not include man/meson.build if xsltproc not found
Fixes #7232.
Lennart Poettering [Wed, 4 Oct 2017 15:34:03 +0000 (17:34 +0200)]
fs-util: small tweak in chase_symlinks()
If we follow an absolute symlink there's no need to prefix the path with
a "/", since by definition it already has one.
This helps suppressing double "/" in resolved paths containing absolute
symlinks.
Razvan Cojocaru [Thu, 26 Oct 2017 14:59:04 +0000 (17:59 +0300)]
elogind-detect-virt: refine hypervisor detection (#7171)
Continue to try to get more details about the actual underlying
hypervisor with successive tests until none are available.
This fixes issue #7165.