summaryrefslogtreecommitdiffstats
path: root/src/basic/unit-file.c
diff options
context:
space:
mode:
authorOMOJOLA JOSHUA DAMILOLA <omojolajoshua@gmail.com>2023-04-01 20:52:32 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-04-04 01:10:22 +0200
commitde2820606d872ddc9c82cc138a5bdfc302863a2d (patch)
treeac8af3e7c9a69ccc31db668ca7fd92b185303f1d /src/basic/unit-file.c
parentMerge pull request #27114 from keszybz/trivial-cleanups (diff)
downloadsystemd-de2820606d872ddc9c82cc138a5bdfc302863a2d.tar.xz
systemd-de2820606d872ddc9c82cc138a5bdfc302863a2d.zip
src: changed usage of basename() to path_extract_filename().
TODO.
Diffstat (limited to 'src/basic/unit-file.c')
-rw-r--r--src/basic/unit-file.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/basic/unit-file.c b/src/basic/unit-file.c
index 70b7eb1606..41422579d6 100644
--- a/src/basic/unit-file.c
+++ b/src/basic/unit-file.c
@@ -71,10 +71,11 @@ int unit_symlink_name_compatible(const char *symlink, const char *target, bool i
}
int unit_validate_alias_symlink_or_warn(int log_level, const char *filename, const char *target) {
- const char *src, *dst;
+ _cleanup_free_ char *src = NULL, *dst = NULL;
_cleanup_free_ char *src_instance = NULL, *dst_instance = NULL;
UnitType src_unit_type, dst_unit_type;
UnitNameFlags src_name_type, dst_name_type;
+ int r;
/* Check if the *alias* symlink is valid. This applies to symlinks like
* /etc/systemd/system/dbus.service → dbus-broker.service, but not to .wants or .requires symlinks
@@ -87,8 +88,13 @@ int unit_validate_alias_symlink_or_warn(int log_level, const char *filename, con
* -ELOOP for an alias to self.
*/
- src = basename(filename);
- dst = basename(target);
+ r = path_extract_filename(filename, &src);
+ if (r < 0)
+ return r;
+
+ r = path_extract_filename(target, &dst);
+ if (r < 0)
+ return r;
/* src checks */
@@ -762,7 +768,10 @@ int unit_file_find_fragment(
}
if (fragment && ret_names) {
- const char *fragment_basename = basename(fragment);
+ _cleanup_free_ char *fragment_basename = NULL;
+ r = path_extract_filename(fragment, &fragment_basename);
+ if (r < 0)
+ return r;
if (!streq(fragment_basename, unit_name)) {
/* Add names based on the fragment name to the set of names */