1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

kbx: New function keybox_file_rename to replace rename.

* kbx/keybox-util.c: Include windows.h.
(keybox_file_rename): New.
* kbx/keybox-update.c (rename_tmp_file): Replace remove+rename by
keybox_file_rename.
* g10/keyring.c (rename_tmp_file): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-01-14 16:50:15 +01:00
parent f5cceef115
commit 8241ed59d0
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
4 changed files with 76 additions and 30 deletions

View file

@ -1337,32 +1337,19 @@ rename_tmp_file (const char *bakfname, const char *tmpfname, const char *fname)
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname );
/* First make a backup file. */
#if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__)
gnupg_remove (bakfname);
#endif
if (rename (fname, bakfname) )
{
rc = gpg_error_from_syserror ();
log_error ("renaming '%s' to '%s' failed: %s\n",
fname, bakfname, strerror(errno) );
return rc;
}
rc = keybox_file_rename (fname, bakfname);
if (rc)
goto fail;
/* then rename the file */
#if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__)
gnupg_remove( fname );
#endif
if (rename (tmpfname, fname) )
rc = keybox_file_rename (tmpfname, fname);
if (rc)
{
rc = gpg_error_from_syserror ();
log_error (_("renaming '%s' to '%s' failed: %s\n"),
tmpfname, fname, strerror(errno) );
register_secured_file (fname);
goto fail;
}
/* Now make sure the file has the same permissions as the original */
#ifndef HAVE_DOSISH_SYSTEM
{
struct stat statbuf;