mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Remove superfluous parameter.
Make self-check interval larger
This commit is contained in:
parent
eb4d690db2
commit
41a33e0c78
@ -1,3 +1,7 @@
|
||||
2010-11-26 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpg-agent.c (CHECK_OWN_SOCKET_INTERVAL): New.
|
||||
|
||||
2010-11-23 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (gpg_agent_LDFLAGS): Add extra_bin_ldflags.
|
||||
|
@ -202,6 +202,14 @@ static ARGPARSE_OPTS opts[] = {
|
||||
#define TIMERTICK_INTERVAL (2) /* Seconds. */
|
||||
#endif
|
||||
|
||||
/* How often shall we check our own socket in standard socket mode.
|
||||
For WindowsCE be use a longer interval because we don't expect any
|
||||
problems and resources are anyway scare. */
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
# define CHECK_OWN_SOCKET_INTERVAL (300)
|
||||
#else
|
||||
# define CHECK_OWN_SOCKET_INTERVAL (60) /* Seconds. */
|
||||
#endif
|
||||
|
||||
/* The list of open file descriptors at startup. Note that this list
|
||||
has been allocated using the standard malloc. */
|
||||
@ -1682,8 +1690,8 @@ handle_tick (void)
|
||||
}
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
/* Code to be run every minute. */
|
||||
if (last_minute + 60 <= time (NULL))
|
||||
/* Code to be run from time to time. */
|
||||
if (last_minute + CHECK_OWN_SOCKET_INTERVAL <= time (NULL))
|
||||
{
|
||||
check_own_socket ();
|
||||
last_minute = time (NULL);
|
||||
@ -2179,7 +2187,7 @@ check_own_socket_thread (void *arg)
|
||||
|
||||
/* Check whether we are still listening on our own socket. In case
|
||||
another gpg-agent process started after us has taken ownership of
|
||||
our socket, we woulf linger around without any real task. Thus we
|
||||
our socket, we would linger around without any real task. Thus we
|
||||
better check once in a while whether we are really needed. */
|
||||
static void
|
||||
check_own_socket (void)
|
||||
|
@ -1,3 +1,8 @@
|
||||
2010-11-25 Werner Koch <wk@g10code.com>
|
||||
|
||||
* asshelp.c (start_new_gpg_agent): Change style of startup info.
|
||||
(start_new_dirmngr): Ditto.
|
||||
|
||||
2010-11-23 Werner Koch <wk@g10code.com>
|
||||
|
||||
* asshelp.c (SECS_TO_WAIT_FOR_AGENT, SECS_TO_WAIT_FOR_DIRMNGR):
|
||||
|
@ -431,11 +431,12 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (verbose)
|
||||
log_info (_("waiting %d seconds for the agent "
|
||||
"to come up\n"), SECS_TO_WAIT_FOR_AGENT);
|
||||
for (i=0; i < SECS_TO_WAIT_FOR_AGENT; i++)
|
||||
{
|
||||
if (verbose)
|
||||
log_info (_("waiting for the agent "
|
||||
"to come up ... (%ds)\n"),
|
||||
SECS_TO_WAIT_FOR_AGENT - i);
|
||||
gnupg_sleep (1);
|
||||
err = assuan_socket_connect (ctx, sockname, 0, 0);
|
||||
if (!err)
|
||||
@ -443,7 +444,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
||||
if (verbose)
|
||||
{
|
||||
log_info (_("connection to agent "
|
||||
"established (%ds)\n"), i+1);
|
||||
"established\n"));
|
||||
did_success_msg = 1;
|
||||
}
|
||||
break;
|
||||
@ -624,11 +625,12 @@ start_new_dirmngr (assuan_context_t *r_ctx,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (verbose)
|
||||
log_info (_("waiting %d seconds for the dirmngr to come up\n"),
|
||||
SECS_TO_WAIT_FOR_DIRMNGR);
|
||||
for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++)
|
||||
{
|
||||
if (verbose)
|
||||
log_info (_("waiting for the dirmngr "
|
||||
"to come up ... (%ds)\n"),
|
||||
SECS_TO_WAIT_FOR_DIRMNGR - i);
|
||||
gnupg_sleep (1);
|
||||
err = assuan_socket_connect (ctx, sockname, 0, 0);
|
||||
if (!err)
|
||||
@ -636,7 +638,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
|
||||
if (verbose)
|
||||
{
|
||||
log_info (_("connection to the dirmngr"
|
||||
" established (%ds)\n"), i+1);
|
||||
" established\n"));
|
||||
did_success_msg = 1;
|
||||
}
|
||||
break;
|
||||
|
@ -1,3 +1,11 @@
|
||||
2010-11-25 Werner Koch <wk@g10code.com>
|
||||
|
||||
* base64.c (gpgsm_create_writer): Remove arg FP which is not used
|
||||
by any caller. Change all callers.
|
||||
(struct writer_cb_parm_s): Remove field FP.
|
||||
(do_putc, do_fputs): Remove and replace callers by direct calls to
|
||||
es_ functions.
|
||||
|
||||
2010-11-23 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (gpgsm_LDADD): Add extra_bin_ldflags.
|
||||
|
104
sm/base64.c
104
sm/base64.c
@ -72,10 +72,10 @@ struct reader_cb_parm_s
|
||||
|
||||
|
||||
/* Data used by the writer callbacks. */
|
||||
struct writer_cb_parm_s {
|
||||
FILE *fp; /* FP is only used if STREAM is NULL. */
|
||||
estream_t stream; /* Alternative output if not NULL. */
|
||||
|
||||
struct writer_cb_parm_s
|
||||
{
|
||||
estream_t stream; /* Output stream. */
|
||||
|
||||
const char *pem_name;
|
||||
|
||||
int wrote_begin;
|
||||
@ -404,27 +404,6 @@ simple_reader_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
|
||||
|
||||
|
||||
|
||||
/* Call either es_putc or the plain putc. */
|
||||
static void
|
||||
do_putc (int value, FILE *fp, estream_t stream)
|
||||
{
|
||||
if (stream)
|
||||
es_putc (value, stream);
|
||||
else
|
||||
putc (value, fp);
|
||||
}
|
||||
|
||||
/* Call either es_fputs or the plain fputs. */
|
||||
static void
|
||||
do_fputs (const char *string, FILE *fp, estream_t stream)
|
||||
{
|
||||
if (stream)
|
||||
es_fputs (string, stream);
|
||||
else
|
||||
fputs (string, fp);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
base64_writer_cb (void *cb_value, const void *buffer, size_t count)
|
||||
{
|
||||
@ -432,7 +411,6 @@ base64_writer_cb (void *cb_value, const void *buffer, size_t count)
|
||||
unsigned char radbuf[4];
|
||||
int i, c, idx, quad_count;
|
||||
const unsigned char *p;
|
||||
FILE *fp = parm->fp;
|
||||
estream_t stream = parm->stream;
|
||||
|
||||
if (!count)
|
||||
@ -442,9 +420,9 @@ base64_writer_cb (void *cb_value, const void *buffer, size_t count)
|
||||
{
|
||||
if (parm->pem_name)
|
||||
{
|
||||
do_fputs ("-----BEGIN ", fp, stream);
|
||||
do_fputs (parm->pem_name, fp, stream);
|
||||
do_fputs ("-----\n", fp, stream);
|
||||
es_fputs ("-----BEGIN ", stream);
|
||||
es_fputs (parm->pem_name, stream);
|
||||
es_fputs ("-----\n", stream);
|
||||
}
|
||||
parm->wrote_begin = 1;
|
||||
parm->base64.idx = 0;
|
||||
@ -463,16 +441,16 @@ base64_writer_cb (void *cb_value, const void *buffer, size_t count)
|
||||
{
|
||||
idx = 0;
|
||||
c = bintoasc[(*radbuf >> 2) & 077];
|
||||
do_putc (c, fp, stream);
|
||||
es_putc (c, stream);
|
||||
c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1] >> 4)&017))&077];
|
||||
do_putc (c, fp, stream);
|
||||
es_putc (c, stream);
|
||||
c = bintoasc[(((radbuf[1]<<2)&074)|((radbuf[2]>>6)&03))&077];
|
||||
do_putc (c, fp, stream);
|
||||
es_putc (c, stream);
|
||||
c = bintoasc[radbuf[2]&077];
|
||||
do_putc (c, fp, stream);
|
||||
es_putc (c, stream);
|
||||
if (++quad_count >= (64/4))
|
||||
{
|
||||
do_fputs (LF, fp, stream);
|
||||
es_fputs (LF, stream);
|
||||
quad_count = 0;
|
||||
}
|
||||
}
|
||||
@ -482,39 +460,32 @@ base64_writer_cb (void *cb_value, const void *buffer, size_t count)
|
||||
parm->base64.idx = idx;
|
||||
parm->base64.quad_count = quad_count;
|
||||
|
||||
return ((stream? es_ferror (stream) : ferror (fp))
|
||||
? gpg_error_from_syserror ()
|
||||
: 0);
|
||||
return es_ferror (stream)? gpg_error_from_syserror () : 0;
|
||||
}
|
||||
|
||||
|
||||
/* This callback is only used in stream mode. Hiowever, we don't
|
||||
restrict it to this. */
|
||||
static int
|
||||
plain_writer_cb (void *cb_value, const void *buffer, size_t count)
|
||||
{
|
||||
struct writer_cb_parm_s *parm = cb_value;
|
||||
FILE *fp = parm->fp;
|
||||
estream_t stream = parm->stream;
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
|
||||
if (stream)
|
||||
es_write (stream, buffer, count, NULL);
|
||||
else
|
||||
fwrite (buffer, count, 1, fp);
|
||||
es_write (stream, buffer, count, NULL);
|
||||
|
||||
return ((stream? es_ferror (stream) : ferror (fp))
|
||||
? gpg_error_from_syserror ()
|
||||
: 0);
|
||||
return es_ferror (stream)? gpg_error_from_syserror () : 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
base64_finish_write (struct writer_cb_parm_s *parm)
|
||||
{
|
||||
unsigned char radbuf[4];
|
||||
int i, c, idx, quad_count;
|
||||
FILE *fp = parm->fp;
|
||||
estream_t stream = parm->stream;
|
||||
|
||||
if (!parm->wrote_begin)
|
||||
@ -529,43 +500,41 @@ base64_finish_write (struct writer_cb_parm_s *parm)
|
||||
if (idx)
|
||||
{
|
||||
c = bintoasc[(*radbuf>>2)&077];
|
||||
do_putc (c, fp, stream);
|
||||
es_putc (c, stream);
|
||||
if (idx == 1)
|
||||
{
|
||||
c = bintoasc[((*radbuf << 4) & 060) & 077];
|
||||
do_putc (c, fp, stream);
|
||||
do_putc ('=', fp, stream);
|
||||
do_putc ('=', fp, stream);
|
||||
es_putc (c, stream);
|
||||
es_putc ('=', stream);
|
||||
es_putc ('=', stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077];
|
||||
do_putc (c, fp, stream);
|
||||
es_putc (c, stream);
|
||||
c = bintoasc[((radbuf[1] << 2) & 074) & 077];
|
||||
do_putc (c, fp, stream);
|
||||
do_putc ('=', fp, stream);
|
||||
es_putc (c, stream);
|
||||
es_putc ('=', stream);
|
||||
|
||||
}
|
||||
if (++quad_count >= (64/4))
|
||||
{
|
||||
do_fputs (LF, fp, stream);
|
||||
es_fputs (LF, stream);
|
||||
quad_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (quad_count)
|
||||
do_fputs (LF, fp, stream);
|
||||
es_fputs (LF, stream);
|
||||
|
||||
if (parm->pem_name)
|
||||
{
|
||||
do_fputs ("-----END ", fp, stream);
|
||||
do_fputs (parm->pem_name, fp, stream);
|
||||
do_fputs ("-----\n", fp, stream);
|
||||
es_fputs ("-----END ", stream);
|
||||
es_fputs (parm->pem_name, stream);
|
||||
es_fputs ("-----\n", stream);
|
||||
}
|
||||
|
||||
return ((stream? es_ferror (stream) : ferror (fp))
|
||||
? gpg_error_from_syserror ()
|
||||
: 0);
|
||||
return es_ferror (stream)? gpg_error_from_syserror () : 0;
|
||||
}
|
||||
|
||||
|
||||
@ -651,15 +620,14 @@ gpgsm_destroy_reader (Base64Context ctx)
|
||||
|
||||
|
||||
|
||||
/* Create a writer for the given stream FP or STREAM. Depending on
|
||||
/* Create a writer for the given STREAM. Depending on
|
||||
the control information an output encoding is automagically
|
||||
choosen. The function returns a Base64Context object which must be
|
||||
passed to the gpgme_destroy_writer function. The created
|
||||
KsbaWriter object is also returned, but the caller must not call
|
||||
the ksba_reader_release function on. */
|
||||
the ksba_reader_release function on it. */
|
||||
int
|
||||
gpgsm_create_writer (Base64Context *ctx,
|
||||
ctrl_t ctrl, FILE *fp, estream_t stream,
|
||||
gpgsm_create_writer (Base64Context *ctx, ctrl_t ctrl, estream_t stream,
|
||||
ksba_writer_t *r_writer)
|
||||
{
|
||||
int rc;
|
||||
@ -679,7 +647,6 @@ gpgsm_create_writer (Base64Context *ctx,
|
||||
|
||||
if (ctrl->create_pem || ctrl->create_base64)
|
||||
{
|
||||
(*ctx)->u.wparm.fp = fp;
|
||||
(*ctx)->u.wparm.stream = stream;
|
||||
if (ctrl->create_pem)
|
||||
(*ctx)->u.wparm.pem_name = ctrl->pem_name? ctrl->pem_name
|
||||
@ -688,12 +655,11 @@ gpgsm_create_writer (Base64Context *ctx,
|
||||
}
|
||||
else if (stream)
|
||||
{
|
||||
(*ctx)->u.wparm.fp = fp;
|
||||
(*ctx)->u.wparm.stream = stream;
|
||||
rc = ksba_writer_set_cb (w, plain_writer_cb, &(*ctx)->u.wparm);
|
||||
}
|
||||
else
|
||||
rc = ksba_writer_set_file (w, fp);
|
||||
rc = gpg_error (GPG_ERR_INV_ARG);
|
||||
|
||||
if (rc)
|
||||
{
|
||||
@ -719,7 +685,7 @@ gpgsm_finish_writer (Base64Context ctx)
|
||||
if (parm->did_finish)
|
||||
return 0; /* Already done. */
|
||||
parm->did_finish = 1;
|
||||
if (!parm->fp && !parm->stream)
|
||||
if (!parm->stream)
|
||||
return 0; /* Callback was not used. */
|
||||
return base64_finish_write (parm);
|
||||
}
|
||||
|
@ -854,7 +854,7 @@ gpgsm_genkey (ctrl_t ctrl, estream_t in_stream, estream_t out_stream)
|
||||
ksba_writer_t writer;
|
||||
|
||||
ctrl->pem_name = "CERTIFICATE REQUEST";
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_stream, &writer);
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, out_stream, &writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gpg_strerror (rc));
|
||||
|
@ -279,7 +279,7 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
|
||||
goto leave;
|
||||
}
|
||||
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer);
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gpg_strerror (rc));
|
||||
|
@ -361,7 +361,7 @@ gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int data_fd, estream_t out_fp)
|
||||
encparm.fp = data_fp;
|
||||
|
||||
ctrl->pem_name = "ENCRYPTED MESSAGE";
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer);
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gpg_strerror (rc));
|
||||
|
@ -262,8 +262,7 @@ gpgsm_export (ctrl_t ctrl, strlist_t names, estream_t stream)
|
||||
if (!b64writer)
|
||||
{
|
||||
ctrl->pem_name = "CERTIFICATE";
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl,
|
||||
NULL, stream, &writer);
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, stream, &writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gpg_strerror (rc));
|
||||
@ -424,7 +423,7 @@ gpgsm_p12_export (ctrl_t ctrl, const char *name, estream_t stream)
|
||||
}
|
||||
|
||||
ctrl->pem_name = "PKCS12";
|
||||
err = gpgsm_create_writer (&b64writer, ctrl, NULL, stream, &writer);
|
||||
err = gpgsm_create_writer (&b64writer, ctrl, stream, &writer);
|
||||
if (err)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gpg_strerror (err));
|
||||
|
@ -261,7 +261,7 @@ int gpgsm_create_reader (Base64Context *ctx,
|
||||
int gpgsm_reader_eof_seen (Base64Context ctx);
|
||||
void gpgsm_destroy_reader (Base64Context ctx);
|
||||
int gpgsm_create_writer (Base64Context *ctx,
|
||||
ctrl_t ctrl, FILE *fp, estream_t stream,
|
||||
ctrl_t ctrl, estream_t stream,
|
||||
ksba_writer_t *r_writer);
|
||||
int gpgsm_finish_writer (Base64Context ctx);
|
||||
void gpgsm_destroy_writer (Base64Context ctx);
|
||||
|
@ -340,7 +340,7 @@ gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
|
||||
}
|
||||
|
||||
ctrl->pem_name = "SIGNED MESSAGE";
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer);
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gpg_strerror (rc));
|
||||
|
@ -134,7 +134,7 @@ gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, estream_t out_fp)
|
||||
|
||||
if (out_fp)
|
||||
{
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, NULL, out_fp, &writer);
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, &writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't create writer: %s\n", gpg_strerror (rc));
|
||||
|
Loading…
x
Reference in New Issue
Block a user