1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-04 20:38:50 +01:00
* g10.c, options.h: New options --display, --ttyname, --ttytype,
--lc-ctype, --lc-messages to be used with future versions of the
gpg-agent.
* passphrase.c (agent_send_option,agent_send_all_options): New.
(agent_open): Send options to the agent.

* trustdb.c (update_ownertrust, clear_ownertrust): Do an explicit
do_sync because revalidation_mark does it only if when the
timestamp actually changes.
/
* configure.ac: Check for locale.h and setlocale
This commit is contained in:
Werner Koch 2002-04-25 08:30:35 +00:00
parent bf2c77073d
commit ecbf6f4d46
8 changed files with 166 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2002-04-25 Werner Koch <wk@gnupg.org>
* configure.ac: Check for locale.h and setlocale
2002-04-24 David Shaw <dshaw@jabberwocky.com>
* Update NEWS with recent changes.

3
TODO
View File

@ -109,6 +109,9 @@
packet (See bug report 817). This is not easy to do as we don't
store the one-pass packets.
* cat foo | gpg --sign | gpg --list-packets
Does not list the signature packet.
Things we won't do

View File

@ -449,8 +449,7 @@ AC_SUBST(DYNLINK_MOD_CFLAGS)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h langinfo.h termio.h)
AC_CHECK_HEADERS(unistd.h langinfo.h termio.h locale.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@ -485,7 +484,7 @@ AC_FUNC_VPRINTF
AC_FUNC_FORK
AC_CHECK_FUNCS(strerror stpcpy strsep strlwr stricmp tcgetattr strtoul mmap)
AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo)
AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo setlocale)
AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat)
AC_REPLACE_FUNCS(mkdtemp)

View File

@ -1,3 +1,15 @@
2002-04-25 Werner Koch <wk@gnupg.org>
* g10.c, options.h: New options --display, --ttyname, --ttytype,
--lc-ctype, --lc-messages to be used with future versions of the
gpg-agent.
* passphrase.c (agent_send_option,agent_send_all_options): New.
(agent_open): Send options to the agent.
* trustdb.c (update_ownertrust, clear_ownertrust): Do an explicit
do_sync because revalidation_mark does it only if when the
timestamp actually changes.
2002-04-23 David Shaw <dshaw@jabberwocky.com>
* main.h, keygen.c (do_generate_keypair), keylist.c

View File

@ -274,6 +274,11 @@ enum cmd_and_opt_values { aNull = 0,
oPreferenceList,
oEmu3DESS2KBug, /* will be removed in 1.1 */
oEmuMDEncodeBug,
oDisplay,
oTTYname,
oTTYtype,
oLCctype,
oLCmessages,
aTest };
@ -537,6 +542,11 @@ static ARGPARSE_OPTS opts[] = {
{ oPreferenceList, "preference-list", 2, "@"},
{ oEmu3DESS2KBug, "emulate-3des-s2k-bug", 0, "@"},
{ oEmuMDEncodeBug, "emulate-md-encode-bug", 0, "@"},
{ oDisplay, "display", 2, "@" },
{ oTTYname, "ttyname", 2, "@" },
{ oTTYtype, "ttytype", 2, "@" },
{ oLCctype, "lc-ctype", 2, "@" },
{ oLCmessages, "lc-messages", 2, "@" },
{0} };
@ -1277,6 +1287,11 @@ main( int argc, char **argv )
case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break;
case oPreservePermissions: opt.preserve_permissions=1; break;
case oPreferenceList: preference_list = pargs.r.ret_str; break;
case oDisplay: opt.display = pargs.r.ret_str; break;
case oTTYname: opt.ttyname = pargs.r.ret_str; break;
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;
default : pargs.err = configfp? 1:2; break;
}
}

View File

@ -75,6 +75,13 @@ struct {
int completes_needed;
int max_cert_depth;
const char *homedir;
char *display; /* 5 options to be passed to the gpg-agent */
char *ttyname;
char *ttytype;
char *lc_ctype;
char *lc_messages;
int skip_verify;
int compress_keys;
int compress_sigs;

View File

@ -33,6 +33,9 @@
# include <windows.h>
#endif
#include <errno.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include "util.h"
#include "memory.h"
@ -309,6 +312,115 @@ readline (int fd, char *buf, size_t buflen)
#if !defined (__riscos__)
#if !defined (__MINGW32__) && !defined (__CYGWIN32__)
/* For the new Assuan protocol we may have to send options */
static int
agent_send_option (int fd, const char *name, const char *value)
{
char buf[200];
int nread;
char *line;
int i;
line = m_alloc (7 + strlen (name) + 1 + strlen (value) + 2);
strcpy (stpcpy (stpcpy (stpcpy (
stpcpy (line, "OPTION "), name), "="), value), "\n");
i = writen (fd, line, strlen (line));
m_free (line);
if (i)
return -1;
/* get response */
nread = readline (fd, buf, DIM(buf)-1);
if (nread < 3)
return -1;
if (buf[0] == 'O' && buf[1] == 'K' && (buf[2] == ' ' || buf[2] == '\n'))
return 0; /* okay */
return -1;
}
static int
agent_send_all_options (int fd)
{
char *dft_display = NULL;
char *dft_ttyname = NULL;
char *dft_ttytype = NULL;
char *old_lc = NULL;
char *dft_lc = NULL;
int rc = 0;
dft_display = getenv ("DISPLAY");
if (opt.display || dft_display)
{
if (agent_send_option (fd, "display",
opt.display ? opt.display : dft_display))
return -1;
}
if (!opt.ttyname && ttyname (1))
dft_ttyname = ttyname (1);
if (opt.ttyname || dft_ttyname)
{
if (agent_send_option (fd, "ttyname",
opt.ttyname ? opt.ttyname : dft_ttyname))
return -1;
}
dft_ttytype = getenv ("TERM");
if (opt.ttytype || (dft_ttyname && dft_ttytype))
{
if (agent_send_option (fd, "ttytype",
opt.ttyname ? opt.ttytype : dft_ttytype))
return -1;
}
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
old_lc = setlocale (LC_CTYPE, NULL);
if (old_lc)
old_lc = m_strdup (old_lc);
dft_lc = setlocale (LC_CTYPE, "");
#endif
if (opt.lc_ctype || (dft_ttyname && dft_lc))
{
rc = agent_send_option (fd, "lc-ctype",
opt.lc_ctype ? opt.lc_ctype : dft_lc);
}
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
if (old_lc)
{
setlocale (LC_CTYPE, old_lc);
m_free (old_lc);
}
#endif
if (rc)
return rc;
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
old_lc = setlocale (LC_MESSAGES, NULL);
if (old_lc)
old_lc = m_strdup (old_lc);
dft_lc = setlocale (LC_MESSAGES, "");
#endif
if (opt.lc_messages || (dft_ttyname && dft_lc))
{
rc = agent_send_option (fd, "lc-messages",
opt.lc_messages ? opt.lc_messages : dft_lc);
}
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
if (old_lc)
{
setlocale (LC_MESSAGES, old_lc);
m_free (old_lc);
}
#endif
return rc;
}
#endif /*!__MINGW32__ && !__CYGWIN32__*/
/*
* Open a connection to the agent and send the magic string
* Returns: -1 on error or an filedescriptor for urther processing
@ -444,6 +556,13 @@ agent_open (int *ret_prot)
opt.use_agent = 0;
return -1;
}
if (agent_send_all_options (fd)) {
log_error (_("problem with the agent - disabling agent use\n"));
close (fd);
opt.use_agent = 0;
return -1;
}
}
#endif
@ -465,6 +584,7 @@ agent_close ( int fd )
#endif /* !__riscos__ */
/*
* Ask the GPG Agent for the passphrase.
* Mode 0: Allow cached passphrase

View File

@ -593,6 +593,7 @@ update_ownertrust (PKT_public_key *pk, unsigned int new_trust )
rec.r.trust.ownertrust = new_trust;
write_record( &rec );
revalidation_mark ();
do_sync ();
}
}
else if (rc == -1)
@ -609,6 +610,7 @@ update_ownertrust (PKT_public_key *pk, unsigned int new_trust )
rec.r.trust.ownertrust = new_trust;
write_record (&rec);
revalidation_mark ();
do_sync ();
rc = 0;
}
else
@ -635,6 +637,7 @@ clear_ownertrust (PKT_public_key *pk)
rec.r.trust.ownertrust = 0;
write_record( &rec );
revalidation_mark ();
do_sync ();
return 1;
}
}