summaryrefslogtreecommitdiff
path: root/src/random-seed
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2022-10-19 15:27:04 +0200
committerFranck Bui <fbui@suse.com>2022-10-21 14:49:01 +0200
commit249d31b00a42aa016639bc0e9d708803d26f8f8f (patch)
treee7ff3154cec9bbf96f16dcb02dfdacaea7c8acfa /src/random-seed
parent8ff92848a6d68e0659e0a777a0de84130e3a74a1 (diff)
downloadsystemd-249d31b00a42aa016639bc0e9d708803d26f8f8f.tar.gz
random-seed: shorten a bit may_credit()
No functional change.
Diffstat (limited to 'src/random-seed')
-rw-r--r--src/random-seed/random-seed.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c
index 82c29d0d7f..569b916f4a 100644
--- a/src/random-seed/random-seed.c
+++ b/src/random-seed/random-seed.c
@@ -87,20 +87,17 @@ static CreditEntropy may_credit(int seed_fd) {
/* Don't credit the random seed if we are in first-boot mode, because we are supposed to start from
* scratch. This is a safety precaution for cases where we people ship "golden" images with empty
* /etc but populated /var that contains a random seed. */
- if (access("/run/systemd/first-boot", F_OK) < 0) {
-
- if (errno != ENOENT) {
- log_warning_errno(errno, "Failed to check whether we are in first-boot mode, not crediting entropy: %m");
- return CREDIT_ENTROPY_NO_WAY;
- }
-
- /* If ENOENT all is good, we are not in first-boot mode. */
- } else {
- log_debug("Not crediting entropy, since booted in first-boot mode.");
+ r = RET_NERRNO(access("/run/systemd/first-boot", F_OK));
+ if (r == -ENOENT)
+ /* All is good, we are not in first-boot mode. */
+ return CREDIT_ENTROPY_YES_PLEASE;
+ if (r < 0) {
+ log_warning_errno(r, "Failed to check whether we are in first-boot mode, not crediting entropy: %m");
return CREDIT_ENTROPY_NO_WAY;
}
- return CREDIT_ENTROPY_YES_PLEASE;
+ log_debug("Not crediting entropy, since booted in first-boot mode.");
+ return CREDIT_ENTROPY_NO_WAY;
}
static int run(int argc, char *argv[]) {