Commit Graph

1410 Commits

Author SHA1 Message Date
Lennart Poettering f2835dd4a6 logind: use free_and_strdup() where appropriate 2020-12-09 10:09:11 +01:00
Lennart Poettering c74d5fe25d logind: fix closing of button input devices
This is a fix of #17751. Specifically:

1. Sort #include headers again

2. Remove tabs, as per coding style

3. Don't install fds in half-initialized objects

4. Use asynchronous_close() everywhere

That all said:

Quit frankly, I am not convinced we should do all this at all. If
close()ing of these input devices is really that slow, then this should
probably be fixed in the kernel, not worked around in userspace like
this.
2020-12-09 10:08:51 +01:00
nihilix-melix eee582e795 Update logind-button.c 2020-11-28 12:44:48 +01:00
Jörg Thalheim d7aa78c32f meson: add option to skip installing to $sysconfdir
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to https://github.com/systemd/systemd/pull/17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
2020-11-12 11:21:46 +01:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering 74d6421da0 tree-wide: cast result of get_process_comm() to (void) where we ignore it 2020-10-27 14:06:49 +01:00
Yu Watanabe 4b28e50f9e
Merge pull request #17390 from keszybz/logind-notifications-and-links
Fix sd_notify() usage in various daemons and update some documentation links
2020-10-20 13:44:52 +09:00
Zbigniew Jędrzejewski-Szmek 6c75e31703 logind: minor indentation adjustments 2020-10-19 15:23:37 +02:00
Zbigniew Jędrzejewski-Szmek 21fe744cfb logind: use notify_start/notify_on_cleanup
Logging about the pid is dropped, pid1 does that better.
2020-10-19 15:23:37 +02:00
Zbigniew Jędrzejewski-Szmek ab4a88eb92 sd-bus: add custom return code when $XDG_RUNTIME_DIR is not set
We would return ENOENT, which is extremely confusing. Strace is not helpful because
no *file* is actually missing. So let's add some logs at debug level and also use
a custom return code. Let all user-facing utilities print a custom error message
in that case.
2020-10-14 18:28:30 +02:00
Lennart Poettering 5de5dc30df
Merge pull request #17302 from keszybz/fix-inhibitors
Fix inhibitors
2020-10-12 11:41:18 +02:00
Zbigniew Jędrzejewski-Szmek 43e94f86c0 logind: fix taking of inhibitors
Ooops made in 0a9bf7fa59.
2020-10-10 09:58:47 +02:00
Zbigniew Jędrzejewski-Szmek bf135d8258 logind: print what action is ignored
My logs have lines like this:
Oct 10 09:38:38 krowka systemd-logind[1889]: External (2) displays connected.
Oct 10 09:38:38 krowka systemd-logind[1889]: Refusing operation, as it is turned off.
Without some hint *what* operation is ignored, this is not very informative.

(I remember this came up before, but I don't remember why we didn't change this
log line back then...)
2020-10-10 09:58:47 +02:00
Frantisek Sumsal d7a0f1f4f9 tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
Ronan Pigott 60b254ca1a loginctl: add -P as short for --value --property= 2020-09-30 10:25:06 +02:00
Lennart Poettering bcaf20dc38
Merge pull request #17143 from keszybz/late-exec-resolution-alt
Late exec resolution (subset)
2020-09-24 09:38:36 +02:00
Lennart Poettering 21935150a0 tree-wide: switch remaining mount() invocations over to mount_nofollow_verbose()
(Well, at least the ones where that makes sense. Where it does't make
sense are the ones that re invoked on the root path, which cannot
possibly be a symlink.)
2020-09-23 18:57:37 +02:00
Zbigniew Jędrzejewski-Szmek 0a9bf7fa59 logind: use _cleanup_ in one more place 2020-09-22 18:00:44 +02:00
Zbigniew Jędrzejewski-Szmek 0706c01259 Add CLOSE_AND_REPLACE helper
Similar to free_and_replace. I think this should be uppercase to make it
clear that this is a macro. free_and_replace should probably be uppercased
too.
2020-09-18 15:28:48 +02:00
Lennart Poettering 2a03b9ed21 tree-wide: don't needlessly negate error number passed to bus_error_message()
Like it's customary in our codebase bus_error_message() internally takes
abs() of the passed error anyway, hence no need to explicitly negate it.
We mostly got this right, but in too many cases we didn't. Fix that.
2020-09-14 21:42:22 +02:00
Lennart Poettering 1a42ce0920 logind: make sure when we are explicitly asked to terminate session/user/seat to use "replace" job mode
Otherwise our request will possibly fail if something else is already
enqeued, but given this is an explicit user request, let's not allow
things to fail.

