summaryrefslogtreecommitdiffstats
path: root/src/vconsole (follow)
Commit message (Collapse)AuthorAgeFilesLines
* core,vconsole-setup: treat locking failure as non-fatalZbigniew Jędrzejewski-Szmek2024-05-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Locking of the tty device and then /dev/console was added to synchronize vconsole-setup with other writers to the console. But it turns out that often the locking doesn't work and we carved out various cases where we ignore failure: - lack of permissions (in the user manager) - missing device node It turns out that there's at least one more failure mode: we get -EIO when the console is (mis-)configured to point to an invalid device. E.g. in rhbug#2273069 the reporter has a VM in Proxmox without a virtual console configured and has 'console=tty console=ttyS0' on the kernel cmdline. I couldn't reproduce this under libvirt, but failure with EIO has been reported by at least four users in #30501. Note that in systemd-vconsole-setup we report this is a hard failure, while in the manager, we only do a debug line. So it's possible that the failure also occured there, causing the rest of the setup of the tty to be skipped without further notice. Ignore the locking failure, since there's just too many ways it can fail. If we proceed without a lock, we're back to the situation before we started locking, which wasn't too bad. OTOH, skipping setup of the console is problematic for users, and it seems better to try to do the setup without locking. Fixes https://github.com/systemd/systemd/issues/30501, https://bugzilla.redhat.com/show_bug.cgi?id=2273069.
* tree-wide: 'allows to' -> 'allows one to'Luca Boccassi2024-05-141-6/+4
| | | | As flagged by Lintian
* vconsole-setup: fix typoYu Watanabe2024-02-201-2/+2
| | | | Follow-up for 190ff0d0a8d1fc367ec04296f24cd1cab5b7543b.
* vconsole-setup: don't fail if the only found vc is already used by plymouthFranck Bui2024-02-191-11/+37
| | | | | | | | | | | During the boot process, systemd-vconsole-setup can be started when the only allocated VC is already taken by plymouth. This case is expected when a boot splash is displayed hence systemd-vconsole-setup.service should not fail if it happens. However rather than doing nothing, the sysfs utf8 flag is set before exiting early.
* pid1,vconsole-setup: gracefully handle if /dev/vconsole is not accessible ↵Lennart Poettering2024-02-091-8/+4
| | | | | | | | | due to ENODEV I think this is generally the right thing to do and is just an extension of the existing ENOENT check. Prompted by: #31257
* vconsole-setup: remember the correct error value when open_terminal() failsFranck Bui2023-12-181-6/+3
|
* vconsole-setup: handle the case where the vc is in KD_GRAPHICS mode more ↵Franck Bui2023-12-181-16/+37
| | | | | | | | | | | | | | | | | | gracefully Regardless of whether a vc path is passed, the behavior of systemd-vconsole-setup wasn't ideal when either the passed vc or /dev/tty1 was in graphics mode. When a vc in graphics mode was passed, no message was emitted despite the fact that the font settings couldn't be applied. The previous code might have assumed that setfont(8) would throw a warning but that's not case. When no argument was passed, systemd-vconsole-setup was supposed to automatically select a valid tty, init it and copy the font setting to the remaining ttys. However if the selected virtual console was in KD_GRAPHICS mode the initialization of the font failed not only for the selected source vc but for all of them.
* vconsole-setup: use a consistent log level when setfont fails with EX_OSERRFranck Bui2023-12-011-7/+12
| | | | | | | | | | | | | | | | | Since we accept that setfont(8) can fail with EX_OSERR and we dont treat it as an error, dont log this failure at LOG_ERR. Before: ------- /usr/bin/setfont failed with exit status 71. [LOG_ERR] Setting fonts failed with a "system error", ignoring. [LOG_NOTICE] After: ----- /usr/bin/setfont failed with a "system error" (EX_OSERR), ignoring. [LOG_NOTICE] Setting source virtual console failed, ignoring remaining ones [LOG_NOTICE] Follow-up for 93c9a9d235e2304500c490b4868534385f925c76
* pid1,vconsole-setup: lock /dev/console instead of the tty deviceZbigniew Jędrzejewski-Szmek2023-10-191-5/+11
| | | | | | | | | | | | | | As requested in https://github.com/systemd/systemd/pull/27867#pullrequestreview-1567161854. /dev/console, /dev/tty0, and /dev/ttyN are "different" device nodes that may point to a single underlying device. We want to use a single lock so that we don't get a race if different writers are using a different device path, so let's just always lock around /dev/console. This effectively makes the locking less granular. Fixup for a0043bfa51281c2374878e2a98cf2a3ee10fd92c. Fixes https://github.com/systemd/systemd/issues/28721. Maybe fixes https://github.com/systemd/systemd/issues/28778 and https://github.com/systemd/systemd/issues/28634.
* tree-wide: fix typoYu Watanabe2023-10-041-1/+1
|
* io-util: introduce loop_write_full that takes a timeoutMike Yuan2023-09-071-1/+1
| | | | | Also drop do_poll as the use case is covered by timeout.
* vconsole-setup: use "@kernel" rather than "kernel" as special string to ↵Lennart Poettering2023-08-101-1/+1
| | | | | | | | | | | | | leave keymap untouched This is a magic string, and we should avoid stepping into the territory of normal keymap names with that, given that users can pick names otherwise freely. Hence, prefix the name with a special char to avoid any namespace issues. Follow-up for: #28660
* vconsole-setup: simplify error handlingLennart Poettering2023-08-091-6/+6
| | | | | | no need to negate an error which we don't need negated. also, add debug log about errors we ignore.
* vconsole-setup: simplify path allocationLennart Poettering2023-08-091-4/+6
| | | | | | | | Let's code this straighforwadly, and just allocate the string as we need it, instead of doing pre-allocation. This is not performance sensitive, as this will almost certainly just return /dev/tty1 after the first transition.
* vconsole-setup: use FOREACH_ARRAY() at one more placeLennart Poettering2023-08-091-2/+2
|
* vconsole-setup: port to main-func.h boilerplateLennart Poettering2023-08-091-6/+7
|
* vconsole: support KEYMAP=kernel for preserving kernel keymapMike Yuan2023-08-031-1/+1
| | | | | | | | | | Follow-up for #26089 and #28505 Currently, if default-keymap is not empty, there's no way to ask vconsole-setup to retain the kernel keymap. Let's accept a special value "kernel" for that purpose. Addresses the problem mentioned in https://github.com/systemd/systemd/pull/28505#issuecomment-1663681665
* include missing sys/file.h for LOCK_EXKhem Raj2023-08-021-0/+1
|
* meson: move declarations of random-seed, vconsole, and sysupdateYu Watanabe2023-08-011-0/+9
|
* vconsole-setup: don't fail with an empty keymapLuca Boccassi2023-07-241-1/+1
| | | | | | | | The new meson option 'default-keymap' means that by default there's always a keymap to configure, so vconsole-setup fails. Allow to set -Ddefault-keymap="" to disable it and skip gracefully again. Follow-up for f129d0e77c4c9a0e12ae38cd241cd49846844a80
* Merge pull request #27867 from keszybz/vconsole-reload-againLuca Boccassi2023-07-151-0/+9
|\ | | | | Restore ordering between vconsole-setup and firstboot services
| * pid1,vconsole-setup: take a lock for the console deviceZbigniew Jędrzejewski-Szmek2023-07-131-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When systemd-firstboot (or any other unit which uses the tty) is started, systemd will reset the terminal. If systemd-vconsole-setup happens to be running at that time, it'll error out when it tries to use the vconsole fd and gets an EIO from ioctl. e019ea738d63d5f7803f378f8bd3e074d66be08f was the first fix. It added an implicit ordering between units using the tty and systemd-vconsole-setup. (The commit title is wrong. The approach was generalized, but the commit title wasn't updated.) Then cea32691c313b2dab91cef986d08f309edeb4a40 was added to restart systemd-vconsole-setup.service from systemd-firstboot.service. This was OK, with the ordering in place, systemd-vconsole-setup.service would wait until systemd-firstboot.service exited. But this wasn't enough, because we want the key mappings to be loaded immediately after systemd-firstboot writes the config. 8eb668b9ab2f7627a89c95ffd61350ee9d416da1 implemented that, but actually reintroduced the original issue. I had to drop the ordering between the two units because otherwise we'd deadlock, waiting from firstboot for vconsole-setup which wouldn't start while firstboot was running. Restarting vconsole-setup.service from systemd-firstboot.service works just fine, but when vconsole-setup.service is started earlier, it may be interrupted by systemd-firstboot.service. To resolve the issue, let's take a lock around the tty device. The reset is performed after fork, so the (short) delay should not matter too much. In xopenat_lock() the assert on <path> is dropped so that we can call xopenat(fd, NULL) to get a copy of the original fd. Fixes #26908.
* | loop-write: do strlen() implicitly if size is specified as SIZE_MAXLennart Poettering2023-07-131-1/+1
|/ | | | | | | This reduces repetition in the function calls, since quite often we write out strings with loop_write(). Noticed while reviewing #28077.
* vconsole-setup: reduce variable scope, shorten thingsZbigniew Jędrzejewski-Szmek2023-05-191-22/+13
|
* shared/creds-util: return 0 for missing creds in read_credential_strings_manyZbigniew Jędrzejewski-Szmek2023-04-251-5/+2
| | | | | | | | | | | Realistically, the only thing that the caller can do is ignore failures related to missing credentials. If the caller requires some credentials to be present, they should just check which output variables are not NULL. One of the callers was already doing that, and the other wanted to, but missed -ENOENT. By suppressing -ENOENT and -ENXIO, both callers are simplified. Fixes a warning at boot: systemd-vconsole-setup[221]: Failed to import credentials, ignoring: No such file or directory
* vconsole: introduce context_get_config() helper functionYu Watanabe2023-03-241-14/+34
| | | | And make keyboard_load_and_wait() and font_load_and_wait() take Context.
* vconsole: introduce Context and its helper functionsYu Watanabe2023-03-241-41/+149
| | | | | | | Fixes memleaks introduced by 01771226c202183ff447da712f43d2fad8874484 and ea575e176aac9fa8f430bb30a3e8abd8da767a10 Fixes #26945.
* vconsole: allow setting default keymap through build optionMike Yuan2023-02-151-4/+7
| | | | | | | Allow defining the default keymap to be used by vconsole-setup through a build option. A template vconsole.conf also gets populated by tmpfiles if it doesn't exist.
* vconsole: permit configuration of vconsole settings via credentialsLennart Poettering2023-01-051-3/+15
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-4/+4
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* Use https for freedesktop.orgMichael Biebl2022-06-281-1/+1
| | | | grep -l -r http:// | xargs sed -E -i s'#http://(.*).freedesktop.org#https://\1.freedesktop.org#'
* meson: move vconsole rules to rules.d/Zbigniew Jędrzejewski-Szmek2022-05-052-21/+0
|
* meson: also allow setting GIT_VERSION via templatesZbigniew Jędrzejewski-Szmek2022-04-051-1/+1
| | | | | | | | | GIT_VERSION is not available as a config.h variable, because it's rendered into version.h during builds. Let's rework jinja2 rendering to also parse version.h. No functional change, the new variable is so far unused. I guess this will make partial rebuilds a bit slower, but it's useful to be able to use the full version string.
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-11/+3
|
* build: preserve correct mode when generating files via jinja2Christian Brauner2021-11-081-2/+1
| | | | | | | | | When using "capture : true" in custom_target()s the mode of the source file is not preserved when the generated file is not installed and so needs to be tweaked manually. Switch from output capture to creating the target file and copy the permissions from the input file. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
* meson: use jinja2 in src/vconsoleZbigniew Jędrzejewski-Szmek2021-05-192-9/+9
|
* tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-141-2/+2
| | | | | | | With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-01-311-1/+1
| | | | It may be useful when debugging daemons.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-093-3/+3
|
* vconsole-setup: downgrade log message when setting font fails on dummy consoleFranck Bui2020-07-201-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 883eb9be985fd86d9cabe967eeeab91cdd396a81, vconsole-setup might be called again to operate on dummy console where font operations are not supported but where it's still important to have the correct keymap set [0][1]. vconsole-setup is mainly called by udev but can also be run via a dependency of an early service. Both cases might end up calling vconsole-setup on the dummy console. The first case can happen during early boot even on systems that use (instead of the dummy console) a "simple" video console driver supporting font operations (such as vgacon) until a more specific driver (such as i915) takes the console over. While this is happening vgacon is deactivated and temporarly replaced by the dummy console [2]. There are also other cases where systemd-vconsole-setup might be called on dummy console especially during (very) early boot. Indeed systemd-vconsole-setup.service might be pulled in by early interactive services such as 'dracut-cmdline-ask.service` which is run before udev. If that happens on platforms with no grapical HWs (such as embedded ARM) or with dummy console initially installed until a driver takes over (like Xen and xen-fbfront) then setting font will fail. Therefore this patch downgrades the log message emitted when setting font fails to LOG_DEBUG and when font operations is not implemented like it's the case for the dummy console. Fixes: #16406. [0] https://github.com/systemd/systemd/issues/10826 [1] https://bugzilla.redhat.com/show_bug.cgi?id=1652473 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/vga/vgaarb.c?h=v5.7#n204
* tree-wide: drop stdio.h when stdio-util.h is includedYu Watanabe2019-11-031-1/+0
|
* vconsole-setup: rename toggle_utf8() → toggle_utf8_vc()Lennart Poettering2019-07-181-3/+4
| | | | | Let's make clearer that toggle_utf8_sysfs() is about sysfs, and toggle_utf8_vc() about VC access
* Revert "Move verify_vc_kbmode() to terminal-util.c as vt_verify_kbmode()"Lennart Poettering2019-07-181-3/+20
| | | | This reverts commit bb5ac84d79ac3aef606a4a9eeaafef94a1f199be.
* Revert "Add check to switch VTs only between K_XLATE or K_UNICODE"Lennart Poettering2019-07-181-7/+0
| | | | This reverts commit 13a43c73d8cbac4b65472de04bb88ea1bacdeb89.
* Merge pull request #12378 from rbalint/vt-kbd-reset-checkLennart Poettering2019-05-161-20/+10
|\ | | | | VT kbd reset check
| * Add check to switch VTs only between K_XLATE or K_UNICODEBalint Reczey2019-05-151-0/+7
| | | | | | | | | | | | | | Switching to K_UNICODE from other than L_XLATE can make the keyboard unusable and possibly leak keypresses from X. BugLink: https://launchpad.net/bugs/1803993
| * Move verify_vc_kbmode() to terminal-util.c as vt_verify_kbmode()Balint Reczey2019-04-241-20/+3
| |
* | codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|/
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+2
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.