From 55ba204bfa848c2e591a29fedc9f103103493a57 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 19 Nov 2007 16:03:50 +0000 Subject: Started to implement the audit log feature. Pass PINENTRY_USER_DATA and XAUTHORITY to Pinentry. Improved support for the quality bar. Minor internal restructuring. Translation fixes. --- g10/ChangeLog | 24 ++ g10/Makefile.am | 3 +- g10/armor.c | 2 +- g10/build-packet.c | 2 +- g10/call-agent.c | 1 + g10/cipher.c | 2 +- g10/comment.c | 2 +- g10/cpr.c | 537 +++++++++++++++++++++++++++++++++++++++++++++ g10/dearmor.c | 2 +- g10/decrypt.c | 2 +- g10/delkey.c | 2 +- g10/encode.c | 2 +- g10/export.c | 2 +- g10/gpg.c | 5 +- g10/import.c | 2 +- g10/keyedit.c | 6 +- g10/keylist.c | 2 +- g10/main.h | 24 ++ g10/mdfilter.c | 2 +- g10/misc.c | 2 +- g10/options.h | 2 + g10/pkclist.c | 2 +- g10/revoke.c | 2 +- g10/server.c | 6 + g10/sign.c | 2 +- g10/signal.c | 2 +- g10/skclist.c | 2 +- g10/status.c | 631 ----------------------------------------------------- g10/status.h | 149 ------------- g10/tdbdump.c | 2 +- g10/tdbio.c | 2 +- g10/textfilter.c | 2 +- g10/trustdb.c | 2 +- g10/verify.c | 2 +- 34 files changed, 625 insertions(+), 809 deletions(-) create mode 100644 g10/cpr.c delete mode 100644 g10/status.c delete mode 100644 g10/status.h (limited to 'g10') diff --git a/g10/ChangeLog b/g10/ChangeLog index e4702b041..decbc8ca0 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,27 @@ +2007-11-19 Werner Koch + + * keyedit.c (keyedit_menu): String grammar fix. + +2007-11-15 Werner Koch + + * gpg.c (main): New option --xauthority. + * call-agent.c (start_agent): Adjust changed start_new_gpg_agent. + +2007-11-12 Werner Koch + + * cpr.c (do_get_from_fd): s/bool/getbool/ to overcome problems + with Mac OS 10.5 which seems to include stdbool.h silently. + +2007-11-07 Werner Koch + + Replace all includes of errors.h by status.h (found in common/). + + * status.h: Remove. + * status.h: Move prototypes to main.h. + * status.c: Rename to .. + * cpr.c: .. this. + (get_status_string): Remove. We take this now from common/. + 2007-10-25 David Shaw (wk) From 1.4 (October): diff --git a/g10/Makefile.am b/g10/Makefile.am index 056ff9a97..ff5081200 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -62,8 +62,7 @@ common_source = \ keyid.c \ packet.h \ parse-packet.c \ - status.c \ - status.h \ + cpr.c \ plaintext.c \ sig-check.c \ keylist.c \ diff --git a/g10/armor.c b/g10/armor.c index 76a2bdfbd..2dde9fe05 100644 --- a/g10/armor.c +++ b/g10/armor.c @@ -27,7 +27,7 @@ #include #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "filter.h" diff --git a/g10/build-packet.c b/g10/build-packet.c index 4c27823cd..88f196a3b 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -27,7 +27,7 @@ #include "gpg.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "cipher.h" diff --git a/g10/call-agent.c b/g10/call-agent.c index 03c3a74b7..8800f938a 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -82,6 +82,7 @@ start_agent (void) opt.agent_program, opt.display, opt.ttyname, opt.ttytype, opt.lc_ctype, opt.lc_messages, + opt.xauthority, opt.pinentry_user_data, opt.verbose, DBG_ASSUAN, NULL, NULL); } diff --git a/g10/cipher.c b/g10/cipher.c index fcd3965c3..dc248e395 100644 --- a/g10/cipher.c +++ b/g10/cipher.c @@ -26,7 +26,7 @@ #include #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "filter.h" diff --git a/g10/comment.c b/g10/comment.c index d3dab2a9a..7f9295ea5 100644 --- a/g10/comment.c +++ b/g10/comment.c @@ -26,7 +26,7 @@ #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "main.h" diff --git a/g10/cpr.c b/g10/cpr.c new file mode 100644 index 000000000..83f0ccb4d --- /dev/null +++ b/g10/cpr.c @@ -0,0 +1,537 @@ +/* status.c - Status message and command-fd interface + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, + * 2004, 2005, 2006 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GnuPG is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "gpg.h" +#include "util.h" +#include "status.h" +#include "ttyio.h" +#include "options.h" +#include "main.h" +#include "i18n.h" +#include "cipher.h" /* for progress functions */ + +#define CONTROL_D ('D' - 'A' + 1) + + + +static FILE *statusfp; + + +static void +progress_cb (void *ctx, const char *what, int printchar, + int current, int total) +{ + char buf[50]; + + if ( printchar == '\n' && !strcmp (what, "primegen") ) + snprintf (buf, sizeof buf -1, "%.20s X 100 100", what ); + else + snprintf (buf, sizeof buf -1, "%.20s %c %d %d", + what, printchar=='\n'?'X':printchar, current, total ); + write_status_text (STATUS_PROGRESS, buf); +} + + +/* Return true if the status message NO may currently be issued. We + need this to avoid syncronisation problem while auto retrieving a + key. There it may happen that a status NODATA is issued for a non + available key and the user may falsely interpret this has a missing + signature. */ +static int +status_currently_allowed (int no) +{ + if (!glo_ctrl.in_auto_key_retrieve) + return 1; /* Yes. */ + + /* We allow some statis anyway, so that import statistics are + correct and to avoid problems if the retriebval subsystem will + prompt the user. */ + switch (no) + { + case STATUS_GET_BOOL: + case STATUS_GET_LINE: + case STATUS_GET_HIDDEN: + case STATUS_GOT_IT: + case STATUS_IMPORTED: + case STATUS_IMPORT_OK: + case STATUS_IMPORT_CHECK: + case STATUS_IMPORT_RES: + return 1; /* Yes. */ + default: + break; + } + return 0; /* No. */ +} + + +void +set_status_fd ( int fd ) +{ + static int last_fd = -1; + + if ( fd != -1 && last_fd == fd ) + return; + + if ( statusfp && statusfp != stdout && statusfp != stderr ) + fclose (statusfp); + statusfp = NULL; + if ( fd == -1 ) + return; + + if( fd == 1 ) + statusfp = stdout; + else if( fd == 2 ) + statusfp = stderr; + else + statusfp = fdopen( fd, "w" ); + if( !statusfp ) { + log_fatal("can't open fd %d for status output: %s\n", + fd, strerror(errno)); + } + last_fd = fd; + + gcry_set_progress_handler ( progress_cb, NULL ); +} + +int +is_status_enabled() +{ + return !!statusfp; +} + +void +write_status ( int no ) +{ + write_status_text( no, NULL ); +} + +void +write_status_text ( int no, const char *text) +{ + if( !statusfp || !status_currently_allowed (no) ) + return; /* Not enabled or allowed. */ + + fputs ( "[GNUPG:] ", statusfp ); + fputs ( get_status_string (no), statusfp ); + if( text ) { + putc ( ' ', statusfp ); + for (; *text; text++) { + if (*text == '\n') + fputs ( "\\n", statusfp ); + else if (*text == '\r') + fputs ( "\\r", statusfp ); + else + putc ( *(const byte *)text, statusfp ); + } + } + putc ('\n',statusfp); + if ( fflush (statusfp) && opt.exit_on_status_write_error ) + g10_exit (0); +} + + +/* + * Write a status line with a buffer using %XX escapes. If WRAP is > + * 0 wrap the line after this length. If STRING is not NULL it will + * be prepended to the buffer, no escaping is done for string. + * A wrap of -1 forces spaces not to be encoded as %20. + */ +void +write_status_text_and_buffer ( int no, const char *string, + const char *buffer, size_t len, int wrap ) +{ + const char *s, *text; + int esc, first; + int lower_limit = ' '; + size_t n, count, dowrap; + + if( !statusfp || !status_currently_allowed (no) ) + return; /* Not enabled or allowed. */ + + if (wrap == -1) { + lower_limit--; + wrap = 0; + } + + text = get_status_string (no); + count = dowrap = first = 1; + do { + if (dowrap) { + fprintf (statusfp, "[GNUPG:] %s ", text ); + count = dowrap = 0; + if (first && string) { + fputs (string, statusfp); + count += strlen (string); + } + first = 0; + } + for (esc=0, s=buffer, n=len; n && !esc; s++, n-- ) { + if ( *s == '%' || *(const byte*)s <= lower_limit + || *(const byte*)s == 127 ) + esc = 1; + if ( wrap && ++count > wrap ) { + dowrap=1; + break; + } + } + if (esc) { + s--; n++; + } + if (s != buffer) + fwrite (buffer, s-buffer, 1, statusfp ); + if ( esc ) { + fprintf (statusfp, "%%%02X", *(const byte*)s ); + s++; n--; + } + buffer = s; + len = n; + if ( dowrap && len ) + putc ( '\n', statusfp ); + } while ( len ); + + putc ('\n',statusfp); + if ( fflush (statusfp) && opt.exit_on_status_write_error ) + g10_exit (0); +} + +void +write_status_buffer ( int no, const char *buffer, size_t len, int wrap ) +{ + write_status_text_and_buffer (no, NULL, buffer, len, wrap); +} + + +/* Print the BEGIN_SIGNING status message. If MD is not NULL it is + used retrieve the hash algorithms used for the message. */ +void +write_status_begin_signing (gcry_md_hd_t md) +{ + if (md) + { + char buf[100]; + size_t buflen; + int i; + + /* We use a hard coded list of possible algorithms. Using other + algorithms than specified by OpenPGP does not make sense + anyway. We do this out of performance reasons: Walking all + the 110 allowed Ids is not a good idea given the way the + check is implemented in libgcrypt. Recall that the only use + of this status code is to create the micalg algorithm for + PGP/MIME. */ + buflen = 0; + for (i=1; i <= 11; i++) + if (i < 4 || i > 7) + if ( gcry_md_is_enabled (md, i) && buflen < DIM(buf) ) + { + snprintf (buf+buflen, DIM(buf) - buflen - 1, + "%sH%d", buflen? " ":"",i); + buflen += strlen (buf+buflen); + } + write_status_text ( STATUS_BEGIN_SIGNING, buf ); + } + else + write_status ( STATUS_BEGIN_SIGNING ); +} + + +static int +myread(int fd, void *buf, size_t count) +{ + int rc; + do { + rc = read( fd, buf, count ); + } while ( rc == -1 && errno == EINTR ); + if ( !rc && count ) { + static int eof_emmited=0; + if ( eof_emmited < 3 ) { + *(char*)buf = CONTROL_D; + rc = 1; + eof_emmited++; + } + else { /* Ctrl-D not caught - do something reasonable */ +#ifdef HAVE_DOSISH_SYSTEM + raise (SIGINT); /* nothing to hangup under DOS */ +#else + raise (SIGHUP); /* no more input data */ +#endif + } + } + return rc; +} + + + +/* Request a string from the client over the command-fd. If GETBOOL + is set the function returns a static string (do not free) if the + netered value was true or NULL if the entered value was false. */ +static char * +do_get_from_fd ( const char *keyword, int hidden, int getbool ) +{ + int i, len; + char *string; + + if (statusfp != stdout) + fflush (stdout); + + write_status_text (getbool? STATUS_GET_BOOL : + hidden? STATUS_GET_HIDDEN : STATUS_GET_LINE, keyword); + + for (string = NULL, i = len = 200; ; i++ ) + { + if (i >= len-1 ) + { + char *save = string; + len += 100; + string = hidden? xmalloc_secure ( len ) : xmalloc ( len ); + if (save) + memcpy (string, save, i ); + else + i = 0; + } + /* Fixme: why not use our read_line function here? */ + if ( myread( opt.command_fd, string+i, 1) != 1 || string[i] == '\n' ) + break; + else if ( string[i] == CONTROL_D ) + { + /* Found ETX - Cancel the line and return a sole ETX. */ + string[0] = CONTROL_D; + i = 1; + break; + } + } + string[i] = 0; + + write_status (STATUS_GOT_IT); + + if (getbool) /* Fixme: is this correct??? */ + return (string[0] == 'Y' || string[0] == 'y') ? "" : NULL; + + return string; +} + + + +int +cpr_enabled() +{ + if( opt.command_fd != -1 ) + return 1; +#ifdef USE_SHM_COPROCESSING + if( opt.shm_coprocess ) + return 1; +#endif + return 0; +} + +char * +cpr_get_no_help( const char *keyword, const char *prompt ) +{ + char *p; + + if( opt.command_fd != -1 ) + return do_get_from_fd ( keyword, 0, 0 ); +#ifdef USE_SHM_COPROCESSING + if( opt.shm_coprocess ) + return do_shm_get( keyword, 0, 0 ); +#endif + for(;;) { + p = tty_get( prompt ); + return p; + } +} + +char * +cpr_get( const char *keyword, const char *prompt ) +{ + char *p; + + if( opt.command_fd != -1 ) + return do_get_from_fd ( keyword, 0, 0 ); +#ifdef USE_SHM_COPROCESSING + if( opt.shm_coprocess ) + return do_shm_get( keyword, 0, 0 ); +#endif + for(;;) { + p = tty_get( prompt ); + if( *p=='?' && !p[1] && !(keyword && !*keyword)) { + xfree(p); + display_online_help( keyword ); + } + else + return p; + } +} + + +char * +cpr_get_utf8( const char *keyword, const char *prompt ) +{ + char *p; + p = cpr_get( keyword, prompt ); + if( p ) { + char *utf8 = native_to_utf8( p ); + xfree( p ); + p = utf8; + } + return p; +} + +char * +cpr_get_hidden( const char *keyword, const char *prompt ) +{ + char *p; + + if( opt.command_fd != -1 ) + return do_get_from_fd ( keyword, 1, 0 ); +#ifdef USE_SHM_COPROCESSING + if( opt.shm_coprocess ) + return do_shm_get( keyword, 1, 0 ); +#endif + for(;;) { + p = tty_get_hidden( prompt ); + if( *p == '?' && !p[1] ) { + xfree(p); + display_online_help( keyword ); + } + else + return p; + } +} + +void +cpr_kill_prompt(void) +{ + if( opt.command_fd != -1 ) + return; +#ifdef USE_SHM_COPROCESSING + if( opt.shm_coprocess ) + return; +#endif + tty_kill_prompt(); + return; +} + +int +cpr_get_answer_is_yes( const char *keyword, const char *prompt ) +{ + int yes; + char *p; + + if( opt.command_fd != -1 ) + return !!do_get_from_fd ( keyword, 0, 1 ); +#ifdef USE_SHM_COPROCESSING + if( opt.shm_coprocess ) + return !!do_shm_get( keyword, 0, 1 ); +#endif + for(;;) { + p = tty_get( prompt ); + trim_spaces(p); /* it is okay to do this here */ + if( *p == '?' && !p[1] ) { + xfree(p); + display_online_help( keyword ); + } + else { + tty_kill_prompt(); + yes = answer_is_yes(p); + xfree(p); + return yes; + } + } +} + +int +cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt ) +{ + int yes; + char *p; + + if( opt.command_fd != -1 ) + return !!do_get_from_fd ( keyword, 0, 1 ); +#ifdef USE_SHM_COPROCESSING + if( opt.shm_coprocess ) + return !!do_shm_get( keyword, 0, 1 ); +#endif + for(;;) { + p = tty_get( prompt ); + trim_spaces(p); /* it is okay to do this here */ + if( *p == '?' && !p[1] ) { + xfree(p); + display_online_help( keyword ); + } + else { + tty_kill_prompt(); + yes = answer_is_yes_no_quit(p); + xfree(p); + return yes; + } + } +} + + +int +cpr_get_answer_okay_cancel (const char *keyword, + const char *prompt, + int def_answer) +{ + int yes; + char *answer = NULL; + char *p; + + if( opt.command_fd != -1 ) + answer = do_get_from_fd ( keyword, 0, 0 ); +#ifdef USE_SHM_COPROCESSING + else if( opt.shm_coprocess ) + answer = do_shm_get( keyword, 0, 0 ); +#endif + + if (answer) + { + yes = answer_is_okay_cancel (answer, def_answer); + xfree (answer); + return yes; + } + + for(;;) + { + p = tty_get( prompt ); + trim_spaces(p); /* it is okay to do this here */ + if (*p == '?' && !p[1]) + { + xfree(p); + display_online_help (keyword); + } + else + { + tty_kill_prompt(); + yes = answer_is_okay_cancel (p, def_answer); + xfree(p); + return yes; + } + } +} diff --git a/g10/dearmor.c b/g10/dearmor.c index 6f429490f..da888ad14 100644 --- a/g10/dearmor.c +++ b/g10/dearmor.c @@ -25,7 +25,7 @@ #include #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "filter.h" diff --git a/g10/decrypt.c b/g10/decrypt.c index 2c0f25f57..ce400b022 100644 --- a/g10/decrypt.c +++ b/g10/decrypt.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "util.h" diff --git a/g10/delkey.c b/g10/delkey.c index 5eb57e5f0..fe29d52ea 100644 --- a/g10/delkey.c +++ b/g10/delkey.c @@ -29,7 +29,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "util.h" diff --git a/g10/encode.c b/g10/encode.c index 4a5733220..ee2ce9703 100644 --- a/g10/encode.c +++ b/g10/encode.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "util.h" diff --git a/g10/export.c b/g10/export.c index 931f7ce75..09faa0375 100644 --- a/g10/export.c +++ b/g10/export.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "keydb.h" #include "util.h" #include "main.h" diff --git a/g10/gpg.c b/g10/gpg.c index e1b1efbcd..b548cdf25 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -338,6 +338,7 @@ enum cmd_and_opt_values oTTYtype, oLCctype, oLCmessages, + oXauthority, oGroup, oUnGroup, oNoGroups, @@ -465,7 +466,7 @@ static ARGPARSE_OPTS opts[] = { { oMinCertLevel, "min-cert-level", 1, "@"}, { oAskCertLevel, "ask-cert-level", 0, "@"}, { oNoAskCertLevel, "no-ask-cert-level", 0, "@"}, - { oOutput, "output", 2, N_("use as output file")}, + { oOutput, "output", 2, N_("|FILE|write output to FILE")}, { oMaxOutput, "max-output", 16|4, "@" }, { oVerbose, "verbose", 0, N_("verbose") }, { oQuiet, "quiet", 0, "@"}, @@ -679,6 +680,7 @@ static ARGPARSE_OPTS opts[] = { { oTTYtype, "ttytype", 2, "@" }, { oLCctype, "lc-ctype", 2, "@" }, { oLCmessages, "lc-messages", 2, "@" }, + { oXauthority, "xauthority", 2, "@" }, { oGroup, "group", 2, "@" }, { oUnGroup, "ungroup", 2, "@" }, { oNoGroups, "no-groups", 0, "@" }, @@ -2800,6 +2802,7 @@ main (int argc, char **argv ) case oTTYtype: opt.ttytype = pargs.r.ret_str; break; case oLCctype: opt.lc_ctype = pargs.r.ret_str; break; case oLCmessages: opt.lc_messages = pargs.r.ret_str; break; + case oXauthority: opt.xauthority = pargs.r.ret_str; break; case oGroup: add_group(pargs.r.ret_str); break; case oUnGroup: rm_group(pargs.r.ret_str); break; case oNoGroups: diff --git a/g10/import.c b/g10/import.c index fbfb18d0e..a58637c9d 100644 --- a/g10/import.c +++ b/g10/import.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "keydb.h" #include "util.h" #include "trustdb.h" diff --git a/g10/keyedit.c b/g10/keyedit.c index 1078758dd..8efe824ce 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -33,7 +33,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "photoid.h" @@ -2095,8 +2095,8 @@ keyedit_menu( const char *username, strlist_t locusr, case cmdTRUST: if(opt.trust_model==TM_EXTERNAL) { - tty_printf(_("Owner trust may not be set while " - "using an user provided trust database\n")); + tty_printf (_("Owner trust may not be set while " + "using a user provided trust database\n")); break; } diff --git a/g10/keylist.c b/g10/keylist.c index adb32e76e..db4ef50f3 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "keydb.h" #include "photoid.h" #include "util.h" diff --git a/g10/main.h b/g10/main.h index e782a453f..963387007 100644 --- a/g10/main.h +++ b/g10/main.h @@ -145,6 +145,30 @@ int pubkey_get_nenc( int algo ); unsigned int pubkey_nbits( int algo, gcry_mpi_t *pkey ); int mpi_print( FILE *fp, gcry_mpi_t a, int mode ); +/*-- status.c --*/ +void set_status_fd ( int fd ); +int is_status_enabled ( void ); +void write_status ( int no ); +void write_status_text ( int no, const char *text ); +void write_status_buffer ( int no, + const char *buffer, size_t len, int wrap ); +void write_status_text_and_buffer ( int no, const char *text, + const char *buffer, size_t len, int wrap ); + +void write_status_begin_signing (gcry_md_hd_t md); + + +int cpr_enabled(void); +char *cpr_get( const char *keyword, const char *prompt ); +char *cpr_get_no_help( const char *keyword, const char *prompt ); +char *cpr_get_utf8( const char *keyword, const char *prompt ); +char *cpr_get_hidden( const char *keyword, const char *prompt ); +void cpr_kill_prompt(void); +int cpr_get_answer_is_yes( const char *keyword, const char *prompt ); +int cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt ); +int cpr_get_answer_okay_cancel (const char *keyword, + const char *prompt, + int def_answer); /*-- helptext.c --*/ void display_online_help( const char *keyword ); diff --git a/g10/mdfilter.c b/g10/mdfilter.c index 7a12269e0..a00516456 100644 --- a/g10/mdfilter.c +++ b/g10/mdfilter.c @@ -25,7 +25,7 @@ #include #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "filter.h" diff --git a/g10/misc.c b/g10/misc.c index 96bb6c559..f02601fc4 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -55,7 +55,7 @@ #include "gpg.h" #ifdef HAVE_W32_SYSTEM -# include "errors.h" +# include "status.h" #endif /*HAVE_W32_SYSTEM*/ #include "util.h" #include "main.h" diff --git a/g10/options.h b/g10/options.h index be7394e35..fac05b6ed 100644 --- a/g10/options.h +++ b/g10/options.h @@ -90,6 +90,8 @@ struct char *ttytype; char *lc_ctype; char *lc_messages; + char *xauthority; + char *pinentry_user_data; int skip_verify; int compress_keys; diff --git a/g10/pkclist.c b/g10/pkclist.c index c94c0b297..6b7401826 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "keydb.h" #include "util.h" #include "main.h" diff --git a/g10/revoke.c b/g10/revoke.c index 3a532b1d3..cc66dfced 100644 --- a/g10/revoke.c +++ b/g10/revoke.c @@ -29,7 +29,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "keydb.h" #include "util.h" #include "main.h" diff --git a/g10/server.c b/g10/server.c index 1c17b9f6e..7e783e51e 100644 --- a/g10/server.c +++ b/g10/server.c @@ -85,6 +85,12 @@ option_handler (assuan_context_t ctx, const char *key, const char *value) else if (!strcmp (key, "lc-messages")) { } + else if (!strcmp (key, "xauthority")) + { + } + else if (!strcmp (key, "pinentry_user_data")) + { + } else if (!strcmp (key, "list-mode")) { /* This is for now a dummy option. */ diff --git a/g10/sign.c b/g10/sign.c index 6e3671dbd..6bb30f04b 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "util.h" diff --git a/g10/signal.c b/g10/signal.c index 3a0b438a4..2cabd1990 100644 --- a/g10/signal.c +++ b/g10/signal.c @@ -29,7 +29,7 @@ #include "gpg.h" #include "options.h" -#include "errors.h" +#include "status.h" #include "util.h" #include "main.h" #include "ttyio.h" diff --git a/g10/skclist.c b/g10/skclist.c index e0e1256d6..405f3f516 100644 --- a/g10/skclist.c +++ b/g10/skclist.c @@ -27,7 +27,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "keydb.h" #include "util.h" #include "i18n.h" diff --git a/g10/status.c b/g10/status.c deleted file mode 100644 index e78652482..000000000 --- a/g10/status.c +++ /dev/null @@ -1,631 +0,0 @@ -/* status.c - Status message and command-fd interface - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004, 2005, 2006 Free Software Foundation, Inc. - * - * This file is part of GnuPG. - * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * GnuPG is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "gpg.h" -#include "util.h" -#include "status.h" -#include "ttyio.h" -#include "options.h" -#include "main.h" -#include "i18n.h" -#include "cipher.h" /* for progress functions */ - -#define CONTROL_D ('D' - 'A' + 1) - - - -static FILE *statusfp; - - -static void -progress_cb (void *ctx, const char *what, int printchar, - int current, int total) -{ - char buf[50]; - - if ( printchar == '\n' && !strcmp (what, "primegen") ) - snprintf (buf, sizeof buf -1, "%.20s X 100 100", what ); - else - snprintf (buf, sizeof buf -1, "%.20s %c %d %d", - what, printchar=='\n'?'X':printchar, current, total ); - write_status_text (STATUS_PROGRESS, buf); -} - -static const char * -get_status_string ( int no ) -{ - const char *s; - - switch( no ) - { - case STATUS_ENTER : s = "ENTER"; break; - case STATUS_LEAVE : s = "LEAVE"; break; - case STATUS_ABORT : s = "ABORT"; break; - case STATUS_NEWSIG : s = "NEWSIG"; break; - case STATUS_GOODSIG: s = "GOODSIG"; break; - case STATUS_KEYEXPIRED: s = "KEYEXPIRED"; break; - case STATUS_KEYREVOKED: s = "KEYREVOKED"; break; - case STATUS_BADSIG : s = "BADSIG"; break; - case STATUS_ERRSIG : s = "ERRSIG"; break; - case STATUS_BADARMOR : s = "BADARMOR"; break; - case STATUS_RSA_OR_IDEA : s= "RSA_OR_IDEA"; break; - case STATUS_TRUST_UNDEFINED: s = "TRUST_UNDEFINED"; break; - case STATUS_TRUST_NEVER : s = "TRUST_NEVER"; break; - case STATUS_TRUST_MARGINAL : s = "TRUST_MARGINAL"; break; - case STATUS_TRUST_FULLY : s = "TRUST_FULLY"; break; - case STATUS_TRUST_ULTIMATE : s = "TRUST_ULTIMATE"; break; - case STATUS_GET_BOOL : s = "GET_BOOL"; break; - case STATUS_GET_LINE : s = "GET_LINE"; break; - case STATUS_GET_HIDDEN : s = "GET_HIDDEN"; break; - case STATUS_GOT_IT : s = "GOT_IT"; break; - case STATUS_SHM_INFO : s = "SHM_INFO"; break; - case STATUS_SHM_GET : s = "SHM_GET"; break; - case STATUS_SHM_GET_BOOL : s = "SHM_GET_BOOL"; break; - case STATUS_SHM_GET_HIDDEN : s = "SHM_GET_HIDDEN"; break; - case STATUS_NEED_PASSPHRASE: s = "NEED_PASSPHRASE"; break; - case STATUS_VALIDSIG : s = "VALIDSIG"; break; - case STATUS_SIG_ID : s = "SIG_ID"; break; - case STATUS_ENC_TO : s = "ENC_TO"; break; - case STATUS_NODATA : s = "NODATA"; break; - case STATUS_BAD_PASSPHRASE : s = "BAD_PASSPHRASE"; break; - case STATUS_NO_PUBKEY : s = "NO_PUBKEY"; break; - case STATUS_NO_SECKEY : s = "NO_SECKEY"; break; - case STATUS_NEED_PASSPHRASE_SYM: s = "NEED_PASSPHRASE_SYM"; break; - case STATUS_NEED_PASSPHRASE_PIN: s = "NEED_PASSPHRASE_PIN"; break; - case STATUS_DECRYPTION_FAILED: s = "DECRYPTION_FAILED"; break; - case STATUS_DECRYPTION_OKAY: s = "DECRYPTION_OKAY"; break; - case STATUS_MISSING_PASSPHRASE: s = "MISSING_PASSPHRASE"; break; - case STATUS_GOOD_PASSPHRASE : s = "GOOD_PASSPHRASE"; break; - case STATUS_GOODMDC : s = "GOODMDC"; break; - case STATUS_BADMDC : s = "BADMDC"; break; - case STATUS_ERRMDC : s = "ERRMDC"; break; - case STATUS_IMPORTED : s = "IMPORTED"; break; - case STATUS_IMPORT_OK : s = "IMPORT_OK"; break; - case STATUS_IMPORT_CHECK : s = "IMPORT_CHECK"; break; - case STATUS_IMPORT_RES : s = "IMPORT_RES"; break; - case STATUS_FILE_START : s = "FILE_START"; break; - case STATUS_FILE_DONE : s = "FILE_DONE"; break; - case STATUS_FILE_ERROR : s = "FILE_ERROR"; break; - case STATUS_BEGIN_DECRYPTION:s = "BEGIN_DECRYPTION"; break; - case STATUS_END_DECRYPTION : s = "END_DECRYPTION"; break; - case STATUS_BEGIN_ENCRYPTION:s = "BEGIN_ENCRYPTION"; break; - case STATUS_END_ENCRYPTION : s = "END_ENCRYPTION"; break; - case STATUS_DELETE_PROBLEM : s = "DELETE_PROBLEM"; break; - case STATUS_PROGRESS : s = "PROGRESS"; break; - case STATUS_SIG_CREATED : s = "SIG_CREATED"; break; - case STATUS_SESSION_KEY : s = "SESSION_KEY"; break; - case STATUS_NOTATION_NAME : s = "NOTATION_NAME" ; break; - case STATUS_NOTATION_DATA : s = "NOTATION_DATA" ; break; - case STATUS_POLICY_URL : s = "POLICY_URL" ; break; - case STATUS_BEGIN_STREAM : s = "BEGIN_STREAM"; break; - case STATUS_END_STREAM : s = "END_STREAM"; break; - case STATUS_KEY_CREATED : s = "KEY_CREATED"; break; - case STATUS_KEY_NOT_CREATED: s = "KEY_NOT_CREATED"; break; - case STATUS_USERID_HINT : s = "USERID_HINT"; break; - case STATUS_UNEXPECTED : s = "UNEXPECTED"; break; - case STATUS_INV_RECP : s = "INV_RECP"; break; - case STATUS_NO_RECP : s = "NO_RECP"; break; - case STATUS_ALREADY_SIGNED : s = "ALREADY_SIGNED"; break; - case STATUS_SIGEXPIRED : s = "SIGEXPIRED deprecated-use-keyexpired-instead"; break; - case STATUS_EXPSIG : s = "EXPSIG"; break; - case STATUS_EXPKEYSIG : s = "EXPKEYSIG"; break; - case STATUS_REVKEYSIG : s = "REVKEYSIG"; break; - case STATUS_ATTRIBUTE : s = "ATTRIBUTE"; break; - case STATUS_CARDCTRL : s = "CARDCTRL"; break; - case STATUS_PLAINTEXT : s = "PLAINTEXT"; break; - case STATUS_PLAINTEXT_LENGTH:s = "PLAINTEXT_LENGTH"; break; - case STATUS_SIG_SUBPACKET : s = "SIG_SUBPACKET"; break; - case STATUS_SC_OP_SUCCESS : s = "SC_OP_SUCCESS"; break; - case STATUS_SC_OP_FAILURE : s = "SC_OP_FAILURE"; break; - case STATUS_BACKUP_KEY_CREATED:s="BACKUP_KEY_CREATED"; break; - case STATUS_PKA_TRUST_BAD : s = "PKA_TRUST_BAD"; break; - case STATUS_PKA_TRUST_GOOD : s = "PKA_TRUST_GOOD"; break; - case STATUS_BEGIN_SIGNING : s = "BEGIN_SIGNING"; break; - case STATUS_ERROR : s = "ERROR"; break; - default: s = "?"; break; - } - return s; -} - - -/* Return true if the status message NO may currently be issued. We - need this to avoid syncronisation problem while auto retrieving a - key. There it may happen that a status NODATA is issued for a non - available key and the user may falsely interpret this has a missing - signature. */ -static int -status_currently_allowed (int no) -{ - if (!glo_ctrl.in_auto_key_retrieve) - return 1; /* Yes. */ - - /* We allow some statis anyway, so that import statistics are - correct and to avoid problems if the retriebval subsystem will - prompt the user. */ - switch (no) - { - case STATUS_GET_BOOL: - case STATUS_GET_LINE: - case STATUS_GET_HIDDEN: - case STATUS_GOT_IT: - case STATUS_IMPORTED: - case STATUS_IMPORT_OK: - case STATUS_IMPORT_CHECK: - case STATUS_IMPORT_RES: - return 1; /* Yes. */ - default: - break; - } - return 0; /* No. */ -} - - -void -set_status_fd ( int fd ) -{ - static int last_fd = -1; - - if ( fd != -1 && last_fd == fd ) - return; - - if ( statusfp && statusfp != stdout && statusfp != stderr ) - fclose (statusfp); - statusfp = NULL; - if ( fd == -1 ) - return; - - if( fd == 1 ) - statusfp = stdout; - else if( fd == 2 ) - statusfp = stderr; - else - statusfp = fdopen( fd, "w" ); - if( !statusfp ) { - log_fatal("can't open fd %d for status output: %s\n", - fd, strerror(errno)); - } - last_fd = fd; - - gcry_set_progress_handler ( progress_cb, NULL ); -} - -int -is_status_enabled() -{ - return !!statusfp; -} - -void -write_status ( int no ) -{ - write_status_text( no, NULL ); -} - -void -write_status_text ( int no, const char *text) -{ - if( !statusfp || !status_currently_allowed (no) ) - return; /* Not enabled or allowed. */ - - fputs ( "[GNUPG:] ", statusfp ); - fputs ( get_status_string (no), statusfp ); - if( text ) { - putc ( ' ', statusfp ); - for (; *text; text++) { - if (*text == '\n') - fputs ( "\\n", statusfp ); - else if (*text == '\r') - fputs ( "\\r", statusfp ); - else - putc ( *(const byte *)text, statusfp ); - } - } - putc ('\n',statusfp); - if ( fflush (statusfp) && opt.exit_on_status_write_error ) - g10_exit (0); -} - - -/* - * Write a status line with a buffer using %XX escapes. If WRAP is > - * 0 wrap the line after this length. If STRING is not NULL it will - * be prepended to the buffer, no escaping is done for string. - * A wrap of -1 forces spaces not to be encoded as %20. - */ -void -write_status_text_and_buffer ( int no, const char *string, - const char *buffer, size_t len, int wrap ) -{ - const char *s, *text; - int esc, first; - int lower_limit = ' '; - size_t n, count, dowrap; - - if( !statusfp || !status_currently_allowed (no) ) - return; /* Not enabled or allowed. */ - - if (wrap == -1) { - lower_limit--; - wrap = 0; - } - - text = get_status_string (no); - count = dowrap = first = 1; - do { - if (dowrap) { - fprintf (statusfp, "[GNUPG:] %s ", text ); - count = dowrap = 0; - if (first && string) { - fputs (string, statusfp); - count += strlen (string); - } - first = 0; - } - for (esc=0, s=buffer, n=len; n && !esc; s++, n-- ) { - if ( *s == '%' || *(const byte*)s <= lower_limit - || *(const byte*)s == 127 ) - esc = 1; - if ( wrap && ++count > wrap ) { - dowrap=1; - break; - } - } - if (esc) { - s--; n++; - } - if (s != buffer) - fwrite (buffer, s-buffer, 1, statusfp ); - if ( esc ) { - fprintf (statusfp, "%%%02X", *(const byte*)s ); - s++; n--; - } - buffer = s; - len = n; - if ( dowrap && len ) - putc ( '\n', statusfp ); - } while ( len ); - - putc ('\n',statusfp); - if ( fflush (statusfp) && opt.exit_on_status_write_error ) - g10_exit (0); -} - -void -write_status_buffer ( int no, const char *buffer, size_t len, int wrap ) -{ - write_status_text_and_buffer (no, NULL, buffer, len, wrap); -} - - -/* Print the BEGIN_SIGNING status message. If MD is not NULL it is - used retrieve the hash algorithms used for the message. */ -void -write_status_begin_signing (gcry_md_hd_t md) -{ - if (md) - { - char buf[100]; - size_t buflen; - int i; - - /* We use a hard coded list of possible algorithms. Using other - algorithms than specified by OpenPGP does not make sense - anyway. We do this out of performance reasons: Walking all - the 110 allowed Ids is not a good idea given the way the - check is implemented in libgcrypt. Recall that the only use - of this status code is to create the micalg algorithm for - PGP/MIME. */ - buflen = 0; - for (i=1; i <= 11; i++) - if (i < 4 || i > 7) - if ( gcry_md_is_enabled (md, i) && buflen < DIM(buf) ) - { - snprintf (buf+buflen, DIM(buf) - buflen - 1, - "%sH%d", buflen? " ":"",i); - buflen += strlen (buf+buflen); - } - write_status_text ( STATUS_BEGIN_SIGNING, buf ); - } - else - write_status ( STATUS_BEGIN_SIGNING ); -} - - -static int -myread(int fd, void *buf, size_t count) -{ - int rc; - do { - rc = read( fd, buf, count ); - } while ( rc == -1 && errno == EINTR ); - if ( !rc && count ) { - static int eof_emmited=0; - if ( eof_emmited < 3 ) { - *(char*)buf = CONTROL_D; - rc = 1; - eof_emmited++; - } - else { /* Ctrl-D not caught - do something reasonable */ -#ifdef HAVE_DOSISH_SYSTEM - raise (SIGINT); /* nothing to hangup under DOS */ -#else - raise (SIGHUP); /* no more input data */ -#endif - } - } - return rc; -} - - - -/**************** - * Request a string from the client over the command-fd - * If bool, returns static string on true (do not free) or NULL for false - */ -static char * -do_get_from_fd( const char *keyword, int hidden, int bool ) -{ - int i, len; - char *string; - - if(statusfp!=stdout) - fflush(stdout); - - write_status_text( bool? STATUS_GET_BOOL : - hidden? STATUS_GET_HIDDEN : STATUS_GET_LINE, keyword ); - - for( string = NULL, i = len = 200; ; i++ ) { - if( i >= len-1 ) { - char *save = string; - len += 100; - string = hidden? xmalloc_secure ( len ) : xmalloc ( len ); - if( save ) - memcpy(string, save, i ); - else - i=0; - } - /* Hmmm: why not use our read_line function here */ - if( myread( opt.command_fd, string+i, 1) != 1 || string[i] == '\n' ) - break; - else if ( string[i] == CONTROL_D ) { - /* found ETX - cancel the line and return a sole ETX */ - string[0] = CONTROL_D; - i=1; - break; - } - } - string[i] = 0; - - write_status( STATUS_GOT_IT ); - - if( bool ) /* Fixme: is this correct??? */ - return (string[0] == 'Y' || string[0] == 'y') ? "" : NULL; - - return string; -} - - - -int -cpr_enabled() -{ - if( opt.command_fd != -1 ) - return 1; -#ifdef USE_SHM_COPROCESSING - if( opt.shm_coprocess ) - return 1; -#endif - return 0; -} - -char * -cpr_get_no_help( const char *keyword, const char *prompt ) -{ - char *p; - - if( opt.command_fd != -1 ) - return do_get_from_fd ( keyword, 0, 0 ); -#ifdef USE_SHM_COPROCESSING - if( opt.shm_coprocess ) - return do_shm_get( keyword, 0, 0 ); -#endif - for(;;) { - p = tty_get( prompt ); - return p; - } -} - -char * -cpr_get( const char *keyword, const char *prompt ) -{ - char *p; - - if( opt.command_fd != -1 ) - return do_get_from_fd ( keyword, 0, 0 ); -#ifdef USE_SHM_COPROCESSING - if( opt.shm_coprocess ) - return do_shm_get( keyword, 0, 0 ); -#endif - for(;;) { - p = tty_get( prompt ); - if( *p=='?' && !p[1] && !(keyword && !*keyword)) { - xfree(p); - display_online_help( keyword ); - } - else - return p; - } -} - - -char * -cpr_get_utf8( const char *keyword, const char *prompt ) -{ - char *p; - p = cpr_get( keyword, prompt ); - if( p ) { - char *utf8 = native_to_utf8( p ); - xfree( p ); - p = utf8; - } - return p; -} - -char * -cpr_get_hidden( const char *keyword, const char *prompt ) -{ - char *p; - - if( opt.command_fd != -1 ) - return do_get_from_fd ( keyword, 1, 0 ); -#ifdef USE_SHM_COPROCESSING - if( opt.shm_coprocess ) - return do_shm_get( keyword, 1, 0 ); -#endif - for(;;) { - p = tty_get_hidden( prompt ); - if( *p == '?' && !p[1] ) { - xfree(p); - display_online_help( keyword ); - } - else - return p; - } -} - -void -cpr_kill_prompt(void) -{ - if( opt.command_fd != -1 ) - return; -#ifdef USE_SHM_COPROCESSING - if( opt.shm_coprocess ) - return; -#endif - tty_kill_prompt(); - return; -} - -int -cpr_get_answer_is_yes( const char *keyword, const char *prompt ) -{ - int yes; - char *p; - - if( opt.command_fd != -1 ) - return !!do_get_from_fd ( keyword, 0, 1 ); -#ifdef USE_SHM_COPROCESSING - if( opt.shm_coprocess ) - return !!do_shm_get( keyword, 0, 1 ); -#endif - for(;;) { - p = tty_get( prompt ); - trim_spaces(p); /* it is okay to do this here */ - if( *p == '?' && !p[1] ) { - xfree(p); - display_online_help( keyword ); - } - else { - tty_kill_prompt(); - yes = answer_is_yes(p); - xfree(p); - return yes; - } - } -} - -int -cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt ) -{ - int yes; - char *p; - - if( opt.command_fd != -1 ) - return !!do_get_from_fd ( keyword, 0, 1 ); -#ifdef USE_SHM_COPROCESSING - if( opt.shm_coprocess ) - return !!do_shm_get( keyword, 0, 1 ); -#endif - for(;;) { - p = tty_get( prompt ); - trim_spaces(p); /* it is okay to do this here */ - if( *p == '?' && !p[1] ) { - xfree(p); - display_online_help( keyword ); - } - else { - tty_kill_prompt(); - yes = answer_is_yes_no_quit(p); - xfree(p); - return yes; - } - } -} - - -int -cpr_get_answer_okay_cancel (const char *keyword, - const char *prompt, - int def_answer) -{ - int yes; - char *answer = NULL; - char *p; - - if( opt.command_fd != -1 ) - answer = do_get_from_fd ( keyword, 0, 0 ); -#ifdef USE_SHM_COPROCESSING - else if( opt.shm_coprocess ) - answer = do_shm_get( keyword, 0, 0 ); -#endif - - if (answer) - { - yes = answer_is_okay_cancel (answer, def_answer); - xfree (answer); - return yes; - } - - for(;;) - { - p = tty_get( prompt ); - trim_spaces(p); /* it is okay to do this here */ - if (*p == '?' && !p[1]) - { - xfree(p); - display_online_help (keyword); - } - else - { - tty_kill_prompt(); - yes = answer_is_okay_cancel (p, def_answer); - xfree(p); - return yes; - } - } -} diff --git a/g10/status.h b/g10/status.h deleted file mode 100644 index 0a2a9e0b6..000000000 --- a/g10/status.h +++ /dev/null @@ -1,149 +0,0 @@ -/* status.h - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004 Free Software Foundation, Inc. - * - * This file is part of GnuPG. - * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * GnuPG is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -#ifndef G10_STATUS_H -#define G10_STATUS_H - -#define STATUS_ENTER 1 -#define STATUS_LEAVE 2 -#define STATUS_ABORT 3 - -#define STATUS_GOODSIG 4 -#define STATUS_BADSIG 5 -#define STATUS_ERRSIG 6 - -#define STATUS_BADARMOR 7 - -#define STATUS_RSA_OR_IDEA 8 -#define STATUS_KEYEXPIRED 9 -#define STATUS_KEYREVOKED 10 - -#define STATUS_TRUST_UNDEFINED 11 -#define STATUS_TRUST_NEVER 12 -#define STATUS_TRUST_MARGINAL 13 -#define STATUS_TRUST_FULLY 14 -#define STATUS_TRUST_ULTIMATE 15 - -#define STATUS_SHM_INFO 16 -#define STATUS_SHM_GET 17 -#define STATUS_SHM_GET_BOOL 18 -#define STATUS_SHM_GET_HIDDEN 19 - -#define STATUS_NEED_PASSPHRASE 20 -#define STATUS_VALIDSIG 21 -#define STATUS_SIG_ID 22 -#define STATUS_ENC_TO 23 -#define STATUS_NODATA 24 -#define STATUS_BAD_PASSPHRASE 25 -#define STATUS_NO_PUBKEY 26 -#define STATUS_NO_SECKEY 27 -#define STATUS_NEED_PASSPHRASE_SYM 28 -#define STATUS_DECRYPTION_FAILED 29 -#define STATUS_DECRYPTION_OKAY 30 -#define STATUS_MISSING_PASSPHRASE 31 -#define STATUS_GOOD_PASSPHRASE 32 -#define STATUS_GOODMDC 33 -#define STATUS_BADMDC 34 -#define STATUS_ERRMDC 35 -#define STATUS_IMPORTED 36 -#define STATUS_IMPORT_RES 37 -#define STATUS_FILE_START 38 -#define STATUS_FILE_DONE 39 -#define STATUS_FILE_ERROR 40 - -#define STATUS_BEGIN_DECRYPTION 41 -#define STATUS_END_DECRYPTION 42 -#define STATUS_BEGIN_ENCRYPTION 43 -#define STATUS_END_ENCRYPTION 44 - -#define STATUS_DELETE_PROBLEM 45 -#define STATUS_GET_BOOL 46 -#define STATUS_GET_LINE 47 -#define STATUS_GET_HIDDEN 48 -#define STATUS_GOT_IT 49 -#define STATUS_PROGRESS 50 -#define STATUS_SIG_CREATED 51 -#define STATUS_SESSION_KEY 52 -#define STATUS_NOTATION_NAME 53 -#define STATUS_NOTATION_DATA 54 -#define STATUS_POLICY_URL 55 -#define STATUS_BEGIN_STREAM 56 -#define STATUS_END_STREAM 57 -#define STATUS_KEY_CREATED 58 -#define STATUS_USERID_HINT 59 -#define STATUS_UNEXPECTED 60 -#define STATUS_INV_RECP 61 -#define STATUS_NO_RECP 62 -#define STATUS_ALREADY_SIGNED 63 -#define STATUS_SIGEXPIRED 64 -#define STATUS_EXPSIG 65 -#define STATUS_EXPKEYSIG 66 -#define STATUS_ATTRIBUTE 67 -#define STATUS_IMPORT_OK 68 -#define STATUS_IMPORT_CHECK 69 -#define STATUS_REVKEYSIG 70 -#define STATUS_CARDCTRL 71 -#define STATUS_NEWSIG 72 -#define STATUS_PLAINTEXT 73 -#define STATUS_PLAINTEXT_LENGTH 74 -#define STATUS_KEY_NOT_CREATED 75 -#define STATUS_NEED_PASSPHRASE_PIN 76 -#define STATUS_SIG_SUBPACKET 77 - -/* Extra status codes for certain smartcard operations. Primary - useful to double check that change PIN worked as expected. */ -#define STATUS_SC_OP_FAILURE 79 -#define STATUS_SC_OP_SUCCESS 80 - -#define STATUS_BACKUP_KEY_CREATED 81 - -#define STATUS_PKA_TRUST_BAD 82 -#define STATUS_PKA_TRUST_GOOD 83 - -#define STATUS_BEGIN_SIGNING 84 - -#define STATUS_ERROR 85 - - -/*-- status.c --*/ -void set_status_fd ( int fd ); -int is_status_enabled ( void ); -void write_status ( int no ); -void write_status_text ( int no, const char *text ); -void write_status_buffer ( int no, - const char *buffer, size_t len, int wrap ); -void write_status_text_and_buffer ( int no, const char *text, - const char *buffer, size_t len, int wrap ); - -void write_status_begin_signing (gcry_md_hd_t md); - - -int cpr_enabled(void); -char *cpr_get( const char *keyword, const char *prompt ); -char *cpr_get_no_help( const char *keyword, const char *prompt ); -char *cpr_get_utf8( const char *keyword, const char *prompt ); -char *cpr_get_hidden( const char *keyword, const char *prompt ); -void cpr_kill_prompt(void); -int cpr_get_answer_is_yes( const char *keyword, const char *prompt ); -int cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt ); -int cpr_get_answer_okay_cancel (const char *keyword, - const char *prompt, - int def_answer); - -#endif /*G10_STATUS_H*/ diff --git a/g10/tdbdump.c b/g10/tdbdump.c index 2d69d9fbd..5e7b685e2 100644 --- a/g10/tdbdump.c +++ b/g10/tdbdump.c @@ -30,7 +30,7 @@ #include #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "util.h" diff --git a/g10/tdbio.c b/g10/tdbio.c index 563178f61..d763d2a92 100644 --- a/g10/tdbio.c +++ b/g10/tdbio.c @@ -29,7 +29,7 @@ #include #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "options.h" diff --git a/g10/textfilter.c b/g10/textfilter.c index 34b12790f..14bf69962 100644 --- a/g10/textfilter.c +++ b/g10/textfilter.c @@ -25,7 +25,7 @@ #include #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "util.h" #include "filter.h" diff --git a/g10/trustdb.c b/g10/trustdb.c index c5caf2843..62eafba0d 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -30,7 +30,7 @@ #endif /* !DISABLE_REGEX */ #include "gpg.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "util.h" diff --git a/g10/verify.c b/g10/verify.c index edaefcd0d..702547ea2 100644 --- a/g10/verify.c +++ b/g10/verify.c @@ -28,7 +28,7 @@ #include "gpg.h" #include "options.h" #include "packet.h" -#include "errors.h" +#include "status.h" #include "iobuf.h" #include "keydb.h" #include "util.h" -- cgit v1.2.3