Skip to content

Commit

Permalink
systemctl: enable: overwrite broken alias symlinks
Browse files Browse the repository at this point in the history
When switching to an alternative alias provider,
the previous one might have been uninstalled or so.
It should be fine for us to overwrite them directly.

Closes systemd#23694
  • Loading branch information
YHNdnzj authored and d-hatayama committed Feb 15, 2023
1 parent 772e713 commit 892be1b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/shared/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,7 @@ static int install_info_symlink_alias(

STRV_FOREACH(s, info->aliases) {
_cleanup_free_ char *alias_path = NULL, *dst = NULL, *dst_updated = NULL;
bool broken;

q = install_name_printf(scope, info, *s, &dst);
if (q < 0) {
Expand All @@ -1912,7 +1913,14 @@ static int install_info_symlink_alias(
if (!alias_path)
return -ENOMEM;

q = create_symlink(lp, info->path, alias_path, force, changes, n_changes);
q = chase_symlinks(alias_path, lp->root_dir, CHASE_NONEXISTENT, NULL, NULL);
if (q < 0 && q != -ENOENT) {
r = r < 0 ? r : q;
continue;
}
broken = q == 0; /* symlink target does not exist? */

q = create_symlink(lp, info->path, alias_path, force || broken, changes, n_changes);
r = r < 0 ? r : q;
}

Expand Down

0 comments on commit 892be1b

Please sign in to comment.