mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-22 14:57:02 +01:00
* passphrase.c (read_passphrase_from_fd): Do a dummy read if the
agent is to be used. Noted by Ingo Kl�cker. (agent_get_passphrase): Inhibit caching when we have no fingerprint. This is required for key generation as well as for symmetric only encryption.
This commit is contained in:
parent
3ff3ac5ba4
commit
ed16a85de8
@ -1,3 +1,11 @@
|
||||
2003-04-10 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* passphrase.c (read_passphrase_from_fd): Do a dummy read if the
|
||||
agent is to be used. Noted by Ingo Klöcker.
|
||||
(agent_get_passphrase): Inhibit caching when we have no
|
||||
fingerprint. This is required for key generation as well as for
|
||||
symmetric only encryption.
|
||||
|
||||
2003-04-09 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* passphrase .c (agent_get_passphrase): New arg CANCELED.
|
||||
|
@ -150,12 +150,22 @@ read_passphrase_from_fd( int fd )
|
||||
int i, len;
|
||||
char *pw;
|
||||
|
||||
if ( opt.use_agent )
|
||||
return; /* not used here */
|
||||
if (opt.use_agent)
|
||||
{ /* Not used but we have to do a dummy read, so that it won't end
|
||||
up at the begin of the message if the quite usual trick to
|
||||
prepend the passphtrase to the message is used. */
|
||||
char buf[1];
|
||||
|
||||
while (!(read (fd, buf, 1) != 1 || *buf == '\n' ))
|
||||
;
|
||||
*buf = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !opt.batch )
|
||||
tty_printf("Reading passphrase from file descriptor %d ...", fd );
|
||||
for( pw = NULL, i = len = 100; ; i++ ) {
|
||||
for (pw = NULL, i = len = 100; ; i++ )
|
||||
{
|
||||
if( i >= len-1 ) {
|
||||
char *pw2 = pw;
|
||||
len += 100;
|
||||
@ -165,12 +175,12 @@ read_passphrase_from_fd( int fd )
|
||||
else
|
||||
i=0;
|
||||
}
|
||||
if( read( fd, pw+i, 1) != 1 || pw[i] == '\n' )
|
||||
if (read( fd, pw+i, 1) != 1 || pw[i] == '\n' )
|
||||
break;
|
||||
}
|
||||
pw[i] = 0;
|
||||
if( !opt.batch )
|
||||
tty_printf("\b\b\b \n" );
|
||||
if (!opt.batch)
|
||||
tty_printf ("\b\b\b \n" );
|
||||
|
||||
m_free( fd_passwd );
|
||||
fd_passwd = pw;
|
||||
@ -614,6 +624,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text,
|
||||
char *pw = NULL;
|
||||
PKT_public_key *pk = m_alloc_clear( sizeof *pk );
|
||||
byte fpr[MAX_FINGERPRINT_LEN];
|
||||
int have_fpr = 0;
|
||||
int prot;
|
||||
char *orig_codeset = NULL;
|
||||
|
||||
@ -635,21 +646,15 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text,
|
||||
#ifdef ENABLE_NLS
|
||||
/* The Assuan agent protol requires us to trasnmit utf-8 strings */
|
||||
orig_codeset = bind_textdomain_codeset (PACKAGE, NULL);
|
||||
log_debug ("old codeset: `%s'\n", orig_codeset);
|
||||
#ifdef HAVE_LANGINFO_CODESET
|
||||
if (!orig_codeset)
|
||||
{
|
||||
orig_codeset = nl_langinfo (CODESET);
|
||||
log_debug ("assuming `%s'\n", orig_codeset);
|
||||
}
|
||||
#endif
|
||||
if (orig_codeset)
|
||||
{ /* We only switch when we are able to restore the codeset later. */
|
||||
orig_codeset = m_strdup (orig_codeset);
|
||||
if (!bind_textdomain_codeset (PACKAGE, "utf-8"))
|
||||
orig_codeset = NULL;
|
||||
log_debug ("switched to: `%s'\n",
|
||||
bind_textdomain_codeset (PACKAGE, NULL));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -695,6 +700,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text,
|
||||
{
|
||||
size_t dummy;
|
||||
fingerprint_from_pk( pk, fpr, &dummy );
|
||||
have_fpr = 1;
|
||||
}
|
||||
|
||||
}
|
||||
@ -783,12 +789,12 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text,
|
||||
tryagain_text = _(tryagain_text);
|
||||
|
||||
/* We allocate 2 time the needed space for atext so that there
|
||||
is nenough space for escaping */
|
||||
is enough space for escaping */
|
||||
line = m_alloc (15 + 46
|
||||
+ 3*strlen (tryagain_text) + 3*strlen (atext) + 2);
|
||||
strcpy (line, "GET_PASSPHRASE ");
|
||||
p = line+15;
|
||||
if (!mode)
|
||||
if (!mode && have_fpr)
|
||||
{
|
||||
for (i=0; i < 20; i++, p +=2 )
|
||||
sprintf (p, "%02X", fpr[i]);
|
||||
@ -872,7 +878,6 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text,
|
||||
#ifdef ENABLE_NLS
|
||||
if (orig_codeset)
|
||||
bind_textdomain_codeset (PACKAGE, orig_codeset);
|
||||
log_debug ("restored to: `%s'\n", bind_textdomain_codeset (PACKAGE, NULL));
|
||||
#endif
|
||||
m_free (atext);
|
||||
if ( fd != -1 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user