mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Merged Dirmngr with GnuPG.
A few code changes to support dirmngr.
This commit is contained in:
parent
70f3a9bbb6
commit
c3f08dcb72
61 changed files with 22335 additions and 177 deletions
|
@ -1,3 +1,21 @@
|
|||
2010-06-09 Werner Koch <wk@g10code.com>
|
||||
|
||||
* exechelp-posix.c, exechelp-w32.c
|
||||
* exechelp-w32ce.c (gnupg_wait_process): Add new arg HANG. Change
|
||||
all callers.
|
||||
(gnupg_release_process): New. Use it after all calls to
|
||||
gnupg_wait_process.
|
||||
|
||||
* util.h (GNUPG_MODULE_NAME_DIRMNGR_LDAP): New.
|
||||
* homedir.c (gnupg_cachedir): New.
|
||||
(w32_try_mkdir): New.
|
||||
(dirmngr_socket_name): Chanmge standard socket name.
|
||||
(gnupg_module_name): Support GNUPG_MODULE_NAME_DIRMNGR_LDAP.
|
||||
|
||||
* logging.c (log_set_get_tid_callback): Replace by ...
|
||||
(log_set_pid_suffix_cb): .. new.
|
||||
(do_logv): Change accordingly.
|
||||
|
||||
2010-06-08 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* Makefile.am (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS).
|
||||
|
@ -5,7 +23,7 @@
|
|||
* sysutils.c: Include <assuan.h>.
|
||||
(translate_sys2libc_fd_int): Cast to silence gcc warning.
|
||||
* iobuf.c: Include <assuan.h>
|
||||
(translate_file_handle): Fix syntax error.
|
||||
(translate_file_handle): Fix syntax error.
|
||||
|
||||
2010-06-08 Werner Koch <wk@g10code.com>
|
||||
|
||||
|
|
|
@ -362,12 +362,13 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
|||
if (err)
|
||||
log_debug ("starting `%s' for testing failed: %s\n",
|
||||
agent_program, gpg_strerror (err));
|
||||
else if ((err = gnupg_wait_process (agent_program, pid, &excode)))
|
||||
else if ((err = gnupg_wait_process (agent_program, pid, 0, &excode)))
|
||||
{
|
||||
if (excode == -1)
|
||||
log_debug ("running `%s' for testing failed: %s\n",
|
||||
agent_program, gpg_strerror (err));
|
||||
}
|
||||
gnupg_release_process (pid);
|
||||
|
||||
if (!err && !excode)
|
||||
{
|
||||
|
|
|
@ -416,37 +416,39 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
|
|||
}
|
||||
|
||||
|
||||
/* Wait for the process identified by PID to terminate. PGMNAME should
|
||||
be the same as supplied to the spawn function and is only used for
|
||||
diagnostics. Returns 0 if the process succeeded, GPG_ERR_GENERAL
|
||||
for any failures of the spawned program or other error codes. If
|
||||
EXITCODE is not NULL the exit code of the process is stored at this
|
||||
address or -1 if it could not be retrieved and no error message is
|
||||
logged. */
|
||||
/* See exechelp.h for the description. */
|
||||
gpg_error_t
|
||||
gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
||||
gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
|
||||
{
|
||||
gpg_err_code_t ec;
|
||||
|
||||
int i, status;
|
||||
|
||||
if (exitcode)
|
||||
*exitcode = -1;
|
||||
if (r_exitcode)
|
||||
*r_exitcode = -1;
|
||||
|
||||
if (pid == (pid_t)(-1))
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
#ifdef USE_GNU_PTH
|
||||
i = pth_waitpid ? pth_waitpid (pid, &status, 0) : waitpid (pid, &status, 0);
|
||||
#else
|
||||
while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR)
|
||||
;
|
||||
if (pth_waitpid)
|
||||
i = pth_waitpid (pid, &status, hang? 0:WNOHANG);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
while ((i=waitpid (pid, &status, hang? 0:WNOHANG)) == (pid_t)(-1)
|
||||
&& errno == EINTR)
|
||||
;
|
||||
}
|
||||
|
||||
if (i == (pid_t)(-1))
|
||||
{
|
||||
ec = gpg_err_code_from_errno (errno);
|
||||
log_error (_("waiting for process %d to terminate failed: %s\n"),
|
||||
(int)pid, strerror (errno));
|
||||
ec = gpg_err_code_from_errno (errno);
|
||||
}
|
||||
else if (!i)
|
||||
{
|
||||
ec = GPG_ERR_TIMEOUT; /* Still running. */
|
||||
}
|
||||
else if (WIFEXITED (status) && WEXITSTATUS (status) == 127)
|
||||
{
|
||||
|
@ -455,11 +457,11 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
|||
}
|
||||
else if (WIFEXITED (status) && WEXITSTATUS (status))
|
||||
{
|
||||
if (!exitcode)
|
||||
if (!r_exitcode)
|
||||
log_error (_("error running `%s': exit status %d\n"), pgmname,
|
||||
WEXITSTATUS (status));
|
||||
else
|
||||
*exitcode = WEXITSTATUS (status);
|
||||
*r_exitcode = WEXITSTATUS (status);
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else if (!WIFEXITED (status))
|
||||
|
@ -469,8 +471,8 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (exitcode)
|
||||
*exitcode = 0;
|
||||
if (r_exitcode)
|
||||
*r_exitcode = 0;
|
||||
ec = 0;
|
||||
}
|
||||
|
||||
|
@ -478,7 +480,14 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
|||
}
|
||||
|
||||
|
||||
/* Spawn a new process and immediatley detach from it. The name of
|
||||
void
|
||||
gnupg_release_process (pid_t pid)
|
||||
{
|
||||
(void)pid;
|
||||
}
|
||||
|
||||
|
||||
/* Spawn a new process and immediately detach from it. The name of
|
||||
the program to exec is PGMNAME and its arguments are in ARGV (the
|
||||
programname is automatically passed as first argument).
|
||||
Environment strings in ENVP are set. An error is returned if
|
||||
|
|
|
@ -382,7 +382,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
|
|||
int cr_flags;
|
||||
char *cmdline;
|
||||
int fd, fdout, rp[2];
|
||||
HANDLE nullhd[];
|
||||
HANDLE nullhd[2];
|
||||
int i;
|
||||
|
||||
(void)preexec;
|
||||
|
@ -428,7 +428,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
|
|||
}
|
||||
|
||||
nullhd[0] = fd == -1? w32_open_null (0) : INVALID_HANDLE_VALUE;
|
||||
nullhd[1] = outfd == -1? w32_open_null (1) : INVALID_HANDLE_VALUE;
|
||||
nullhd[1] = fdout == -1? w32_open_null (1) : INVALID_HANDLE_VALUE;
|
||||
|
||||
/* Start the process. Note that we can't run the PREEXEC function
|
||||
because this would change our own environment. */
|
||||
|
@ -437,7 +437,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
|
|||
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = DEBUG_W32_SPAWN? SW_SHOW : SW_MINIMIZE;
|
||||
si.hStdInput = fd == -1? nullhd[0] : fd_to_handle (fd);
|
||||
si.hStdOutput = outfd == -1? nullhd[1] : fd_to_handle (fdout);
|
||||
si.hStdOutput = fdout == -1? nullhd[1] : fd_to_handle (fdout);
|
||||
si.hStdError = fd_to_handle (rp[1]);
|
||||
|
||||
cr_flags = (CREATE_DEFAULT_ERROR_MODE
|
||||
|
@ -599,22 +599,17 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
|
|||
}
|
||||
|
||||
|
||||
/* Wait for the process identified by PID to terminate. PGMNAME should
|
||||
be the same as supplied to the spawn function and is only used for
|
||||
diagnostics. Returns 0 if the process succeeded, GPG_ERR_GENERAL
|
||||
for any failures of the spawned program or other error codes. If
|
||||
EXITCODE is not NULL the exit code of the process is stored at this
|
||||
address or -1 if it could not be retrieved. */
|
||||
/* See exechelp.h for a description. */
|
||||
gpg_error_t
|
||||
gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
||||
gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
|
||||
{
|
||||
gpg_err_code_t ec;
|
||||
HANDLE proc = fd_to_handle (pid);
|
||||
int code;
|
||||
DWORD exc;
|
||||
|
||||
if (exitcode)
|
||||
*exitcode = -1;
|
||||
if (r_exitcode)
|
||||
*r_exitcode = -1;
|
||||
|
||||
if (pid == (pid_t)(-1))
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
@ -622,50 +617,66 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
|||
/* FIXME: We should do a pth_waitpid here. However this has not yet
|
||||
been implemented. A special W32 pth system call would even be
|
||||
better. */
|
||||
code = WaitForSingleObject (proc, INFINITE);
|
||||
code = WaitForSingleObject (proc, hang? INFINITE : 0);
|
||||
switch (code)
|
||||
{
|
||||
case WAIT_FAILED:
|
||||
log_error (_("waiting for process %d to terminate failed: %s\n"),
|
||||
(int)pid, w32_strerror (-1));
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
case WAIT_TIMEOUT:
|
||||
ec = GPG_ERR_TIMEOUT;
|
||||
break;
|
||||
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetExitCodeProcess (proc, &exc))
|
||||
{
|
||||
log_error (_("error getting exit code of process %d: %s\n"),
|
||||
(int)pid, w32_strerror (-1) );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else if (exc)
|
||||
{
|
||||
log_error (_("error running `%s': exit status %d\n"),
|
||||
pgmname, (int)exc );
|
||||
if (exitcode)
|
||||
*exitcode = (int)exc;
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exitcode)
|
||||
*exitcode = 0;
|
||||
ec = 0;
|
||||
}
|
||||
CloseHandle (proc);
|
||||
break;
|
||||
case WAIT_FAILED:
|
||||
log_error (_("waiting for process %d to terminate failed: %s\n"),
|
||||
(int)pid, w32_strerror (-1));
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error ("WaitForSingleObject returned unexpected "
|
||||
"code %d for pid %d\n", code, (int)pid );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetExitCodeProcess (proc, &exc))
|
||||
{
|
||||
log_error (_("error getting exit code of process %d: %s\n"),
|
||||
(int)pid, w32_strerror (-1) );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else if (exc)
|
||||
{
|
||||
log_error (_("error running `%s': exit status %d\n"),
|
||||
pgmname, (int)exc );
|
||||
if (r_exitcode)
|
||||
*r_exitcode = (int)exc;
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r_exitcode)
|
||||
*r_exitcode = 0;
|
||||
ec = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error ("WaitForSingleObject returned unexpected "
|
||||
"code %d for pid %d\n", code, (int)pid );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
gnupg_release_process (pid_t pid)
|
||||
{
|
||||
if (pid != (pid_t)INVALID_HANDLE_VALUE)
|
||||
{
|
||||
HANDLE process = (HANDLE)pid;
|
||||
|
||||
CloseHandle (process);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Spawn a new process and immediatley detach from it. The name of
|
||||
the program to exec is PGMNAME and its arguments are in ARGV (the
|
||||
programname is automatically passed as first argument).
|
||||
|
|
|
@ -653,14 +653,10 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Wait for the process identified by PID to terminate. PGMNAME should
|
||||
be the same as supplied to the spawn function and is only used for
|
||||
diagnostics. Returns 0 if the process succeeded, GPG_ERR_GENERAL
|
||||
for any failures of the spawned program or other error codes. If
|
||||
EXITCODE is not NULL the exit code of the process is stored at this
|
||||
address or -1 if it could not be retrieved. */
|
||||
|
||||
/* See exechelp.h for a description. */
|
||||
gpg_error_t
|
||||
gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
||||
gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *exitcode)
|
||||
{
|
||||
gpg_err_code_t ec;
|
||||
HANDLE proc = fd_to_handle (pid);
|
||||
|
@ -676,50 +672,65 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
|
|||
/* FIXME: We should do a pth_waitpid here. However this has not yet
|
||||
been implemented. A special W32 pth system call would even be
|
||||
better. */
|
||||
code = WaitForSingleObject (proc, INFINITE);
|
||||
code = WaitForSingleObject (proc, hang? INFINITE : 0);
|
||||
switch (code)
|
||||
{
|
||||
case WAIT_FAILED:
|
||||
log_error (_("waiting for process %d to terminate failed: %s\n"),
|
||||
(int)pid, w32_strerror (-1));
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
case WAIT_TIMEOUT:
|
||||
ec = GPG_ERR_TIMEOUT;
|
||||
break;
|
||||
|
||||
case WAIT_FAILED:
|
||||
log_error (_("waiting for process %d to terminate failed: %s\n"),
|
||||
(int)pid, w32_strerror (-1));
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetExitCodeProcess (proc, &exc))
|
||||
{
|
||||
log_error (_("error getting exit code of process %d: %s\n"),
|
||||
(int)pid, w32_strerror (-1) );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetExitCodeProcess (proc, &exc))
|
||||
{
|
||||
log_error (_("error getting exit code of process %d: %s\n"),
|
||||
(int)pid, w32_strerror (-1) );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else if (exc)
|
||||
{
|
||||
log_error (_("error running `%s': exit status %d\n"),
|
||||
else if (exc)
|
||||
{
|
||||
log_error (_("error running `%s': exit status %d\n"),
|
||||
pgmname, (int)exc );
|
||||
if (exitcode)
|
||||
*exitcode = (int)exc;
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exitcode)
|
||||
*exitcode = 0;
|
||||
ec = 0;
|
||||
}
|
||||
CloseHandle (proc);
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error ("WaitForSingleObject returned unexpected "
|
||||
"code %d for pid %d\n", code, (int)pid );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
if (exitcode)
|
||||
*exitcode = (int)exc;
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exitcode)
|
||||
*exitcode = 0;
|
||||
ec = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error ("WaitForSingleObject returned unexpected "
|
||||
"code %d for pid %d\n", code, (int)pid );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnupg_release_process (pid_t pid)
|
||||
{
|
||||
if (pid != (pid_t)INVALID_HANDLE_VALUE)
|
||||
{
|
||||
HANDLE process = (HANDLE)pid;
|
||||
|
||||
CloseHandle (process);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Spawn a new process and immediatley detach from it. The name of
|
||||
the program to exec is PGMNAME and its arguments are in ARGV (the
|
||||
programname is automatically passed as first argument).
|
||||
|
|
|
@ -59,8 +59,8 @@ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]);
|
|||
process are expected in the NULL terminated array ARGV. The
|
||||
program name itself should not be included there. If PREEXEC is
|
||||
not NULL, that function will be called right before the exec.
|
||||
Calling gnupg_wait_process is required. Returns 0 on success or an
|
||||
error code.
|
||||
Calling gnupg_wait_process and gnupg_release_process is required.
|
||||
Returns 0 on success or an error code.
|
||||
|
||||
FLAGS is a bit vector:
|
||||
|
||||
|
@ -85,21 +85,41 @@ gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[],
|
|||
and ERRFD to stderr (any of them may be -1 to connect them to
|
||||
/dev/null). The arguments for the process are expected in the NULL
|
||||
terminated array ARGV. The program name itself should not be
|
||||
included there. Calling gnupg_wait_process is required. Returns 0
|
||||
on success or an error code. */
|
||||
included there. Calling gnupg_wait_process and
|
||||
gnupg_release_process is required. Returns 0 on success or an
|
||||
error code. */
|
||||
gpg_error_t gnupg_spawn_process_fd (const char *pgmname,
|
||||
const char *argv[],
|
||||
int infd, int outfd, int errfd,
|
||||
pid_t *pid);
|
||||
|
||||
|
||||
/* Wait for the process identified by PID to terminate. PGMNAME should
|
||||
be the same as supplied to the spawn fucntion and is only used for
|
||||
diagnostics. Returns 0 if the process succeded, GPG_ERR_GENERAL
|
||||
for any failures of the spawned program or other error codes. If
|
||||
EXITCODE is not NULL the exit code of the process is stored at this
|
||||
address or -1 if it could not be retrieved. */
|
||||
gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode);
|
||||
/* If HANG is true, waits for the process identified by PID to exit;
|
||||
if HANG is false, checks whether the process has terminated.
|
||||
PGMNAME should be the same as supplied to the spawn function and is
|
||||
only used for diagnostics. Return values:
|
||||
|
||||
0
|
||||
The process exited successful. 0 is stored at R_EXITCODE.
|
||||
|
||||
GPG_ERR_GENERAL
|
||||
The process exited without success. The exit code of process
|
||||
is then stored at R_EXITCODE. An exit code of -1 indicates
|
||||
that the process terminated abnormally (e.g. due to a signal).
|
||||
|
||||
GPG_ERR_TIMEOUT
|
||||
The process is still running (returned only if HANG is false).
|
||||
|
||||
GPG_ERR_INV_VALUE
|
||||
An invalid PID has been specified.
|
||||
|
||||
Other error codes may be returned as well. Unless otherwise noted,
|
||||
-1 will be stored at R_EXITCODE. R_EXITCODE may be passed as NULL
|
||||
if the exit code is not required (in that case an error messge will
|
||||
be printed). Note that under Windows PID is not the process id but
|
||||
the handle of the process. */
|
||||
gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int hang,
|
||||
int *r_exitcode);
|
||||
|
||||
|
||||
/* Kill a process; that is send an appropriate signal to the process.
|
||||
|
@ -107,6 +127,11 @@ gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode);
|
|||
from the system. An invalid PID is ignored. */
|
||||
void gnupg_kill_process (pid_t pid);
|
||||
|
||||
/* Release the process identified by PID. This function is actually
|
||||
only required for Windows but it does not harm to always call it.
|
||||
It is a nop if PID is invalid. */
|
||||
void gnupg_release_process (pid_t pid);
|
||||
|
||||
|
||||
/* Spawn a new process and immediatley detach from it. The name of
|
||||
the program to exec is PGMNAME and its arguments are in ARGV (the
|
||||
|
|
|
@ -44,6 +44,24 @@
|
|||
#include "sysutils.h"
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
static void
|
||||
w32_try_mkdir (const char *dir)
|
||||
{
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
wchar_t *wdir = utf8_to_wchar (dir);
|
||||
if (wdir)
|
||||
{
|
||||
CreateDirectory (wdir, NULL);
|
||||
xfree (wdir);
|
||||
}
|
||||
#else
|
||||
CreateDirectory (dir, NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* This is a helper function to load a Windows function from either of
|
||||
one DLLs. */
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
|
@ -114,18 +132,7 @@ standard_homedir (void)
|
|||
|
||||
/* Try to create the directory if it does not yet exists. */
|
||||
if (access (dir, F_OK))
|
||||
{
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
wchar_t *wdir = utf8_to_wchar (dir);
|
||||
if (wdir)
|
||||
{
|
||||
CreateDirectory (wdir, NULL);
|
||||
xfree (wdir);
|
||||
}
|
||||
#else
|
||||
CreateDirectory (dir, NULL);
|
||||
#endif
|
||||
}
|
||||
w32_try_mkdir (dir);
|
||||
}
|
||||
else
|
||||
dir = GNUPG_DEFAULT_HOMEDIR;
|
||||
|
@ -366,6 +373,54 @@ gnupg_localedir (void)
|
|||
}
|
||||
|
||||
|
||||
/* Return the name of the cache directory. The name is allocated in a
|
||||
static area on the first use. Windows only: If the directory does
|
||||
not exist it is created. */
|
||||
const char *
|
||||
gnupg_cachedir (void)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
static const char *dir;
|
||||
|
||||
if (!dir)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
const char *s1[] = { "GNU", "cache", "gnupg", NULL };
|
||||
int s1_len;
|
||||
const char **comp;
|
||||
|
||||
s1_len = 0;
|
||||
for (comp = s1; *comp; comp++)
|
||||
s1_len += 1 + strlen (*comp);
|
||||
|
||||
if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE,
|
||||
NULL, 0, path) >= 0)
|
||||
{
|
||||
char *tmp = xmalloc (strlen (path) + s1_len + 1);
|
||||
char *p;
|
||||
|
||||
p = stpcpy (tmp, path);
|
||||
for (comp = s1; *comp; comp++)
|
||||
{
|
||||
p = stpcpy (p, "\\");
|
||||
p = stpcpy (p, *comp);
|
||||
|
||||
if (access (tmp, F_OK))
|
||||
w32_try_mkdir (tmp);
|
||||
}
|
||||
|
||||
dir = tmp;
|
||||
}
|
||||
else
|
||||
dir = "c:\\temp\\cache\\dirmngr";
|
||||
}
|
||||
return dir;
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
return GNUPG_LOCALSTATEDIR "/cache/" PACKAGE_NAME;
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
}
|
||||
|
||||
|
||||
/* Return the default socket name used by DirMngr. */
|
||||
const char *
|
||||
dirmngr_socket_name (void)
|
||||
|
@ -379,7 +434,10 @@ dirmngr_socket_name (void)
|
|||
const char *s2;
|
||||
|
||||
/* We need something akin CSIDL_COMMON_PROGRAMS, but local
|
||||
(non-roaming). */
|
||||
(non-roaming). This is becuase the file needs to be on the
|
||||
local machine and makes only sense on that machine.
|
||||
CSIDL_WINDOWS seems to be the only location which guarantees
|
||||
that. */
|
||||
if (w32_shgetfolderpath (NULL, CSIDL_WINDOWS, NULL, 0, s1) < 0)
|
||||
strcpy (s1, "C:\\WINDOWS");
|
||||
s2 = DIRSEP_S "S.dirmngr";
|
||||
|
@ -388,7 +446,7 @@ dirmngr_socket_name (void)
|
|||
}
|
||||
return name;
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
return "/var/run/dirmngr/socket";
|
||||
return GNUPG_LOCALSTATEDIR "/run/" PACKAGE_NAME "/S.dirmngr";
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
}
|
||||
|
||||
|
@ -450,6 +508,13 @@ gnupg_module_name (int which)
|
|||
X(libexecdir, "gpg-protect-tool");
|
||||
#endif
|
||||
|
||||
case GNUPG_MODULE_NAME_DIRMNGR_LDAP:
|
||||
#ifdef GNUPG_DEFAULT_DIRMNGR_LDAP
|
||||
return GNUPG_DEFAULT_DIRMNGR_LDAP;
|
||||
#else
|
||||
X(libexecdir, "dirmngr_ldap");
|
||||
#endif
|
||||
|
||||
case GNUPG_MODULE_NAME_CHECK_PATTERN:
|
||||
X(libexecdir, "gpg-check-pattern");
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static char prefix_buffer[80];
|
|||
static int with_time;
|
||||
static int with_prefix;
|
||||
static int with_pid;
|
||||
static unsigned long (*get_tid_callback)(void);
|
||||
static int (*get_pid_suffix_cb)(unsigned long *r_value);
|
||||
static int running_detached;
|
||||
static int force_prefixes;
|
||||
|
||||
|
@ -336,9 +336,9 @@ log_set_fd (int fd)
|
|||
|
||||
|
||||
void
|
||||
log_set_get_tid_callback (unsigned long (*cb)(void))
|
||||
log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value))
|
||||
{
|
||||
get_tid_callback = cb;
|
||||
get_pid_suffix_cb = cb;
|
||||
}
|
||||
|
||||
|
||||
|
@ -441,9 +441,12 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
|
|||
es_fputs_unlocked (prefix_buffer, logstream);
|
||||
if (with_pid || force_prefixes)
|
||||
{
|
||||
if (get_tid_callback)
|
||||
es_fprintf_unlocked (logstream, "[%u.%lx]",
|
||||
(unsigned int)getpid (), get_tid_callback ());
|
||||
unsigned long pidsuf;
|
||||
int pidfmt;
|
||||
|
||||
if (get_pid_suffix_cb && (pidfmt=get_pid_suffix_cb (&pidsuf)))
|
||||
es_fprintf_unlocked (logstream, pidfmt == 1? "[%u.%lu]":"[%u.%lx]",
|
||||
(unsigned int)getpid (), pidsuf);
|
||||
else
|
||||
es_fprintf_unlocked (logstream, "[%u]", (unsigned int)getpid ());
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ int log_get_errorcount (int clear);
|
|||
void log_inc_errorcount (void);
|
||||
void log_set_file( const char *name );
|
||||
void log_set_fd (int fd);
|
||||
void log_set_get_tid_callback (unsigned long (*cb)(void));
|
||||
void log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value));
|
||||
void log_set_prefix (const char *text, unsigned int flags);
|
||||
const char *log_get_prefix (unsigned int *flags);
|
||||
int log_test_fd (int fd);
|
||||
|
|
|
@ -192,6 +192,7 @@ const char *gnupg_libexecdir (void);
|
|||
const char *gnupg_libdir (void);
|
||||
const char *gnupg_datadir (void);
|
||||
const char *gnupg_localedir (void);
|
||||
const char *gnupg_cachedir (void);
|
||||
const char *dirmngr_socket_name (void);
|
||||
|
||||
/* All module names. We also include gpg and gpgsm for the sake for
|
||||
|
@ -206,6 +207,7 @@ const char *dirmngr_socket_name (void);
|
|||
#define GNUPG_MODULE_NAME_GPG 8
|
||||
#define GNUPG_MODULE_NAME_CONNECT_AGENT 9
|
||||
#define GNUPG_MODULE_NAME_GPGCONF 10
|
||||
#define GNUPG_MODULE_NAME_DIRMNGR_LDAP 11
|
||||
const char *gnupg_module_name (int which);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue