diff options
author | Werner Koch <wk@gnupg.org> | 2007-08-29 11:51:37 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2007-08-29 11:51:37 +0200 |
commit | b13587ef167d58f960270fbcef674d8c919ba8dc (patch) | |
tree | f8ec6df5208e0f6dc50941d2f833ee2b3803e7ba /common | |
parent | Add more passphrase policy rules. (diff) | |
download | gnupg2-b13587ef167d58f960270fbcef674d8c919ba8dc.tar.xz gnupg2-b13587ef167d58f960270fbcef674d8c919ba8dc.zip |
New command --check-programs for gpgconf.
Diffstat (limited to 'common')
-rw-r--r-- | common/ChangeLog | 8 | ||||
-rw-r--r-- | common/exechelp.c | 33 | ||||
-rw-r--r-- | common/exechelp.h | 6 | ||||
-rw-r--r-- | common/homedir.c | 6 | ||||
-rw-r--r-- | common/util.h | 4 |
5 files changed, 48 insertions, 9 deletions
diff --git a/common/ChangeLog b/common/ChangeLog index 7f6174340..e577363c3 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -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 diff --git a/common/exechelp.c b/common/exechelp.c index 2a65970bd..4ec481f99 100644 --- a/common/exechelp.c +++ b/common/exechelp.c @@ -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); - } diff --git a/common/exechelp.h b/common/exechelp.h index ff7e59d39..7abc03708 100644 --- a/common/exechelp.h +++ b/common/exechelp.h @@ -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 diff --git a/common/homedir.c b/common/homedir.c index 85506b838..3105aec06 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -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 (); } diff --git a/common/util.h b/common/util.h index 75f6ed05c..f35850904 100644 --- a/common/util.h +++ b/common/util.h @@ -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); |