1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

New command --check-programs for gpgconf.

This commit is contained in:
Werner Koch 2007-08-29 09:51:37 +00:00
parent f268889b8f
commit b13587ef16
17 changed files with 267 additions and 25 deletions

View file

@ -1,3 +1,11 @@
2007-08-29 Werner Koch <wk@g10code.com>
* exechelp.c (gnupg_wait_process): Add arg EXITCODE. Changed all
callers.
* util.h (GNUPG_MODULE_NAME_GPGSM, GNUPG_MODULE_NAME_GPG): New.
* homedir.c (gnupg_module_name): Add them
2007-08-28 Werner Koch <wk@g10code.com>
* gettime.c (check_isotime, add_isotime): New. Orginally written

View file

@ -570,11 +570,13 @@ 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 suplieed 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.*/
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. */
gpg_error_t
gnupg_wait_process (const char *pgmname, pid_t pid)
gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode)
{
gpg_err_code_t ec;
@ -583,6 +585,9 @@ gnupg_wait_process (const char *pgmname, pid_t pid)
int code;
DWORD exc;
if (exitcode)
*exitcode = -1;
if (pid == (pid_t)(-1))
return gpg_error (GPG_ERR_INV_VALUE);
@ -609,10 +614,16 @@ gnupg_wait_process (const char *pgmname, pid_t pid)
{
log_error (_("error running `%s': exit status %d\n"),
pgmname, (int)exc );
if (exitcode)
*exitcode = (int)exc;
ec = GPG_ERR_GENERAL;
}
else
ec = 0;
{
if (exitcode)
*exitcode = 0;
ec = 0;
}
CloseHandle (proc);
break;
@ -626,6 +637,9 @@ gnupg_wait_process (const char *pgmname, pid_t pid)
#else /* !HAVE_W32_SYSTEM */
int i, status;
if (exitcode)
*exitcode = -1;
if (pid == (pid_t)(-1))
return gpg_error (GPG_ERR_INV_VALUE);
@ -650,6 +664,8 @@ gnupg_wait_process (const char *pgmname, pid_t pid)
{
log_error (_("error running `%s': exit status %d\n"), pgmname,
WEXITSTATUS (status));
if (exitcode)
*exitcode = WEXITSTATUS (status);
ec = GPG_ERR_GENERAL;
}
else if (!WIFEXITED (status))
@ -658,11 +674,14 @@ gnupg_wait_process (const char *pgmname, pid_t pid)
ec = GPG_ERR_GENERAL;
}
else
ec = 0;
{
if (exitcode)
*exitcode = 0;
ec = 0;
}
#endif /* !HAVE_W32_SYSTEM */
return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec);
}

View file

@ -52,8 +52,10 @@ gpg_error_t gnupg_spawn_process_fd (const char *pgmname,
/* 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.*/
gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid);
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);
/* Spawn a new process and immediatley detach from it. The name of

View file

@ -372,6 +372,12 @@ gnupg_module_name (int which)
case GNUPG_MODULE_NAME_CHECK_PATTERN:
X(libexecdir, "gpg-check-pattern");
case GNUPG_MODULE_NAME_GPGSM:
X(bindir, "gpgsm");
case GNUPG_MODULE_NAME_GPG:
X(bindir, "gpg2");
default:
BUG ();
}

View file

@ -182,12 +182,16 @@ const char *gnupg_libdir (void);
const char *gnupg_datadir (void);
const char *dirmngr_socket_name (void);
/* All module names. We also include gpg and gpgsm for the sake for
gpgconf. */
#define GNUPG_MODULE_NAME_AGENT 1
#define GNUPG_MODULE_NAME_PINENTRY 2
#define GNUPG_MODULE_NAME_SCDAEMON 3
#define GNUPG_MODULE_NAME_DIRMNGR 4
#define GNUPG_MODULE_NAME_PROTECT_TOOL 5
#define GNUPG_MODULE_NAME_CHECK_PATTERN 6
#define GNUPG_MODULE_NAME_GPGSM 7
#define GNUPG_MODULE_NAME_GPG 8
const char *gnupg_module_name (int which);