1 From: Werner Koch <wk@gnupg.org>
2 Date: Thu, 23 Mar 2017 09:38:19 +0100
3 Subject: common: Implicitly do a gpgconf --create-socketdir.
5 * common/homedir.c (_gnupg_socketdir_internal): Create the
9 Although there is no auto cleanup (yet) this should be helpful. Let's
10 see whether possibly leaving stale directories around is better than
11 running into trouble when --create-socketdir was not used.
13 Signed-off-by: Werner Koch <wk@gnupg.org>
14 (cherry picked from commit 26086b362ff47d21b1abefaf674a6464bf0a8921)
16 common/homedir.c | 25 ++++++++++++++++++-------
17 1 file changed, 18 insertions(+), 7 deletions(-)
19 diff --git a/common/homedir.c b/common/homedir.c
20 index 6b40bb6..c41cbdc 100644
21 --- a/common/homedir.c
22 +++ b/common/homedir.c
23 @@ -542,7 +542,7 @@ _gnupg_socketdir_internal (int skip_checks, unsigned *r_info)
25 /* If a non default homedir is used, we check whether an
26 * corresponding sub directory below the socket dir is available
27 - * and use that. We has the non default homedir to keep the new
28 + * and use that. We hash the non default homedir to keep the new
29 * subdir short enough. */
30 if (non_default_homedir)
32 @@ -566,16 +566,27 @@ _gnupg_socketdir_internal (int skip_checks, unsigned *r_info)
36 - /* Stat that directory and check constraints. Note that we
37 - * do not auto create such a directory because we would not
38 - * have a way to remove it. Thus the directory needs to be
39 - * pre-created. The command
40 - * gpgconf --create-socketdir
41 - * can be used tocreate that directory. */
42 + /* Stat that directory and check constraints.
44 + * gpgconf --remove-socketdir
45 + * can be used to remove that directory. */
49 *r_info |= 1; /* stat failed. */
50 + else if (!skip_checks)
52 + /* Try to create the directory and check again. */
53 + if (gnupg_mkdir (name, "-rwx"))
54 + *r_info |= 16; /* mkdir failed. */
55 + else if (stat (prefix, &sb))
57 + if (errno != ENOENT)
58 + *r_info |= 1; /* stat failed. */
60 + *r_info |= 64; /* Subdir does not exist. */
64 *r_info |= 64; /* Subdir does not exist. */