]> granicus.if.org Git - linux-pam/commitdiff
pam_tally2: Remove unnecessary fsync()
authorMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Mon, 25 Feb 2019 19:50:48 +0000 (20:50 +0100)
committerTomáš Mráz <t8m@users.noreply.github.com>
Tue, 26 Feb 2019 09:06:07 +0000 (10:06 +0100)
pam_tally2 does fsync() after writing to a tally file.
This causes hard drive cache flushes on every failed SSH login on many
(if not most) filesystems.
And an internet-exposed machine can have a lot of these failed logins.

This operation however doesn't seem to be necessary - the pam_tally2
module does not do any operation which would need explicit post-crash
ordering, it just does simple file reads and writes.
And doing a fsync() after them doesn't close any race if the system happens
to crash between a write being posted and its fsync() completion.

Let's remove this operation to get rid of all these extra cache flushes.

modules/pam_tally2/pam_tally2.c

index 984edf6ad78f975d86809484589a0de664375cd4..ce7f5aee187555ba73ec650b29fce8b0c645d4a2 100644 (file)
@@ -484,10 +484,6 @@ set_tally(pam_handle_t *pamh, uid_t uid,
         }
     }
 
-    if (fsync(*tfile)) {
-      pam_syslog(pamh, LOG_ALERT, "update (fsync) failed for %s: %m", filename);
-      return PAM_AUTH_ERR;
-    }
     return PAM_SUCCESS;
 }