diff options
author | bin456789 <bin456789@gmail.com> | 2022-08-14 03:29:37 +0800 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-08-15 14:08:04 +0900 |
commit | e56dc320d39ade1795118ebe400308a80511e9c9 (patch) | |
tree | dc7dd905074b2633c6b97c5337fdc4068db75b17 | |
parent | 3f504b892b92f54087feeb3fb35e3938567d7fa0 (diff) | |
download | systemd-e56dc320d39ade1795118ebe400308a80511e9c9.tar.gz |
firstboot: fix can't overwrite timezone
-rw-r--r-- | src/firstboot/firstboot.c | 10 |
1 files 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; |