1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-01 22:28:02 +02:00

common: Implicitly do a gpgconf --create-socketdir.

* common/homedir.c (_gnupg_socketdir_internal): Create the
sub-directory.
--

Although there is no auto cleanup (yet) this should be helpful.  Let's
see whether possibly leaving stale directories around is better than
running into trouble when --create-socketdir was not used.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-03-23 09:38:19 +01:00
parent 2c9d9ac55e
commit 26086b362f
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -542,7 +542,7 @@ _gnupg_socketdir_internal (int skip_checks, unsigned *r_info)
/* If a non default homedir is used, we check whether an /* If a non default homedir is used, we check whether an
* corresponding sub directory below the socket dir is available * corresponding sub directory below the socket dir is available
* and use that. We has the non default homedir to keep the new * and use that. We hash the non default homedir to keep the new
* subdir short enough. */ * subdir short enough. */
if (non_default_homedir) if (non_default_homedir)
{ {
@ -566,16 +566,27 @@ _gnupg_socketdir_internal (int skip_checks, unsigned *r_info)
goto leave; goto leave;
} }
/* Stat that directory and check constraints. Note that we /* Stat that directory and check constraints.
* do not auto create such a directory because we would not * The command
* have a way to remove it. Thus the directory needs to be * gpgconf --remove-socketdir
* pre-created. The command * can be used to remove that directory. */
* gpgconf --create-socketdir
* can be used tocreate that directory. */
if (stat (name, &sb)) if (stat (name, &sb))
{ {
if (errno != ENOENT) if (errno != ENOENT)
*r_info |= 1; /* stat failed. */ *r_info |= 1; /* stat failed. */
else if (!skip_checks)
{
/* Try to create the directory and check again. */
if (gnupg_mkdir (name, "-rwx"))
*r_info |= 16; /* mkdir failed. */
else if (stat (prefix, &sb))
{
if (errno != ENOENT)
*r_info |= 1; /* stat failed. */
else
*r_info |= 64; /* Subdir does not exist. */
}
}
else else
*r_info |= 64; /* Subdir does not exist. */ *r_info |= 64; /* Subdir does not exist. */
if (!skip_checks) if (!skip_checks)