summaryrefslogtreecommitdiff
path: root/src/basic/path-lookup.c
Commit message (Collapse)AuthorAgeFilesLines
* basic: add RuntimeScope enumLennart Poettering2023-03-101-38/+44
| | | | | | | | | | | | 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.
* nulstr-util: Declare NULSTR_FOREACH() iterator inlineDaan De Meyer2022-11-111-1/+1
|
* 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#'
* Rename UnitFileScope to LookupScopeZbigniew Jędrzejewski-Szmek2022-03-291-32/+32
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/22649/commits/8b3ad3983f5440eef812b34e5ed862ca59fdf7f7#r837345892 The define is generalized and moved to path-lookup.h, where it seems to fit better. This allows a recursive include to be removed and in general makes things simpler.
* systemctl: fix silent failure when --root is not foundZbigniew Jędrzejewski-Szmek2022-03-291-23/+33
| | | | | | | | | | | | | | | | | | | | Some calls to lookup_path_init() were not followed by any log emission. E.g.: $ SYSTEMD_LOG_LEVEL=debug systemctl --root=/missing enable unit; echo $? 1 Let's add a helper function and use it in various places. $ SYSTEMD_LOG_LEVEL=debug build/systemctl --root=/missing enable unit; echo $? Failed to initialize unit search paths for root directory /missing: No such file or directory 1 $ SYSTEMCTL_SKIP_SYSV=1 build/systemctl --root=/missing enable unit; echo $? Failed to initialize unit search paths for root directory /missing: No such file or directory Failed to enable: No such file or directory. 1 The repeated error in the second case is not very nice, but this is a niche case and I don't think it's worth the trouble to trying to avoid it.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* tree-wide: don't use strjoina() on getenv() valuesAnita Zhang2022-01-271-2/+6
| | | | Avoid doing stack allocations on environment variables.
* portable: move profile search helper to path-lookupLuca Boccassi2021-11-261-0/+28
| | | | Will be used in systemd-analyze later
* alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhereLennart Poettering2021-10-141-1/+1
| | | | | | | | | | | | | Let's define two helpers strdupa_safe() + strndupa_safe() which do the same as their non-safe counterparts, except that they abort if called with allocations larger than ALLOCA_MAX. This should ensure that all our alloca() based allocations are subject to this limit. afaics glibc offers three alloca() based APIs: alloca() itself, strndupa() + strdupa(). With this we have now replacements for all of them, that take the limit into account.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-4/+4
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* tree-wide: make use of path_extend() at many placesLennart Poettering2021-05-271-21/+18
| | | | This is not a comprehensive port, but mostly some low-hanging fruit.
* meson: use jinja2 for rpm templatesZbigniew Jędrzejewski-Szmek2021-05-191-1/+1
| | | | | | | The naming of variables is very inconsistent. I tried to use more modern style naming (UNDERSCORED_TITLE_CASE), but I didn't change existing names too much. Only SYSTEM_DATA_UNIT_PATH is renamed to SYSTEM_DATA_UNIT_DIR to match SYSTEM_CONFIG_UNIT_DIR.
* tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-141-1/+1
| | | | | | | 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.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* path-lookup: Correct order of XDG_CONFIG_HOME and XDG_CONFIG_DIRSPass Automated Testing Suite2020-09-291-2/+2
| | | | | | | | | According to the XDG Base Directory Specification [1] XDG_CONFIG_HOME should take precedence over XDG_CONFIG_DIRS. Fixes: https://github.com/systemd/systemd/issues/16095 [1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
* path-lookup: path_join() all the things!Lennart Poettering2020-08-191-5/+5
| | | | | When we talk about paths, better use path_join(), who knows what callers pass to us, i.e. prefixed with "/" or not.
* Rename _PATH variables to _DIR when they refer to a directoryZbigniew Jędrzejewski-Szmek2020-03-271-11/+11
| | | | | We were very inconsistent in this, but in general _PATH signifies a search path (separated with :), and _DIR signifies a single directory.
* Move path-lookup.c to src/basicZbigniew Jędrzejewski-Szmek2020-03-271-0/+869
I want to use it from sd-path later on so it needs to be moved out of src/shared (libsystemd is not allowed to use code from src/shared).