mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Add option --data to GETAUDITLOG command.
Return HTML formatted dummy output.
This commit is contained in:
parent
95b57d9337
commit
3d4ef0c814
5 changed files with 57 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
|||
2007-11-22 Werner Koch <wk@g10code.com>
|
||||
h2007-11-22 Werner Koch <wk@g10code.com>
|
||||
|
||||
* server.c (cmd_getauditlog): New.
|
||||
(register_commands): Register GETAUDITLOG
|
||||
(register_commands): Register GETAUDITLOG.
|
||||
|
||||
2007-11-19 Werner Koch <wk@g10code.com>
|
||||
|
||||
|
|
|
@ -1649,7 +1649,7 @@ main ( int argc, char **argv)
|
|||
case aVerify:
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
FILE *auditfp = NULL;
|
||||
estream_t auditfp = NULL;
|
||||
|
||||
set_binary (stdin);
|
||||
if (argc == 2 && opt.outfile)
|
||||
|
@ -1661,7 +1661,7 @@ main ( int argc, char **argv)
|
|||
{
|
||||
audit_release (ctrl.audit);
|
||||
ctrl.audit = audit_new ();
|
||||
auditfp = open_fwrite (auditlog);
|
||||
auditfp = open_es_fwrite (auditlog);
|
||||
}
|
||||
|
||||
if (!argc)
|
||||
|
@ -1682,8 +1682,7 @@ main ( int argc, char **argv)
|
|||
|
||||
if (fp && fp != stdout)
|
||||
fclose (fp);
|
||||
if (auditfp && auditfp != stdout)
|
||||
fclose (auditfp);
|
||||
es_fclose (auditfp);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
44
sm/server.c
44
sm/server.c
|
@ -934,36 +934,56 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||
|
||||
|
||||
|
||||
/* GETAUDITLOG
|
||||
/* GETAUDITLOG [--data]
|
||||
|
||||
!!!WORK in PROGRESS!!!
|
||||
|
||||
If --data is used, the output is send using D-lines and not to the
|
||||
source given by an OUTPUT command.
|
||||
*/
|
||||
static int
|
||||
cmd_getauditlog (assuan_context_t ctx, char *line)
|
||||
{
|
||||
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||
int out_fd;
|
||||
FILE *out_fp;
|
||||
estream_t out_stream;
|
||||
int opt_data;
|
||||
int rc;
|
||||
|
||||
opt_data = has_option (line, "--data");
|
||||
line = skip_options (line);
|
||||
|
||||
if (!ctrl->audit)
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
|
||||
out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
||||
if (out_fd == -1)
|
||||
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
||||
|
||||
out_fp = fdopen ( dup(out_fd), "w");
|
||||
if (!out_fp)
|
||||
if (opt_data)
|
||||
{
|
||||
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
|
||||
out_stream = es_fopencookie (ctx, "w", data_line_cookie_functions);
|
||||
if (!out_stream)
|
||||
return set_error (GPG_ERR_ASS_GENERAL,
|
||||
"error setting up a data stream");
|
||||
}
|
||||
audit_print_result (ctrl->audit, out_fp);
|
||||
else
|
||||
{
|
||||
out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
||||
if (out_fd == -1)
|
||||
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
||||
|
||||
out_stream = es_fdopen_nc ( dup (out_fd), "w");
|
||||
if (!out_stream)
|
||||
{
|
||||
return set_error (GPG_ERR_ASS_GENERAL, "es_fdopen() failed");
|
||||
}
|
||||
}
|
||||
|
||||
audit_print_result (ctrl->audit, out_stream);
|
||||
rc = 0;
|
||||
fclose (out_fp);
|
||||
|
||||
es_fclose (out_stream);
|
||||
|
||||
/* Close and reset the fd. */
|
||||
assuan_close_output_fd (ctx);
|
||||
if (!opt_data)
|
||||
assuan_close_output_fd (ctx);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue