summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-path
Commit message (Collapse)AuthorAgeFilesLines
* basic: add RuntimeScope enumLennart Poettering2023-03-101-5/+6
| | | | | | | | | | | | 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.
* sd-path: export env. generators pathsDavid Tardon2023-01-211-0/+20
|
* strv: move nulstr utilities to nulstr-util.[ch]Lennart Poettering2022-11-131-0/+1
| | | | | | | Let's move them out of the generic, already very long strv.[ch] module into the more specific nulst-util.[ch] No code changes.
* 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.
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* Rename UnitFileScope to LookupScopeZbigniew Jędrzejewski-Szmek2022-03-291-4/+4
| | | | | | | | | 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.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+1
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* tree-wide: make use of path_extend() at many placesLennart Poettering2021-05-271-16/+9
| | | | 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.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* pkg-config: prefix is not really configurable, don't pretend it wasLennart Poettering2020-09-111-2/+0
| | | | | | We generally don't support prefix being != /usr, and this is hardcoded all over the place. In the systemd.pc file it wasn't so far. Let's adjust this to match the rest of the codebase.
* sd-path: use ROOTPREFIX without suffixed slashLennart Poettering2020-09-111-9/+9
| | | | | | | We already have rootprefix_noslash as meson variable, export it so that we can also use it in C code. Fixes: #16773
* sd-path: drop "-dir" and "-path" suffixes from path enumsLennart Poettering2020-05-281-24/+24
| | | | | | | | | | | | | | | | | | | | | | | Clean up the naming of the sd-path enums. Previously, the more recently added fields where named in the form SD_PATH_xyz_DIR and SD_PATH_xyz_PATH, while the older fields where called just SD_PATH_xyz and SD_PATH_SEARCH_xyz. Let's clean this up, to come to a more unified way how we name this stuff. I opted to stick to the old naming, i.e. dropthe suffixes. It's a bit of a bike-shedding question of course, but I think there's a good reason to avoid the additional DIR and PATH suffixes: the enum prefix contains "PATH" anyway (i.e. "SD_PATH_"), so including PATH twice in each name is redundant. Moreover, the key difference between the enums with the "dir" and the "path" in the name is that the latter are *seach* paths, and I think this is better emphasized by sticking to the "SEARCH" in the name. Moreover dropping the suffixes makes the identifiers a lot shorter, in particular in the "systemd-path" list output. And that's always good. This means the naming pkgconfig file and in sd-path slightly deviate (though the mapping is very simple), but I think that's OK, given that this is developer facing and not user facing.
* path: use ROOTPREFIX properlyLennart Poettering2020-05-281-9/+9
| | | | | | | | ROOTPREFIX doesn't include the trailing /, hence add it in where needed. Also, given that sysctl.d/, binfmt.d/, sysusers.d/ are generally accessed before /var/ is up they should use ROOTPREFIX rather than PREFIX. Fix that.
* sd-path: fix systemd-system-generator-path lookupZbigniew Jędrzejewski-Szmek2020-05-211-1/+1
| | | | CID#1422164.
* sd-path: export "systemd-network-path"Zbigniew Jędrzejewski-Szmek2020-03-271-1/+6
| | | | Inspired by https://lists.freedesktop.org/archives/systemd-devel/2020-March/044169.html.
* Rename _PATH variables to _DIR when they refer to a directoryZbigniew Jędrzejewski-Szmek2020-03-271-5/+5
| | | | | We were very inconsistent in this, but in general _PATH signifies a search path (separated with :), and _DIR signifies a single directory.
* path: show various systemd directories and search paths tooZbigniew Jędrzejewski-Szmek2020-03-271-0/+97
| | | | | | | | | | | | | | | | | | | | So far we had various ad hoc APIs to query search paths: systemd-analyze unit-paths, lookup_paths_log(), the pkgconfig file, debug logs emitted by systemd-analyze cat-config. But answering a simple question "what is the search path for tmpfiles, sysusers, .network files, ..." is surprisingly hard. I think we should have an api that makes it easy to query this. Pkgconfig is not bad, but it is primarily a development tool, so it's not available in many context. Also it can't provide support for paths which are influenced by environment variables, and I'd like to be able to answer the question "what is the search path for ..., assuming that VAR_FOO=... is set?". Extending sd-path to support more of our internal paths seems to be most flexible solution. We already have systemd-path which provides a nice way to query, and we can add stuff like optional descriptions later on. We we essentially get a nice programmatic and commmandline apis for the price of one.
* sd-path: simplify implementation of sd_path_lookup*()Zbigniew Jędrzejewski-Szmek2020-03-271-60/+42
| | | | | | | The two functions were duplicating a lot of functionality and more importantly, they both had explicit lists of types which are search paths. I want to add more types, and I don't want to have to remember to add them to both lists.
* sd-path,strv: add simple helper to wrap oom handling around strv_split_nulstr()Zbigniew Jędrzejewski-Szmek2020-03-271-8/+3
|
* sd-path: rename the two functionsZbigniew Jędrzejewski-Szmek2020-03-271-4/+4
| | | | | | | | | | | I think the two names were both pretty bad. They did not give a proper hint what the difference between the two functions is, and sd_path_home sounds like it is somehow related to /home or home directories or whatever, when in fact both functions return the same set of paths as either a colon-delimited string or a strv. "_strv" suffix is used by various functions in sd-bus, so let's reuse that. Those functions are not public yet, so let's rename.
* tree-wide: drop missing.hYu Watanabe2019-10-311-1/+0
|
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-3/+3
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* sd-path: use _cleanup_strv_free_ attributeYu Watanabe2019-06-241-13/+6
|
* sd-path: use _cleanup_ attributeYu Watanabe2019-06-211-7/+5
|
* tree-wide: replace strjoin() with path_join()Yu Watanabe2019-06-211-19/+4
|
* Move LONG_LINE_MAX definition to fileio.hZbigniew Jędrzejewski-Szmek2018-11-141-1/+0
| | | | | | | | | | | All users of the macro (except for one, in serialize.c), use the macro in connection with read_line(), so they must include fileio.h. Let's not play libc games and require multiple header file to be included for the most common use of a function. The removal of def.h includes is not exact. I mostly went over the commits that switch over to use read_line() and add def.h at the same time and reverted the addition of def.h in those files.
* sd-path: FOREACH_LINE exorcismLennart Poettering2018-10-181-2/+9
|
* tree-wide: drop empty commentsYu Watanabe2018-06-291-2/+0
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* 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.
* systemd-path: fix memory leak reported by ASAN (#8874)Filipe Brandenburger2018-05-021-11/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The leak can be reproduced by running systemd-path --suffix .tmp under valgrind or asan: $ ./build/systemd-path --suffix .tmp search-binaries /usr/local/bin/.tmp:/usr/bin/.tmp:/usr/local/sbin/.tmp:/usr/sbin/.tmp:/home/vagrant/.local/bin/.tmp:/home/vagrant/bin/.tmp ================================================================= ==19177==ERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 1 object(s) allocated from: *0 0x7fd6adf72850 in malloc (/lib64/libasan.so.4+0xde850) *1 0x7fd6ad2b93d2 in malloc_multiply ../src/basic/alloc-util.h:69 *2 0x7fd6ad2bafd2 in strv_split ../src/basic/strv.c:269 *3 0x7fd6ad42ba67 in search_from_environment ../src/libsystemd/sd-path/sd-path.c:409 *4 0x7fd6ad42bffe in get_search ../src/libsystemd/sd-path/sd-path.c:482 *5 0x7fd6ad42c55b in sd_path_search ../src/libsystemd/sd-path/sd-path.c:607 *6 0x7fd6ad42b3a2 in sd_path_home ../src/libsystemd/sd-path/sd-path.c:348 *7 0x55f59c65ebea in print_home ../src/path/path.c:97 *8 0x55f59c65f157 in main ../src/path/path.c:177 *9 0x7fd6abaea009 in __libc_start_main (/lib64/libc.so.6+0x21009) Indirect leak of 68 byte(s) in 5 object(s) allocated from: *0 0x7fd6adf72850 in malloc (/lib64/libasan.so.4+0xde850) *1 0x7fd6abb5f689 in strndup (/lib64/libc.so.6+0x96689) Indirect leak of 25 byte(s) in 1 object(s) allocated from: *0 0x7fd6adf72850 in malloc (/lib64/libasan.so.4+0xde850) *1 0x7fd6abb5f689 in strndup (/lib64/libc.so.6+0x96689) *2 0x6c2e2f746e617266 (<unknown module>) SUMMARY: AddressSanitizer: 149 byte(s) leaked in 7 allocation(s).
* Merge pull request #8575 from keszybz/non-absolute-pathsLennart Poettering2018-04-171-1/+13
|\ | | | | Do not require absolute paths in ExecStart and friends
| * systemd-path: allow the default search path to be queriedZbigniew Jędrzejewski-Szmek2018-04-161-1/+13
| |
* | 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.
* Remove /sbin from paths if split-bin is false (#8324)Zbigniew Jędrzejewski-Szmek2018-03-011-6/+9
| | | Follow-up for 157baa87e4.
* 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-3/+3
| | | | | | | | | | | | | | | 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
* Merge pull request #6266 from keszybz/drop-autotoolsLennart Poettering2017-07-201-1/+0
|\ | | | | Drop support for autotools / automake / make
| * build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | | | | | | v2: - also mention m4
* | sd-path: make sure to use tmp_dir() and var_tmp_dir() (#6397)Lennart Poettering2017-07-201-2/+3
|/ | | Let's reuse the common code wherever appropriate.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-4/+4
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* sd-path: use XDG_CONFIG_HOME instead of hardcoding ~/.config for user-dirsEmmanuel Gil Peyrot2016-03-151-2/+7
|
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering2015-10-261-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-3/+5
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* tree-wide: there is no ENOTSUP on linuxDavid Herrmann2015-03-131-2/+2
| | | | Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
* build-sys: export sd_path APIsLennart Poettering2014-07-111-2/+2
|