Commit Graph

157 Commits

Author SHA1 Message Date
Yu Watanabe
d4f60bdc11 path-util: introduce path_make_relative_parent() 2022-09-03 05:01:51 +09:00
Lennart Poettering
6eeadaa141 path-util: return error if fnmatch() fails 2022-08-31 17:31:11 +02:00
Lennart Poettering
e08c10a424 path-util: drop the now unused dirname_malloc() 2022-08-23 15:10:15 +02:00
Yu Watanabe
3b703fe269 path-util: introduce path_glob_can_match() 2022-08-17 14:30:20 +09:00
Lennart Poettering
39e419a2b5 tree-wide: trivial tweaks 2022-07-11 15:11:58 +02:00
Zbigniew Jędrzejewski-Szmek
c3eaba2d3d Move path_simplify_and_warn() to new shared/parse-helpers.c
This is a high-level function, and it belongs in libsystemd-shared. This way we
don't end up linking a separate copy into various binaries. It would even end
up in libsystemd, where it is not needed. (Maybe it'd be removed in some
optimization phase, but it's better to not rely on that.)

$ grep -l -r -a 'path is not absolute%s' build/
build/libnss_systemd.so.2
build/pam_systemd_home.so
build/test-dlopen
build/src/basic/libbasic.a.p/path-util.c.o
build/src/basic/libbasic.a
build/src/shared/libsystemd-shared-249.so
build/test-bus-error
build/libnss_mymachines.so.2
build/pam_systemd.so
build/libnss_resolve.so.2
build/libnss_myhostname.so.2
build/libsystemd.so.0.32.0
build/libudev.so.1.7.2

$ grep -l -r -a 'path is not absolute%s' build/
build/src/shared/libsystemd-shared-251.a.p/parse-helpers.c.o
build/src/shared/libsystemd-shared-251.a
build/src/shared/libsystemd-shared-251.so

No functional change.
2022-04-07 18:25:55 +02:00
Zbigniew Jędrzejewski-Szmek
c9394f4f93 Move systemd_installation_has_version() to src/nspawn/
This function implements a heuristic that is only used by nspawn. It doesn't
belong in basic. I opted for a new file "nspawn-utils.c", because it seems
likely that we'll need some other new utilities like that in the future.

No functional change.
2022-04-07 18:17:20 +02:00
Lennart Poettering
fdf02a4f26 path-util: use STR_IN_SET() where appropriate 2022-04-01 15:23:43 +02:00
Lennart Poettering
aed3c5eca3 process-util: refactor APIs for reading /proc/self/xyz symlinks
The three functions for reading cwd, exe and root symlinks of processes
already share a common core: get_process_link_contents(). Let's refactor
that a bit, and move formatting of the /proc/self/ path into this helper
function instead of doing that in the caller, thus sharing more code.

While we are at it, make the return parameters optional, in case the
information if the links are readable is interesting, but the contents
is not. (This also means safe_getcwd() and readlinkat_malloc() are
updated to make the return parameter optional, as these are called by
the relevant three functions)
2022-04-01 15:22:27 +02:00
Yu Watanabe
3066293dd3 path-util: use PTR_SUB1() macro in path_find_last_component() 2022-03-23 21:57:39 +09:00
Yu Watanabe
de010b0b2e strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
2022-03-19 08:33:33 +09:00
Zbigniew Jędrzejewski-Szmek
3c7af1af7d basic: adjust wording and wrapping of comments 2022-01-03 19:18:55 +01:00
Lennart Poettering
f435195925 basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch] 2021-10-05 16:14:37 +02:00
alexlzhu
8c35c10d20 core: Add ExecSearchPath parameter to specify the directory relative to which binaries executed by Exec*= should be found
Currently there does not exist a way to specify a path relative to which
all binaries executed by Exec should be found. The only way is to
specify the absolute path.

This change implements the functionality to specify a path relative to which
binaries executed by Exec*= can be found.

Closes #6308
2021-09-28 14:52:27 +01:00
Yu Watanabe
93413acd3e path-util: make find_executable() work without /proc mounted
Follow-up for 888f65ace6.

Hopefully fixes #20514.
2021-08-24 02:04:24 +09:00
Yu Watanabe
ded8039abe path-util: split out common part in find_executable_full() 2021-08-24 02:04:24 +09:00
Maanya Goenka
36f4af0568 path-util: teach find_executable_full how to look into the root directory
When the root parameter in find_executable_full is set, chase_symlinks prefixes this root
to every check of the path name to find the complete path of the execuatble in case the
path provided is not absolute. This is only done for the non NULL root because otherwise
the chase_symlinks function would alter the behavior of some of the callers which would
in turn alter the outputs in a way that is undesirable. The find_execuatble_full function is
invoked by the verify_executable function in analyze-verify.
2021-08-10 10:14:01 -07:00
Lennart Poettering
1053967781 path-util: make path_compare() accept NULL 2021-07-08 13:56:06 +02:00
Lennart Poettering
1a27c323dd path-util: make path_equal() an inline wrapper around path_compare()
The two are completely identical, only the return code is inverted.
let's hence make it easy for the compiler to make it the same function
call even in lowest optimization modes.
2021-06-18 13:46:43 +09:00
Zbigniew Jędrzejewski-Szmek
0d5a24beae various: don't say that the timestamp 'changed' on initial load
I always found this a bit annoying.
With the patch:

$ SYSTEMD_LOG_LEVEL=debug build/udevadm test /sys/class/block/dm-1
...
Loaded timestamp for '/etc/systemd/network'.
Loaded timestamp for '/usr/lib/systemd/network'.
Parsed configuration file /usr/lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/10-eth0.link
Created link configuration context.
Loaded timestamp for '/etc/udev/rules.d'.
Loaded timestamp for '/usr/lib/udev/rules.d'.
...
2021-06-02 16:23:54 +02:00
Yu Watanabe
50fd596efc path-util: add missing varargs cleanup
Fixes CID#1453293.
2021-05-28 19:38:37 +09:00
Yu Watanabe
cb71ed91f7 path-util: make path_simplify() use path_find_first_component() 2021-05-28 13:44:38 +09:00
Yu Watanabe
4ff361cc86 tree-wide: always drop unnecessary dot in path 2021-05-28 13:44:38 +09:00
Yu Watanabe
0195046449 path-util: make path_extract_filename/directory() handle "." gracefully
This makes the functions handle "xx/" and "xx/." as equivalent.
Moreover, now path_extract_directory() returns normalized path, that is
no redundant "/" or "/./" are contained.
2021-05-28 13:44:38 +09:00
Yu Watanabe
484cd43cae path-util: introduce path_find_last_component() 2021-05-28 13:44:38 +09:00