summaryrefslogtreecommitdiff
path: root/src/system-update-generator
diff options
context:
space:
mode:
Diffstat (limited to 'src/system-update-generator')
-rw-r--r--src/system-update-generator/system-update-generator.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c
index 54cd943af7..ee5f8ec12e 100644
--- a/src/system-update-generator/system-update-generator.c
+++ b/src/system-update-generator/system-update-generator.c
@@ -6,6 +6,7 @@
#include "fs-util.h"
#include "generator.h"
#include "log.h"
+#include "path-util.h"
#include "proc-cmdline.h"
#include "special.h"
#include "string-util.h"
@@ -18,19 +19,25 @@
static const char *arg_dest = NULL;
static int generate_symlink(void) {
- const char *p = NULL;
+ _cleanup_free_ char *j = NULL;
- if (laccess("/system-update", F_OK) < 0) {
- if (errno == ENOENT)
- return 0;
+ FOREACH_STRING(p, "/system-update", "/etc/system-update") {
+ if (laccess(p, F_OK) >= 0)
+ goto link_found;
- log_error_errno(errno, "Failed to check for system update: %m");
- return -EINVAL;
+ if (errno != ENOENT)
+ log_warning_errno(errno, "Failed to check if %s symlink exists, ignoring: %m", p);
}
- p = strjoina(arg_dest, "/" SPECIAL_DEFAULT_TARGET);
- if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", p) < 0)
- return log_error_errno(errno, "Failed to create symlink %s: %m", p);
+ return 0;
+
+link_found:
+ j = path_join(arg_dest, SPECIAL_DEFAULT_TARGET);
+ if (!j)
+ return log_oom();
+
+ if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", j) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", j);
return 1;
}