]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
firstboot: Refactor should_configure() 27053/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 29 Mar 2023 16:03:32 +0000 (18:03 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 29 Mar 2023 16:05:04 +0000 (18:05 +0200)
src/firstboot/firstboot.c

index 432cab47866b404c8a95365d036bad9021a0f600..ba7e08913f338a543305df3735bb6fc5f2d2da82 100644 (file)
@@ -230,16 +230,17 @@ static int prompt_loop(const char *text, char **l, unsigned percentage, bool (*i
 }
 
 static int should_configure(int dir_fd, const char *filename) {
-        int r;
-
         assert(dir_fd >= 0);
         assert(filename);
 
-        r = faccessat(dir_fd, filename, F_OK, AT_SYMLINK_NOFOLLOW);
-        if (r < 0 && errno != ENOENT)
-                return log_error_errno(errno, "Failed to access %s: %m", filename);
+        if (faccessat(dir_fd, filename, F_OK, AT_SYMLINK_NOFOLLOW) < 0) {
+                if (errno != ENOENT)
+                        return log_error_errno(errno, "Failed to access %s: %m", filename);
+
+                return true; /* missing */
+        }
 
-        return r < 0 || arg_force;
+        return arg_force; /* exists, but if --force was given we should still configure the file. */
 }
 
 static bool locale_is_ok(const char *name) {