1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-05-24 16:43:28 +02:00

g10: Use es_fopen instead of open.

* g10/tofu.c: Don't include <utime.h>, <fcntl.h> or <unistd.h>.
(busy_handler): Replace use of open with es_fopen.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>

Thanks for Werner for pointing this out: es_fopen is more portable
than open.
This commit is contained in:
Neal H. Walfield 2016-11-22 17:12:38 +01:00
parent 44c17bcb00
commit bfeafe2d3f

View File

@ -29,9 +29,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <sqlite3.h> #include <sqlite3.h>
#include <time.h> #include <time.h>
#include <utime.h>
#include <fcntl.h>
#include <unistd.h>
#include "gpg.h" #include "gpg.h"
#include "types.h" #include "types.h"
@ -909,21 +906,23 @@ busy_handler (void *cookie, int call_count)
(void) call_count; (void) call_count;
/* Update the lock file time stamp so that the current owner knows /* Update the want-lock-file time stamp (specifically, the ctime) so
that we want the lock. */ * that the current owner knows that we (well, someone) want the
* lock. */
if (dbs) if (dbs)
{ {
/* Note: we don't fail if we can't create the lock file: this /* Note: we don't fail if we can't create the lock file: this
process will have to wait a bit longer, but otherwise nothing * process will have to wait a bit longer, but otherwise nothing
horrible should happen. */ * horrible should happen. */
int fd = open (dbs->want_lock_file, O_CREAT|O_WRONLY|O_TRUNC, estream_t fp;
S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR);
if (fd == -1) fp = es_fopen (dbs->want_lock_file, "w");
if (! fp)
log_debug ("TOFU: Error opening '%s': %s\n", log_debug ("TOFU: Error opening '%s': %s\n",
dbs->want_lock_file, strerror (errno)); dbs->want_lock_file, strerror (errno));
else else
close (fd); es_fclose (fp);
} }
/* Call again. */ /* Call again. */