Fixes: #16702
2020-09-11 18:09:34 +02:00
Lennart Poettering bda625730d logind: clarify what the second argument of session_stop() means when calling it 2020-09-11 18:09:30 +02:00
Lennart Poettering 40771cf524 logind: minor simplification 2020-09-11 18:09:11 +02:00
Yu Watanabe 196d41bcde login: downgrade log level if the error will be ignored 2020-09-10 15:18:26 +09:00
Lennart Poettering 197db625a3 logind: fix merge issue
The two PRs #16664 and #16635 individually passed CI, but when combined
cannot build. Since both are merged now, let's fix that.
2020-09-09 20:13:57 +02:00
Robert Marko adbb2b6afe login: Add KEY_RESTART handling
KEY_RESTART is widely used in Linux to indicate device reboot.
So lets handle it in the same fashion as KEY_POWER.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
2020-09-09 18:40:13 +02:00
Franck Bui 6e220b4b88 logind.conf: document UserStopDelaySec in logind.conf 2020-09-09 17:46:00 +02:00
Lennart Poettering 12ce0f4173
Merge pull request #16635 from keszybz/do-not-for-each-word
Drop FOREACH_WORD
2020-09-09 17:43:38 +02:00
Zbigniew Jędrzejewski-Szmek 46ed9f4ce1 logind: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Lennart Poettering 643bb92408 logind: always check current tag list before using a device 2020-09-01 17:40:13 +02:00
Lennart Poettering fccb48b286 logind: only apply ACLs for device currently tagged with "uaccess"
This is about security, hence let's be particularly careful here: only
devices currenlty tagged with "uaccess" will get ACL management, and
it's not sufficient if they once were (though that is used for
filtering).
2020-09-01 17:40:12 +02:00
fangxiuning 6d95e7d9b2
tree-wide: drop pointless zero initialization (#16900) 2020-08-30 06:21:20 +09:00
Ikey Doherty 97207ac85c login/logind: Include sys/stat.h for struct stat usage
We need to include `<sys/stat.h>` for usage of the `struct stat` in
the Manager struct, much as we already include `<stdbool.h>` for C99
booleans.

This helps alleviate another minor build failure on non-glibc systems.
2020-08-28 17:44:39 +02:00
PhoenixDiscord e8607daf7d
Replace gendered pronouns with gender neutral ones. (#16844) 2020-08-27 11:52:48 +09:00
Zbigniew Jędrzejewski-Szmek 955a632971 tree-wide: use sd_bus_error_has_names() in more places 2020-08-24 19:48:26 +02:00
Zbigniew Jędrzejewski-Szmek 2aed63f427 tree-wide: fix spelling of "fallback"
Similarly to "setup" vs. "set up", "fallback" is a noun, and "fall back"
is the verb. (This is pretty clear when we construct a sentence in the
present continous: "we are falling back" not "we are fallbacking").
2020-08-20 17:45:32 +02:00
Lennart Poettering 5b14956385
Merge pull request #16543 from poettering/nspawn-run-host
nspawn: /run/host/ tweaks
2020-08-20 16:20:05 +02:00
Lennart Poettering 5d1e68b494 user-runtime-dir: deal gracefully with missing logind properties
Fixes: #16685
2020-08-20 13:12:02 +02:00
Lennart Poettering 3242980582 core: create per-user inaccessible node from the service manager
Previously, we'd create them from user-runtime-dir@.service. That has
one benefit: since this service runs privileged, we can create the full
set of device nodes. It has one major drawback though: it security-wise
problematic to create files/directories in directories as privileged
user in directories owned by unprivileged users, since they can use
symlinks to redirect what we want to do. As a general rule we hence
avoid this logic: only unpriv code should populate unpriv directories.

Hence, let's move this code to an appropriate place in the service
manager. This means we lose the inaccessible block device node, but
since there's already a fallback in place, this shouldn't be too bad.
2020-08-20 10:18:02 +02:00
Lennart Poettering 9fac502920 nspawn,pid1: pass "inaccessible" nodes from cntr mgr to pid1 payload via /run/host
Let's make /run/host the sole place we pass stuff from host to container
in and place the "inaccessible" nodes in /run/host too.

In contrast to the previous two commits this is a minor compat break, but
not a relevant one I think. Previously the container manager would place
these nodes in /run/systemd/inaccessible/ and that's where PID 1 in the
container would try to add them too when missing. Container manager and
PID 1 in the container would thus manage the same dir together.

With this change the container manager now passes an immutable directory
to the container and leaves /run/systemd entirely untouched, and managed
exclusively by PID 1 inside the container, which is nice to have clear
separation on who manages what.

In order to make sure systemd then usses the /run/host/inaccesible/
nodes this commit changes PID 1 to look for that dir and if it exists
will symlink it to /run/systemd/inaccessible.

Now, this will work fine if new nspawn and new pid 1 in the container
work together. as then the symlink is created and the difference between
the two dirs won't matter.

For the case where an old nspawn invokes a new PID 1: in this case
things work as they always worked: the dir is managed together.

For the case where different container manager invokes a new PID 1: in
this case the nodes aren't typically passed in, and PID 1 in the
container will try to create them and will likely fail partially (though
gracefully) when trying to create char/block device nodes. THis is fine
though as there are fallbacks in place for that case.

For the case where a new nspawn invokes an old PID1: this is were the
(minor) incompatibily happens: in this case new nspawn will place the
nodes in the /run/host/inaccessible/ subdir, but the PID 1 in the
container won't look for them there. Since the nodes are also not
pre-created in /run/systed/inaccessible/ PID 1 will try to create them
there as if a different container manager sets them up. This is of
course not sexy, but is not a total loss, since as mentioned fallbacks
are in place anyway. Hence I think it's OK to accept this minor
incompatibility.
2020-08-20 10:17:52 +02:00
Lennart Poettering 39cf0351c5 tree-wide: make use of new relative time events in sd-event.h 2020-07-28 11:24:55 +02:00
Hans de Goede 3a978b30cd logind: Fix org.freedesktop.login1.set-reboot-to-boot-loader-menu saving to the wrong file in the non EFI case
According to the docs, and to the
org.freedesktop.login1.get-reboot-to-boot-loader-menu code, the
(oneshot) boot-loader-menu timeout should be stored in
/run/systemd/reboot-to-boot-loader-menu, but the set method was storing it
in /run/systemd/reboot-to-loader-menu.

This commit fixes this. Note that the fixed name also is a better match
for the dbus call names and matches the related
/run/systemd/reboot-to-boot-loader-entry structure, so fixing the set code,
rather then the get code + docs seems like the right thing to do here.
2020-07-21 10:02:34 +09:00
fangxiuning ddbab78f9a bus: use bus_log_connect_error to print error message 2020-07-21 10:02:01 +09:00
Lennart Poettering 24e2494407
Merge pull request #16385 from JackFangXN/master
table add table_log_xx_error()
2020-07-08 12:12:29 +02:00
fangxiuning 4b6607d949 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
fangxiuning df83eb546b table add table_log_sort_error() 2020-07-08 10:53:57 +08:00
fangxiuning d836018a73 table add table_log_show_error() 2020-07-08 10:50:59 +08:00
Lennart Poettering b3077c47a8
Merge pull request #16344 from keszybz/update-utmp-erofs
Make update-utmp not fail if it only fails to write wtmp records
2020-07-06 17:52:17 +02:00
Zbigniew Jędrzejewski-Szmek c2a9909377 Define _cleanup_ helper for setutxent()+endutxent() 2020-07-05 12:16:01 +02:00