ssh-generator: follow symlink when searching for sshd@.service

unit_file_exists() currently does not follow symlinks, as it is
mainly used to test whether the unit (of any install state)
has been seen under search dirs. However, in ssh-generator
we should search for and honor whatever the distro ships,
which might be an alias or linked externally.
This commit is contained in:
Mike Yuan
2026-02-03 08:17:34 +09:00
committed by Yu Watanabe
parent ce41216e49
commit c27d1b3eec
3 changed files with 20 additions and 5 deletions
+4 -1
View File
@@ -475,7 +475,10 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
return r;
_cleanup_free_ char *found_sshd_template_unit = NULL;
r = unit_file_exists_full(RUNTIME_SCOPE_SYSTEM, &lp, "sshd@.service", &found_sshd_template_unit);
r = unit_file_exists_full(RUNTIME_SCOPE_SYSTEM, &lp,
/* follow = */ true,
"sshd@.service",
&found_sshd_template_unit);
if (r < 0)
return log_error_errno(r, "Unable to detect if sshd@.service exists: %m");