Note that this change does not make symlink creation failing fatal. I am
not entirely sure about whether it should be, but I am leaning towards
not making it fatal for two reasons: symlinks like this tend to be a
compatibility feature, and hence unlikely to be essential for operation,
in a way this breaks compatibility, and while doing that is not off the
table, we should probably avoid it if we are not entirely sure it's a
good thing.
Note that this also changes plain symlink() to symlink_idempotent() so
that existing symlinks with the right destination are nothing we log
about.
Fixes: #6920
#include "exit-status.h"
#include "fd-util.h"
#include "format-util.h"
+#include "fs-util.h"
#include "in-addr-util.h"
#include "io-util.h"
#include "label.h"
static int socket_symlink(Socket *s) {
const char *p;
char **i;
+ int r;
assert(s);
if (!p)
return 0;
- STRV_FOREACH(i, s->symlinks)
- symlink_label(p, *i);
+ STRV_FOREACH(i, s->symlinks) {
+ r = symlink_idempotent(p, *i);
+ if (r < 0)
+ log_unit_warning_errno(UNIT(s), r, "Failed to create symlink %s → %s, ignoring: %m", p, *i);
+ }
return 0;
}