summaryrefslogtreecommitdiffstats
path: root/src/vconsole (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* vconsole-setup: fonts copy will fail if the current terminal is in graphical ↵Franck Bui2018-12-131-4/+18
| | | | | | | | | | mode If the terminal is in graphical mode, the kernel will refuse to copy the fonts and will return -EINVAL. Also having the graphical mode in effect probably indicates that the terminal is in used by another application and we shouldn't interfer in such cases.
* Merge pull request #10935 from poettering/rlimit-nofile-safeZbigniew Jędrzejewski-Szmek2018-12-061-2/+2
|\ | | | | | | Merged by hand to resolve a trivial conflict in TODO.
| * tree-wide: use FORK_RLIMIT_NOFILE_SAFE wherever possibleLennart Poettering2018-12-011-2/+2
| | | | | | | | | | | | | | Similar to the previous commit: in many cases no further fd processing needs to be done in forked of children before execve() or any of its flavours are called. In those case we can use FORK_RLIMIT_NOFILE_SAFE instead.
* | util-lib: split out env file parsing code into env-file.cLennart Poettering2018-12-021-0/+1
|/ | | | | | It's quite complex, let's split this out. No code changes, just some file rearranging.
* vconsole: Don't skip udev call for dummy deviceTim Ruffing2018-11-221-1/+1
| | | | | | | | | | | | | | | | | | | | | Kernel 4.19 supports deferred console takeover [0], i.e., fbcon will take over the console only when the first text is displayed on the console. Before that event, only the dummy console is active. Our currently udev rules call systemd-vconsole on every vtcon except for dummy consoles. Thus the exception for dummy consoles prevents a call to systemd-vconsole when no text is displayed on the console, and as a consequence, the keymap will not be set in that case. This is wrong and leads to issues when keyboard input is expected without text on the console, e.g., when a graphical password prompt is used in the boot process. This reverts commit 6b169c13ecf645a0a341f49b9dc2afb312a74206, which introduced the exception for dummy devices to save unnecessary udev calls. Fixes #10826. [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83d83bebf40132e2d55ec58af666713cc76f9764
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* fileio: automatically add NULL sentinel to parse_env_file()Lennart Poettering2018-11-141-2/+1
| | | | Let's modernize things a bit.
* fileio: drop "newline" parameter for env file parsersLennart Poettering2018-11-141-1/+1
| | | | | | | Now that we don't (mis-)use the env file parser to parse kernel command lines there's no need anymore to override the used newline character set. Let's hence drop the argument and just "\n\r" always. This nicely simplifies our code.