mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01: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:
parent
7e752a4208
commit
34dde96669
@ -1,3 +1,7 @@
|
||||
2010-08-16 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpg-agent.c: Repalce remaining printf by es_printf.
|
||||
|
||||
2010-08-11 Werner Koch <wk@g10code.com>
|
||||
|
||||
* call-pinentry.c (agent_get_passphrase, agent_askpin): Fix
|
||||
|
@ -823,9 +823,9 @@ main (int argc, char **argv )
|
||||
|
||||
if (greeting)
|
||||
{
|
||||
fprintf (stderr, "%s %s; %s\n",
|
||||
es_fprintf (es_stderr, "%s %s; %s\n",
|
||||
strusage(11), strusage(13), strusage(14) );
|
||||
fprintf (stderr, "%s\n", strusage(15) );
|
||||
es_fprintf (es_stderr, "%s\n", strusage(15) );
|
||||
}
|
||||
#ifdef IS_DEVELOPMENT_VERSION
|
||||
/* We don't want to print it here because gpg-agent is useful of its
|
||||
@ -874,12 +874,12 @@ main (int argc, char **argv )
|
||||
filename = make_filename (opt.homedir, "gpg-agent.conf", NULL );
|
||||
filename_esc = percent_escape (filename, NULL);
|
||||
|
||||
printf ("gpgconf-gpg-agent.conf:%lu:\"%s\n",
|
||||
es_printf ("gpgconf-gpg-agent.conf:%lu:\"%s\n",
|
||||
GC_OPT_FLAG_DEFAULT, filename_esc);
|
||||
xfree (filename);
|
||||
xfree (filename_esc);
|
||||
|
||||
printf ("verbose:%lu:\n"
|
||||
es_printf ("verbose:%lu:\n"
|
||||
"quiet:%lu:\n"
|
||||
"debug-level:%lu:\"none:\n"
|
||||
"log-file:%lu:\n",
|
||||
@ -887,35 +887,35 @@ main (int argc, char **argv )
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME,
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME );
|
||||
printf ("default-cache-ttl:%lu:%d:\n",
|
||||
es_printf ("default-cache-ttl:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, DEFAULT_CACHE_TTL );
|
||||
printf ("default-cache-ttl-ssh:%lu:%d:\n",
|
||||
es_printf ("default-cache-ttl-ssh:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, DEFAULT_CACHE_TTL_SSH );
|
||||
printf ("max-cache-ttl:%lu:%d:\n",
|
||||
es_printf ("max-cache-ttl:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL );
|
||||
printf ("max-cache-ttl-ssh:%lu:%d:\n",
|
||||
es_printf ("max-cache-ttl-ssh:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL_SSH );
|
||||
printf ("enforce-passphrase-constraints:%lu:\n",
|
||||
es_printf ("enforce-passphrase-constraints:%lu:\n",
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
||||
printf ("min-passphrase-len:%lu:%d:\n",
|
||||
es_printf ("min-passphrase-len:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MIN_PASSPHRASE_LEN );
|
||||
printf ("min-passphrase-nonalpha:%lu:%d:\n",
|
||||
es_printf ("min-passphrase-nonalpha:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
|
||||
MIN_PASSPHRASE_NONALPHA);
|
||||
printf ("check-passphrase-pattern:%lu:\n",
|
||||
es_printf ("check-passphrase-pattern:%lu:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME);
|
||||
printf ("max-passphrase-days:%lu:%d:\n",
|
||||
es_printf ("max-passphrase-days:%lu:%d:\n",
|
||||
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
|
||||
MAX_PASSPHRASE_DAYS);
|
||||
printf ("enable-passphrase-history:%lu:\n",
|
||||
es_printf ("enable-passphrase-history:%lu:\n",
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
||||
printf ("no-grab:%lu:\n",
|
||||
es_printf ("no-grab:%lu:\n",
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
||||
printf ("ignore-cache-for-signing:%lu:\n",
|
||||
es_printf ("ignore-cache-for-signing:%lu:\n",
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
||||
printf ("allow-mark-trusted:%lu:\n",
|
||||
es_printf ("allow-mark-trusted:%lu:\n",
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
||||
printf ("disable-scdaemon:%lu:\n",
|
||||
es_printf ("disable-scdaemon:%lu:\n",
|
||||
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
||||
|
||||
agent_exit (0);
|
||||
@ -1026,7 +1026,7 @@ main (int argc, char **argv )
|
||||
fflush (NULL);
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
pid = getpid ();
|
||||
printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid);
|
||||
es_printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid);
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
pid = fork ();
|
||||
if (pid == (pid_t)-1)
|
||||
@ -1098,24 +1098,24 @@ main (int argc, char **argv )
|
||||
|
||||
if (env_file_name)
|
||||
{
|
||||
FILE *fp;
|
||||
estream_t fp;
|
||||
|
||||
fp = fopen (env_file_name, "w");
|
||||
fp = es_fopen (env_file_name, "w");
|
||||
if (!fp)
|
||||
log_error (_("error creating `%s': %s\n"),
|
||||
env_file_name, strerror (errno));
|
||||
else
|
||||
{
|
||||
fputs (infostr, fp);
|
||||
putc ('\n', fp);
|
||||
es_fputs (infostr, fp);
|
||||
es_putc ('\n', fp);
|
||||
if (opt.ssh_support)
|
||||
{
|
||||
fputs (infostr_ssh_sock, fp);
|
||||
putc ('\n', fp);
|
||||
fputs (infostr_ssh_pid, fp);
|
||||
putc ('\n', fp);
|
||||
es_fputs (infostr_ssh_sock, fp);
|
||||
es_putc ('\n', fp);
|
||||
es_fputs (infostr_ssh_pid, fp);
|
||||
es_putc ('\n', fp);
|
||||
}
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1163,22 +1163,24 @@ main (int argc, char **argv )
|
||||
if (csh_style)
|
||||
{
|
||||
*strchr (infostr, '=') = ' ';
|
||||
printf ("setenv %s\n", infostr);
|
||||
es_printf ("setenv %s\n", infostr);
|
||||
if (opt.ssh_support)
|
||||
{
|
||||
*strchr (infostr_ssh_sock, '=') = ' ';
|
||||
printf ("setenv %s\n", infostr_ssh_sock);
|
||||
es_printf ("setenv %s\n", infostr_ssh_sock);
|
||||
*strchr (infostr_ssh_pid, '=') = ' ';
|
||||
printf ("setenv %s\n", infostr_ssh_pid);
|
||||
es_printf ("setenv %s\n", infostr_ssh_pid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ( "%s; export GPG_AGENT_INFO;\n", infostr);
|
||||
es_printf ( "%s; export GPG_AGENT_INFO;\n", infostr);
|
||||
if (opt.ssh_support)
|
||||
{
|
||||
printf ("%s; export SSH_AUTH_SOCK;\n", infostr_ssh_sock);
|
||||
printf ("%s; export SSH_AGENT_PID;\n", infostr_ssh_pid);
|
||||
es_printf ("%s; export SSH_AUTH_SOCK;\n",
|
||||
infostr_ssh_sock);
|
||||
es_printf ("%s; export SSH_AGENT_PID;\n",
|
||||
infostr_ssh_pid);
|
||||
}
|
||||
}
|
||||
xfree (infostr);
|
||||
|
@ -1,5 +1,16 @@
|
||||
2010-08-18 Werner Koch <wk@g10code.com>
|
||||
|
||||
* logging.c (writen): Add arg IS_SOCKET.
|
||||
(fun_writer): Pass the is_socket flag.
|
||||
(do_logv) [W32]: Allow for a default log stream
|
||||
|
||||
* estream.c (struct estream_internal): Remove obsolete fields
|
||||
PRINT_FP, PRINT_ERRNO, PRINT_ERR and all remaining code cruft.
|
||||
|
||||
2010-08-16 Werner Koch <wk@g10code.com>
|
||||
|
||||
* estream.c (es_printf_unlocked, es_printf): New.
|
||||
|
||||
* asshelp.c (lock_agent_t): Rename to lock_spawn_t.
|
||||
(lock_agent_spawning, unlock_agent_spawning): Factor code out to ...
|
||||
(lock_spawning, unlock_spawning): .. new.
|
||||
|
@ -218,7 +218,7 @@ struct estream_internal
|
||||
es_cookie_seek_function_t func_seek;
|
||||
es_cookie_close_function_t func_close;
|
||||
int strategy;
|
||||
int fd;
|
||||
int fd; /* Value to return by es_fileno(). */
|
||||
struct
|
||||
{
|
||||
unsigned int err: 1;
|
||||
@ -227,11 +227,8 @@ struct estream_internal
|
||||
unsigned int deallocate_buffer: 1;
|
||||
unsigned int is_stdstream:1; /* This is a standard stream. */
|
||||
unsigned int stdstream_fd:2; /* 0, 1 or 2 for a standard stream. */
|
||||
unsigned int print_err: 1; /* Error in print_fun_writer. */
|
||||
unsigned int printable_fname_inuse: 1; /* es_fname_get has been used. */
|
||||
int print_errno; /* Errno from print_fun_writer. */
|
||||
size_t print_ntotal; /* Bytes written from in print_fun_writer. */
|
||||
FILE *print_fp; /* Stdio stream used by print_fun_writer. */
|
||||
size_t print_ntotal; /* Bytes written from in print_writer. */
|
||||
};
|
||||
|
||||
|
||||
@ -899,7 +896,8 @@ typedef struct estream_cookie_fp
|
||||
int no_close; /* If set we won't close the file pointer. */
|
||||
} *estream_cookie_fp_t;
|
||||
|
||||
/* Create function for fd objects. */
|
||||
|
||||
/* Create function for FILE objects. */
|
||||
static int
|
||||
es_func_fp_create (void **cookie, FILE *fp,
|
||||
unsigned int modeflags, int no_close)
|
||||
@ -948,12 +946,10 @@ es_func_fp_read (void *cookie, void *buffer, size_t size)
|
||||
/* Write function for FILE* objects. */
|
||||
static ssize_t
|
||||
es_func_fp_write (void *cookie, const void *buffer, size_t size)
|
||||
|
||||
{
|
||||
estream_cookie_fp_t file_cookie = cookie;
|
||||
size_t bytes_written;
|
||||
|
||||
|
||||
if (file_cookie->fp)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
@ -1285,10 +1281,7 @@ es_initialize (estream_t stream,
|
||||
stream->intern->func_close = functions.func_close;
|
||||
stream->intern->strategy = _IOFBF;
|
||||
stream->intern->fd = fd;
|
||||
stream->intern->print_err = 0;
|
||||
stream->intern->print_errno = 0;
|
||||
stream->intern->print_ntotal = 0;
|
||||
stream->intern->print_fp = NULL;
|
||||
stream->intern->indicators.err = 0;
|
||||
stream->intern->indicators.eof = 0;
|
||||
stream->intern->is_stdstream = 0;
|
||||
@ -1319,14 +1312,6 @@ es_deinitialize (estream_t stream)
|
||||
es_cookie_close_function_t func_close;
|
||||
int err, tmp_err;
|
||||
|
||||
if (stream->intern->print_fp)
|
||||
{
|
||||
int save_errno = errno;
|
||||
fclose (stream->intern->print_fp);
|
||||
stream->intern->print_fp = NULL;
|
||||
_set_errno (save_errno);
|
||||
}
|
||||
|
||||
func_close = stream->intern->func_close;
|
||||
|
||||
err = 0;
|
||||
@ -3205,6 +3190,38 @@ es_fprintf (estream_t ES__RESTRICT stream,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
es_printf_unlocked (const char *ES__RESTRICT format, ...)
|
||||
{
|
||||
int ret;
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, format);
|
||||
ret = es_print (es_stdout, format, ap);
|
||||
va_end (ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
es_printf (const char *ES__RESTRICT format, ...)
|
||||
{
|
||||
int ret;
|
||||
estream_t stream = es_stdout;
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, format);
|
||||
ESTREAM_LOCK (stream);
|
||||
ret = es_print (stream, format, ap);
|
||||
ESTREAM_UNLOCK (stream);
|
||||
va_end (ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* A variant of asprintf. The function returns the allocated buffer
|
||||
or NULL on error; ERRNO is set in the error case. The caller
|
||||
should use es_free to release the buffer. This function actually
|
||||
|
@ -121,6 +121,8 @@
|
||||
#define es_free _ESTREAM_PREFIX(es_free)
|
||||
#define es_fprintf _ESTREAM_PREFIX(es_fprintf)
|
||||
#define es_fprintf_unlocked _ESTREAM_PREFIX(es_fprintf_unlocked)
|
||||
#define es_printf _ESTREAM_PREFIX(es_printf)
|
||||
#define es_printf_unlocked _ESTREAM_PREFIX(es_printf_unlocked)
|
||||
#define es_vfprintf _ESTREAM_PREFIX(es_vfprint)
|
||||
#define es_vfprintf_unlocked _ESTREAM_PREFIX(es_vfprint_unlocked)
|
||||
#define es_setvbuf _ESTREAM_PREFIX(es_setvbuf)
|
||||
@ -345,6 +347,11 @@ int es_fprintf_unlocked (estream_t ES__RESTRICT stream,
|
||||
const char *ES__RESTRICT format, ...)
|
||||
_ESTREAM_GCC_A_PRINTF(2,3);
|
||||
|
||||
int es_printf (const char *ES__RESTRICT format, ...)
|
||||
_ESTREAM_GCC_A_PRINTF(1,2);
|
||||
int es_printf_unlocked (const char *ES__RESTRICT format, ...)
|
||||
_ESTREAM_GCC_A_PRINTF(1,2);
|
||||
|
||||
int es_vfprintf (estream_t ES__RESTRICT stream,
|
||||
const char *ES__RESTRICT format, va_list ap)
|
||||
_ESTREAM_GCC_A_PRINTF(2,0);
|
||||
|
@ -120,19 +120,24 @@ struct fun_cookie_s
|
||||
|
||||
/* Write NBYTES of BUFFER to file descriptor FD. */
|
||||
static int
|
||||
writen (int fd, const void *buffer, size_t nbytes)
|
||||
writen (int fd, const void *buffer, size_t nbytes, int is_socket)
|
||||
{
|
||||
const char *buf = buffer;
|
||||
size_t nleft = nbytes;
|
||||
int nwritten;
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
(void)is_socket; /* Not required. */
|
||||
#endif
|
||||
|
||||
while (nleft > 0)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
if (is_socket)
|
||||
nwritten = send (fd, buf, nleft, 0);
|
||||
#else
|
||||
nwritten = write (fd, buf, nleft);
|
||||
else
|
||||
#endif
|
||||
nwritten = write (fd, buf, nleft);
|
||||
|
||||
if (nwritten < 0 && errno == EINTR)
|
||||
continue;
|
||||
if (nwritten < 0)
|
||||
@ -171,6 +176,9 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
|
||||
{
|
||||
struct fun_cookie_s *cookie = cookie_arg;
|
||||
|
||||
/* FIXME: Use only estream with a callback for socket writing. This
|
||||
avoids the ugly mix of fd and estream code. */
|
||||
|
||||
/* Note that we always try to reconnect to the socket but print
|
||||
error messages only the first time an error occured. If
|
||||
RUNNING_DETACHED is set we don't fall back to stderr and even do
|
||||
@ -345,7 +353,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
|
||||
}
|
||||
|
||||
log_socket = cookie->fd;
|
||||
if (cookie->fd != -1 && !writen (cookie->fd, buffer, size))
|
||||
if (cookie->fd != -1 && !writen (cookie->fd, buffer, size, cookie->is_socket))
|
||||
return (ssize_t)size; /* Okay. */
|
||||
|
||||
if (!running_detached && cookie->fd != -1
|
||||
@ -561,7 +569,16 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
|
||||
{
|
||||
if (!logstream)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
char *tmp;
|
||||
|
||||
tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG",
|
||||
"DefaultLogFile");
|
||||
log_set_file (tmp);
|
||||
jnlib_free (tmp);
|
||||
#else
|
||||
log_set_file (NULL); /* Make sure a log stream has been set. */
|
||||
#endif
|
||||
assert (logstream);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdio.h>
|
||||
#include "estream.h"
|
||||
#include "mischelp.h"
|
||||
#include "w32help.h"
|
||||
|
||||
/* Flag values for log_set_prefix. */
|
||||
#define JNLIB_LOG_WITH_PREFIX 1
|
||||
|
@ -1,3 +1,7 @@
|
||||
2010-08-18 Werner Koch <wk@g10code.com>
|
||||
|
||||
* tools.texi (watchgnupg): Add examples section.
|
||||
|
||||
2010-06-10 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (gnupg_TEXINFOS): Add dirmngr.texi.
|
||||
|
@ -42,11 +42,12 @@ GnuPG comes with a couple of smaller tools:
|
||||
@end ifset
|
||||
|
||||
@mansect description
|
||||
Most of the main utilities are able to write their log files to a
|
||||
Unix Domain socket if configured that way. @command{watchgnupg} is a simple
|
||||
listener for such a socket. It ameliorates the output with a time
|
||||
stamp and makes sure that long lines are not interspersed with log
|
||||
output from other utilities.
|
||||
Most of the main utilities are able to write their log files to a Unix
|
||||
Domain socket if configured that way. @command{watchgnupg} is a simple
|
||||
listener for such a socket. It ameliorates the output with a time stamp
|
||||
and makes sure that long lines are not interspersed with log output from
|
||||
other utilities. This tool is not available for Windows.
|
||||
|
||||
|
||||
@noindent
|
||||
@command{watchgnupg} is commonly invoked as
|
||||
@ -70,6 +71,10 @@ This starts it on the current terminal for listening on the socket
|
||||
@opindex force
|
||||
Delete an already existing socket file.
|
||||
|
||||
@item --tcp @var{n}
|
||||
Instead of reading from a local socket, listen for connects on TCP port
|
||||
@var{n}.
|
||||
|
||||
@item --verbose
|
||||
@opindex verbose
|
||||
Enable extra informational output.
|
||||
@ -84,6 +89,41 @@ Display a brief help page and exit.
|
||||
|
||||
@end table
|
||||
|
||||
@noindent
|
||||
@mansect examples
|
||||
@chapheading Examples
|
||||
|
||||
@example
|
||||
$ watchgnupg --force /home/foo/.gnupg/S.log
|
||||
@end example
|
||||
|
||||
This waits for connections on the local socket
|
||||
@file{/home/foo/.gnupg/S.log} and shows all log entries. To make this
|
||||
work the option @option{log-file} needs to be used with all modules
|
||||
which logs are to be shown. The value for that option must be given
|
||||
with a special prefix (e.g. in the conf file):
|
||||
|
||||
@example
|
||||
log-file socket:///home/foo/.gnupg/S.log
|
||||
@end example
|
||||
|
||||
For debugging purposes it is also possible to do remote logging. Take
|
||||
care if you use this feature because the information is send in the
|
||||
clear over the network. Use this syntax in the conf files:
|
||||
|
||||
@example
|
||||
log-file tcp://192.168.1.1:4711
|
||||
@end example
|
||||
|
||||
You may use any port and not just 4711 as shown above; only IP addresses
|
||||
are supported (v4 and v6) and no host names. You need to start
|
||||
@command{watchgnupg} with the @option{tcp} option. Note that under
|
||||
Windows the registry entry @var{HKCU\Software\GNU\GnuPG:DefaultLogFile}
|
||||
can be used to change the default log output from @code{stderr} to
|
||||
whatever is given by that entry. However the only useful entry is a TCP
|
||||
name for remote debugging.
|
||||
|
||||
|
||||
@mansect see also
|
||||
@ifset isman
|
||||
@command{gpg}(1),
|
||||
|
@ -1,3 +1,9 @@
|
||||
2010-08-16 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpg.c (list_config, gpgconf_list): Use es_printf.
|
||||
(print_hex, print_hashline, print_algo_numbers)
|
||||
(print_algo_names): Use es_printf.
|
||||
|
||||
2010-07-20 Werner Koch <wk@g10code.com>
|
||||
|
||||
* mainproc.c (print_pkenc_list): Write a STATUS_ERROR. Fixes
|
||||
|
145
g10/gpg.c
145
g10/gpg.c
@ -1449,8 +1449,8 @@ print_algo_numbers(int (*checker)(int))
|
||||
if(first)
|
||||
first=0;
|
||||
else
|
||||
printf(";");
|
||||
printf("%d",i);
|
||||
es_printf (";");
|
||||
es_printf ("%d",i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1468,8 +1468,8 @@ print_algo_names(int (*checker)(int),const char *(*mapper)(int))
|
||||
if(first)
|
||||
first=0;
|
||||
else
|
||||
printf(";");
|
||||
printf("%s",mapper(i));
|
||||
es_printf (";");
|
||||
es_printf ("%s",mapper(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1508,10 +1508,10 @@ list_config(char *items)
|
||||
{
|
||||
print_sanitized_string2 (stdout, sl->d, ':',';');
|
||||
if(sl->next)
|
||||
printf(";");
|
||||
es_printf(";");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
es_printf("\n");
|
||||
}
|
||||
|
||||
any=1;
|
||||
@ -1519,33 +1519,33 @@ list_config(char *items)
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"version")==0)
|
||||
{
|
||||
printf("cfg:version:");
|
||||
es_printf("cfg:version:");
|
||||
es_write_sanitized (es_stdout, VERSION, strlen(VERSION), ":", NULL);
|
||||
printf("\n");
|
||||
es_printf ("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"pubkey")==0)
|
||||
{
|
||||
printf("cfg:pubkey:");
|
||||
es_printf ("cfg:pubkey:");
|
||||
print_algo_numbers (openpgp_pk_test_algo);
|
||||
printf("\n");
|
||||
es_printf ("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"cipher")==0)
|
||||
{
|
||||
printf("cfg:cipher:");
|
||||
es_printf ("cfg:cipher:");
|
||||
print_algo_numbers(openpgp_cipher_test_algo);
|
||||
printf("\n");
|
||||
es_printf ("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if (show_all || !ascii_strcasecmp (name,"ciphername"))
|
||||
{
|
||||
printf ("cfg:ciphername:");
|
||||
es_printf ("cfg:ciphername:");
|
||||
print_algo_names (openpgp_cipher_test_algo,openpgp_cipher_algo_name);
|
||||
printf ("\n");
|
||||
es_printf ("\n");
|
||||
any = 1;
|
||||
}
|
||||
|
||||
@ -1553,9 +1553,9 @@ list_config(char *items)
|
||||
|| ascii_strcasecmp(name,"digest")==0
|
||||
|| ascii_strcasecmp(name,"hash")==0)
|
||||
{
|
||||
printf("cfg:digest:");
|
||||
es_printf ("cfg:digest:");
|
||||
print_algo_numbers(openpgp_md_test_algo);
|
||||
printf("\n");
|
||||
es_printf ("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
@ -1563,17 +1563,17 @@ list_config(char *items)
|
||||
|| !ascii_strcasecmp(name,"digestname")
|
||||
|| !ascii_strcasecmp(name,"hashname"))
|
||||
{
|
||||
printf ("cfg:digestname:");
|
||||
es_printf ("cfg:digestname:");
|
||||
print_algo_names (openpgp_md_test_algo, gcry_md_algo_name);
|
||||
printf("\n");
|
||||
es_printf ("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
if(show_all || ascii_strcasecmp(name,"compress")==0)
|
||||
{
|
||||
printf("cfg:compress:");
|
||||
es_printf ("cfg:compress:");
|
||||
print_algo_numbers(check_compress_algo);
|
||||
printf("\n");
|
||||
es_printf ("\n");
|
||||
any=1;
|
||||
}
|
||||
|
||||
@ -1587,7 +1587,7 @@ list_config(char *items)
|
||||
for (p=list; p && (p2 = strchr (p, '\n')); p = p2+1)
|
||||
{
|
||||
*p2 = 0;
|
||||
printf("cfg:ccid-reader-id:%s\n", p);
|
||||
es_printf ("cfg:ccid-reader-id:%s\n", p);
|
||||
}
|
||||
free (list);
|
||||
#endif
|
||||
@ -1613,22 +1613,23 @@ gpgconf_list (const char *configfile)
|
||||
{
|
||||
char *configfile_esc = percent_escape (configfile, NULL);
|
||||
|
||||
printf ("gpgconf-gpg.conf:%lu:\"%s\n",
|
||||
GC_OPT_FLAG_DEFAULT, configfile_esc ? configfile_esc : "/dev/null");
|
||||
printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("default-key:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("auto-key-locate:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
|
||||
printf ("group:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("gpgconf-gpg.conf:%lu:\"%s\n",
|
||||
GC_OPT_FLAG_DEFAULT,
|
||||
configfile_esc ? configfile_esc : "/dev/null");
|
||||
es_printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("default-key:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("auto-key-locate:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
|
||||
es_printf ("group:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
|
||||
/* The next one is an info only item and should match the macros at
|
||||
the top of keygen.c */
|
||||
printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
|
||||
es_printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
|
||||
"RSA-2048");
|
||||
|
||||
xfree (configfile_esc);
|
||||
@ -2992,10 +2993,11 @@ main (int argc, char **argv)
|
||||
if( nogreeting )
|
||||
greeting = 0;
|
||||
|
||||
if( greeting ) {
|
||||
fprintf(stderr, "%s %s; %s\n",
|
||||
if( greeting )
|
||||
{
|
||||
es_fprintf (es_stderr, "%s %s; %s\n",
|
||||
strusage(11), strusage(13), strusage(14) );
|
||||
fprintf(stderr, "%s\n", strusage(15) );
|
||||
es_fprintf (es_stderr, "%s\n", strusage(15) );
|
||||
}
|
||||
#ifdef IS_DEVELOPMENT_VERSION
|
||||
if (!opt.batch)
|
||||
@ -4092,33 +4094,33 @@ g10_exit( int rc )
|
||||
display, but there are a few other similar assumptions in the
|
||||
display code. */
|
||||
static void
|
||||
print_hex( gcry_md_hd_t md, int algo, const char *fname )
|
||||
print_hex (gcry_md_hd_t md, int algo, const char *fname)
|
||||
{
|
||||
int i,n,count,indent=0;
|
||||
const byte *p;
|
||||
|
||||
if(fname)
|
||||
indent=printf("%s: ",fname);
|
||||
if (fname)
|
||||
indent = es_printf("%s: ",fname);
|
||||
|
||||
if(indent>40)
|
||||
if (indent>40)
|
||||
{
|
||||
printf("\n");
|
||||
indent=0;
|
||||
}
|
||||
|
||||
if(algo==DIGEST_ALGO_RMD160)
|
||||
indent+=printf("RMD160 = ");
|
||||
else if(algo>0)
|
||||
indent+=printf("%6s = ", gcry_md_algo_name (algo));
|
||||
if (algo==DIGEST_ALGO_RMD160)
|
||||
indent += es_printf("RMD160 = ");
|
||||
else if (algo>0)
|
||||
indent += es_printf("%6s = ", gcry_md_algo_name (algo));
|
||||
else
|
||||
algo=abs(algo);
|
||||
algo = abs(algo);
|
||||
|
||||
count=indent;
|
||||
count = indent;
|
||||
|
||||
p = gcry_md_read (md, algo);
|
||||
n = gcry_md_get_algo_dlen (algo);
|
||||
|
||||
count += printf ("%02X",*p++);
|
||||
count += es_printf ("%02X",*p++);
|
||||
|
||||
for(i=1;i<n;i++,p++)
|
||||
{
|
||||
@ -4126,14 +4128,14 @@ print_hex( gcry_md_hd_t md, int algo, const char *fname )
|
||||
{
|
||||
if(count+2>79)
|
||||
{
|
||||
printf("\n%*s",indent," ");
|
||||
count=indent;
|
||||
es_printf ("\n%*s",indent," ");
|
||||
count = indent;
|
||||
}
|
||||
else
|
||||
count+=printf(" ");
|
||||
count += es_printf(" ");
|
||||
|
||||
if(!(i%8))
|
||||
count+=printf(" ");
|
||||
if (!(i%8))
|
||||
count += es_printf(" ");
|
||||
}
|
||||
else if (n==20)
|
||||
{
|
||||
@ -4141,34 +4143,34 @@ print_hex( gcry_md_hd_t md, int algo, const char *fname )
|
||||
{
|
||||
if(count+4>79)
|
||||
{
|
||||
printf("\n%*s",indent," ");
|
||||
es_printf ("\n%*s",indent," ");
|
||||
count=indent;
|
||||
}
|
||||
else
|
||||
count+=printf(" ");
|
||||
count += es_printf(" ");
|
||||
}
|
||||
|
||||
if(!(i%10))
|
||||
count+=printf(" ");
|
||||
if (!(i%10))
|
||||
count += es_printf(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!(i%4))
|
||||
{
|
||||
if(count+8>79)
|
||||
if (count+8>79)
|
||||
{
|
||||
printf("\n%*s",indent," ");
|
||||
es_printf ("\n%*s",indent," ");
|
||||
count=indent;
|
||||
}
|
||||
else
|
||||
count+=printf(" ");
|
||||
count += es_printf(" ");
|
||||
}
|
||||
}
|
||||
|
||||
count+=printf("%02X",*p);
|
||||
count += es_printf("%02X",*p);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
es_printf ("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4177,22 +4179,23 @@ print_hashline( gcry_md_hd_t md, int algo, const char *fname )
|
||||
int i, n;
|
||||
const byte *p;
|
||||
|
||||
if ( fname ) {
|
||||
for (p = fname; *p; p++ ) {
|
||||
if ( fname )
|
||||
{
|
||||
for (p = fname; *p; p++ )
|
||||
{
|
||||
if ( *p <= 32 || *p > 127 || *p == ':' || *p == '%' )
|
||||
printf("%%%02X", *p );
|
||||
es_printf ("%%%02X", *p );
|
||||
else
|
||||
putchar( *p );
|
||||
es_putc (*p, es_stdout);
|
||||
}
|
||||
}
|
||||
putchar(':');
|
||||
printf("%d:", algo );
|
||||
es_putc (':', es_stdout);
|
||||
es_printf ("%d:", algo);
|
||||
p = gcry_md_read (md, algo);
|
||||
n = gcry_md_get_algo_dlen (algo);
|
||||
for(i=0; i < n ; i++, p++ )
|
||||
printf("%02X", *p );
|
||||
putchar(':');
|
||||
putchar('\n');
|
||||
es_printf ("%02X", *p);
|
||||
es_fputs (":\n", es_stdout);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1,3 +1,7 @@
|
||||
2010-08-16 Werner Koch <wk@g10code.com>
|
||||
|
||||
* scdaemon.c: Replace remaining printf by es_printf.
|
||||
|
||||
2010-06-09 Werner Koch <wk@g10code.com>
|
||||
|
||||
* scdaemon.c (main): s/log_set_get_tid_callback/log_set_pid_suffix_cb/.
|
||||
|
@ -617,9 +617,9 @@ main (int argc, char **argv )
|
||||
|
||||
if (greeting)
|
||||
{
|
||||
fprintf (stderr, "%s %s; %s\n",
|
||||
es_fprintf (es_stderr, "%s %s; %s\n",
|
||||
strusage(11), strusage(13), strusage(14) );
|
||||
fprintf (stderr, "%s\n", strusage(15) );
|
||||
es_fprintf (es_stderr, "%s\n", strusage(15) );
|
||||
}
|
||||
#ifdef IS_DEVELOPMENT_VERSION
|
||||
log_info ("NOTE: this is a development version!\n");
|
||||
@ -651,12 +651,12 @@ main (int argc, char **argv )
|
||||
filename = make_filename (opt.homedir, "scdaemon.conf", NULL);
|
||||
filename_esc = percent_escape (filename, NULL);
|
||||
|
||||
printf ("gpgconf-scdaemon.conf:%lu:\"%s\n",
|
||||
es_printf ("gpgconf-scdaemon.conf:%lu:\"%s\n",
|
||||
GC_OPT_FLAG_DEFAULT, filename_esc);
|
||||
xfree (filename_esc);
|
||||
xfree (filename);
|
||||
|
||||
printf ("verbose:%lu:\n"
|
||||
es_printf ("verbose:%lu:\n"
|
||||
"quiet:%lu:\n"
|
||||
"debug-level:%lu:\"none:\n"
|
||||
"log-file:%lu:\n",
|
||||
@ -665,16 +665,16 @@ main (int argc, char **argv )
|
||||
GC_OPT_FLAG_DEFAULT,
|
||||
GC_OPT_FLAG_NONE );
|
||||
|
||||
printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
printf ("ctapi-driver:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
printf ("pcsc-driver:%lu:\"%s:\n",
|
||||
es_printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
es_printf ("ctapi-driver:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
es_printf ("pcsc-driver:%lu:\"%s:\n",
|
||||
GC_OPT_FLAG_DEFAULT, DEFAULT_PCSC_DRIVER );
|
||||
#ifdef HAVE_LIBUSB
|
||||
printf ("disable-ccid:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
es_printf ("disable-ccid:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
#endif
|
||||
printf ("deny-admin:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
printf ("disable-keypad:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
printf ("card-timeout:%lu:%d:\n", GC_OPT_FLAG_DEFAULT, 0);
|
||||
es_printf ("deny-admin:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
es_printf ("disable-keypad:%lu:\n", GC_OPT_FLAG_NONE );
|
||||
es_printf ("card-timeout:%lu:%d:\n", GC_OPT_FLAG_DEFAULT, 0);
|
||||
|
||||
scd_exit (0);
|
||||
}
|
||||
@ -831,11 +831,11 @@ main (int argc, char **argv )
|
||||
if (csh_style)
|
||||
{
|
||||
*strchr (infostr, '=') = ' ';
|
||||
printf ( "setenv %s\n", infostr);
|
||||
es_printf ( "setenv %s\n", infostr);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ( "%s; export SCDAEMON_INFO;\n", infostr);
|
||||
es_printf ( "%s; export SCDAEMON_INFO;\n", infostr);
|
||||
}
|
||||
xfree (infostr);
|
||||
exit (0);
|
||||
|
@ -1,5 +1,7 @@
|
||||
2010-08-16 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpgsm.c (main) <aGPGConfList>: Use es_printf.
|
||||
|
||||
* call-dirmngr.c (start_dirmngr_ext): Use new start_new_dirmngr
|
||||
function.
|
||||
|
||||
|
42
sm/gpgsm.c
42
sm/gpgsm.c
@ -908,7 +908,7 @@ main ( int argc, char **argv)
|
||||
log_set_prefix ("gpgsm", 1);
|
||||
|
||||
/* Make sure that our subsystems are ready. */
|
||||
i18n_init();
|
||||
i18n_init ();
|
||||
init_common_subsystems (&argc, &argv);
|
||||
|
||||
/* Check that the libraries are suitable. Do it here because the
|
||||
@ -1429,9 +1429,9 @@ main ( int argc, char **argv)
|
||||
|
||||
if (greeting)
|
||||
{
|
||||
fprintf(stderr, "%s %s; %s\n",
|
||||
es_fprintf (es_stderr, "%s %s; %s\n",
|
||||
strusage(11), strusage(13), strusage(14) );
|
||||
fprintf(stderr, "%s\n", strusage(15) );
|
||||
es_fprintf (es_stderr, "%s\n", strusage(15) );
|
||||
}
|
||||
# ifdef IS_DEVELOPMENT_VERSION
|
||||
if (!opt.batch)
|
||||
@ -1638,32 +1638,32 @@ main ( int argc, char **argv)
|
||||
{ /* List options and default values in the GPG Conf format. */
|
||||
char *config_filename_esc = percent_escape (opt.config_filename, NULL);
|
||||
|
||||
printf ("gpgconf-gpgsm.conf:%lu:\"%s\n",
|
||||
es_printf ("gpgconf-gpgsm.conf:%lu:\"%s\n",
|
||||
GC_OPT_FLAG_DEFAULT, config_filename_esc);
|
||||
xfree (config_filename_esc);
|
||||
|
||||
printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
|
||||
printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("disable-crl-checks:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("disable-trusted-cert-crl-check:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("enable-ocsp:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("include-certs:%lu:%d:\n", GC_OPT_FLAG_DEFAULT,
|
||||
es_printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
|
||||
es_printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("disable-crl-checks:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("disable-trusted-cert-crl-check:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("enable-ocsp:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("include-certs:%lu:%d:\n", GC_OPT_FLAG_DEFAULT,
|
||||
DEFAULT_INCLUDE_CERTS);
|
||||
printf ("disable-policy-checks:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("auto-issuer-key-retrieve:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("disable-dirmngr:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
printf ("cipher-algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
|
||||
es_printf ("disable-policy-checks:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("auto-issuer-key-retrieve:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("disable-dirmngr:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("cipher-algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
|
||||
DEFAULT_CIPHER_ALGO);
|
||||
printf ("p12-charset:%lu:\n", GC_OPT_FLAG_DEFAULT);
|
||||
printf ("default-key:%lu:\n", GC_OPT_FLAG_DEFAULT);
|
||||
printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_DEFAULT);
|
||||
printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
es_printf ("p12-charset:%lu:\n", GC_OPT_FLAG_DEFAULT);
|
||||
es_printf ("default-key:%lu:\n", GC_OPT_FLAG_DEFAULT);
|
||||
es_printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_DEFAULT);
|
||||
es_printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
|
||||
|
||||
/* The next one is an info only item and should match what
|
||||
proc_parameters actually implements. */
|
||||
printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
|
||||
es_printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
|
||||
"RSA-2048");
|
||||
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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:",
|
||||
es_fprintf (out, "%s:%s:",
|
||||
gc_component[component].name, gc_percent_escape (desc));
|
||||
fprintf (out, "%s\n", gc_percent_escape (pgmname));
|
||||
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:",
|
||||
es_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_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",
|
||||
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)
|
||||
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:",
|
||||
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
|
||||
|
@ -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,19 +290,19 @@ main (int argc, char **argv)
|
||||
case aListDirs:
|
||||
/* Show the system configuration directories for gpgconf. */
|
||||
get_outfp (&outfp);
|
||||
fprintf (outfp, "sysconfdir:%s\n",
|
||||
es_fprintf (outfp, "sysconfdir:%s\n",
|
||||
gc_percent_escape (gnupg_sysconfdir ()));
|
||||
fprintf (outfp, "bindir:%s\n",
|
||||
es_fprintf (outfp, "bindir:%s\n",
|
||||
gc_percent_escape (gnupg_bindir ()));
|
||||
fprintf (outfp, "libexecdir:%s\n",
|
||||
es_fprintf (outfp, "libexecdir:%s\n",
|
||||
gc_percent_escape (gnupg_libexecdir ()));
|
||||
fprintf (outfp, "libdir:%s\n",
|
||||
es_fprintf (outfp, "libdir:%s\n",
|
||||
gc_percent_escape (gnupg_libdir ()));
|
||||
fprintf (outfp, "datadir:%s\n",
|
||||
es_fprintf (outfp, "datadir:%s\n",
|
||||
gc_percent_escape (gnupg_datadir ()));
|
||||
fprintf (outfp, "localedir:%s\n",
|
||||
es_fprintf (outfp, "localedir:%s\n",
|
||||
gc_percent_escape (gnupg_localedir ()));
|
||||
fprintf (outfp, "dirmngr-socket:%s\n",
|
||||
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",
|
||||
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;
|
||||
|
@ -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*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user