summaryrefslogtreecommitdiffstats
path: root/src/locale (follow)
Commit message (Collapse)AuthorAgeFilesLines
* locale: when no xvariant match select the entry with an empty xvariantFranck Bui2023-04-262-1/+45
| | | | | | When doing a conversion and the specified 'xc->xvariant' has no match, select the x11 layout entry with a matching layout and an empty xvariant if such entry exists. It's still better than no conversion at all.
* locale: convert generated vconsole keymap to x11 layout automaticallyFranck Bui2023-04-241-5/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When doing x11->console conversions, find_converted_keymap() searches automatically for a candidate in the converted keymap directory for a given x11 layout. However doing console->x11 conversions, this automatic search is not done hence simple conversion in this direction can't be achieved without populating kbd-model-map with entries for converted keymaps. For example, let's consider "at" layout which is not part of kbd-model-map. The "at" x11 layout has a generated keymap "/usr/share/kbd/keymaps/xkb/at.map.gz". If we configure "at" for the x11 layout, localed is able to automatically find the "at" converted vc layout and the conversion just works : $ localectl set-x11-keymap at $ localectl System Locale: LANG=en_US.UTF-8 VC Keymap: at X11 Layout: at However in the opposite direction, ie when setting the vc keymap to "at", no conversion is done and the x11 layout is not defined: $ localectl set-keymap at $ localectl System Locale: LANG=en_US.UTF-8 VC Keymap: at X11 Layout: (unset) This patch fixes this limitation as the implemenation is relatively simple and it removes the need to populate kbd-model-map with (many) entries for converted keymaps. However the patch doesn't remove the existing entries in kbd-model-map which became unneeded after this change to be on the safe side. Note: by default the automatically generated x11 keyboard configs use keyboard model "microsoftpro" which should be equivalent to "pc105" model but with the internet/media key mapping added.
* localed-util: make use of strdupcspn()Franck Bui2023-04-241-2/+2
|
* tree-wide: use TAKE_STRUCTDavid Tardon2023-04-141-4/+2
|
* localed: fix invalid free after shifting pointers using strstripOlivier Gayot2023-04-071-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | After manually editing /etc/locale.gen, calling localectl set-locale sometimes fails. When it fails, the systemd journal shows: systemd-localed: free() / invalid pointer. It turned out that it only fails if some of the uncommented lines in /etc/locale.gen have leading spaces, as in: * C.UTF-8 <= OK * en_US.UTF-8 <= OK * fr_FR.UTF-8 <= NOK After parsing a line from /etc/locale.gen, we use strstrip() to obtain the "trimmed" line (without leading or trailing spaces). However, we store the result of strstrip() in the original pointer containing the untrimmed line. This pointer is later passed to free (this is done automatically using _cleanup_free_). This is a problem because if any leading space is present, the pointer will essentially be shifted from its original value. This will result in an invalid free upon cleanup. The same issue is present in the locale_gen_locale_supported function. Fixed by storing the result of strstrip() in a different pointer.
* locale: Add missing libxkbcommon dependency to testsDaan De Meyer2023-03-271-0/+1
| | | | Fixes opensuse mkosi CI build
* locale: also verify keymaps loaded from config file and converted keymapsYu Watanabe2023-03-251-14/+34
| | | | | If vconsole.conf or friends contain an invalid keymap, then let's ignore the settings.
* locale: introduce x11_context_verify()Yu Watanabe2023-03-253-13/+37
| | | | No functional change, preparation for later commits.
* locale: split out xkbcommon related functions to xkbcommon-util.cYu Watanabe2023-03-254-107/+122
| | | | Then, use dlopen_many_sym_or_warn() with DLSYM_ARG() macro.
* locale: split out checking existence of keymapYu Watanabe2023-03-253-9/+47
| | | | No functional change, preparation for later commits.
* locale: move x11_convert_to_vconsole() near the relevant functionsYu Watanabe2023-03-251-24/+24
| | | | No functional changes, just refactoring.
* fileio: add new helper fdopen_independent()Lennart Poettering2023-03-231-10/+4
| | | | | | | | This is a combination of fdopen() and fd_reopen(). i.e. it first reopens the fd, and then converts that into a FILE*. We do this at various places already manually. let's move this into a helper call of its own.
* updated usage of SD_BUS_METHOD_WITH_NAMES macros to SD_BUS_METHOD_WIT… ↵OMOJOLA JOSHUA2023-03-151-27/+15
| | | | | (#26840) * localed: update usage of SD_BUS_METHOD_WITH_NAMES macros to SD_BUS_METHOD_WITH_ARGS
* src: changed instances of sd_bus_call_method() to bus_call_method() (#26819)OMOJOLA JOSHUA2023-03-151-8/+2
| | | * src: changed instances of sd_bus_call_method() to bus_call_method()
* basic: add RuntimeScope enumLennart Poettering2023-03-101-1/+1
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* localed: print a custom message if libxkbcommon.so is unvailableZbigniew Jędrzejewski-Szmek2023-03-091-7/+6
| | | | | | | | | | | | | Follow-up for 82c2095a5e407bcf041dc7bde84791deec95ff9c. > I feel like the logging here may be a bit confusing on the new path. > Previously you did get a message that explained what was going on. Now you get > an info message that the layout could not be compiled, and … that's all. I can > imagine this being a confusing red herring if someone was trying to debug a > problem and saw this message. Perhaps we should log something else instead/as > well, on the case where libxkbcommon isn't present, to say that's what we're > logging about and it just means we can't validate the configuration, not that > it's definitely invalid?
* localed: skip verification when libxkbcommon is not installedZbigniew Jędrzejewski-Szmek2023-03-081-6/+6
| | | | | | | | | | | | | | | | | | | | | | | When compliled without libxkbcommon, we do no verification and accept the arguments as given. When compliled against with, if dlopen() works, we do the verification. But if dlopen() fails, we would refuse the call and return SD_BUS_ERROR_INVALID_ARGS. 5de344704df64d8f31448f1222432bc87ddcfbef added things this way when converting to dlopen(), but it seems not very useful: it can be expected that when the library is supported but missing at runtime, we degrade softly, and that the behaviour is something inbetween the cases of hard disable at compilation time and full support. But right now we behave more strictly then if disabled at compilation. Change the code to just warn if dlopen fails, but accept the arguments. (There are various minimization scenarios where forcing the installation of libxkbcommon is not useful. E.g. a small installation where we want to set the keymap via logind, but the configuration is managed by a configuration management system and is known to be valid. Verification via libxkbcommon is just overhead in this case.) 800f65f827c9828d4c872d44b19ca8a008505690 moved the check earlier, so now even a noop case of setting the values that were already in place can fail. C.f. https://bugzilla.redhat.com/show_bug.cgi?id=2175244.
* meson: Use dicts for test definitionsJan Janssen2023-02-211-2/+6
| | | | | | | Although this slightly more verbose it makes it much easier to reason about. The code that produces the tests heavily benefits from this. Test lists are also now sorted by test name.
* copy: Make copy_xattr() more genericDaan De Meyer2023-02-141-1/+1
| | | | | Let's make copy_xattr() a little more generic in preparation for copying symlink xattrs.
* locale: drop context_clear_x11()Yu Watanabe2023-02-011-8/+2
| | | | | It is used at only place, and mostly trivial. No functional change, just refactoring.
* locale: fix ENOENT handling for vconsole.conf or xorg.confYu Watanabe2023-02-011-1/+2
|
* locale: downgrade level of one more log messageYu Watanabe2023-01-281-1/+1
|
* locale: move logging from library-like functions to callerYu Watanabe2023-01-282-16/+16
|
* locale: decouple vconsole_read_data() from x11_read_data()Yu Watanabe2023-01-282-4/+10
| | | | | Let's make library-functions simple and independent as possible as they are. No functional change, just refactoring.
* locale: also check if converted keymap or friends is same as the current ↵Yu Watanabe2023-01-281-47/+51
| | | | | | | | | | settings Before this commit, if virtual console keymap is unchanged, localed just returns without modifying anything. However, the X11 part may need updating. So we should check for both and ensure they are unmodified. Replaces #26190.
* locale: sync two X11 contexts on updateYu Watanabe2023-01-282-34/+38
|
* locale: always check input keyboard layout and friends earlierYu Watanabe2023-01-281-17/+17
|
* locale: replace context_get_x11_context() with context_get_x11_context_safe()Yu Watanabe2023-01-283-16/+11
| | | | | Then, context_get_x11_context() always replies a valid X11 context. No functional change, just refactoring.
* locale: make vconsole_convert_to_x11() not update ContextYu Watanabe2023-01-284-184/+169
| | | | | | | This also makes x11_convert_to_vconsole() changed in the same way. Then, their callers update Context if necessary. No functional change, just preparation for later commits.
* locale: introduce VCContext and several helper functions for the structYu Watanabe2023-01-284-53/+110
| | | | No functional changes, preparation for later commits.
* locale: add missing logsYu Watanabe2023-01-281-6/+6
|
* locale: rename new XKB variables to match Debian/Ubuntu'sLuca Boccassi2023-01-241-8/+8
| | | | | | | | | | | | Debian/Ubuntu use almost the same variables, but without '_'. Given our usage is new, rename them so that they match and downstream tech debt can be removed. Follow-up for https://github.com/systemd/systemd/pull/25805 See: https://github.com/systemd/systemd/issues/24228 https://github.com/systemd/systemd/pull/25412
* meson: Do not include headers in source listsJan Janssen2023-01-241-3/+1
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* locale: also save XKB settings to vconsole.confYu Watanabe2023-01-234-14/+54
| | | | | Closes #24228. Replaces #25412.
* locale: make errors in writing files not criticalYu Watanabe2023-01-231-8/+4
| | | | | | | | | | Suggested at https://github.com/systemd/systemd/pull/25805#discussion_r1054871210 > we now write multiple files and we cannot possibly guarantee that > either both updates worked or neither. unix fs apis simply have > no concept that would allow us to implement that. hence I think > we should update what we can, log about what we cannot, but return > success as long as our in-memory state was updated.
* locale: merge vconsole_convert_to_x11_and_emit() with method_set_vc_keyboard()Yu Watanabe2023-01-231-67/+58
| | | | | | | Similary, this also merges x11_convert_to_vconsole_and_emit() with method_set_x11_keyboard(). No functional changes, preparation for later commits.
* locale: split out XKB settings to X11ContextYu Watanabe2023-01-234-140/+262
| | | | | No functional changes, just refactoring and preparation for later commits.
* locale: rename context_free_vconsole() -> context_clear_vconsole()Yu Watanabe2023-01-231-16/+16
| | | | | | | Similary, this also renames context_free_x11() -> context_clear_x11(), to make it clear that these functions do not free Context. Also, this makes context_clear() support to be called more than once.
* locale: do not use alloca() for strings which can be potentially arbitraryYu Watanabe2023-01-231-6/+13
|
* locale: several coding style fixletsYu Watanabe2023-01-233-55/+80
| | | | | | | - add missing assertions, - rename arguments for storing results, - always initialize results on success, - use _cleanup_ attribute at more places, etc.
* string-util: add new strdupcspn()/strdupspn()Lennart Poettering2023-01-201-1/+3
| | | | | | | | These combine strndup() + strspn()/strcspn() into one. There are a bunch of strndupa() calls that could use similar treatment (or should be converted to strdup[c]spn(), but this commit doesn't bother with that.
* tree-wide: change initialization to use EBADF instead of EBADFDZbigniew Jędrzejewski-Szmek2022-12-191-2/+2
| | | | | Those fds never were, so it's not fair to say that they are in "bad state". Let's use the shorter and more direct errno.
* Merge pull request #25718 from yuwata/locale-cleanupsYu Watanabe2022-12-154-41/+47
|\ | | | | locale: avoid TOCTOU in reading config files
| * locale-setup: avoid TOCTOU in reading locale.confYu Watanabe2022-12-142-4/+2
| |
| * localed: avoid TOCTOU in loading configYu Watanabe2022-12-143-37/+45
| |
* | Merge pull request #25602 from fbuihuu/fix-TEST-73-LOCALEYu Watanabe2022-12-151-12/+8
|\ \ | |/ |/| localed: reload PID1 configuration after modifying /etc/locale.conf
| * localed: reload PID1 configuration after modifying /etc/locale.confFranck Bui2022-12-081-12/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 1ad6e8b302e87b6891a2bfc35ad397b0afe3d940, unsetting an environment variable means restoring it to its default value. However this doesn't work well when localed updates locale.conf. Indeed when a variable is removed from that file, localed calls "UnsetAndSetEnvironment" method which restores the default values of the unset variables obtained by PID1 when it first read locale.conf. But since locale.conf has been updated, these default values might be outdated and localed needs to instruct PID1 to read locale.conf again. Reloading PID1 configuration is quite an heavy operation for this purpose but there's no other way unless we change again the meaning of "UnsetEnvironment" or we introduce a new method that really unset an env variable. That said given the fact that localed modifies locale.conf, it should have an effect on PID1 default environment rather than on the environment explicitly set by the user (m->client_manager).
* | localed-util: use _cleanup_ harderDavid Tardon2022-12-141-12/+4
|/
* localectl,analyze: some minor vertical table rework fixesLennart Poettering2022-11-161-1/+1
| | | | Follow-up for #25339
* localectl: port to vertical tableDavid Tardon2022-11-131-11/+8
|