From: nekral-guest Date: Sat, 21 Mar 2009 19:12:00 +0000 (+0000) Subject: * lib/commonio.c: Call fsync before closing the backup file. This X-Git-Tag: 4.1.3~73 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5dd5f51700d8d12b6ddc7e4aea27f3cd523cf22b;p=shadow * lib/commonio.c: Call fsync before closing the backup file. This ensures that the backup file is flushed to the storage medium. --- diff --git a/ChangeLog b/ChangeLog index 5000c2dc..501d7838 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-03-21 Nicolas François + + * lib/commonio.c: Call fsync before closing the backup file. This + ensures that the backup file is flushed to the storage medium. + 2009-03-15 Nicolas François * src/groupmod.c: Embed gshadow related cleanup in #ifdef diff --git a/lib/commonio.c b/lib/commonio.c index 0e9da37f..c80b9855 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -251,7 +251,8 @@ static int create_backup (const char *backup, FILE * fp) fclose (bkfp); return -1; } - if (fclose (bkfp) != 0) { + if ( (fsync (fileno (bkfp)) != 0) + || (fclose (bkfp) != 0)) { return -1; }