[31499] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit [krb5-1.22]: Make atomic ccache replacement work on

daemon@ATHENA.MIT.EDU (ghudson@mit.edu)
Tue Jan 27 23:49:12 2026

From: ghudson@mit.edu
To: cvs-krb5@mit.edu
Message-Id: <20260128044907.EF7B110430D@krbdev.mit.edu>
Date: Tue, 27 Jan 2026 23:49:07 -0500 (EST)
MIME-Version: 1.0
Reply-To: krbdev@mit.edu
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/de93bb35195d03c822afb3c8bad93ae9dde9055d
commit de93bb35195d03c822afb3c8bad93ae9dde9055d
Author: YUBI LEE <eubnara@gmail.com>
Date:   Fri Oct 31 20:26:05 2025 +0900

    Make atomic ccache replacement work on Windows
    
    Commit 371f09d4bf4ca0c7ba15c5ef909bc35307ed9cc3 relies on POSIX
    rename() semantics for atomic ccache replacement.  Windows rename()
    fails if the destination file exists.  Add a fallback to ReplaceFile()
    when this happens.  We may be able to do better using
    FILE_RENAME_FLAG_POSIX_SEMANTICS (added in Windows 10 update 1067) but
    this should generally suffice.
    
    [ghudson@mit.edu: simplified code slightly; rewrote commit message]
    
    (cherry picked from commit 04816024aadbfd64b5306942e2dfbd757cb05f93)
    
    ticket: 9190
    version_fixed: 1.22.2

 src/lib/krb5/ccache/cc_file.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c
index 198152a9e..f34c0f106 100644
--- a/src/lib/krb5/ccache/cc_file.c
+++ b/src/lib/krb5/ccache/cc_file.c
@@ -1311,6 +1311,14 @@ fcc_replace(krb5_context context, krb5_ccache id, krb5_principal princ,
         goto errno_cleanup;
 
     st = rename(tmpname, data->filename);
+#ifdef _WIN32
+    /* Windows cannot rename over an existing file under most circumstances.
+     * Try ReplaceFile() (which only works if the destination file exists). */
+    if (st != 0) {
+        if (ReplaceFile(data->filename, tmpname, NULL, 0, NULL, NULL))
+            st = 0;
+    }
+#endif
     if (st != 0)
         goto errno_cleanup;
     tmpfile_exists = FALSE;
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post