From ba463128ce65a0f347643f7246a8e097c5be19f1 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 21 Feb 2020 21:45:13 +0100 Subject: [PATCH] Use gpgrt's new option parser for the remaining daemons. * scd/scdaemon.c: Switch to the new option parser and enable a global conf file. * dirmngr/dirmngr.c: Ditto. * g13/g13.c: Ditto. * g13/g13-syshelp.c: Ditto. Do not force verbose mode. * dirmngr/dirmngr_ldap.c: Switch to the new option parser. * dirmngr/dirmngr-client.c: Switch to the new option parser. -- This finalizes the switch to the new option parser. What's left is to remove the old argparser code from common. g13-syshelp does not anymore default to --verbose because that can now be enabled in /etc/gnupg/g13-syshelp.conf. GnuPG-bug-id: 4788 Signed-off-by: Werner Koch --- dirmngr/dirmngr-client.c | 31 ++++--- dirmngr/dirmngr.c | 182 +++++++++++++++++---------------------- dirmngr/dirmngr_ldap.c | 24 +++--- g13/g13-syshelp.c | 121 ++++++++++++-------------- g13/g13.c | 172 +++++++++++++++++------------------- scd/scdaemon.c | 165 +++++++++++++++-------------------- 6 files changed, 313 insertions(+), 382 deletions(-) diff --git a/dirmngr/dirmngr-client.c b/dirmngr/dirmngr-client.c index e0bc80fcf..1ea10a8ad 100644 --- a/dirmngr/dirmngr-client.c +++ b/dirmngr/dirmngr-client.c @@ -16,12 +16,10 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . + * SPDX-License-Identifier: GPL-3.0-or-later */ #include -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS #include #include @@ -35,7 +33,6 @@ #include #include "../common/logging.h" -#include "../common/argparse.h" #include "../common/stringhelp.h" #include "../common/mischelp.h" #include "../common/strlist.h" @@ -44,7 +41,6 @@ #include "../common/i18n.h" #include "../common/util.h" #include "../common/init.h" -#include "../common/argparse.h" /* temporary hack. */ /* Constants for the options. */ @@ -69,7 +65,7 @@ enum /* The list of options as used by the argparse.c code. */ -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { { oVerbose, "verbose", 0, N_("verbose") }, { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, { oOCSP, "ocsp", 0, N_("use OCSP instead of CRLs") }, @@ -162,9 +158,11 @@ my_strusage (int level) switch(level) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "dirmngr-client (@GNUPG@)"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; case 49: p = PACKAGE_BUGREPORT; break; @@ -190,7 +188,7 @@ my_strusage (int level) int main (int argc, char **argv ) { - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; assuan_context_t ctx; gpg_error_t err; unsigned char *certbuf; @@ -203,9 +201,12 @@ main (int argc, char **argv ) int cmd_squid_mode = 0; early_system_init (); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); log_set_prefix ("dirmngr-client", GPGRT_LOG_WITH_PREFIX); + /* Register our string mapper with gpgrt. Usually done in + * init_common_subsystems, but we don't need that here. */ + gpgrt_set_fixed_string_mapper (map_static_macro_string); /* For W32 we need to initialize the socket subsystem. Because we don't use Pth we need to do this explicit. */ @@ -227,8 +228,8 @@ main (int argc, char **argv ) /* Parse the command line. */ pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1; /* Do not remove the args. */ - while (arg_parse (&pargs, opts) ) + pargs.flags= ARGPARSE_FLAG_KEEP; + while (gpgrt_argparse (NULL, &pargs, opts)) { switch (pargs.r_opt) { @@ -251,9 +252,11 @@ main (int argc, char **argv ) break; case oForceDefaultResponder: opt.force_default_responder = 1; break; - default : pargs.err = 2; break; + default : pargs.err = ARGPARSE_PRINT_ERROR; break; } } + gpgrt_argparse (NULL, &pargs, NULL); + if (log_get_errorcount (0)) exit (2); @@ -262,14 +265,14 @@ main (int argc, char **argv ) else if (cmd_lookup || cmd_loadcrl) { if (!argc) - usage (1); + gpgrt_usage (1); err = 0; } else if (cmd_squid_mode) { err = 0; if (argc) - usage (1); + gpgrt_usage (1); } else if (!argc) { @@ -288,7 +291,7 @@ main (int argc, char **argv ) else { err = 0; - usage (1); + gpgrt_usage (1); } if (log_get_errorcount (0)) diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index 9838b1c7b..875a42442 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -17,14 +17,10 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . - * - * SPDX-License-Identifier: GPL-3.0+ + * SPDX-License-Identifier: GPL-3.0-or-later */ #include -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS #include #include @@ -79,7 +75,6 @@ #include "../common/gc-opt-flags.h" #include "dns-stuff.h" #include "http-common.h" -#include "../common/argparse.h" /* temporary hack. */ #ifndef ENAMETOOLONG # define ENAMETOOLONG EINVAL @@ -162,7 +157,7 @@ enum cmd_and_opt_values { -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { ARGPARSE_group (300, N_("@Commands:\n ")), @@ -185,7 +180,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")), ARGPARSE_s_n (oSh, "sh", N_("sh-style command output")), ARGPARSE_s_n (oCsh, "csh", N_("csh-style command output")), - ARGPARSE_s_s (oOptions, "options", N_("|FILE|read options from FILE")), + ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")), ARGPARSE_s_s (oDebugLevel, "debug-level", N_("|LEVEL|set the debugging level to LEVEL")), ARGPARSE_s_n (oNoDetach, "no-detach", N_("do not detach from the console")), @@ -263,6 +258,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_i (oConnectTimeout, "connect-timeout", "@"), ARGPARSE_s_i (oConnectQuickTimeout, "connect-quick-timeout", "@"), ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"), + ARGPARSE_noconffile (oNoOptions, "no-options", "@"), ARGPARSE_group (302,N_("@\n(See the \"info\" manual for a complete listing " "of all commands and options)\n")), @@ -392,9 +388,11 @@ my_strusage( int level ) const char *p; switch ( level ) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "@DIRMNGR@ (@GNUPG@)"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; /* TRANSLATORS: @EMAIL@ will get replaced by the actual bug reporting address. This is so that we can change the @@ -593,7 +591,7 @@ shutdown_reaper (void) 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, int reread) +parse_rereadable_options (gpgrt_argparse_t *pargs, int reread) { if (!pargs) { /* Reset mode. */ @@ -824,15 +822,13 @@ int main (int argc, char **argv) { enum cmd_and_opt_values cmd = 0; - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; int orig_argc; char **orig_argv; - FILE *configfp = NULL; - char *configname = NULL; + char *last_configname = NULL; + const char *configname = NULL; const char *shell; - unsigned configlineno; - int parse_debug = 0; - int default_config =1; + int debug_argparser = 0; int greeting = 0; int nogreeting = 0; int nodetach = 0; @@ -846,7 +842,7 @@ main (int argc, char **argv) struct assuan_malloc_hooks malloc_hooks; early_system_init (); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); log_set_prefix (DIRMNGR_NAME, GPGRT_LOG_WITH_PREFIX | GPGRT_LOG_WITH_PID); /* Make sure that our subsystems are ready. */ @@ -914,63 +910,56 @@ main (int argc, char **argv) orig_argv = argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1|(1<<6); /* do not remove the args, ignore version */ - while (arg_parse( &pargs, opts)) + pargs.flags= (ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); + while (gpgrt_argparse (NULL, &pargs, opts)) { - if (pargs.r_opt == oDebug || pargs.r_opt == oDebugAll) - parse_debug++; - else if (pargs.r_opt == oOptions) - { /* Yes there is one, so we do not try the default one, but - read the option file when it is encountered at the - commandline */ - default_config = 0; - } - else if (pargs.r_opt == oNoOptions) - default_config = 0; /* --no-options */ - else if (pargs.r_opt == oHomedir) + switch (pargs.r_opt) { + case oDebug: + case oDebugAll: + debug_argparser++; + break; + case oHomedir: gnupg_set_homedir (pargs.r.ret_str); + break; } } + /* Reset the flags. */ + pargs.flags &= ~(ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); socket_name = dirmngr_socket_name (); - if (default_config) - configname = make_filename (gnupg_homedir (), DIRMNGR_NAME".conf", NULL ); + /* The configuraton directories for use by gpgrt_argparser. */ + gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ()); + gpgrt_set_confdir (GPGRT_CONFDIR_USER, gnupg_homedir ()); + + /* We are re-using the struct, thus the reset flag. We OR the + * flags so that the internal intialized flag won't be cleared. */ argc = orig_argc; argv = orig_argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1; /* do not remove the args */ - next_pass: - if (configname) + pargs.flags |= (ARGPARSE_FLAG_RESET + | ARGPARSE_FLAG_KEEP + | ARGPARSE_FLAG_SYS + | ARGPARSE_FLAG_USER); + while (gpgrt_argparser (&pargs, opts, DIRMNGR_NAME EXTSEP_S "conf")) { - configlineno = 0; - configfp = fopen (configname, "r"); - if (!configfp) + if (pargs.r_opt == ARGPARSE_CONFFILE) { - if (default_config) + if (debug_argparser) + log_info (_("reading options from '%s'\n"), + pargs.r_type? pargs.r.ret_str: "[cmdline]"); + if (pargs.r_type) { - if( parse_debug ) - log_info (_("Note: no default option file '%s'\n"), - configname ); - } + xfree (last_configname); + last_configname = xstrdup (pargs.r.ret_str); + configname = last_configname; + } else - { - log_error (_("option file '%s': %s\n"), - configname, strerror(errno) ); - exit(2); - } - xfree (configname); - configname = NULL; - } - if (parse_debug && configname ) - log_info (_("reading options from '%s'\n"), configname ); - default_config = 0; - } - - while (optfile_parse( configfp, configname, &configlineno, &pargs, opts) ) - { + configname = NULL; + continue; + } if (parse_rereadable_options (&pargs, 0)) continue; /* Already handled */ switch (pargs.r_opt) @@ -994,18 +983,8 @@ main (int argc, char **argv) case oDebugWait: debug_wait = pargs.r.ret_int; break; - case oOptions: - /* Config files may not be nested (silently ignore them) */ - if (!configfp) - { - xfree(configname); - configname = xstrdup(pargs.r.ret_str); - goto next_pass; - } - break; case oNoGreeting: nogreeting = 1; break; case oNoVerbose: opt.verbose = 0; break; - case oNoOptions: break; /* no-options */ case oHomedir: /* Ignore this option here. */; break; case oNoDetach: nodetach = 1; break; case oLogFile: logfile = pargs.r.ret_str; break; @@ -1033,20 +1012,26 @@ main (int argc, char **argv) listen_backlog = pargs.r.ret_int; break; - default : pargs.err = configfp? 1:2; break; + default: + if (configname) + pargs.err = ARGPARSE_PRINT_WARNING; + else + pargs.err = ARGPARSE_PRINT_ERROR; + break; } } - if (configfp) + gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */ + + if (!last_configname) + opt.config_filename = gpgrt_fnameconcat (gnupg_homedir (), + DIRMNGR_NAME EXTSEP_S "conf", + NULL); + else { - fclose (configfp); - configfp = NULL; - /* Keep a copy of the name so that it can be read on SIGHUP. */ - opt.config_filename = configname; - configname = NULL; - goto next_pass; + opt.config_filename = last_configname; + last_configname = NULL; } - xfree (configname); - configname = NULL; + if (log_get_errorcount(0)) exit(2); if (nogreeting ) @@ -1058,8 +1043,8 @@ main (int argc, char **argv) if (greeting) { es_fprintf (es_stderr, "%s %s; %s\n", - strusage(11), strusage(13), strusage(14) ); - es_fprintf (es_stderr, "%s\n", strusage(15) ); + gpgrt_strusage(11), gpgrt_strusage(13), gpgrt_strusage(14)); + es_fprintf (es_stderr, "%s\n", gpgrt_strusage(15)); } #ifdef IS_DEVELOPMENT_VERSION @@ -1489,10 +1474,6 @@ main (int argc, char **argv) /* First the configuration file. This is not an option, but it is vital information for GPG Conf. */ - if (!opt.config_filename) - opt.config_filename = make_filename (gnupg_homedir (), - "dirmngr.conf", NULL ); - filename = percent_escape (opt.config_filename, NULL); es_printf ("gpgconf-dirmngr.conf:%lu:\"%s\n", GC_OPT_FLAG_DEFAULT, filename); @@ -1830,36 +1811,33 @@ parse_ocsp_signer (const char *string) static void reread_configuration (void) { - ARGPARSE_ARGS pargs; - FILE *fp; - unsigned int configlineno = 0; + gpgrt_argparse_t pargs; int dummy; if (!opt.config_filename) return; /* No config file. */ - fp = fopen (opt.config_filename, "r"); - if (!fp) - { - log_error (_("option file '%s': %s\n"), - opt.config_filename, strerror(errno) ); - return; - } - parse_rereadable_options (NULL, 1); /* Start from the default values. */ memset (&pargs, 0, sizeof pargs); dummy = 0; pargs.argc = &dummy; - pargs.flags = 1; /* do not remove the args */ - while (optfile_parse (fp, opt.config_filename, &configlineno, &pargs, opts) ) + pargs.flags = (ARGPARSE_FLAG_KEEP + |ARGPARSE_FLAG_SYS + |ARGPARSE_FLAG_USER); + while (gpgrt_argparser (&pargs, opts, DIRMNGR_NAME EXTSEP_S "conf") ) { - if (pargs.r_opt < -1) - pargs.err = 1; /* Print a warning. */ + if (pargs.r_opt == ARGPARSE_CONFFILE) + { + log_info (_("reading options from '%s'\n"), + pargs.r_type? pargs.r.ret_str: "[cmdline]"); + } + else if (pargs.r_opt < -1) + pargs.err = ARGPARSE_PRINT_WARNING; else /* Try to parse this option - ignore unchangeable ones. */ parse_rereadable_options (&pargs, 1); } - fclose (fp); + gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */ post_option_parsing (); } @@ -1924,7 +1902,7 @@ handle_signal (int signo) if (shutdown_pending > 2) { log_info (_("shutdown forced\n")); - log_info ("%s %s stopped\n", strusage(11), strusage(13) ); + log_info ("%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13)); cleanup (); dirmngr_exit (0); } @@ -1932,7 +1910,7 @@ handle_signal (int signo) case SIGINT: log_info (_("SIGINT received - immediate shutdown\n")); - log_info( "%s %s stopped\n", strusage(11), strusage(13)); + log_info( "%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13)); cleanup (); dirmngr_exit (0); break; @@ -2348,7 +2326,7 @@ handle_connections (assuan_fd_t listen_fd) if (listen_fd != GNUPG_INVALID_FD) assuan_sock_close (listen_fd); cleanup (); - log_info ("%s %s stopped\n", strusage(11), strusage(13)); + log_info ("%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13)); } const char* diff --git a/dirmngr/dirmngr_ldap.c b/dirmngr/dirmngr_ldap.c index a96722619..7d19410f3 100644 --- a/dirmngr/dirmngr_ldap.c +++ b/dirmngr/dirmngr_ldap.c @@ -16,12 +16,11 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . + * SPDX-License-Identifier: GPL-3.0-or-later */ #include -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS + #include #include @@ -50,7 +49,6 @@ #include #include "../common/logging.h" -#include "../common/argparse.h" #include "../common/stringhelp.h" #include "../common/mischelp.h" #include "../common/strlist.h" @@ -58,7 +56,6 @@ #include "../common/i18n.h" #include "../common/util.h" #include "../common/init.h" -#include "../common/argparse.h" /* temporary hack. */ /* There is no need for the npth_unprotect and leave functions here; * thus we redefine them to nops. We keep them in the code just for @@ -101,7 +98,7 @@ enum /* The list of options as used by the argparse.c code. */ -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { { oVerbose, "verbose", 0, N_("verbose") }, { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, { oTimeout, "timeout", 1, N_("|N|set LDAP timeout to N seconds")}, @@ -167,11 +164,13 @@ my_strusage (int level) { const char *p; - switch(level) + switch (level) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "dirmngr_ldap (@GNUPG@)"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; case 49: p = PACKAGE_BUGREPORT; break; @@ -194,7 +193,7 @@ my_strusage (int level) int main (int argc, char **argv) { - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; int any_err = 0; char *p; int only_search_timeout = 0; @@ -206,7 +205,7 @@ main (int argc, char **argv) early_system_init (); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); log_set_prefix ("dirmngr_ldap", GPGRT_LOG_WITH_PREFIX); /* Setup I18N and common subsystems. */ @@ -225,8 +224,8 @@ main (int argc, char **argv) /* Parse the command line. */ pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1; /* Do not remove the args. */ - while (arg_parse (&pargs, opts) ) + pargs.flags= ARGPARSE_FLAG_KEEP; + while (gpgrt_argparse (NULL, &pargs, opts)) { switch (pargs.r_opt) { @@ -264,6 +263,7 @@ main (int argc, char **argv) break; } } + gpgrt_argparse (NULL, &pargs, NULL); if (only_search_timeout) myopt->alarm_timeout = 0; @@ -293,7 +293,7 @@ main (int argc, char **argv) if (log_get_errorcount (0)) exit (2); if (argc < 1) - usage (1); + gpgrt_usage (1); if (myopt->alarm_timeout) { diff --git a/g13/g13-syshelp.c b/g13/g13-syshelp.c index 205456568..d65f26b2f 100644 --- a/g13/g13-syshelp.c +++ b/g13/g13-syshelp.c @@ -15,12 +15,11 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . + * SPDX-License-Identifier: GPL-3.0-or-later */ #include -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS + #include #include #include @@ -45,7 +44,6 @@ #include "../common/asshelp.h" #include "../common/init.h" #include "keyblob.h" -#include "../common/argparse.h" /* temporary hack. */ enum cmd_and_opt_values { @@ -93,7 +91,7 @@ enum cmd_and_opt_values { }; -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { ARGPARSE_s_n (oDryRun, "dry-run", N_("do not make any changes")), @@ -149,9 +147,11 @@ my_strusage( int level ) switch (level) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "@G13@-syshelp (@GNUPG@)"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <" PACKAGE_BUGREPORT ">.\n"); break; @@ -221,20 +221,18 @@ set_debug (void) int -main ( int argc, char **argv) +main (int argc, char **argv) { - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; int orig_argc; char **orig_argv; gpg_error_t err = 0; /* const char *fname; */ int may_coredump; - FILE *configfp = NULL; - char *configname = NULL; - unsigned configlineno; - int parse_debug = 0; + char *last_configname = NULL; + const char *configname = NULL; + int debug_argparser = 0; int no_more_options = 0; - int default_config =1; char *logfile = NULL; /* int debug_wait = 0; */ int use_random_seed = 1; @@ -246,7 +244,7 @@ main ( int argc, char **argv) early_system_init (); gnupg_reopen_std (G13_NAME "-syshelp"); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); log_set_prefix (G13_NAME "-syshelp", GPGRT_LOG_WITH_PREFIX); @@ -269,22 +267,24 @@ main ( int argc, char **argv) log_fatal ("error allocating session environment block: %s\n", strerror (errno)); - /* Fixme: We enable verbose mode here because there is currently no - way to do this when starting g13-syshelp. To fix that we should - add a g13-syshelp.conf file in /etc/gnupg. */ - opt.verbose = 1; - /* First check whether we have a debug option on the commandline. */ orig_argc = argc; orig_argv = argv; pargs.argc = &argc; pargs.argv = &argv; pargs.flags= (ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); - while (arg_parse( &pargs, opts)) + while (gpgrt_argparse (NULL, &pargs, opts)) { - if (pargs.r_opt == oDebug || pargs.r_opt == oDebugAll) - parse_debug++; + switch (pargs.r_opt) + { + case oDebug: + case oDebugAll: + debug_argparser++; + break; + } } + /* Reset the flags. */ + pargs.flags &= ~(ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); /* Initialize the secure memory. */ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); @@ -315,47 +315,40 @@ main ( int argc, char **argv) ctrl.no_server = 1; ctrl.status_fd = -1; /* No status output. */ - if (default_config ) - configname = make_filename (gnupg_sysconfdir (), - G13_NAME"-syshelp.conf", NULL); + /* The configuraton directories for use by gpgrt_argparser. */ + gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ()); + gpgrt_set_confdir (GPGRT_CONFDIR_USER, gnupg_homedir ()); argc = orig_argc; argv = orig_argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags = 1; /* Do not remove the args. */ - - next_pass: - if (configname) - { - configlineno = 0; - configfp = fopen (configname, "r"); - if (!configfp) - { - if (default_config) - { - if (parse_debug) - log_info (_("NOTE: no default option file '%s'\n"), configname); - } - else - { - log_error (_("option file '%s': %s\n"), - configname, strerror(errno)); - g13_exit(2); - } - xfree (configname); - configname = NULL; - } - if (parse_debug && configname) - log_info (_("reading options from '%s'\n"), configname); - default_config = 0; - } + pargs.flags |= (ARGPARSE_FLAG_RESET + | ARGPARSE_FLAG_KEEP + | ARGPARSE_FLAG_SYS + | ARGPARSE_FLAG_USER); while (!no_more_options - && optfile_parse (configfp, configname, &configlineno, &pargs, opts)) + && gpgrt_argparser (&pargs, opts, G13_NAME"-syshelp" EXTSEP_S "conf")) { switch (pargs.r_opt) { + case ARGPARSE_CONFFILE: + { + if (debug_argparser) + log_info (_("reading options from '%s'\n"), + pargs.r_type? pargs.r.ret_str: "[cmdline]"); + if (pargs.r_type) + { + xfree (last_configname); + last_configname = xstrdup (pargs.r.ret_str); + configname = last_configname; + } + else + configname = NULL; + } + break; + case oQuiet: opt.quiet = 1; break; case oDryRun: opt.dry_run = 1; break; @@ -408,26 +401,22 @@ main ( int argc, char **argv) case oNoRandomSeedFile: use_random_seed = 0; break; default: - pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; + pargs.err = configname? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; break; } } + gpgrt_argparse (NULL, &pargs, NULL); - if (configfp) + + if (!last_configname) + opt.config_filename = gpgrt_fnameconcat (gnupg_homedir (), + G13_NAME"-syshelp" EXTSEP_S "conf", + NULL); + else { - fclose (configfp); - configfp = NULL; - /* Keep a copy of the config filename. */ - opt.config_filename = configname; - configname = NULL; - goto next_pass; + opt.config_filename = last_configname; + last_configname = NULL; } - xfree (configname); - configname = NULL; - - if (!opt.config_filename) - opt.config_filename = make_filename (gnupg_homedir (), - G13_NAME".conf", NULL); if (log_get_errorcount(0)) g13_exit(2); diff --git a/g13/g13.c b/g13/g13.c index 385ba0f9b..2bbb453eb 100644 --- a/g13/g13.c +++ b/g13/g13.c @@ -15,12 +15,11 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . + * SPDX-License-Identifier: GPL-3.0-or-later */ #include -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS + #include #include #include @@ -50,7 +49,6 @@ #include "mountinfo.h" #include "backend.h" #include "call-syshelp.h" -#include "../common/argparse.h" /* temporary hack. */ enum cmd_and_opt_values { @@ -111,7 +109,7 @@ enum cmd_and_opt_values { }; -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { ARGPARSE_group (300, N_("@Commands:\n ")), @@ -142,7 +140,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oDryRun, "dry-run", N_("do not make any changes")), - ARGPARSE_s_s (oOptions, "options", N_("|FILE|read options from FILE")), + ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")), ARGPARSE_s_s (oDebug, "debug", "@"), ARGPARSE_s_s (oDebugLevel, "debug-level", @@ -167,7 +165,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oNoVerbose, "no-verbose", "@"), ARGPARSE_s_n (oNoSecmemWarn, "no-secmem-warning", "@"), ARGPARSE_s_n (oNoGreeting, "no-greeting", "@"), - ARGPARSE_s_n (oNoOptions, "no-options", "@"), + ARGPARSE_noconffile (oNoOptions, "no-options", "@"), ARGPARSE_s_s (oHomedir, "homedir", "@"), ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), ARGPARSE_s_s (oGpgProgram, "gpg-program", "@"), @@ -239,9 +237,11 @@ my_strusage( int level ) switch (level) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "@G13@ (@GNUPG@)"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <" PACKAGE_BUGREPORT ">.\n"); break; @@ -339,20 +339,18 @@ set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd) int -main ( int argc, char **argv) +main (int argc, char **argv) { - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; int orig_argc; char **orig_argv; gpg_error_t err = 0; /* const char *fname; */ int may_coredump; - FILE *configfp = NULL; - char *configname = NULL; - unsigned configlineno; - int parse_debug = 0; + char *last_configname = NULL; + const char *configname = NULL; + int debug_argparser = 0; int no_more_options = 0; - int default_config =1; char *logfile = NULL; int greeting = 0; int nogreeting = 0; @@ -368,7 +366,7 @@ main ( int argc, char **argv) early_system_init (); gnupg_reopen_std (G13_NAME); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); log_set_prefix (G13_NAME, GPGRT_LOG_WITH_PREFIX); @@ -398,30 +396,31 @@ main ( int argc, char **argv) orig_argv = argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1|(1<<6); /* Do not remove the args, ignore version. */ - while (arg_parse( &pargs, opts)) + pargs.flags= (ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); + while (gpgrt_argparse (NULL, &pargs, opts)) { - if (pargs.r_opt == oDebug || pargs.r_opt == oDebugAll) - parse_debug++; - else if (pargs.r_opt == oOptions) - { /* Yes, there is one, so we do not try the default one but - read the config file when it is encountered at the - commandline. */ - default_config = 0; - } - else if (pargs.r_opt == oNoOptions) - default_config = 0; /* --no-options */ - else if (pargs.r_opt == oHomedir) - gnupg_set_homedir (pargs.r.ret_str); + switch (pargs.r_opt) + { + case oDebug: + case oDebugAll: + debug_argparser++; + break; + + case oHomedir: + gnupg_set_homedir (pargs.r.ret_str); + break; + } } + /* Reset the flags. */ + pargs.flags &= ~(ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); /* Initialize the secure memory. */ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); maybe_setuid = 0; /* - Now we are now working under our real uid - */ + * Now we are now working under our real uid + */ /* Setup malloc hooks. */ { @@ -444,47 +443,42 @@ main ( int argc, char **argv) ctrl.no_server = 1; ctrl.status_fd = -1; /* No status output. */ - /* Set the default option file */ - if (default_config ) - configname = make_filename (gnupg_homedir (), G13_NAME".conf", NULL); + /* The configuraton directories for use by gpgrt_argparser. */ + gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ()); + gpgrt_set_confdir (GPGRT_CONFDIR_USER, gnupg_homedir ()); + /* We are re-using the struct, thus the reset flag. We OR the + * flags so that the internal intialized flag won't be cleared. */ argc = orig_argc; argv = orig_argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags = 1; /* Do not remove the args. */ - - next_pass: - if (configname) - { - configlineno = 0; - configfp = fopen (configname, "r"); - if (!configfp) - { - if (default_config) - { - if (parse_debug) - log_info (_("Note: no default option file '%s'\n"), configname); - } - else - { - log_error (_("option file '%s': %s\n"), - configname, strerror(errno)); - g13_exit(2); - } - xfree (configname); - configname = NULL; - } - if (parse_debug && configname) - log_info (_("reading options from '%s'\n"), configname); - default_config = 0; - } + pargs.flags |= (ARGPARSE_FLAG_RESET + | ARGPARSE_FLAG_KEEP + | ARGPARSE_FLAG_SYS + | ARGPARSE_FLAG_USER); while (!no_more_options - && optfile_parse (configfp, configname, &configlineno, &pargs, opts)) + && gpgrt_argparser (&pargs, opts, G13_NAME EXTSEP_S "conf")) { switch (pargs.r_opt) { + case ARGPARSE_CONFFILE: + { + if (debug_argparser) + log_info (_("reading options from '%s'\n"), + pargs.r_type? pargs.r.ret_str: "[cmdline]"); + if (pargs.r_type) + { + xfree (last_configname); + last_configname = xstrdup (pargs.r.ret_str); + configname = last_configname; + } + else + configname = NULL; + } + break; + case aGPGConfList: case aGPGConfTest: set_cmd (&cmd, pargs.r_opt); @@ -542,17 +536,6 @@ main ( int argc, char **argv) case oStatusFD: ctrl.status_fd = pargs.r.ret_int; break; case oLoggerFD: log_set_fd (pargs.r.ret_int ); break; - case oNoOptions: break; /* no-options */ - case oOptions: - /* Config files may not be nested (silently ignore them). */ - if (!configfp) - { - xfree(configname); - configname = xstrdup (pargs.r.ret_str); - goto next_pass; - } - break; - case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break; case oAgentProgram: opt.agent_program = pargs.r.ret_str; break; @@ -596,12 +579,17 @@ main ( int argc, char **argv) break; default: - pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; + if (configname) + pargs.err = ARGPARSE_PRINT_WARNING; + else + pargs.err = ARGPARSE_PRINT_ERROR; break; } } - /* XXX Construct GPG arguments. */ + gpgrt_argparse (NULL, &pargs, NULL); + + /* Construct GPG arguments. */ { strlist_t last; last = append_to_strlist (&opt.gpg_arguments, "-z"); @@ -611,21 +599,15 @@ main ( int argc, char **argv) (void) last; } - if (configfp) + if (!last_configname) + opt.config_filename = gpgrt_fnameconcat (gnupg_homedir (), + G13_NAME EXTSEP_S "conf", + NULL); + else { - fclose (configfp); - configfp = NULL; - /* Keep a copy of the config filename. */ - opt.config_filename = configname; - configname = NULL; - goto next_pass; + opt.config_filename = last_configname; + last_configname = NULL; } - xfree (configname); - configname = NULL; - - if (!opt.config_filename) - opt.config_filename = make_filename (gnupg_homedir (), - G13_NAME".conf", NULL); if (log_get_errorcount(0)) g13_exit(2); @@ -642,8 +624,8 @@ main ( int argc, char **argv) if (greeting) { fprintf (stderr, "%s %s; %s\n", - strusage(11), strusage(13), strusage(14) ); - fprintf (stderr, "%s\n", strusage(15) ); + gpgrt_strusage(11), gpgrt_strusage(13), gpgrt_strusage(14) ); + fprintf (stderr, "%s\n", gpgrt_strusage(15)); } if (may_coredump && !opt.quiet) @@ -663,7 +645,9 @@ main ( int argc, char **argv) if (logfile) { log_set_file (logfile); - log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX | GPGRT_LOG_WITH_TIME | GPGRT_LOG_WITH_PID); + log_set_prefix (NULL, (GPGRT_LOG_WITH_PREFIX + | GPGRT_LOG_WITH_TIME + | GPGRT_LOG_WITH_PID)); } if (gnupg_faked_time_p ()) @@ -907,14 +891,14 @@ handle_signal (int signo) if (shutdown_pending > 2) { log_info ("shutdown forced\n"); - log_info ("%s %s stopped\n", strusage(11), strusage(13) ); + log_info ("%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13) ); g13_exit (0); } break; case SIGINT: log_info ("SIGINT received - immediate shutdown\n"); - log_info( "%s %s stopped\n", strusage(11), strusage(13)); + log_info( "%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13)); g13_exit (0); break; #endif /*!HAVE_W32_SYSTEM*/ @@ -1012,7 +996,7 @@ idle_task (void *dummy_arg) /* Here one would add processing of file descriptors. */ } - log_info (_("%s %s stopped\n"), strusage(11), strusage(13)); + log_info (_("%s %s stopped\n"), gpgrt_strusage(11), gpgrt_strusage(13)); return NULL; } diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 507266532..1a145d8fc 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -16,12 +16,10 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . + * SPDX-License-Identifier: GPL-3.0-or-later */ #include -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS #include #include @@ -48,7 +46,6 @@ #include /* malloc hooks */ -#include "../common/argparse.h" /* temporary hack. */ #include "../common/i18n.h" #include "../common/sysutils.h" #include "iso7816.h" @@ -109,7 +106,7 @@ enum cmd_and_opt_values -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { ARGPARSE_c (aGPGConfList, "gpgconf-list", "@"), ARGPARSE_c (aGPGConfTest, "gpgconf-test", "@"), @@ -123,7 +120,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")), ARGPARSE_s_n (oSh, "sh", N_("sh-style command output")), ARGPARSE_s_n (oCsh, "csh", N_("csh-style command output")), - ARGPARSE_s_s (oOptions, "options", N_("|FILE|read options from FILE")), + ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")), ARGPARSE_s_s (oDebug, "debug", "@"), ARGPARSE_s_n (oDebugAll, "debug-all", "@"), ARGPARSE_s_s (oDebugLevel, "debug-level" , @@ -165,6 +162,7 @@ static ARGPARSE_OPTS opts[] = { N_("use variable length input for pinpad")), ARGPARSE_s_s (oHomedir, "homedir", "@"), ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"), + ARGPARSE_noconffile (oNoOptions, "no-options", "@"), ARGPARSE_end () }; @@ -289,9 +287,11 @@ my_strusage (int level) switch (level) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "@SCDAEMON@ (@GNUPG@)"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; @@ -420,16 +420,14 @@ setup_signal_mask (void) int main (int argc, char **argv ) { - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; int orig_argc; char **orig_argv; - FILE *configfp = NULL; - char *configname = NULL; + char *last_configname = NULL; + const char *configname = NULL; const char *shell; - unsigned int configlineno; - int parse_debug = 0; + int debug_argparser = 0; const char *debug_level = NULL; - int default_config =1; int greeting = 0; int nogreeting = 0; int multi_server = 0; @@ -439,7 +437,7 @@ main (int argc, char **argv ) char *logfile = NULL; int debug_wait = 0; int gpgconf_list = 0; - const char *config_filename = NULL; + char *config_filename = NULL; int allow_coredump = 0; struct assuan_malloc_hooks malloc_hooks; int res; @@ -447,7 +445,7 @@ main (int argc, char **argv ) const char *application_priority = NULL; early_system_init (); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); /* Please note that we may running SUID(ROOT), so be very CAREFUL when adding any stuff between here and the call to INIT_SECMEM() @@ -487,22 +485,22 @@ main (int argc, char **argv ) orig_argv = argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1|(1<<6); /* do not remove the args, ignore version */ - while (arg_parse( &pargs, opts)) + pargs.flags= (ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); + while (gpgrt_argparse (NULL, &pargs, opts)) { - if (pargs.r_opt == oDebug || pargs.r_opt == oDebugAll) - parse_debug++; - else if (pargs.r_opt == oOptions) - { /* yes there is one, so we do not try the default one, but - read the option file when it is encountered at the - commandline */ - default_config = 0; - } - else if (pargs.r_opt == oNoOptions) - default_config = 0; /* --no-options */ - else if (pargs.r_opt == oHomedir) + switch (pargs.r_opt) + { + case oDebug: + case oDebugAll: + debug_argparser++; + break; + case oHomedir: gnupg_set_homedir (pargs.r.ret_str); + break; + } } + /* Reset the flags. */ + pargs.flags &= ~(ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION); /* initialize the secure memory. */ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); @@ -512,48 +510,38 @@ main (int argc, char **argv ) Now we are working under our real uid */ + /* The configuraton directories for use by gpgrt_argparser. */ + gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ()); + gpgrt_set_confdir (GPGRT_CONFDIR_USER, gnupg_homedir ()); - if (default_config) - configname = make_filename (gnupg_homedir (), SCDAEMON_NAME EXTSEP_S "conf", - NULL ); - - + /* We are re-using the struct, thus the reset flag. We OR the + * flags so that the internal intialized flag won't be cleared. */ argc = orig_argc; argv = orig_argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1; /* do not remove the args */ - next_pass: - if (configname) - { - configlineno = 0; - configfp = fopen (configname, "r"); - if (!configfp) - { - if (default_config) - { - if( parse_debug ) - log_info (_("Note: no default option file '%s'\n"), - configname ); - } - else - { - log_error (_("option file '%s': %s\n"), - configname, strerror(errno) ); - exit(2); - } - xfree (configname); - configname = NULL; - } - if (parse_debug && configname ) - log_info (_("reading options from '%s'\n"), configname ); - default_config = 0; - } - - while (optfile_parse( configfp, configname, &configlineno, &pargs, opts) ) + pargs.flags |= (ARGPARSE_FLAG_RESET + | ARGPARSE_FLAG_KEEP + | ARGPARSE_FLAG_SYS + | ARGPARSE_FLAG_USER); + while (gpgrt_argparser (&pargs, opts, SCDAEMON_NAME EXTSEP_S "conf")) { switch (pargs.r_opt) { + case ARGPARSE_CONFFILE: + if (debug_argparser) + log_info (_("reading options from '%s'\n"), + pargs.r_type? pargs.r.ret_str: "[cmdline]"); + if (pargs.r_type) + { + xfree (last_configname); + last_configname = xstrdup (pargs.r.ret_str); + configname = last_configname; + } + else + configname = NULL; + break; + case aGPGConfList: gpgconf_list = 1; break; case aGPGConfTest: gpgconf_list = 2; break; case oQuiet: opt.quiet = 1; break; @@ -586,18 +574,8 @@ main (int argc, char **argv ) set_libassuan_log_cats (pargs.r.ret_ulong); break; - case oOptions: - /* config files may not be nested (silently ignore them) */ - if (!configfp) - { - xfree(configname); - configname = xstrdup(pargs.r.ret_str); - goto next_pass; - } - break; case oNoGreeting: nogreeting = 1; break; case oNoVerbose: opt.verbose = 0; break; - case oNoOptions: break; /* no-options */ case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break; case oNoDetach: nodetach = 1; break; case oLogFile: logfile = pargs.r.ret_str; break; @@ -636,21 +614,26 @@ main (int argc, char **argv ) break; default: - pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; + if (configname) + pargs.err = ARGPARSE_PRINT_WARNING; + else + pargs.err = ARGPARSE_PRINT_ERROR; break; } } - if (configfp) + + gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */ + + if (!last_configname) + config_filename = gpgrt_fnameconcat (gnupg_homedir (), + SCDAEMON_NAME EXTSEP_S "conf", + NULL); + else { - fclose( configfp ); - configfp = NULL; - /* Keep a copy of the config name for use by --gpgconf-list. */ - config_filename = configname; - configname = NULL; - goto next_pass; + config_filename = last_configname; + last_configname = NULL; } - xfree (configname); - configname = NULL; + if (log_get_errorcount(0)) exit(2); if (nogreeting ) @@ -659,8 +642,8 @@ main (int argc, char **argv ) if (greeting) { es_fprintf (es_stderr, "%s %s; %s\n", - strusage(11), strusage(13), strusage(14) ); - es_fprintf (es_stderr, "%s\n", strusage(15) ); + gpgrt_strusage (11),gpgrt_strusage (13),gpgrt_strusage (14)); + es_fprintf (es_stderr, "%s\n", gpgrt_strusage (15)); } #ifdef IS_DEVELOPMENT_VERSION log_info ("NOTE: this is a development version!\n"); @@ -697,21 +680,14 @@ main (int argc, char **argv ) if (gpgconf_list) { /* List options and default values in the GPG Conf format. */ - char *filename = NULL; char *filename_esc; - if (config_filename) - filename = xstrdup (config_filename); - else - filename = make_filename (gnupg_homedir (), - SCDAEMON_NAME EXTSEP_S "conf", NULL); - filename_esc = percent_escape (filename, NULL); + filename_esc = percent_escape (config_filename, NULL); es_printf ("%s-%s.conf:%lu:\"%s\n", GPGCONF_NAME, SCDAEMON_NAME, GC_OPT_FLAG_DEFAULT, filename_esc); xfree (filename_esc); - xfree (filename); es_printf ("verbose:%lu:\n" "quiet:%lu:\n" @@ -969,6 +945,7 @@ main (int argc, char **argv ) close (fd); } + xfree (config_filename); return 0; } @@ -1063,7 +1040,7 @@ handle_signal (int signo) if (shutdown_pending > 2) { log_info ("shutdown forced\n"); - log_info ("%s %s stopped\n", strusage(11), strusage(13) ); + log_info ("%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13)); cleanup (); scd_exit (0); } @@ -1071,7 +1048,7 @@ handle_signal (int signo) case SIGINT: log_info ("SIGINT received - immediate shutdown\n"); - log_info( "%s %s stopped\n", strusage(11), strusage(13)); + log_info( "%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13)); cleanup (); scd_exit (0); break; @@ -1455,7 +1432,7 @@ handle_connections (int listen_fd) close (pipe_fd[1]); #endif cleanup (); - log_info (_("%s %s stopped\n"), strusage(11), strusage(13)); + log_info (_("%s %s stopped\n"), gpgrt_strusage(11), gpgrt_strusage(13)); npth_attr_destroy (&tattr); }