mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Use keyboxd on a fresh install also on Windows.
* common/homedir.c (gnupg_maybe_make_homedir): Factor some code out to ... (create_common_conf): new. (standard_homedir): Call it also from here. -- Fixes-commit: d9e7488b17fdc617eec735e2c0485b69285ba511
This commit is contained in:
parent
fa4f716917
commit
80d4ae1215
@ -154,6 +154,42 @@ w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d)
|
|||||||
}
|
}
|
||||||
#endif /*HAVE_W32_SYSTEM*/
|
#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. */
|
/* Check whether DIR is the default homedir. */
|
||||||
static int
|
static int
|
||||||
@ -259,7 +295,9 @@ standard_homedir (void)
|
|||||||
|
|
||||||
/* Try to create the directory if it does not yet exists. */
|
/* Try to create the directory if it does not yet exists. */
|
||||||
if (gnupg_access (dir, F_OK))
|
if (gnupg_access (dir, F_OK))
|
||||||
gnupg_mkdir (dir, "-rwx");
|
if (!gnupg_mkdir (dir, "-rwx"))
|
||||||
|
create_common_conf (dir);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dir = GNUPG_DEFAULT_HOMEDIR;
|
dir = GNUPG_DEFAULT_HOMEDIR;
|
||||||
@ -791,39 +829,9 @@ gnupg_maybe_make_homedir (const char *fname, int quiet)
|
|||||||
fname, strerror(errno) );
|
fname, strerror(errno) );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
estream_t fp;
|
|
||||||
char *fcommon;
|
|
||||||
|
|
||||||
if (!quiet )
|
if (!quiet )
|
||||||
log_info ( _("directory '%s' created\n"), fname );
|
log_info ( _("directory '%s' created\n"), fname );
|
||||||
|
create_common_conf (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 */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user