diff --git a/NEWS b/NEWS index 09893127b..b20b0efda 100644 --- a/NEWS +++ b/NEWS @@ -41,7 +41,8 @@ Noteworthy changes in version 2.0.10 (unreleased) * [w32] Fixed a race condition bteween gpg and gpgsm in the use of temporary file names. - * The gpg-preset-passphrase mechanism works again. + * The gpg-preset-passphrase mechanism works again. An arbitrary + string may now be used for a custom cache ID. * Admin PINs are cached again (bug in 2.0.9). diff --git a/agent/ChangeLog b/agent/ChangeLog index 65669d76a..a9e7be62b 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,12 @@ +2008-12-09 Werner Koch + + * gpg-agent.c (main): Call i18n_init before init_common_subsystems. + * preset-passphrase.c (main): Ditto. + * protect-tool.c (main): Ditto. + + * command.c (cmd_preset_passphrase): Allow an arbitrary string for + the cache id. + 2008-12-08 Werner Koch * gpg-agent.c (handle_connections): Sync the ticker to the next diff --git a/agent/command.c b/agent/command.c index e3e51f4dd..4f28d411b 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1093,7 +1093,7 @@ cmd_passwd (assuan_context_t ctx, char *line) return rc; } -/* PRESET_PASSPHRASE +/* PRESET_PASSPHRASE Set the cached passphrase/PIN for the key identified by the keygrip to passwd for the given time, where -1 means infinite and 0 means @@ -1104,7 +1104,6 @@ static int cmd_preset_passphrase (assuan_context_t ctx, char *line) { int rc; - unsigned char grip[20]; char *grip_clear = NULL; char *passphrase = NULL; int ttl; @@ -1113,11 +1112,6 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line) if (!opt.allow_preset_passphrase) return set_error (GPG_ERR_NOT_SUPPORTED, "no --allow-preset-passphrase"); - rc = parse_keygrip (ctx, line, grip); - if (rc) - return rc; - - /* FIXME: parse_keygrip should return a tail pointer. */ grip_clear = line; while (*line && (*line != ' ' && *line != '\t')) line++; diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 8aae8a6a3..21e4c4345 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -535,9 +535,9 @@ main (int argc, char **argv ) log_set_prefix ("gpg-agent", JNLIB_LOG_WITH_PREFIX|JNLIB_LOG_WITH_PID); /* Make sure that our subsystems are ready. */ + i18n_init (); init_common_subsystems (); - i18n_init (); /* Libgcrypt requires us to register the threading model first. Note that this will also do the pth_init. */ diff --git a/agent/preset-passphrase.c b/agent/preset-passphrase.c index cb906ad89..77646d87e 100644 --- a/agent/preset-passphrase.c +++ b/agent/preset-passphrase.c @@ -209,9 +209,8 @@ main (int argc, char **argv) log_set_prefix ("gpg-preset-passphrase", 1); /* Make sure that our subsystems are ready. */ - init_common_subsystems (); - i18n_init (); + init_common_subsystems (); opt_homedir = default_homedir (); diff --git a/agent/protect-tool.c b/agent/protect-tool.c index 288dbe83b..ddf91e03d 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -1059,9 +1059,8 @@ main (int argc, char **argv ) log_set_prefix ("gpg-protect-tool", 1); /* Make sure that our subsystems are ready. */ - init_common_subsystems (); - i18n_init (); + init_common_subsystems (); if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) ) { diff --git a/doc/tools.texi b/doc/tools.texi index fdbabcd4c..e89a998dc 100644 --- a/doc/tools.texi +++ b/doc/tools.texi @@ -979,7 +979,7 @@ which will be printed to stdout. .B gpg-preset-passphrase .RI [ options ] .RI [ command ] -.I keygrip +.I cache-id @end ifset @mansect description @@ -1009,14 +1009,19 @@ starting @command{gpg-agent} with the @command{gpg-preset-passphrase} is invoked this way: @example -gpg-preset-passphrase [options] [command] @var{keygrip} +gpg-preset-passphrase [options] [command] @var{cacheid} @end example -@var{keygrip} is a 40 character string of hexadecimal characters -identifying the key for which the passphrase should be set or cleared. -This keygrip is listed along with the key when running the command: -@code{gpgsm --dump-secret-keys}. One of the following command options -must be given: +@var{cacheid} is either a 40 character keygrip of hexadecimal +characters identifying the key for which the passphrase should be set +or cleared. The keygrip is listed along with the key when running the +command: @code{gpgsm --dump-secret-keys}. Alternatively an arbitrary +string may be used to identify a passphrase; it is suggested that such +a string is prefixed with the name of the application (e.g +@code{foo:12346}). + +@noindent +One of the following command options must be given: @table @gnupgtabopt @item --preset @@ -1027,7 +1032,7 @@ use. @command{gpg-preset-passphrase} will then read the passphrase from @item --forget @opindex forget -Flush the passphrase for the given keygrip from the cache. +Flush the passphrase for the given cache ID from the cache. @end table diff --git a/g10/ChangeLog b/g10/ChangeLog index 0ad19abaf..23b254ef2 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,15 @@ +2008-12-09 Werner Koch + + * gpg.c (open_info_file): Add arg BINARY and adjust callers. + + * gpg.c (main): Call i18n_init before init_common_subsystems. + * gpgv.c (main): Ditto. + + * keylist.c (set_attrib_fd): Do not close ATTRIB_FP if it is the + log stream. + (set_attrib_fd) [W32]: Set to binary mode. + (dump_attribs): Flush the stream after writing. + 2008-12-05 Werner Koch * call-agent.c (percent_plus_escape): Rename to diff --git a/g10/cpr.c b/g10/cpr.c index a1e904e07..6e89d393d 100644 --- a/g10/cpr.c +++ b/g10/cpr.c @@ -229,7 +229,7 @@ write_status_buffer ( int no, const char *buffer, size_t len, int wrap ) /* Print the BEGIN_SIGNING status message. If MD is not NULL it is - used retrieve the hash algorithms used for the message. */ + used to retrieve the hash algorithms used for the message. */ void write_status_begin_signing (gcry_md_hd_t md) { diff --git a/g10/gpg.c b/g10/gpg.c index ee6061a22..9af97fb16 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -1036,9 +1036,9 @@ set_screen_dimensions(void) used with --status-file etc functions. Not generally useful but it avoids the riscos specific functions and well some Windows people might like it too. Prints an error message and returns -1 on - error. On success the file descriptor is returned. */ + error. On success the file descriptor is returned. */ static int -open_info_file (const char *fname, int for_write) +open_info_file (const char *fname, int for_write, int binary) { #ifdef __riscos__ return riscos_fdopenfile (fname, for_write); @@ -1048,10 +1048,16 @@ open_info_file (const char *fname, int for_write) similar to the option file but in that case it is unlikely that sensitive information may be retrieved by means of error messages. */ + (void)fname; + (void)for_write; + (void)binary; return -1; #else int fd; + if (binary) + binary = MY_O_BINARY; + /* if (is_secured_filename (fname)) */ /* { */ /* fd = -1; */ @@ -1062,10 +1068,10 @@ open_info_file (const char *fname, int for_write) do { if (for_write) - fd = open (fname, O_CREAT | O_TRUNC | O_WRONLY, + fd = open (fname, O_CREAT | O_TRUNC | O_WRONLY | binary, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); else - fd = open (fname, O_RDONLY | MY_O_BINARY); + fd = open (fname, O_RDONLY | binary); } while (fd == -1 && errno == EINTR); /* } */ @@ -1910,6 +1916,7 @@ main (int argc, char **argv) log_set_prefix ("gpg", 1); /* Make sure that our subsystems are ready. */ + i18n_init(); init_common_subsystems (); /* Check that the libraries are suitable. Do it right here because the @@ -1929,7 +1936,6 @@ main (int argc, char **argv) create_dotlock(NULL); /* Register locking cleanup. */ - i18n_init(); opt.command_fd = -1; /* no command fd */ opt.compress_level = -1; /* defaults to standard compress level */ @@ -2216,16 +2222,16 @@ main (int argc, char **argv) case oDebugLevel: debug_level = pargs.r.ret_str; break; case oStatusFD: - set_status_fd( translate_sys2libc_fd_int (pargs.r.ret_int, 1) ); + set_status_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) ); break; case oStatusFile: - set_status_fd ( open_info_file (pargs.r.ret_str, 1) ); + set_status_fd ( open_info_file (pargs.r.ret_str, 1, 0) ); break; case oAttributeFD: - set_attrib_fd(translate_sys2libc_fd_int (pargs.r.ret_int, 1)); + set_attrib_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) ); break; case oAttributeFile: - set_attrib_fd ( open_info_file (pargs.r.ret_str, 1) ); + set_attrib_fd ( open_info_file (pargs.r.ret_str, 1, 1) ); break; case oLoggerFD: log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); @@ -2522,14 +2528,14 @@ main (int argc, char **argv) pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); break; case oPasswdFile: - pwfd = open_info_file (pargs.r.ret_str, 0); + pwfd = open_info_file (pargs.r.ret_str, 0, 1); break; case oPasswdRepeat: opt.passwd_repeat=pargs.r.ret_int; break; case oCommandFD: opt.command_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); break; case oCommandFile: - opt.command_fd = open_info_file (pargs.r.ret_str, 0); + opt.command_fd = open_info_file (pargs.r.ret_str, 0, 1); break; case oCipherAlgo: def_cipher_string = xstrdup(pargs.r.ret_str); diff --git a/g10/gpgv.c b/g10/gpgv.c index 2f64f83c7..fd0ae8b87 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -147,10 +147,10 @@ main( int argc, char **argv ) log_set_prefix ("gpgv", 1); /* Make sure that our subsystems are ready. */ + i18n_init(); init_common_subsystems (); gnupg_init_signals (0, NULL); - i18n_init(); opt.command_fd = -1; /* no command fd */ opt.pgp2_workarounds = 1; diff --git a/g10/keylist.c b/g10/keylist.c index 5f86a38e4..91b337407 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -24,6 +24,9 @@ #include #include #include +#ifdef HAVE_DOSISH_SYSTEM +#include /* for setmode() */ +#endif #include "gpg.h" #include "options.h" @@ -50,7 +53,8 @@ struct sig_stats int oth_err; }; -static FILE *attrib_fp=NULL; +/* The stream used to write attribute packets to. */ +static FILE *attrib_fp = NULL; /**************** * List the keys @@ -745,6 +749,7 @@ dump_attribs(const PKT_user_id *uid,PKT_public_key *pk,PKT_secret_key *sk) } fwrite(uid->attribs[i].data,uid->attribs[i].len,1,attrib_fp); + fflush (attrib_fp); } } @@ -1609,29 +1614,35 @@ print_card_serialno (PKT_secret_key *sk) -void set_attrib_fd(int fd) +void +set_attrib_fd (int fd) { static int last_fd=-1; if ( fd != -1 && last_fd == fd ) return; - if ( attrib_fp && attrib_fp != stdout && attrib_fp != stderr ) + if ( attrib_fp && attrib_fp != stdout && attrib_fp != stderr + && attrib_fp != log_get_stream () ) fclose (attrib_fp); attrib_fp = NULL; if ( fd == -1 ) return; +#ifdef HAVE_DOSISH_SYSTEM + setmode ( fileno(fp) , O_BINARY ); +#endif if( fd == 1 ) attrib_fp = stdout; else if( fd == 2 ) attrib_fp = stderr; else - attrib_fp = fdopen( fd, "wb" ); - if( !attrib_fp ) { - log_fatal("can't open fd %d for attribute output: %s\n", - fd, strerror(errno)); - } - + attrib_fp = fdopen (fd, "wb"); + if (!attrib_fp) + { + log_fatal("can't open fd %d for attribute output: %s\n", + fd, strerror(errno)); + } + last_fd = fd; } diff --git a/kbx/ChangeLog b/kbx/ChangeLog index c91092858..b4f988234 100644 --- a/kbx/ChangeLog +++ b/kbx/ChangeLog @@ -1,3 +1,7 @@ +2008-12-09 Werner Koch + + * kbxutil.c (main): Call i18n_init before init_common_subsystems. + 2008-11-20 Werner Koch * keybox-update.c (create_tmp_file) [USE_ONLY_8DOT3]: Use other diff --git a/kbx/kbxutil.c b/kbx/kbxutil.c index afc4b79e4..efb2eff7e 100644 --- a/kbx/kbxutil.c +++ b/kbx/kbxutil.c @@ -419,9 +419,8 @@ main( int argc, char **argv ) log_set_prefix ("kbxutil", 1); /* Make sure that our subsystems are ready. */ - init_common_subsystems (); - i18n_init (); + init_common_subsystems (); /* Check that the libraries are suitable. Do it here because the option parsing may need services of the library. */ diff --git a/scd/ChangeLog b/scd/ChangeLog index e582ae5b4..4b6575679 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,7 @@ +2008-12-09 Werner Koch + + * scdaemon.c (main): Call i18n_init before init_common_subsystems. + 2008-12-08 Werner Koch * scdaemon.c (handle_connections): Sync ticker to the next full diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 5f3078c19..a094ae36b 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -364,9 +364,9 @@ main (int argc, char **argv ) log_set_prefix ("scdaemon", 1|4); /* Make sure that our subsystems are ready. */ + i18n_init (); init_common_subsystems (); - i18n_init (); /* Libgcrypt requires us to register the threading model first. Note that this will also do the pth_init. */ diff --git a/sm/ChangeLog b/sm/ChangeLog index 67e35f0b5..5f76a5983 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,3 +1,7 @@ +2008-12-09 Werner Koch + + * gpgsm.c (main): Call i18n_init before init_common_subsystems. + 2008-12-05 Werner Koch * certreqgen.c (create_request): Provide a custom prompt for the diff --git a/sm/gpgsm.c b/sm/gpgsm.c index 5177d108e..4aa0dc9eb 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -869,6 +869,7 @@ main ( int argc, char **argv) log_set_prefix ("gpgsm", 1); /* Make sure that our subsystems are ready. */ + i18n_init(); init_common_subsystems (); /* Check that the libraries are suitable. Do it here because the @@ -888,7 +889,6 @@ main ( int argc, char **argv) gnupg_init_signals (0, emergency_cleanup); create_dotlock (NULL); /* register locking cleanup */ - i18n_init(); opt.def_cipher_algoid = "AES"; /*des-EDE3-CBC*/ diff --git a/tools/ChangeLog b/tools/ChangeLog index b7cd7d53d..c533085d5 100644 --- a/tools/ChangeLog +++ b/tools/ChangeLog @@ -1,3 +1,11 @@ +2008-12-09 Werner Koch + + * gpg-check-pattern.c (main): Call i18n_init before + init_common_subsystems. + * gpg-connect-agent.c (main): Ditto. + * gpgconf.c (main): Ditto. + * symcryptrun.c (main): Ditto. + 2008-12-08 Werner Koch * gpgkey2ssh.c (main): Change order of output for RSA. Change name diff --git a/tools/gpg-check-pattern.c b/tools/gpg-check-pattern.c index a2926b951..b29687d37 100644 --- a/tools/gpg-check-pattern.c +++ b/tools/gpg-check-pattern.c @@ -168,9 +168,8 @@ main (int argc, char **argv ) log_set_prefix ("gpg-check-pattern", 1); /* Make sure that our subsystems are ready. */ - init_common_subsystems (); - i18n_init (); + init_common_subsystems (); /* We need Libgcrypt for hashing. */ if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) ) diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c index 92a6e7001..ba97c1a10 100644 --- a/tools/gpg-connect-agent.c +++ b/tools/gpg-connect-agent.c @@ -1152,11 +1152,11 @@ main (int argc, char **argv) log_set_prefix ("gpg-connect-agent", 1); /* Make sure that our subsystems are ready. */ + i18n_init(); init_common_subsystems (); assuan_set_assuan_err_source (0); - i18n_init(); opt.homedir = default_homedir (); opt.connect_flags = 1; /* Use extended connect mode. */ diff --git a/tools/gpgconf.c b/tools/gpgconf.c index 9054e29b3..57ea08b3d 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -147,9 +147,8 @@ main (int argc, char **argv) log_set_prefix ("gpgconf", 1); /* Make sure that our subsystems are ready. */ - init_common_subsystems (); - i18n_init(); + init_common_subsystems (); /* Parse the command line. */ pargs.argc = &argc; diff --git a/tools/symcryptrun.c b/tools/symcryptrun.c index e720eab2f..286680496 100644 --- a/tools/symcryptrun.c +++ b/tools/symcryptrun.c @@ -884,9 +884,8 @@ main (int argc, char **argv) log_set_prefix ("symcryptrun", 1); /* Make sure that our subsystems are ready. */ - init_common_subsystems (); - i18n_init(); + init_common_subsystems (); opt.homedir = default_homedir ();