kbx: Create public-keys.d, after creating the homedir.

* kbx/keyboxd.c (create_directories): Following the behavior of
gpg-agent, call create_public_keys_directory after mkdir.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2023-12-19 15:56:13 +09:00
parent bd8346f7ab
commit 1c5584c395
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054
2 changed files with 88 additions and 0 deletions

View File

@ -1262,6 +1262,7 @@ create_directories (void)
{
if (!opt.quiet)
log_info (_("directory '%s' created\n"), home);
create_public_keys_directory (home);
}
}
}

87
tools/dotlock.c Normal file
View File

@ -0,0 +1,87 @@
/* dotlock.c - Command to handle dotlock.
* Copyright (C) 2023 g10 Code GmbH
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#ifdef HAVE_W32_SYSTEM
# include "windows.h"
#else
#include <sys/random.h>
#endif
#include "dotlock.h"
static void
lock (const char *fname)
{
dotlock_t h;
unsigned int flags = DOTLOCK_FLAG_LOCK_BY_PARENT;
h = dotlock_create (fname, flags);
if (!h)
die ("error creating lock file for '%s': %s", fname, strerror (errno));
if (dotlock_take (h, 0))
die ("error taking lock");
}
static void
unlock (const char *fname, long timeout)
{
dotlock_t h;
unsigned int flags = (DOTLOCK_FLAG_LOCK_BY_PARENT
| DOTLOCK_FLAG_READONLY);
h = dotlock_create (fname, flags);
if (!h)
die ("error creating lock file for '%s': %s", fname, strerror (errno));
dotlock_destroy (h);
}
int
main (int argc, char **argv)
{
const char *fname;
fname = argv[argc-1];
if ()
lock (fname);
else
unlock (fname);
return 0;
}
/*
Local Variables:
compile-command: "cc -Wall -O2 -D_FILE_OFFSET_BITS=64 -o t-dotlock t-dotlock.c"
End:
*/