The function is now only used by sd-device.c and pam_systemd.c, and they
expects the result are not directory. Hence, it is safe to change the
behavior.
Addresses https://github.com/systemd/systemd/pull/23089#discussion_r853006017.
}
int readlink_value(const char *p, char **ret) {
- _cleanup_free_ char *link = NULL;
+ _cleanup_free_ char *link = NULL, *name = NULL;
int r;
assert(p);
if (r < 0)
return r;
- return path_extract_filename(link, ret);
+ r = path_extract_filename(link, &name);
+ if (r < 0)
+ return r;
+ if (r == O_DIRECTORY)
+ return -EINVAL;
+
+ *ret = TAKE_PTR(name);
+ return 0;
}
int readlink_and_make_absolute(const char *p, char **r) {