]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
commonio: force lock file sync 293/head
authorikerexxe <ipedrosa@redhat.com>
Mon, 2 Nov 2020 16:08:55 +0000 (17:08 +0100)
committerikerexxe <ipedrosa@redhat.com>
Thu, 5 Nov 2020 16:15:56 +0000 (17:15 +0100)
lib/commonio.c: after writing to the lock file, force a file sync to
the storage system.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1862056

lib/commonio.c

index 16fa7e755cd54a7abb0f20aa4296a0e411901e87..c5b3d104011e9fc721c1e3b0c3c80a0492317602 100644 (file)
@@ -157,7 +157,17 @@ static int do_lock_file (const char *file, const char *lock, bool log)
        if (write (fd, buf, (size_t) len) != len) {
                if (log) {
                        (void) fprintf (stderr,
-                                       "%s: %s: %s\n",
+                                       "%s: %s file write error: %s\n",
+                                       Prog, file, strerror (errno));
+               }
+               (void) close (fd);
+               unlink (file);
+               return 0;
+       }
+       if (fdatasync (fd) == -1) {
+               if (log) {
+                       (void) fprintf (stderr,
+                                       "%s: %s file sync error: %s\n",
                                        Prog, file, strerror (errno));
                }
                (void) close (fd);