/* Check if the symlink goes outside of our search path.
* If yes, it's a linked unit file or mask, and we don't care about the target name.
- * Let's just store the link destination directly.
+ * Let's just store the link source directly.
* If not, let's verify that it's a good symlink. */
char *tail = path_startswith_strv(simplified, lp->search_path);
- if (tail) {
+ if (!tail) {
+ log_debug("%s: linked unit file: %s → %s",
+ __func__, filename, simplified);
+
+ dst = filename;
+ } else {
+
bool self_alias;
dst = basename(simplified);
}
log_debug("%s: alias: %s/%s → %s", __func__, *dir, de->d_name, dst);
- } else {
- dst = simplified;
-
- log_debug("%s: linked unit file: %s/%s → %s", __func__, *dir, de->d_name, dst);
}
} else {
}
}
- /* We do the merge dance here because for some unit types, the unit might have aliases which are not
+ /* Call merge_by_names with the name derived from the fragment path as the preferred name.
+ *
+ * We do the merge dance here because for some unit types, the unit might have aliases which are not
* declared in the file system. In particular, this is true (and frequent) for device and swap units.
*/
- Unit *merged;
const char *id = u->id;
_cleanup_free_ char *free_id = NULL;
}
}
- merged = u;
+ Unit *merged = u;
r = merge_by_names(&merged, names, id);
if (r < 0)
return r;