summaryrefslogtreecommitdiff
path: root/src/locale/localed.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* locale: add _unused_ attribute for dummy variableYu Watanabe2018-06-061-3/+2
| | | | | | | | | | This suppresses the following warning by clang: ``` [588/1179] Compiling C object 'systemd-localed@exe/src_locale_localed.c.o'. ../src/locale/localed.c:271:39: warning: unused variable 'dummy' [-Wunused-variable] _cleanup_(locale_free) char **dummy = new_locale; ^ ```
* locale: assume locale is for LANG= when variable name is not specifiedYu Watanabe2018-05-311-0/+12
| | | | Closes #6070.
* locale: re-read configuration files if changedYu Watanabe2018-05-311-114/+173
| | | | Closes #8491.
* locale: check xkb data before requesting authenticationYu Watanabe2018-05-311-11/+11
|
* locale: return earlier if no operation will be doneYu Watanabe2018-05-311-102/+100
|
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-04-191-1/+0
| | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* 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.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-2/+1
|
* tree-wide: make name requesting asynchronous in all our servicesLennart Poettering2018-01-051-2/+2
| | | | | This optimizes service startup a bit, and makes it less prone to deadlocks.
* tree-wide: generate SD_BUS_ERROR_INVALID_ARGS when we get invalid arguments ↵Lennart Poettering2017-11-291-2/+2
| | | | | | | | | | on bus calls Let's make sure that when we return a D-Bus error, we return a native one, if we generate it ourselves, and use errno-based error synthetization only if we received an errno ourselves. Yes, this makes things slightly longer, but is highly misleading as we propagate D-Bus errors, and not errnos to the client.
* 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.
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-2/+2
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* basic/log: fix _printf_ annotation on log_object_internalvZbigniew Jędrzejewski-Szmek2017-04-201-0/+3
| | | | | | | | | | | | Fixup for 4b58153dd22172d817055d2a09a0cdf3f4bd9db3. I saw this because of a clang warning. With gcc the -Wformat-nonliteral warning doesn't seem to work as expected. In two places, a string constructed with strjoina is used as the pattern. This is safe, because we're taking a pattern which was already marked with _printf_ and prepending a known value to it. Those places are marked with #pragma to silence the warning.
* tree-wide: use %m in calls to sd_bus_error_set_errnofZbigniew Jędrzejewski-Szmek2016-09-131-3/+3
| | | | | sd_bus_error_set_errnof supports %m, so there's no need to call strerror manually.
* localed: split out keymap parsing to a separate fileZbigniew Jędrzejewski-Szmek2016-06-061-686/+39
| | | | | This way the dbus and management logic is seperated from the business logic and we can write test cases for the mapping functionality.
* localed: get rid of duplicated enum and string tableZbigniew Jędrzejewski-Szmek2016-06-061-85/+68
|
* util-lib: make localed's nonempty() generic, rename it to empty_to_null() ↵Lennart Poettering2016-05-301-22/+7
| | | | and make use of it everywhere
* localed: downgrade libxkbcommon to an optional runtime dependencyLennart Poettering2016-04-121-10/+66
| | | | | | | | | | | | | | Previously, libxkbcommon was a compile-time option. When enabled the localed binary would strictly depend on it, thus pulling in libxkbcommon and its dependencies, which are non-trivial in size. With this change we dlopen() libxkbcommon when it is available instead. If the library is available behaviour is as before. However, if it isn't the system is considered "headless", i.e. without local hardware and all attempts to set the local keyboard configuration will be refused. This is useful for general-purpose distributions which want to support "headless" (such as container systems) and "full" systems with the same build.
* selinux: always try to load the full selinux dbZbigniew Jędrzejewski-Szmek2016-03-011-1/+1
| | | | | https://github.com/systemd/systemd/pull/2508#issuecomment-190901170 Maybe fixes https://bugzilla.redhat.com/show_bug.cgi?id=1308771.
* tree-wide: make ++/-- usage consistent WRT spacingVito Caputo2016-02-221-1/+1
| | | | | | Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: check if errno is greater then zeroZbigniew Jędrzejewski-Szmek2016-01-131-1/+1
| | | | | | | | | | | | | | gcc is confused by the common idiom of return errno ? -errno : -ESOMETHING and thinks a positive value may be returned. Replace this condition with errno > 0 to help gcc and avoid many spurious warnings. I filed a gcc rfe a long time ago, but it hard to say if it will ever be implemented [1]. Both conventions were used in the codebase, this change makes things more consistent. This is a follow up to bcb161b0230f. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* user-util: move UID/GID related macros from macro.h to user-util.hLennart Poettering2015-10-271-0/+1
|
* util: move filename_is_valid() and path_is_safe() to path-util.[ch]Lennart Poettering2015-10-271-9/+10
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-4/+5
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* locale: kill free_and_replace()Daniel Mack2015-09-091-24/+30
| | | | | | | | | That function really makes little sense, as the open-coded variant is much more readable. Also, if the 2nd argument is NULL, mfree() is a much better candidate. Convert the only users of this function in localed, and then remove it entirely.
* bus-util: support details in CheckAuthorization callsMichael Chapman2015-09-061-0/+3
| | | | | | Extra details for an action can be supplied when calling polkit's CheckAuthorization method. Details are a list of key/value string pairs. Custom policy can use these details when making authorization decisions.
* locale: add printf attribute to log_xkb()Cristian Rodríguez2015-08-301-0/+1
|
* strv: convert strv_split_quotes into a generic strv_split_extractRichard Maw2015-08-071-3/+3
| | | | | | | | | strv_split_extract is to strv_split_quotes as extract_first_word was to unquote_first_word. Now there's extract_first_word for extracting a single argument, extract_many_words for extracting a bounded number of arguments, and strv_split_extract for extracting an arbitrary number of arguments.
* Merge branch 'hostnamectl-dot-v2'Zbigniew Jędrzejewski-Szmek2015-08-051-5/+0
|\ | | | | | | Manual merge of https://github.com/systemd/systemd/pull/751.
| * hostname-util: add relax parameter to hostname_is_validZbigniew Jędrzejewski-Szmek2015-08-051-5/+0
| | | | | | | | | | | | | | | | | | | | Tests are modified to check behaviour with relax and without relax. New tests are added for hostname_cleanup(). Tests are moved a new file (test-hostname-util) because there's now a bunch of them. New parameter is not used anywhere, except in tests, so there should be no observable change.
* | tree-wide: port everything over to fflush_and_check()Lennart Poettering2015-07-291-7/+17
|/ | | | | | | | Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
* sd-bus: introduce new sd_bus_flush_close_unref() callLennart Poettering2015-07-031-2/+2
| | | | | | | | | | | | | | | | sd_bus_flush_close_unref() is a call that simply combines sd_bus_flush() (which writes all unwritten messages out) + sd_bus_close() (which terminates the connection, releasing all unread messages) + sd_bus_unref() (which frees the connection). The combination of this call is used pretty frequently in systemd tools right before exiting, and should also be relevant for most external clients, and is hence useful to cover in a call of its own. Previously the combination of the three calls was already done in the _cleanup_bus_close_unref_ macro, but this was only available internally. Also see #327
* sd-bus: drop bus parameter from message callback prototypeLennart Poettering2015-04-291-10/+22
| | | | | | This should simplify the prototype a bit. The bus parameter is redundant in most cases, and in the few where it matters it can be derived from the message via sd_bus_message_get_bus().
* util: rework word parsing and c unescaping codeLennart Poettering2015-03-261-3/+3
| | | | | | | | | | | When parsing words from input files, optionally automatically unescape the passed strings, controllable via a new flags parameter. Make use of this in tmpfiles, and port everything else over, too. This improves parsing quite a bit, since we no longer have to process the same string multiple times with different calls, where an earlier call might corrupt the input for a later call.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* logind: open up most bus calls for unpriviliged processes, using PolicyKitLennart Poettering2015-02-181-3/+24
| | | | | | Also, allow clients to alter their own objects without any further priviliges. i.e. this allows clients to kill and lock their own sessions without involving PK.
* localed: add LANGUAGE= fallback when LANG= is specifiedZbigniew Jędrzejewski-Szmek2015-02-061-9/+67
| | | | | | | | For the entries listed in the first column of language-fallback-map, the entry from the second column will be used for LANGUAGE=, if LANGUAGE= is not explicitly specified. https://bugzilla.redhat.com/show_bug.cgi?id=624158
* util: rework strappenda(), and rename it strjoina()Lennart Poettering2015-02-031-1/+1
| | | | | | After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
* tmpfiles: add new line type 'v' for creating btrfs subvolumesLennart Poettering2014-12-281-0/+1
|
* localed: remove spurious include of <sys/capability.h>Filipe Brandenburger2014-12-251-1/+0
| | | | | | | It does not use any functions from libcap directly. The CAP_SYS_ADMIN constant in use by this file comes from <linux/capability.h> imported through "missing.h". Tested that "systemd-localed" builds cleanly and works after this change.
* util: when using basename() for creating temporary files, verify the ↵Lennart Poettering2014-12-121-2/+2
| | | | | | | | resulting name is actually valid Also, rename filename_is_safe() to filename_is_valid(), since it actually does a full validation for what the kernel will accept as file name, it's not just a heuristic.
* localed: log xkbcommon errorsJan Synacek2014-12-031-4/+9
| | | | | | The errors are prefixed with "libxkbcommon" to provide some context, because they are quite confusing without it. With the prefix, we at least know where they come from.
* treewide: yet more log_*_errno + return simplificationsMichal Schmidt2014-11-281-20/+10
| | | | | | | | | | | | | Using: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg; print;' $f done And a couple of manual whitespace fixups.
* treewide: more log_*_errno() conversions, multiline callsMichal Schmidt2014-11-281-2/+2
| | | | | | | | | | | | Basically: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/log_(debug|info|notice|warning|error|emergency)\("([^"]*)%s"([^;]*),\s*strerror\(-?([->a-zA-Z_]+)\)\);/log_\1_errno(\4, "\2%m"\3);/gms;print;' \ $f; done Plus manual indentation fixups.
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-16/+16
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-16/+16
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().