1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-02 22:38:02 +02:00

* gpgsm.c: Add option --enable-crl-checks.

* call-agent.c (start_agent): Implemented socket based access.
* call-dirmngr.c (start_dirmngr): Ditto.
This commit is contained in:
Werner Koch 2002-01-21 12:03:38 +00:00
parent e610a0aa21
commit 1146232890
4 changed files with 105 additions and 45 deletions

View File

@ -1,3 +1,10 @@
2002-01-21 Werner Koch <wk@gnupg.org>
* gpgsm.c: Add option --enable-crl-checks.
* call-agent.c (start_agent): Implemented socket based access.
* call-dirmngr.c (start_dirmngr): Ditto.
2002-01-20 Werner Koch <wk@gnupg.org> 2002-01-20 Werner Koch <wk@gnupg.org>
* server.c (option_handler): New. * server.c (option_handler): New.

View File

@ -35,6 +35,7 @@
static ASSUAN_CONTEXT agent_ctx = NULL; static ASSUAN_CONTEXT agent_ctx = NULL;
static int force_pipe_server = 0;
struct cipher_parm_s { struct cipher_parm_s {
ASSUAN_CONTEXT ctx; ASSUAN_CONTEXT ctx;
@ -126,17 +127,17 @@ start_agent (void)
{ {
int rc; int rc;
char *infostr, *p; char *infostr, *p;
ASSUAN_CONTEXT ctx;
if (agent_ctx) if (agent_ctx)
return 0; /* fixme: We need a context for each thread or serialize return 0; /* fixme: We need a context for each thread or serialize
the access to the agent (which is suitable given that the access to the agent (which is suitable given that
the agent is not MT */ the agent is not MT */
infostr = getenv ("GPG_AGENT_INFO"); infostr = force_pipe_server? NULL : getenv ("GPG_AGENT_INFO");
if (!infostr) if (!infostr)
{ {
const char *pgmname; const char *pgmname;
ASSUAN_CONTEXT ctx;
const char *argv[3]; const char *argv[3];
log_info (_("no running gpg-agent - starting one\n")); log_info (_("no running gpg-agent - starting one\n"));
@ -160,28 +161,52 @@ start_agent (void)
/* connect to the agent and perform initial handshaking */ /* connect to the agent and perform initial handshaking */
rc = assuan_pipe_connect (&ctx, opt.agent_program, (char**)argv, 0); rc = assuan_pipe_connect (&ctx, opt.agent_program, (char**)argv, 0);
if (rc)
{
log_error ("can't connect to the agent: %s\n", assuan_strerror (rc));
return seterr (No_Agent);
}
agent_ctx = ctx;
} }
else else
{ {
int prot;
int pid;
infostr = xstrdup (infostr); infostr = xstrdup (infostr);
if ( !(p = strchr (infostr, ':')) || p == infostr if ( !(p = strchr (infostr, ':')) || p == infostr)
/* || (p-infostr)+1 >= sizeof client_addr.sun_path */)
{ {
log_error (_("malformed GPG_AGENT_INFO environment variable\n")); log_error (_("malformed GPG_AGENT_INFO environment variable\n"));
xfree (infostr); xfree (infostr);
return seterr (General_Error); force_pipe_server = 1;
return start_agent ();
}
*p++ = 0;
pid = atoi (p);
while (*p && *p != ':')
p++;
prot = *p? atoi (p+1) : 0;
if (prot != 1)
{
log_error (_("gpg-agent protocol version %d is not supported\n"),
prot);
xfree (infostr);
force_pipe_server = 1;
return start_agent ();
}
rc = assuan_socket_connect (&ctx, infostr, pid);
xfree (infostr);
if (rc == ASSUAN_Connect_Failed)
{
log_error (_("can't connect to the agent - trying fall back\n"));
force_pipe_server = 1;
return start_agent ();
} }
*p = 0;
log_error (_("socket based agent communication not yet implemented\n"));
return seterr (Not_Implemented);
} }
if (rc)
{
log_error ("can't connect to the agent: %s\n", assuan_strerror (rc));
return seterr (No_Agent);
}
agent_ctx = ctx;
if (DBG_AGENT) if (DBG_AGENT)
log_debug ("connection to agent established\n"); log_debug ("connection to agent established\n");
return 0; return 0;

View File

@ -34,6 +34,7 @@
#include "i18n.h" #include "i18n.h"
static ASSUAN_CONTEXT dirmngr_ctx = NULL; static ASSUAN_CONTEXT dirmngr_ctx = NULL;
static int force_pipe_server = 0;
struct inq_certificate_parm_s { struct inq_certificate_parm_s {
ASSUAN_CONTEXT ctx; ASSUAN_CONTEXT ctx;
@ -57,17 +58,16 @@ start_dirmngr (void)
{ {
int rc; int rc;
char *infostr, *p; char *infostr, *p;
ASSUAN_CONTEXT ctx;
if (dirmngr_ctx) if (dirmngr_ctx)
return 0; /* fixme: We need a context for each thread or serialize return 0; /* fixme: We need a context for each thread or serialize
the access to the agent (which is suitable given that the access to the dirmngr */
the agent is not MT */
infostr = getenv ("DIRMNGR_INFO"); infostr = force_pipe_server? NULL : getenv ("DIRMNGR_INFO");
if (!infostr) if (!infostr)
{ {
const char *pgmname; const char *pgmname;
ASSUAN_CONTEXT ctx;
const char *argv[3]; const char *argv[3];
log_info (_("no running dirmngr - starting one\n")); log_info (_("no running dirmngr - starting one\n"));
@ -91,28 +91,51 @@ start_dirmngr (void)
/* connect to the agent and perform initial handshaking */ /* connect to the agent and perform initial handshaking */
rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, (char**)argv, 0); rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, (char**)argv, 0);
if (rc)
{
log_error ("can't connect to the dirmngr: %s\n", assuan_strerror (rc));
return seterr (No_Dirmngr);
}
dirmngr_ctx = ctx;
} }
else else
{ {
int prot;
int pid;
infostr = xstrdup (infostr); infostr = xstrdup (infostr);
if ( !(p = strchr (infostr, ':')) || p == infostr if ( !(p = strchr (infostr, ':')) || p == infostr)
/* || (p-infostr)+1 >= sizeof client_addr.sun_path */)
{ {
log_error (_("malformed DIRMNGR_INFO environment variable\n")); log_error (_("malformed DIRMNGR_INFO environment variable\n"));
xfree (infostr); xfree (infostr);
return seterr (General_Error); force_pipe_server = 1;
return start_dirmngr ();
}
*p++ = 0;
pid = atoi (p);
while (*p && *p != ':')
p++;
prot = *p? atoi (p+1) : 0;
if (prot != 1)
{
log_error (_("dirmngr protocol version %d is not supported\n"),
prot);
xfree (infostr);
force_pipe_server = 1;
return start_dirmngr ();
}
rc = assuan_socket_connect (&ctx, infostr, pid);
xfree (infostr);
if (rc == ASSUAN_Connect_Failed)
{
log_error (_("can't connect to the dirmngr - trying fall back\n"));
force_pipe_server = 1;
return start_dirmngr ();
} }
*p = 0;
log_error (_("socket based dirmngr communication not yet implemented\n"));
return seterr (Not_Implemented);
} }
if (rc)
{
log_error ("can't connect to the dirmngr: %s\n", assuan_strerror (rc));
return seterr (No_Dirmngr);
}
dirmngr_ctx = ctx;
if (DBG_AGENT) if (DBG_AGENT)
log_debug ("connection to dirmngr established\n"); log_debug ("connection to dirmngr established\n");
return 0; return 0;

View File

@ -36,24 +36,24 @@
enum cmd_and_opt_values { enum cmd_and_opt_values {
aNull = 0, aNull = 0,
oArmor = 'a', oArmor = 'a',
aDetachedSign = 'b', aDetachedSign = 'b',
aSym = 'c', aSym = 'c',
aDecrypt = 'd', aDecrypt = 'd',
aEncr = 'e', aEncr = 'e',
oInteractive = 'i', oInteractive = 'i',
oKOption = 'k', oKOption = 'k',
oDryRun = 'n', oDryRun = 'n',
oOutput = 'o', oOutput = 'o',
oQuiet = 'q', oQuiet = 'q',
oRecipient = 'r', oRecipient = 'r',
aSign = 's', aSign = 's',
oTextmodeShort= 't', oTextmodeShort= 't',
oUser = 'u', oUser = 'u',
oVerbose = 'v', oVerbose = 'v',
oCompress = 'z', oCompress = 'z',
oNotation = 'N', oNotation = 'N',
oBatch = 500, oBatch = 500,
aClearsign, aClearsign,
aStore, aStore,
aKeygen, aKeygen,
@ -96,6 +96,7 @@ enum cmd_and_opt_values {
oNoArmor, oNoArmor,
oDisableCRLChecks, oDisableCRLChecks,
oEnableCRLChecks,
oTextmode, oTextmode,
oFingerprint, oFingerprint,
@ -226,6 +227,7 @@ static ARGPARSE_OPTS opts[] = {
{ oDisableCRLChecks, "disable-crl-checks", 0, N_("never consult a CRL")}, { oDisableCRLChecks, "disable-crl-checks", 0, N_("never consult a CRL")},
{ oEnableCRLChecks, "enable-crl-checks", 0, "@"},
#if 0 #if 0
@ -736,6 +738,9 @@ main ( int argc, char **argv)
case oDisableCRLChecks: case oDisableCRLChecks:
opt.no_crl_check = 1; opt.no_crl_check = 1;
break; break;
case oEnableCRLChecks:
opt.no_crl_check = 0;
break;
case oOutput: opt.outfile = pargs.r.ret_str; break; case oOutput: opt.outfile = pargs.r.ret_str; break;