1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-07 23:27:48 +02:00

g10: Fix flags to open for lock of ToFU.

* g10/tofu.c (busy_handler): Fix the flags and utime is not needed.

--

The argument flags must include one of O_RDONLY, O_WRONLY, or O_RDWR.
Adding O_TRUNC, the file is updated.  So, utime is not needed.

Fixes-commit: b2e1b17efa
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2016-11-18 20:32:22 +09:00
parent 833eef974a
commit 1c0b140ccc

View File

@ -732,16 +732,13 @@ busy_handler (void *cookie, int call_count)
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, int fd = open (dbs->want_lock_file, O_CREAT|O_WRONLY|O_TRUNC,
S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR); S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR);
if (fd == -1) if (fd == -1)
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);
utime (dbs->want_lock_file, NULL);
close (fd);
}
} }
/* Call again. */ /* Call again. */