summaryrefslogtreecommitdiff
path: root/src/vconsole/vconsole-setup.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* 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.
* tree-wide: replace all remaining uses of parse_env_file() for parsing ↵Lennart Poettering2018-11-141-15/+14
| | | | | | /proc/cmdline Let's always go through the proc-cmdline.c APIs.
* tree-wide: set WRITE_STRING_FILE_DISABLE_BUFFER flag when we write files ↵Yu Watanabe2018-11-061-1/+1
| | | | under /proc or /sys
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-1/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-2/+2
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* fileio: accept FILE* in addition to path in parse_env_file()Lennart Poettering2018-05-241-2/+2
| | | | | | | Most our other parsing functions do this, let's do this here too, internally we accept that anyway. Also, the closely related load_env_file() and load_env_file_pairs() also do this, so let's be systematic.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* vconsole: minor modernizationsLennart Poettering2018-03-221-13/+20
|
* vconsole-setup: don't concat strv if we don't need to (i.e. not in debug log ↵Lennart Poettering2018-03-221-6/+12
| | | | mode)
* macro: introduce new TAKE_FD() macroLennart Poettering2018-03-221-9/+5
| | | | | | | This is similar to TAKE_PTR() but operates on file descriptors, and thus assigns -1 to the fd parameter after returning it. Removes 60 lines from our codebase. Pretty good too I think.
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-2/+1
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* coccinelle: similar to reallocarray() let's also systematically use ↵Lennart Poettering2018-03-021-1/+1
| | | | malloc_multiply()
* process-util: rework wait_for_terminate_and_warn() to take a flags parameterLennart Poettering2018-01-041-2/+2
| | | | | | | | | | | | | This renames wait_for_terminate_and_warn() to wait_for_terminate_and_check(), and adds a flags parameter, that controls how much to log: there's one flag that means we log about abnormal stuff, and another one that controls whether we log about non-zero exit codes. Finally, there's a shortcut flag value for logging in both cases, as that's what we usually use. All callers are accordingly updated. At three occasions duplicate logging is removed, i.e. where the old function was called but logged in the caller, too.
* process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN loggingLennart Poettering2018-01-041-4/+4
|
* vconsole-setup: add some void castsLennart Poettering2018-01-041-2/+2
|
* tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2017-12-251-16/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new safe_fork() wrapper around fork() and makes use of it everywhere. The new wrapper does a couple of things we previously did manually and separately in a safer, more correct and automatic way: 1. Optionally resets signal handlers/mask in the child 2. Sets a name on all processes we fork off right after forking off (and the patch assigns useful names for all processes we fork off now, following a systematic naming scheme: always enclosed in () – in order to indicate that these are not proper, exec()ed processes, but only forked off children, and if the process is long-running with only our own code, without execve()'ing something else, it gets am "sd-" prefix.) 3. Optionally closes all file descriptors in the child 4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe way so that the parent dying before this happens being handled safely. 5. Optionally reopens the logs 6. Optionally connects stdin/stdout/stderr to /dev/null 7. Debug logs about the forked off processes.
* tree-wide: drop a few == NULL and != NULL comparisonLennart Poettering2017-12-111-2/+2
| | | | | | | Our CODING_STYLE suggests not comparing with NULL, but relying on C's downgrade-to-bool feature for that. Fix up some code to match these guidelines. (This is not comprehensive, the coccinelle output for this is unfortunately kinda borked)
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* vconsole: search for usable source console (#6180)Michal Soltys2017-07-031-71/+128
| | | | | | | | | | | | | | | | | | | | | When vconsole-setup is called without arguments, search for a usable console instead of using /dev/tty0. /dev/tty0 — pointing to the current active console — it not necessarily usable and in such case vconsole-setup would exit with failure. In particular when systemd-vconsole-setup.service was restarted from within an X session, it always failed. If the function searching for a usable source terminal fails, the first encountered error is returned to the caller. Closes #5367. Additional changes: - true/false functions with 'is_ prefix are renamed to functions with 'verify_vc_' prefix and return 0 on success and negative error on failure - O_NOCTTY flag is used when opening terminals
* vconsole-setup: skip setting fonts when setfont returns EX_OSERRZbigniew Jędrzejewski-Szmek2017-05-241-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On a machine without a VGA console, /dev/tty{0,1,…} exist, so systemd-vconsole-setup is started, but all setfont operations fail. setfont has a bunch of return codes for different failure modes. It uses EX_OSERR when the communication with the kernel using ioctls fails. This isn't too specific, but at least it's only used this general class of errors. Let's swallow the error in this case to avoid systemd-vconsole-setup.service failing on cloud vms. On a machine from https://bugzilla.redhat.com/show_bug.cgi?id=1272686#c4: $ build/systemd-vconsole-setup setfont: putfont: 512,8x16: failed: -1 putfont: PIO_FONT: Invalid argument /usr/bin/setfont failed with error code 71. Setting fonts failed with a "system error", ignoring. $ SYSTEMD_LOG_LEVEL=debug build/systemd-vconsole-setup Found container virtualization none. Sysfs UTF-8 flag enabled UTF-8 kbdmode enabled on /dev/tty0 Executing "/usr/bin/setfont -C /dev/tty0 eurlatgr"... setfont: putfont: 512,8x16: failed: -1 putfont: PIO_FONT: Invalid argument /usr/bin/setfont failed with error code 71. Executing "/usr/bin/loadkeys -q -C /dev/tty0 -u us"... /usr/bin/loadkeys succeeded. Setting fonts failed with a "system error", ignoring. $ lspci | grep -i vga $ ls /dev/tty? /dev/tty0 /dev/tty2 /dev/tty4 /dev/tty6 /dev/tty8 /dev/tty1 /dev/tty3 /dev/tty5 /dev/tty7 /dev/tty9 If we have a better test for /dev/tty? being connected to something that has a font, we could avoid running setfont at all… ATM, I'm not aware of a simple test like that.
* vconsole-setup: add more log messagesZbigniew Jędrzejewski-Szmek2017-05-241-0/+9
| | | | | | | This makes it quite a bit easier to see what failed. strv_join is called inline in log_debug so that it is under the conditional that kills the whole thing if debugging is disabled.
* tree-wide: use SET_FLAG in more places (#5892)Zbigniew Jędrzejewski-Szmek2017-05-071-4/+1
|
* Merge pull request #4448 from msoltyspl/vcfixZbigniew Jędrzejewski-Szmek2016-10-261-19/+39
|\ | | | | | | Fix some formatting details in the merge.
| * vconsole: setup_remaining_vcs() - more sanity checksMichal Soltys2016-10-261-19/+40
|/ | | | | | Check if values filled up by KD_FONT_OP_GET ioctl make sense - dummy driver for example doesn't implement required functionality at all.
* treewide: fix typos (#4217)Torstein Husebø2016-09-261-1/+1
|
* vconsole-setup: add lots of debug messagesZbigniew Jędrzejewski-Szmek2016-07-311-14/+24
| | | | | | For error messages, make them more meaningful by printing the tty name. Follow-up for #3742.
* vconsole: correct kernel command line namespaceMichal Soltys2016-07-271-1/+5
|
* vconsole: add copyright lineMichal Soltys2016-07-271-0/+1
|
* vconsole: use KD_FONT_OP_GET/SET to handle copyingMichal Soltys2016-07-271-27/+66
| | | | | We now use KD_FONT_OP_GET & KD_FONT_OP_SET instead of problematic KD_FONT_OP_COPY.
* vconsole: updates of keyboard/font loading functionsMichal Soltys2016-07-271-21/+14
| | | | | Change return convention to -errno/==0 and use isempty() instead of just pointer tests.
* vconsole: Add generic is_*() functionsMichal Soltys2016-07-271-0/+41
| | | | | | | | | | | | is_allocated() and is_allocated_byfd(): Checks if the console is allocated by its index (first function) or its open descriptor (second function). is_settable(): Checks if the console is in xlate or unicode mode, so we can adjust is safely without interfering with X.
* vconsole: add two new toggle functions, remove old enable/disable onesMichal Soltys2016-07-271-46/+27
| | | | | | | | | Add toggle_utf8() and toggle_utf8_sysfs() and use them in place of old enable/disable functions. toggle_utf8() also adds iutf8 setting and is set up to be called per-console (in subsequent patches). Note, that old disable_utf8() didn't bother checking if it was ok to change the kbdmode.
* vconsole: copy font to 63 consoles instead of 15Michal Soltys2016-07-271-1/+1
| | | | | We copy only to allocated consoles, so the cost of looping over all possible ones is minuscule.
* vconsole: don't do GIO_SCRNMAP / GIO_UNISCRNMAPMichal Soltys2016-07-271-10/+0
| | | | | | | | | | | | | | | | GIO_SCRNMAP / GIO_UNISCRNMAP are related to what setfont does with -m option - namely setting intermediate map from 8bit values into unicode values. This map is global, so single setfont invocation sets it for all applicable consoles. Furthermore calling GIO_SCRNMAP before GIO_UNISCRNMAP causes issues as the former corrupts values > 255 (UNI alone would be sufficient). The bug can be easily tested with the following conf: KEYMAP=pl FONT=LatArCyrHeb-16 FONT_MAP=8859-2
* vconsole: add log_oom() where appropriateLennart Poettering2016-05-171-2/+2
|