1
0
mirror of https://github.com/systemd/systemd synced 2024-07-01 07:34:28 +00:00

dev-setup: Follow /dev/console symlinks when locking /dev/console

systemd-nspawn sets up /dev/console as a symlink to a pty, so let's
make sure we follow the symlink when trying to lock /dev/console so
we don't fail with ELOOP.
This commit is contained in:
Daan De Meyer 2024-06-07 15:10:58 +02:00 committed by Luca Boccassi
parent d91c7c91bf
commit 774eb5dbdd

View File

@ -22,7 +22,9 @@ int lock_dev_console(void) {
_cleanup_close_ int fd = -EBADF;
int r;
fd = open_terminal("/dev/console", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
/* NB: We do not use O_NOFOLLOW here, because some container managers might place a symlink to some
* pty in /dev/console, in which case it should be fine to lock the target TTY. */
fd = open_terminal("/dev/console", O_RDONLY|O_CLOEXEC|O_NOCTTY);
if (fd < 0)
return fd;