aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/homedir.c75
-rw-r--r--common/sexputil.c2
-rw-r--r--common/util.h1
3 files changed, 45 insertions, 33 deletions
diff --git a/common/homedir.c b/common/homedir.c
index 091964fc1..286685feb 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -154,6 +154,42 @@ w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d)
}
#endif /*HAVE_W32_SYSTEM*/
+/* Given the directory name DNAME try to create a common.conf and
+ * enable the keyboxd. This should only be called for the standard
+ * home directory and only if that directory has just been created. */
+static void
+create_common_conf (const char *dname)
+{
+#ifdef BUILD_WITH_KEYBOXD
+ estream_t fp;
+ char *fcommon;
+
+ fcommon = make_filename (dname, "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 */
+}
+
/* Check whether DIR is the default homedir. */
static int
@@ -259,7 +295,9 @@ standard_homedir (void)
/* Try to create the directory if it does not yet exists. */
if (gnupg_access (dir, F_OK))
- gnupg_mkdir (dir, "-rwx");
+ if (!gnupg_mkdir (dir, "-rwx"))
+ create_common_conf (dir);
+
}
else
dir = GNUPG_DEFAULT_HOMEDIR;
@@ -791,39 +829,9 @@ gnupg_maybe_make_homedir (const char *fname, int quiet)
fname, strerror(errno) );
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 */
+ create_common_conf (fname);
}
}
}
@@ -1657,6 +1665,9 @@ gnupg_module_name (int which)
case GNUPG_MODULE_NAME_CARD:
X(bindir, "tools", "gpg-card");
+ case GNUPG_MODULE_NAME_GPGTAR:
+ X(bindir, "tools", "gpgtar");
+
default:
BUG ();
}
diff --git a/common/sexputil.c b/common/sexputil.c
index 29fe508b6..c7471be85 100644
--- a/common/sexputil.c
+++ b/common/sexputil.c
@@ -614,7 +614,7 @@ get_ecc_q_from_canon_sexp (const unsigned char *keydata, size_t keydatalen,
size_t buflen, toklen;
int depth, last_depth1, last_depth2;
const unsigned char *ecc_q = NULL;
- size_t ecc_q_len;
+ size_t ecc_q_len = 0;
*r_q = NULL;
*r_qlen = 0;
diff --git a/common/util.h b/common/util.h
index d80e4fb25..aa24e39e6 100644
--- a/common/util.h
+++ b/common/util.h
@@ -298,6 +298,7 @@ char *_gnupg_socketdir_internal (int skip_checks, unsigned *r_info);
#define GNUPG_MODULE_NAME_KEYBOXD 13
#define GNUPG_MODULE_NAME_TPM2DAEMON 14
#define GNUPG_MODULE_NAME_CARD 15
+#define GNUPG_MODULE_NAME_GPGTAR 16
const char *gnupg_module_name (int which);
void gnupg_module_name_flush_some (void);
void gnupg_set_builddir (const char *newdir);