From: bin456789 Date: Sat, 13 Aug 2022 19:29:37 +0000 (+0800) Subject: firstboot: fix can't overwrite timezone X-Git-Tag: v252-rc1~449 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e56dc320d39ade1795118ebe400308a80511e9c9;p=thirdparty%2Fsystemd.git firstboot: fix can't overwrite timezone --- diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 7684c205fb3..9169129a688 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;