diff options
author | Werner Koch <wk@gnupg.org> | 2023-04-04 16:39:59 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2023-04-04 16:39:59 +0200 |
commit | d9e7488b17fdc617eec735e2c0485b69285ba511 (patch) | |
tree | cd1423ce0870d036b5e0b7dd0425eb7222d84d62 /common | |
parent | speedo: Remove deleted prf files from the Windows installer (diff) | |
download | gnupg2-d9e7488b17fdc617eec735e2c0485b69285ba511.tar.xz gnupg2-d9e7488b17fdc617eec735e2c0485b69285ba511.zip |
Use the keyboxd for a fresh install
* common/homedir.c (gnupg_maybe_make_homedir): Also create a
common.conf.
* g10/keydb.c: Include comopt.h.
(maybe_create_keyring_or_box): Detect the creation of a common.conf.
* g10/gpg.c (main): Avoid adding more resources in this case.
* sm/keydb.c: Include comopt.h.
(maybe_create_keybox): Detect the creation of a common.conf.
* common/comopt.h (comopt): Remove the conditional "extern".
Diffstat (limited to 'common')
-rw-r--r-- | common/comopt.h | 1 | ||||
-rw-r--r-- | common/homedir.c | 38 |
2 files changed, 36 insertions, 3 deletions
diff --git a/common/comopt.h b/common/comopt.h index 7947f35b3..2a27fddac 100644 --- a/common/comopt.h +++ b/common/comopt.h @@ -35,7 +35,6 @@ /* Common options for all GnuPG components. */ -EXTERN_UNLESS_MAIN_MODULE struct { char *logfile; /* Socket used by daemons for logging. */ diff --git a/common/homedir.c b/common/homedir.c index 67bbde8f1..091964fc1 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -789,8 +789,42 @@ gnupg_maybe_make_homedir (const char *fname, int quiet) if (gnupg_mkdir (fname, "-rwx")) log_fatal ( _("can't create directory '%s': %s\n"), fname, strerror(errno) ); - else if (!quiet ) - log_info ( _("directory '%s' created\n"), fname ); + else + { + estream_t fp; + char *fcommon; + + if (!quiet ) + log_info ( _("directory '%s' created\n"), fname ); + +#ifdef BUILD_WITH_KEYBOXD + /* A new default homedir has been created. Now create a + * common.conf. */ + fcommon = make_filename (fname, "common.conf", NULL); + fp = es_fopen (fcommon, "wx,mode=-rw-r"); + if (!fp) + { + log_info (_("error creating '%s': %s\n"), fcommon, + gpg_strerror (gpg_error_from_syserror ())); + } + else + { + if (es_fputs ("use-keyboxd\n", fp) == EOF) + { + log_info (_("error writing to '%s': %s\n"), fcommon, + gpg_strerror (es_ferror (fp) + ? gpg_error_from_syserror () + : gpg_error (GPG_ERR_EOF))); + es_fclose (fp); + } + else if (es_fclose (fp)) + { + log_info (_("error closing '%s': %s\n"), fcommon, + gpg_strerror (gpg_error_from_syserror ())); + } + } +#endif /* BUILD_WITH_KEYBOXD */ + } } } |