1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Fix regression in logging.

Add a registry key to enable catch-all remote debugging for W32.
Replace more stdio stuff by estream.
This commit is contained in:
Werner Koch 2010-08-18 19:25:15 +00:00
parent 7e752a4208
commit 34dde96669
20 changed files with 423 additions and 294 deletions

View file

@ -1,3 +1,13 @@
2010-08-16 Werner Koch <wk@g10code.com>
* gpgconf.c (get_outfp): Change to use estream.
(main): Replace fprintf by es_fprintf.
* gpgconf-comp.c (gc_component_list_components)
(gc_check_programs, gc_component_list_options)
(gc_component_change_options, gc_component_check_options)
(list_one_option, gc_process_gpgconf_conf): Replace FILE* args by
estream_t.
2010-08-13 Werner Koch <wk@g10code.com>
* Makefile.am (gpgkey2ssh_LDADD): Add NETLIBS.

View file

@ -994,7 +994,9 @@ do_open (char *line)
if (fd >= 0 && fd < DIM (open_fd_table))
{
open_fd_table[fd].inuse = 1;
#warning fixme: implement our pipe emulation.
#ifdef HAVE_W32CE_SYSTEM
# warning fixme: implement our pipe emulation.
#endif
#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM)
{
HANDLE prochandle, handle, newhandle;
@ -1246,11 +1248,11 @@ main (int argc, char **argv)
if (opt.exec)
{
int no_close[3];
assuan_fd_t no_close[3];
no_close[0] = assuan_fd_from_posix_fd (fileno (stderr));
no_close[0] = assuan_fd_from_posix_fd (es_fileno (es_stderr));
no_close[1] = assuan_fd_from_posix_fd (log_get_fd ());
no_close[2] = -1;
no_close[2] = ASSUAN_INVALID_FD;
rc = assuan_new (&ctx);
if (rc)

View file

@ -1284,7 +1284,7 @@ percent_deescape (const char *src)
/* List all components that are available. */
void
gc_component_list_components (FILE *out)
gc_component_list_components (estream_t out)
{
gc_component_t component;
gc_option_t *option;
@ -1320,9 +1320,9 @@ gc_component_list_components (FILE *out)
desc = gc_component[component].desc;
desc = my_dgettext (gc_component[component].desc_domain, desc);
fprintf (out, "%s:%s:",
gc_component[component].name, gc_percent_escape (desc));
fprintf (out, "%s\n", gc_percent_escape (pgmname));
es_fprintf (out, "%s:%s:",
gc_component[component].name, gc_percent_escape (desc));
es_fprintf (out, "%s\n", gc_percent_escape (pgmname));
}
}
}
@ -1432,7 +1432,7 @@ collect_error_output (int fd, const char *tag)
/* Check the options of a single component. Returns 0 if everything
is OK. */
int
gc_component_check_options (int component, FILE *out, const char *conf_file)
gc_component_check_options (int component, estream_t out, const char *conf_file)
{
gpg_error_t err;
unsigned int result;
@ -1525,24 +1525,24 @@ gc_component_check_options (int component, FILE *out, const char *conf_file)
desc = gc_component[component].desc;
desc = my_dgettext (gc_component[component].desc_domain, desc);
fprintf (out, "%s:%s:",
gc_component[component].name, gc_percent_escape (desc));
fputs (gc_percent_escape (pgmname), out);
fprintf (out, ":%d:%d:", !(result & 1), !(result & 2));
es_fprintf (out, "%s:%s:",
gc_component[component].name, gc_percent_escape (desc));
es_fputs (gc_percent_escape (pgmname), out);
es_fprintf (out, ":%d:%d:", !(result & 1), !(result & 2));
for (errptr = errlines; errptr; errptr = errptr->next)
{
if (errptr != errlines)
fputs ("\n:::::", out); /* Continuation line. */
es_fputs ("\n:::::", out); /* Continuation line. */
if (errptr->fname)
fputs (gc_percent_escape (errptr->fname), out);
putc (':', out);
es_fputs (gc_percent_escape (errptr->fname), out);
es_putc (':', out);
if (errptr->fname)
fprintf (out, "%u", errptr->lineno);
putc (':', out);
fputs (gc_percent_escape (errptr->errtext), out);
putc (':', out);
es_fprintf (out, "%u", errptr->lineno);
es_putc (':', out);
es_fputs (gc_percent_escape (errptr->errtext), out);
es_putc (':', out);
}
putc ('\n', out);
es_putc ('\n', out);
}
while (errlines)
@ -1558,7 +1558,7 @@ gc_component_check_options (int component, FILE *out, const char *conf_file)
/* Check all components that are available. */
void
gc_check_programs (FILE *out)
gc_check_programs (estream_t out)
{
gc_component_t component;
@ -1587,7 +1587,7 @@ gc_component_find (const char *name)
/* List the option OPTION. */
static void
list_one_option (const gc_option_t *option, FILE *out)
list_one_option (const gc_option_t *option, estream_t out)
{
const char *desc = NULL;
char *arg_name = NULL;
@ -1617,16 +1617,16 @@ list_one_option (const gc_option_t *option, FILE *out)
FIELDS. */
/* The name field. */
fprintf (out, "%s", option->name);
es_fprintf (out, "%s", option->name);
/* The flags field. */
fprintf (out, ":%lu", option->flags);
es_fprintf (out, ":%lu", option->flags);
if (opt.verbose)
{
putc (' ', out);
es_putc (' ', out);
if (!option->flags)
fprintf (out, "none");
es_fprintf (out, "none");
else
{
unsigned long flags = option->flags;
@ -1640,8 +1640,8 @@ list_one_option (const gc_option_t *option, FILE *out)
if (first)
first = 0;
else
putc (',', out);
fprintf (out, "%s", gc_flag[flag].name);
es_putc (',', out);
es_fprintf (out, "%s", gc_flag[flag].name);
}
flags >>= 1;
flag++;
@ -1650,34 +1650,33 @@ list_one_option (const gc_option_t *option, FILE *out)
}
/* The level field. */
fprintf (out, ":%u", option->level);
es_fprintf (out, ":%u", option->level);
if (opt.verbose)
fprintf (out, " %s", gc_level[option->level].name);
es_fprintf (out, " %s", gc_level[option->level].name);
/* The description field. */
fprintf (out, ":%s", desc ? gc_percent_escape (desc) : "");
es_fprintf (out, ":%s", desc ? gc_percent_escape (desc) : "");
/* The type field. */
fprintf (out, ":%u", option->arg_type);
es_fprintf (out, ":%u", option->arg_type);
if (opt.verbose)
fprintf (out, " %s", gc_arg_type[option->arg_type].name);
es_fprintf (out, " %s", gc_arg_type[option->arg_type].name);
/* The alternate type field. */
fprintf (out, ":%u", gc_arg_type[option->arg_type].fallback);
es_fprintf (out, ":%u", gc_arg_type[option->arg_type].fallback);
if (opt.verbose)
fprintf (out, " %s",
gc_arg_type[gc_arg_type[option->arg_type].fallback].name);
es_fprintf (out, " %s",
gc_arg_type[gc_arg_type[option->arg_type].fallback].name);
/* The argument name field. */
fprintf (out, ":%s", arg_name ? gc_percent_escape (arg_name) : "");
if (arg_name)
xfree (arg_name);
es_fprintf (out, ":%s", arg_name ? gc_percent_escape (arg_name) : "");
xfree (arg_name);
/* The default value field. */
fprintf (out, ":%s", option->default_value ? option->default_value : "");
es_fprintf (out, ":%s", option->default_value ? option->default_value : "");
/* The default argument field. */
fprintf (out, ":%s", option->default_arg ? option->default_arg : "");
es_fprintf (out, ":%s", option->default_arg ? option->default_arg : "");
/* The value field. */
if (gc_arg_type[option->arg_type].fallback == GC_ARG_TYPE_NONE
@ -1685,19 +1684,19 @@ list_one_option (const gc_option_t *option, FILE *out)
&& option->value)
/* The special format "1,1,1,1,...,1" is converted to a number
here. */
fprintf (out, ":%u", (unsigned int)((strlen (option->value) + 1) / 2));
es_fprintf (out, ":%u", (unsigned int)((strlen (option->value) + 1) / 2));
else
fprintf (out, ":%s", option->value ? option->value : "");
es_fprintf (out, ":%s", option->value ? option->value : "");
/* ADD NEW FIELDS HERE. */
putc ('\n', out);
es_putc ('\n', out);
}
/* List all options of the component COMPONENT. */
void
gc_component_list_options (int component, FILE *out)
gc_component_list_options (int component, estream_t out)
{
const gc_option_t *option = gc_component[component].options;
@ -2980,7 +2979,7 @@ change_one_value (gc_option_t *option, int *runtime,
modifications are expected to already have been set to the global
table. */
void
gc_component_change_options (int component, FILE *in, FILE *out)
gc_component_change_options (int component, estream_t in, estream_t out)
{
int err = 0;
int runtime[GC_BACKEND_NR];
@ -3004,7 +3003,7 @@ gc_component_change_options (int component, FILE *in, FILE *out)
if (in)
{
/* Read options from the file IN. */
while ((length = read_line (in, &line, &line_len, NULL)) > 0)
while ((length = es_read_line (in, &line, &line_len, NULL)) > 0)
{
char *linep;
unsigned long flags = 0;
@ -3347,7 +3346,7 @@ key_matches_user_or_group (char *user)
returned on error. */
int
gc_process_gpgconf_conf (const char *fname_arg, int update, int defaults,
FILE *listfp)
estream_t listfp)
{
int result = 0;
char *line = NULL;
@ -3560,19 +3559,19 @@ gc_process_gpgconf_conf (const char *fname_arg, int update, int defaults,
*p = 0; /* We better strip any extra stuff. */
}
fprintf (listfp, "k:%s:", gc_percent_escape (key));
fprintf (listfp, "%s\n", group? gc_percent_escape (group):"");
es_fprintf (listfp, "k:%s:", gc_percent_escape (key));
es_fprintf (listfp, "%s\n", group? gc_percent_escape (group):"");
}
/* All other lines are rule records. */
fprintf (listfp, "r:::%s:%s:%s:",
gc_component[component_id].name,
option_info->name? option_info->name : "",
flags? flags : "");
es_fprintf (listfp, "r:::%s:%s:%s:",
gc_component[component_id].name,
option_info->name? option_info->name : "",
flags? flags : "");
if (value != empty)
fprintf (listfp, "\"%s", gc_percent_escape (value));
es_fprintf (listfp, "\"%s", gc_percent_escape (value));
putc ('\n', listfp);
es_putc ('\n', listfp);
}
/* Check whether the key matches but do this only if we are not

View file

@ -118,19 +118,19 @@ my_strusage( int level )
/* Return the fp for the output. This is usually stdout unless
--output has been used. In the latter case this function opens
that file. */
static FILE *
get_outfp (FILE **fp)
static estream_t
get_outfp (estream_t *fp)
{
if (!*fp)
{
if (opt.outfile)
{
*fp = fopen (opt.outfile, "w");
*fp = es_fopen (opt.outfile, "w");
if (!*fp)
gc_error (1, errno, "can not open `%s'", opt.outfile);
}
else
*fp = stdout;
*fp = es_stdout;
}
return *fp;
}
@ -144,7 +144,7 @@ main (int argc, char **argv)
const char *fname;
int no_more_options = 0;
enum cmd_and_opt_values cmd = 0;
FILE *outfp = NULL;
estream_t outfp = NULL;
gnupg_reopen_std ("gpgconf");
set_strusage (my_strusage);
@ -211,10 +211,10 @@ main (int argc, char **argv)
case aCheckOptions:
if (!fname)
{
fputs (_("usage: gpgconf [options] "), stderr);
putc ('\n',stderr);
fputs (_("Need one component argument"), stderr);
putc ('\n',stderr);
es_fputs (_("usage: gpgconf [options] "), es_stderr);
es_putc ('\n', es_stderr);
es_fputs (_("Need one component argument"), es_stderr);
es_putc ('\n', es_stderr);
exit (2);
}
else
@ -222,8 +222,8 @@ main (int argc, char **argv)
int idx = gc_component_find (fname);
if (idx < 0)
{
fputs (_("Component not found"), stderr);
putc ('\n', stderr);
es_fputs (_("Component not found"), es_stderr);
es_putc ('\n', es_stderr);
exit (1);
}
gc_component_retrieve_options (idx);
@ -232,7 +232,7 @@ main (int argc, char **argv)
if (cmd == aListOptions)
gc_component_list_options (idx, get_outfp (&outfp));
else if (cmd == aChangeOptions)
gc_component_change_options (idx, stdin, get_outfp (&outfp));
gc_component_change_options (idx, es_stdin, get_outfp (&outfp));
else
gc_component_check_options (idx, get_outfp (&outfp), NULL);
}
@ -252,8 +252,8 @@ main (int argc, char **argv)
idx = gc_component_find (fname);
if (idx < 0)
{
fputs (_("Component not found"), stderr);
putc ('\n', stderr);
es_fputs (_("Component not found"), es_stderr);
es_putc ('\n', es_stderr);
exit (1);
}
else
@ -276,10 +276,10 @@ main (int argc, char **argv)
case aApplyDefaults:
if (fname)
{
fputs (_("usage: gpgconf [options] "), stderr);
putc ('\n',stderr);
fputs (_("No argument allowed"), stderr);
putc ('\n',stderr);
es_fputs (_("usage: gpgconf [options] "), es_stderr);
es_putc ('\n', es_stderr);
es_fputs (_("No argument allowed"), es_stderr);
es_putc ('\n', es_stderr);
exit (2);
}
gc_component_retrieve_options (-1);
@ -290,20 +290,20 @@ main (int argc, char **argv)
case aListDirs:
/* Show the system configuration directories for gpgconf. */
get_outfp (&outfp);
fprintf (outfp, "sysconfdir:%s\n",
gc_percent_escape (gnupg_sysconfdir ()));
fprintf (outfp, "bindir:%s\n",
gc_percent_escape (gnupg_bindir ()));
fprintf (outfp, "libexecdir:%s\n",
gc_percent_escape (gnupg_libexecdir ()));
fprintf (outfp, "libdir:%s\n",
gc_percent_escape (gnupg_libdir ()));
fprintf (outfp, "datadir:%s\n",
gc_percent_escape (gnupg_datadir ()));
fprintf (outfp, "localedir:%s\n",
gc_percent_escape (gnupg_localedir ()));
fprintf (outfp, "dirmngr-socket:%s\n",
gc_percent_escape (dirmngr_socket_name ()));
es_fprintf (outfp, "sysconfdir:%s\n",
gc_percent_escape (gnupg_sysconfdir ()));
es_fprintf (outfp, "bindir:%s\n",
gc_percent_escape (gnupg_bindir ()));
es_fprintf (outfp, "libexecdir:%s\n",
gc_percent_escape (gnupg_libexecdir ()));
es_fprintf (outfp, "libdir:%s\n",
gc_percent_escape (gnupg_libdir ()));
es_fprintf (outfp, "datadir:%s\n",
gc_percent_escape (gnupg_datadir ()));
es_fprintf (outfp, "localedir:%s\n",
gc_percent_escape (gnupg_localedir ()));
es_fprintf (outfp, "dirmngr-socket:%s\n",
gc_percent_escape (dirmngr_socket_name ()));
{
char *infostr = getenv ("GPG_AGENT_INFO");
@ -323,21 +323,21 @@ main (int argc, char **argv)
else
*tmp = 0;
}
fprintf (outfp, "agent-socket:%s\n",
infostr? gc_percent_escape (infostr) : "");
es_fprintf (outfp, "agent-socket:%s\n",
infostr? gc_percent_escape (infostr) : "");
xfree (infostr);
}
{
/* We need to use make_filename to expand a possible "~/". */
char *tmp = make_filename (default_homedir (), NULL);
fprintf (outfp, "homedir:%s\n", gc_percent_escape (tmp));
es_fprintf (outfp, "homedir:%s\n", gc_percent_escape (tmp));
xfree (tmp);
}
break;
}
if (outfp && outfp != stdout)
if (fclose (outfp))
if (outfp != es_stdout)
if (es_fclose (outfp))
gc_error (1, errno, "error closing `%s'", opt.outfile);
return 0;

View file

@ -48,10 +48,10 @@ void gc_error (int status, int errnum, const char *fmt, ...);
void gc_component_reload (int component);
/* List all components that are available. */
void gc_component_list_components (FILE *out);
void gc_component_list_components (estream_t out);
/* List all programs along with their status. */
void gc_check_programs (FILE *out);
void gc_check_programs (estream_t out);
/* Find the component with the name NAME. Returns -1 if not
found. */
@ -62,19 +62,19 @@ int gc_component_find (const char *name);
void gc_component_retrieve_options (int component);
/* List all options of the component COMPONENT. */
void gc_component_list_options (int component, FILE *out);
void gc_component_list_options (int component, estream_t out);
/* Read the modifications from IN and apply them. */
void gc_component_change_options (int component, FILE *in, FILE *out);
void gc_component_change_options (int component, estream_t in, estream_t out);
/* Check the options of a single component. Returns 0 if everything
is OK. */
int gc_component_check_options (int component, FILE *out,
int gc_component_check_options (int component, estream_t out,
const char *conf_file);
/* Process global configuration file. */
int gc_process_gpgconf_conf (const char *fname, int update, int defaults,
FILE *listfp);
estream_t listfp);
#endif /*GPGCONF_H*/