1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
9 /* When we include libgen.h because we need dirname() we immediately
10 * undefine basename() since libgen.h defines it as a macro to the
11 * POSIX version which is really broken. We prefer GNU basename(). */
15 #include "alloc-util.h"
16 #include "extract-word.h"
19 #include "glob-util.h"
22 #include "nulstr-util.h"
23 #include "parse-util.h"
24 #include "path-util.h"
25 #include "stat-util.h"
26 #include "string-util.h"
28 #include "time-util.h"
31 int path_split_and_make_absolute(const char *p
, char ***ret
) {
38 l
= strv_split(p
, ":");
42 r
= path_strv_make_absolute_cwd(l
);
52 char *path_make_absolute(const char *p
, const char *prefix
) {
55 /* Makes every item in the list an absolute path by prepending
56 * the prefix, if specified and necessary */
58 if (path_is_absolute(p
) || isempty(prefix
))
61 return path_join(prefix
, p
);
64 int safe_getcwd(char **ret
) {
67 cwd
= get_current_dir_name();
69 return negative_errno();
71 /* Let's make sure the directory is really absolute, to protect us from the logic behind
82 int path_make_absolute_cwd(const char *p
, char **ret
) {
89 /* Similar to path_make_absolute(), but prefixes with the
90 * current working directory. */
92 if (path_is_absolute(p
))
95 _cleanup_free_
char *cwd
= NULL
;
97 r
= safe_getcwd(&cwd
);
101 c
= path_join(cwd
, p
);
110 int path_make_relative(const char *from
, const char *to
, char **ret
) {
111 _cleanup_free_
char *result
= NULL
;
121 /* Strips the common part, and adds ".." elements as necessary. */
123 if (!path_is_absolute(from
) || !path_is_absolute(to
))
127 r
= path_find_first_component(&from
, true, &f
);
131 k
= path_find_first_component(&to
, true, &t
);
138 /* from and to are equivalent. */
139 result
= strdup(".");
143 /* 'to' is inside of 'from'. */
148 path_simplify(result
);
150 if (!path_is_valid(result
))
154 *ret
= TAKE_PTR(result
);
158 if (r
!= k
|| !strneq(f
, t
, r
))
162 /* If we're here, then "from_dir" has one or more elements that need to
163 * be replaced with "..". */
165 for (n_parents
= 1;; n_parents
++) {
166 /* If this includes ".." we can't do a simple series of "..". */
167 r
= path_find_first_component(&from
, false, &f
);
174 if (isempty(t
) && n_parents
* 3 > PATH_MAX
)
175 /* PATH_MAX is counted *with* the trailing NUL byte */
178 result
= new(char, n_parents
* 3 + !isempty(t
) + strlen_ptr(t
));
182 for (p
= result
; n_parents
> 0; n_parents
--)
183 p
= mempcpy(p
, "../", 3);
186 /* Remove trailing slash and terminate string. */
188 *ret
= TAKE_PTR(result
);
194 path_simplify(result
);
196 if (!path_is_valid(result
))
199 *ret
= TAKE_PTR(result
);
203 char* path_startswith_strv(const char *p
, char **set
) {
206 STRV_FOREACH(s
, set
) {
207 t
= path_startswith(p
, *s
);
215 int path_strv_make_absolute_cwd(char **l
) {
219 /* Goes through every item in the string list and makes it
220 * absolute. This works in place and won't rollback any
221 * changes on failure. */
226 r
= path_make_absolute_cwd(*s
, &t
);
231 free_and_replace(*s
, t
);
237 char **path_strv_resolve(char **l
, const char *root
) {
246 /* Goes through every item in the string list and canonicalize
247 * the path. This works in place and won't rollback any
248 * changes on failure. */
251 _cleanup_free_
char *orig
= NULL
;
254 if (!path_is_absolute(*s
)) {
261 t
= path_join(root
, orig
);
269 r
= chase_symlinks(t
, root
, 0, &u
, NULL
);
287 x
= path_startswith(u
, root
);
289 /* restore the slash if it was lost */
290 if (!startswith(x
, "/"))
301 /* canonicalized path goes outside of
302 * prefix, keep the original path instead */
303 free_and_replace(u
, orig
);
319 char **path_strv_resolve_uniq(char **l
, const char *root
) {
324 if (!path_strv_resolve(l
, root
))
330 char *path_simplify(char *path
) {
331 bool add_slash
= false;
337 /* Removes redundant inner and trailing slashes. Also removes unnecessary dots.
338 * Modifies the passed string in-place.
340 * ///foo//./bar/. becomes /foo/bar
341 * .//./foo//./bar/. becomes foo/bar
347 if (path_is_absolute(path
))
350 for (const char *p
= f
;;) {
353 r
= path_find_first_component(&p
, true, &e
);
361 /* if path is invalid, then refuse to simplify remaining part. */
362 memmove(f
, p
, strlen(p
) + 1);
372 /* Special rule, if we stripped everything, we need a "." for the current directory. */
380 int path_simplify_and_warn(
384 const char *filename
,
386 const char *lvalue
) {
388 bool fatal
= flag
& PATH_CHECK_FATAL
;
390 assert(!FLAGS_SET(flag
, PATH_CHECK_ABSOLUTE
| PATH_CHECK_RELATIVE
));
392 if (!utf8_is_valid(path
))
393 return log_syntax_invalid_utf8(unit
, LOG_ERR
, filename
, line
, path
);
395 if (flag
& (PATH_CHECK_ABSOLUTE
| PATH_CHECK_RELATIVE
)) {
398 absolute
= path_is_absolute(path
);
400 if (!absolute
&& (flag
& PATH_CHECK_ABSOLUTE
))
401 return log_syntax(unit
, LOG_ERR
, filename
, line
, SYNTHETIC_ERRNO(EINVAL
),
402 "%s= path is not absolute%s: %s",
403 lvalue
, fatal
? "" : ", ignoring", path
);
405 if (absolute
&& (flag
& PATH_CHECK_RELATIVE
))
406 return log_syntax(unit
, LOG_ERR
, filename
, line
, SYNTHETIC_ERRNO(EINVAL
),
407 "%s= path is absolute%s: %s",
408 lvalue
, fatal
? "" : ", ignoring", path
);
413 if (!path_is_valid(path
))
414 return log_syntax(unit
, LOG_ERR
, filename
, line
, SYNTHETIC_ERRNO(EINVAL
),
415 "%s= path has invalid length (%zu bytes)%s.",
416 lvalue
, strlen(path
), fatal
? "" : ", ignoring");
418 if (!path_is_normalized(path
))
419 return log_syntax(unit
, LOG_ERR
, filename
, line
, SYNTHETIC_ERRNO(EINVAL
),
420 "%s= path is not normalized%s: %s",
421 lvalue
, fatal
? "" : ", ignoring", path
);
426 char *path_startswith_full(const char *path
, const char *prefix
, bool accept_dot_dot
) {
430 /* Returns a pointer to the start of the first component after the parts matched by
432 * - both paths are absolute or both paths are relative,
434 * - each component in prefix in turn matches a component in path at the same position.
435 * An empty string will be returned when the prefix and path are equivalent.
437 * Returns NULL otherwise.
440 if ((path
[0] == '/') != (prefix
[0] == '/'))
447 r
= path_find_first_component(&path
, accept_dot_dot
, &p
);
451 k
= path_find_first_component(&prefix
, accept_dot_dot
, &q
);
456 return (char*) (p
?: path
);
461 if (!strneq(p
, q
, r
))
466 int path_compare(const char *a
, const char *b
) {
469 /* Order NULL before non-NULL */
474 /* A relative path and an absolute path must not compare as equal.
475 * Which one is sorted before the other does not really matter.
476 * Here a relative path is ordered before an absolute path. */
477 r
= CMP(path_is_absolute(a
), path_is_absolute(b
));
485 j
= path_find_first_component(&a
, true, &aa
);
486 k
= path_find_first_component(&b
, true, &bb
);
488 if (j
< 0 || k
< 0) {
489 /* When one of paths is invalid, order invalid path after valid one. */
490 r
= CMP(j
< 0, k
< 0);
494 /* fallback to use strcmp() if both paths are invalid. */
498 /* Order prefixes first: "/foo" before "/foo/bar" */
507 /* Alphabetical sort: "/foo/aaa" before "/foo/b" */
508 r
= memcmp(aa
, bb
, MIN(j
, k
));
512 /* Sort "/foo/a" before "/foo/aaa" */
519 bool path_equal_or_files_same(const char *a
, const char *b
, int flags
) {
520 return path_equal(a
, b
) || files_same(a
, b
, flags
) > 0;
523 bool path_equal_filename(const char *a
, const char *b
) {
524 _cleanup_free_
char *a_basename
= NULL
, *b_basename
= NULL
;
530 r
= path_extract_filename(a
, &a_basename
);
532 log_debug_errno(r
, "Failed to parse basename of %s: %m", a
);
535 r
= path_extract_filename(b
, &b_basename
);
537 log_debug_errno(r
, "Failed to parse basename of %s: %m", b
);
541 return path_equal(a_basename
, b_basename
);
544 char* path_extend_internal(char **x
, ...) {
551 /* Joins all listed strings until the sentinel and places a "/" between them unless the strings end/begin
552 * already with one so that it is unnecessary. Note that slashes which are already duplicate won't be
553 * removed. The string returned is hence always equal to or longer than the sum of the lengths of each
556 * The first argument may be an already allocated string that is extended via realloc() if
557 * non-NULL. path_extend() and path_join() are macro wrappers around this function, making use of the
558 * first parameter to distinguish the two operations.
560 * Note: any listed empty string is simply skipped. This can be useful for concatenating strings of which some
565 * path_join("foo", "bar") → "foo/bar"
566 * path_join("foo/", "bar") → "foo/bar"
567 * path_join("", "foo", "", "bar", "") → "foo/bar" */
569 sz
= old_sz
= x
? strlen_ptr(*x
) : 0;
571 while ((p
= va_arg(ap
, char*)) != POINTER_MAX
) {
578 if (sz
> SIZE_MAX
- add
) { /* overflow check */
587 nx
= realloc(x
? *x
: NULL
, GREEDY_ALLOC_ROUND_UP(sz
+1));
594 slash
= nx
[old_sz
-1] == '/';
597 slash
= true; /* no need to generate a slash anymore */
603 while ((p
= va_arg(ap
, char*)) != POINTER_MAX
) {
607 if (!slash
&& p
[0] != '/')
611 slash
= endswith(p
, "/");
618 static int check_x_access(const char *path
, int *ret_fd
) {
619 _cleanup_close_
int fd
= -1;
622 /* We need to use O_PATH because there may be executables for which we have only exec
623 * permissions, but not read (usually suid executables). */
624 fd
= open(path
, O_PATH
|O_CLOEXEC
);
628 r
= fd_verify_regular(fd
);
632 r
= access_fd(fd
, X_OK
);
637 *ret_fd
= TAKE_FD(fd
);
642 static int find_executable_impl(const char *name
, const char *root
, char **ret_filename
, int *ret_fd
) {
643 _cleanup_close_
int fd
= -1;
644 _cleanup_free_
char *path_name
= NULL
;
649 /* Function chase_symlinks() is invoked only when root is not NULL, as using it regardless of
650 * root value would alter the behavior of existing callers for example: /bin/sleep would become
651 * /usr/bin/sleep when find_executables is called. Hence, this function should be invoked when
652 * needed to avoid unforeseen regression or other complicated changes. */
654 r
= chase_symlinks(name
,
658 /* ret_fd= */ NULL
); /* prefix root to name in case full paths are not specified */
665 r
= check_x_access(name
, ret_fd
? &fd
: NULL
);
670 r
= path_make_absolute_cwd(name
, ret_filename
);
676 *ret_fd
= TAKE_FD(fd
);
681 int find_executable_full(const char *name
, const char *root
, bool use_path_envvar
, char **ret_filename
, int *ret_fd
) {
683 const char *p
= NULL
;
688 return find_executable_impl(name
, root
, ret_filename
, ret_fd
);
691 /* Plain getenv, not secure_getenv, because we want to actually allow the user to pick the
697 last_error
= -ENOENT
;
699 /* Resolve a single-component name to a full path */
701 _cleanup_free_
char *element
= NULL
;
703 r
= extract_first_word(&p
, &element
, ":", EXTRACT_RELAX
|EXTRACT_DONT_COALESCE_SEPARATORS
);
709 if (!path_is_absolute(element
))
712 if (!path_extend(&element
, name
))
715 r
= find_executable_impl(element
, root
, ret_filename
, ret_fd
);
717 /* PATH entries which we don't have access to are ignored, as per tradition. */
730 bool paths_check_timestamp(const char* const* paths
, usec_t
*timestamp
, bool update
) {
731 bool changed
= false, originally_unset
;
732 const char* const* i
;
739 originally_unset
= *timestamp
== 0;
741 STRV_FOREACH(i
, paths
) {
745 if (stat(*i
, &stats
) < 0)
748 u
= timespec_load(&stats
.st_mtim
);
754 log_debug(originally_unset
? "Loaded timestamp for '%s'." : "Timestamp of '%s' changed.", *i
);
756 /* update timestamp */
767 static int executable_is_good(const char *executable
) {
768 _cleanup_free_
char *p
= NULL
, *d
= NULL
;
771 r
= find_executable(executable
, &p
);
777 /* An fsck that is linked to /bin/true is a non-existent fsck */
779 r
= readlink_malloc(p
, &d
);
780 if (r
== -EINVAL
) /* not a symlink */
785 return !PATH_IN_SET(d
, "true"
791 int fsck_exists(const char *fstype
) {
796 if (streq(fstype
, "auto"))
799 checker
= strjoina("fsck.", fstype
);
800 return executable_is_good(checker
);
803 char* dirname_malloc(const char *path
) {
804 char *d
, *dir
, *dir2
;
824 static const char *skip_slash_or_dot(const char *p
) {
825 for (; !isempty(p
); p
++) {
828 if (startswith(p
, "./")) {
837 int path_find_first_component(const char **p
, bool accept_dot_dot
, const char **ret
) {
838 const char *q
, *first
, *end_first
, *next
;
843 /* When a path is input, then returns the pointer to the first component and its length, and
844 * move the input pointer to the next component or nul. This skips both over any '/'
845 * immediately *before* and *after* the first component before returning.
848 * Input: p: "//.//aaa///bbbbb/cc"
849 * Output: p: "bbbbb///cc"
850 * ret: "aaa///bbbbb/cc"
851 * return value: 3 (== strlen("aaa"))
854 * Output: p: (pointer to NUL)
856 * return value: 3 (== strlen("aaa"))
858 * Input: p: "/", ".", ""
859 * Output: p: (pointer to NUL)
868 * Input: p: "(too long component)"
869 * Output: return value: -EINVAL
871 * (when accept_dot_dot is false)
872 * Input: p: "//..//aaa///bbbbb/cc"
873 * Output: return value: -EINVAL
878 first
= skip_slash_or_dot(q
);
879 if (isempty(first
)) {
885 if (streq(first
, ".")) {
892 end_first
= strchrnul(first
, '/');
893 len
= end_first
- first
;
897 if (!accept_dot_dot
&& len
== 2 && first
[0] == '.' && first
[1] == '.')
900 next
= skip_slash_or_dot(end_first
);
902 *p
= next
+ streq(next
, ".");
908 static const char *skip_slash_or_dot_backward(const char *path
, const char *q
) {
911 for (; q
>= path
; q
--) {
914 if (q
> path
&& strneq(q
- 1, "/.", 2))
921 int path_find_last_component(const char *path
, bool accept_dot_dot
, const char **next
, const char **ret
) {
922 const char *q
, *last_end
, *last_begin
;
925 /* Similar to path_find_first_component(), but search components from the end.
928 * Input: path: "//.//aaa///bbbbb/cc//././"
930 * Output: next: "/cc//././"
932 * return value: 2 (== strlen("cc"))
934 * Input: path: "//.//aaa///bbbbb/cc//././"
936 * Output: next: "///bbbbb/cc//././"
937 * ret: "bbbbb/cc//././"
938 * return value: 5 (== strlen("bbbbb"))
940 * Input: path: "/", ".", "", or NULL
941 * Output: next: equivalent to path
945 * Input: path: "(too long component)"
946 * Output: return value: -EINVAL
948 * (when accept_dot_dot is false)
949 * Input: path: "//..//aaa///bbbbb/cc/..//"
950 * Output: return value: -EINVAL
962 if (*next
< path
|| *next
> path
+ strlen(path
))
969 if (!IN_SET(**next
, '\0', '/'))
973 q
= path
+ strlen(path
) - 1;
975 q
= skip_slash_or_dot_backward(path
, q
);
976 if ((q
< path
) || /* the root directory */
977 (q
== path
&& *q
== '.')) { /* path is "." or "./" */
987 while (q
>= path
&& *q
!= '/')
991 len
= last_end
- last_begin
;
995 if (!accept_dot_dot
&& len
== 2 && strneq(last_begin
, "..", 2))
999 q
= skip_slash_or_dot_backward(path
, q
);
1011 const char *last_path_component(const char *path
) {
1013 /* Finds the last component of the path, preserving the optional trailing slash that signifies a directory.
1026 * Also, the empty string is mapped to itself.
1028 * This is different than basename(), which returns "" when a trailing slash is present.
1030 * This always succeeds (except if you pass NULL in which case it returns NULL, too).
1038 l
= k
= strlen(path
);
1039 if (l
== 0) /* special case — an empty string */
1042 while (k
> 0 && path
[k
-1] == '/')
1045 if (k
== 0) /* the root directory */
1046 return path
+ l
- 1;
1048 while (k
> 0 && path
[k
-1] != '/')
1054 int path_extract_filename(const char *path
, char **ret
) {
1055 _cleanup_free_
char *a
= NULL
;
1056 const char *c
, *next
= NULL
;
1059 /* Extracts the filename part (i.e. right-most component) from a path, i.e. string that passes
1060 * filename_is_valid(). A wrapper around last_path_component(), but eats up trailing
1063 * -EINVAL → if the path is not valid
1064 * -EADDRNOTAVAIL → if only a directory was specified, but no filename, i.e. the root dir
1065 * itself or "." is specified
1066 * -ENOMEM → no memory
1068 * Returns >= 0 on success. If the input path has a trailing slash, returns O_DIRECTORY, to
1069 * indicate the referenced file must be a directory.
1071 * This function guarantees to return a fully valid filename, i.e. one that passes
1072 * filename_is_valid() – this means "." and ".." are not accepted. */
1074 if (!path_is_valid(path
))
1077 r
= path_find_last_component(path
, false, &next
, &c
);
1080 if (r
== 0) /* root directory */
1081 return -EADDRNOTAVAIL
;
1088 return strlen(c
) > (size_t)r
? O_DIRECTORY
: 0;
1091 int path_extract_directory(const char *path
, char **ret
) {
1092 _cleanup_free_
char *a
= NULL
;
1093 const char *c
, *next
= NULL
;
1096 /* The inverse of path_extract_filename(), i.e. returns the directory path prefix. Returns:
1098 * -EINVAL → if the path is not valid
1099 * -EDESTADDRREQ → if no directory was specified in the passed in path, i.e. only a filename was passed
1100 * -EADDRNOTAVAIL → if the passed in parameter had no filename but did have a directory, i.e.
1101 * the root dir itself or "." was specified
1102 * -ENOMEM → no memory (surprise!)
1104 * This function guarantees to return a fully valid path, i.e. one that passes path_is_valid().
1107 r
= path_find_last_component(path
, false, &next
, &c
);
1110 if (r
== 0) /* empty or root */
1111 return isempty(path
) ? -EINVAL
: -EADDRNOTAVAIL
;
1113 if (*path
!= '/') /* filename only */
1114 return -EDESTADDRREQ
;
1123 a
= strndup(path
, next
- path
);
1129 if (!path_is_valid(a
))
1136 bool filename_is_valid(const char *p
) {
1142 if (dot_or_dot_dot(p
))
1145 e
= strchrnul(p
, '/');
1149 if (e
- p
> NAME_MAX
) /* NAME_MAX is counted *without* the trailing NUL byte */
1155 bool path_is_valid_full(const char *p
, bool accept_dot_dot
) {
1159 for (const char *e
= p
;;) {
1162 r
= path_find_first_component(&e
, accept_dot_dot
, NULL
);
1166 if (e
- p
>= PATH_MAX
) /* Already reached the maximum length for a path? (PATH_MAX is counted
1167 * *with* the trailing NUL byte) */
1169 if (*e
== 0) /* End of string? Yay! */
1174 bool path_is_normalized(const char *p
) {
1175 if (!path_is_safe(p
))
1178 if (streq(p
, ".") || startswith(p
, "./") || endswith(p
, "/.") || strstr(p
, "/./"))
1181 if (strstr(p
, "//"))
1187 char *file_in_same_dir(const char *path
, const char *filename
) {
1194 /* This removes the last component of path and appends
1195 * filename, unless the latter is absolute anyway or the
1198 if (path_is_absolute(filename
))
1199 return strdup(filename
);
1201 e
= strrchr(path
, '/');
1203 return strdup(filename
);
1205 k
= strlen(filename
);
1206 ret
= new(char, (e
+ 1 - path
) + k
+ 1);
1210 memcpy(mempcpy(ret
, path
, e
+ 1 - path
), filename
, k
+ 1);
1214 bool hidden_or_backup_file(const char *filename
) {
1219 if (filename
[0] == '.' ||
1220 streq(filename
, "lost+found") ||
1221 streq(filename
, "aquota.user") ||
1222 streq(filename
, "aquota.group") ||
1223 endswith(filename
, "~"))
1226 p
= strrchr(filename
, '.');
1230 /* Please, let's not add more entries to the list below. If external projects think it's a good idea to come up
1231 * with always new suffixes and that everybody else should just adjust to that, then it really should be on
1232 * them. Hence, in future, let's not add any more entries. Instead, let's ask those packages to instead adopt
1233 * one of the generic suffixes/prefixes for hidden files or backups, possibly augmented with an additional
1234 * string. Specifically: there's now:
1236 * The generic suffixes "~" and ".bak" for backup files
1237 * The generic prefix "." for hidden files
1239 * Thus, if a new package manager "foopkg" wants its own set of ".foopkg-new", ".foopkg-old", ".foopkg-dist"
1240 * or so registered, let's refuse that and ask them to use ".foopkg.new", ".foopkg.old" or ".foopkg~" instead.
1243 return STR_IN_SET(p
+ 1,
1263 bool is_device_path(const char *path
) {
1265 /* Returns true on paths that likely refer to a device, either by path in sysfs or to something in /dev */
1267 return PATH_STARTSWITH_SET(path
, "/dev/", "/sys/");
1270 bool valid_device_node_path(const char *path
) {
1272 /* Some superficial checks whether the specified path is a valid device node path, all without looking at the
1273 * actual device node. */
1275 if (!PATH_STARTSWITH_SET(path
, "/dev/", "/run/systemd/inaccessible/"))
1278 if (endswith(path
, "/")) /* can't be a device node if it ends in a slash */
1281 return path_is_normalized(path
);
1284 bool valid_device_allow_pattern(const char *path
) {
1287 /* Like valid_device_node_path(), but also allows full-subsystem expressions, like DeviceAllow= and DeviceDeny=
1290 if (STARTSWITH_SET(path
, "block-", "char-"))
1293 return valid_device_node_path(path
);
1296 int systemd_installation_has_version(const char *root
, unsigned minimal_version
) {
1297 const char *pattern
;
1300 /* Try to guess if systemd installation is later than the specified version. This
1301 * is hacky and likely to yield false negatives, particularly if the installation
1302 * is non-standard. False positives should be relatively rare.
1305 NULSTR_FOREACH(pattern
,
1306 /* /lib works for systems without usr-merge, and for systems with a sane
1307 * usr-merge, where /lib is a symlink to /usr/lib. /usr/lib is necessary
1308 * for Gentoo which does a merge without making /lib a symlink.
1310 "lib/systemd/libsystemd-shared-*.so\0"
1311 "lib64/systemd/libsystemd-shared-*.so\0"
1312 "usr/lib/systemd/libsystemd-shared-*.so\0"
1313 "usr/lib64/systemd/libsystemd-shared-*.so\0") {
1315 _cleanup_strv_free_
char **names
= NULL
;
1316 _cleanup_free_
char *path
= NULL
;
1319 path
= path_join(root
, pattern
);
1323 r
= glob_extend(&names
, path
, 0);
1329 assert_se(c
= endswith(path
, "*.so"));
1330 *c
= '\0'; /* truncate the glob part */
1332 STRV_FOREACH(name
, names
) {
1333 /* This is most likely to run only once, hence let's not optimize anything. */
1337 t
= startswith(*name
, path
);
1341 t2
= endswith(t
, ".so");
1345 t2
[0] = '\0'; /* truncate the suffix */
1347 r
= safe_atou(t
, &version
);
1349 log_debug_errno(r
, "Found libsystemd shared at \"%s.so\", but failed to parse version: %m", *name
);
1353 log_debug("Found libsystemd shared at \"%s.so\", version %u (%s).",
1355 version
>= minimal_version
? "OK" : "too old");
1356 if (version
>= minimal_version
)
1364 bool dot_or_dot_dot(const char *path
) {
1374 return path
[2] == 0;
1377 bool empty_or_root(const char *path
) {
1379 /* For operations relative to some root directory, returns true if the specified root directory is redundant,
1380 * i.e. either / or NULL or the empty string or any equivalent. */
1385 return path_equal(path
, "/");
1388 bool path_strv_contains(char **l
, const char *path
) {
1392 if (path_equal(*i
, path
))
1398 bool prefixed_path_strv_contains(char **l
, const char *path
) {
1401 STRV_FOREACH(i
, l
) {
1407 if (path_equal(j
, path
))