From e56dc320d39ade1795118ebe400308a80511e9c9 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 14 Aug 2022 03:29:37 +0800 Subject: [PATCH] firstboot: fix can't overwrite timezone --- src/firstboot/firstboot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 7684c205fb..9169129a68 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -479,8 +479,9 @@ static int process_timezone(void) { return log_error_errno(r, "Failed to read host timezone: %m"); (void) mkdir_parents(etc_localtime, 0755); - if (symlink(p, etc_localtime) < 0) - return log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime); + r = symlink_atomic(p, etc_localtime); + if (r < 0) + return log_error_errno(r, "Failed to create %s symlink: %m", etc_localtime); log_info("%s copied.", etc_localtime); return 0; @@ -497,8 +498,9 @@ static int process_timezone(void) { e = strjoina("../usr/share/zoneinfo/", arg_timezone); (void) mkdir_parents(etc_localtime, 0755); - if (symlink(e, etc_localtime) < 0) - return log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime); + r = symlink_atomic(e, etc_localtime); + if (r < 0) + return log_error_errno(r, "Failed to create %s symlink: %m", etc_localtime); log_info("%s written", etc_localtime); return 0; -- 2.25.1