mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
* gpg-agent.c (parse_rereadable_options): New arg REREAD. Allow
changing oLogFile. (current_logfile): New. * logging.c (log_set_file): Make sure the log stream will be closed even if the stderr fileno will be assigned to a new socket.
This commit is contained in:
parent
6d96ca16cf
commit
623fad67a5
@ -1,3 +1,9 @@
|
||||
2004-04-30 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* gpg-agent.c (parse_rereadable_options): New arg REREAD. Allow
|
||||
changing oLogFile.
|
||||
(current_logfile): New.
|
||||
|
||||
2004-04-26 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* call-scd.c (start_scd): Do not register an event signal if we
|
||||
|
@ -155,6 +155,10 @@ static char *config_filename;
|
||||
/* Helper to implement --debug-level */
|
||||
static const char *debug_level;
|
||||
|
||||
/* Keep track of the current log file so that we can avoid updating
|
||||
the log file afte a SIGHUP if id didn't changed. Malloced. */
|
||||
static char *current_logfile;
|
||||
|
||||
/* Local prototypes. */
|
||||
static void create_directories (void);
|
||||
#ifdef USE_GNU_PTH
|
||||
@ -317,9 +321,10 @@ cleanup_sh (int sig)
|
||||
/* Handle options which are allowed to be reset after program start.
|
||||
Return true when the current option in PARGS could be handled and
|
||||
false if not. As a special feature, passing a value of NULL for
|
||||
PARGS, resets the options to the default. */
|
||||
PARGS, resets the options to the default. REREAD should be set
|
||||
true if it is not the initial option parsing. */
|
||||
static int
|
||||
parse_rereadable_options (ARGPARSE_ARGS *pargs)
|
||||
parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
|
||||
{
|
||||
if (!pargs)
|
||||
{ /* reset mode */
|
||||
@ -343,6 +348,16 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs)
|
||||
case oDebugAll: opt.debug = ~0; break;
|
||||
case oDebugLevel: debug_level = pargs->r.ret_str; break;
|
||||
|
||||
case oLogFile:
|
||||
if (!current_logfile || !pargs->r.ret_str
|
||||
|| strcmp (current_logfile, pargs->r.ret_str))
|
||||
{
|
||||
log_set_file (pargs->r.ret_str);
|
||||
xfree (current_logfile);
|
||||
current_logfile = xtrystrdup (pargs->r.ret_str);
|
||||
}
|
||||
break;
|
||||
|
||||
case oNoGrab: opt.no_grab = 1; break;
|
||||
|
||||
case oPinentryProgram: opt.pinentry_program = pargs->r.ret_str; break;
|
||||
@ -424,7 +439,7 @@ main (int argc, char **argv )
|
||||
|
||||
may_coredump = disable_core_dumps ();
|
||||
|
||||
parse_rereadable_options (NULL); /* Reset them to default values. */
|
||||
parse_rereadable_options (NULL, 0); /* Reset them to default values. */
|
||||
|
||||
shell = getenv ("SHELL");
|
||||
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
|
||||
@ -503,7 +518,7 @@ main (int argc, char **argv )
|
||||
|
||||
while (optfile_parse( configfp, configname, &configlineno, &pargs, opts) )
|
||||
{
|
||||
if (parse_rereadable_options (&pargs))
|
||||
if (parse_rereadable_options (&pargs, 0))
|
||||
continue; /* Already handled */
|
||||
switch (pargs.r_opt)
|
||||
{
|
||||
@ -626,7 +641,7 @@ main (int argc, char **argv )
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME,
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME,
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
|
||||
GC_OPT_FLAG_NONE );
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME );
|
||||
printf ("default-cache-ttl:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, DEFAULT_CACHE_TTL );
|
||||
printf ("no-grab:%lu:\n",
|
||||
@ -659,6 +674,7 @@ main (int argc, char **argv )
|
||||
log_set_prefix (NULL, (JNLIB_LOG_WITH_PREFIX
|
||||
|JNLIB_LOG_WITH_TIME
|
||||
|JNLIB_LOG_WITH_PID));
|
||||
current_logfile = xstrdup (logfile);
|
||||
}
|
||||
|
||||
/* Make sure that we have a default ttyname. */
|
||||
@ -957,7 +973,7 @@ reread_configuration (void)
|
||||
return;
|
||||
}
|
||||
|
||||
parse_rereadable_options (NULL); /* Start from the default values. */
|
||||
parse_rereadable_options (NULL, 1); /* Start from the default values. */
|
||||
|
||||
memset (&pargs, 0, sizeof pargs);
|
||||
dummy = 0;
|
||||
@ -968,7 +984,7 @@ reread_configuration (void)
|
||||
if (pargs.r_opt < -1)
|
||||
pargs.err = 1; /* Print a warning. */
|
||||
else /* Try to parse this option - ignore unchangeable ones. */
|
||||
parse_rereadable_options (&pargs);
|
||||
parse_rereadable_options (&pargs, 1);
|
||||
}
|
||||
fclose (fp);
|
||||
set_debug ();
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-04-30 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* logging.c (log_set_file): Make sure the log stream will be
|
||||
closed even if the stderr fileno will be assigned to a new socket.
|
||||
|
||||
2004-04-16 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* logging.h (JNLIB_LOG_WITH_PREFIX): Add constants for the flag
|
||||
|
@ -211,7 +211,7 @@ fun_closer (void *cookie_arg)
|
||||
|
||||
|
||||
|
||||
/* Set the file to write log to. The sepcial names NULL and "_" may
|
||||
/* Set the file to write log to. The special names NULL and "-" may
|
||||
be used to select stderr and names formatted like
|
||||
"socket:///home/foo/mylogs" may be used to write the logging to the
|
||||
socket "/home/foo/mylogs". If the connection to the socket fails
|
||||
@ -258,6 +258,13 @@ log_set_file (const char *name)
|
||||
/* We always need to print the prefix and the pid, so that the
|
||||
server reading the socket can do something meanigful. */
|
||||
force_prefixes = 1;
|
||||
/* On success close the old logstream right now, so that we are
|
||||
really sure it has been closed. */
|
||||
if (fp)
|
||||
{
|
||||
fclose (logstream);
|
||||
logstream = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
fp = (name && strcmp(name,"-"))? fopen (name, "a") : stderr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user