socket: make sure we warn loudly about symlinks we can't create
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
This commit is contained in:
parent
77b79723a6
commit
95f7fbbf88
|
@ -38,6 +38,7 @@
|
|||
#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"
|
||||
|
@ -1324,6 +1325,7 @@ static int mq_address_create(
|
|||
static int socket_symlink(Socket *s) {
|
||||
const char *p;
|
||||
char **i;
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
|
||||
|
@ -1331,8 +1333,11 @@ static int socket_symlink(Socket *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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue