2009-09-23 10:28:41 +00:00
|
|
|
|
/* g13.c - Disk Key management with GnuPG
|
|
|
|
|
* Copyright (C) 2009 Free Software Foundation, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2020-02-21 21:45:13 +01:00
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2009-09-23 10:28:41 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2020-02-21 21:45:13 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <fcntl.h>
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
#include <npth.h>
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2020-02-10 16:37:34 +01:00
|
|
|
|
#define INCLUDED_BY_MAIN_MODULE 1
|
2009-09-23 10:28:41 +00:00
|
|
|
|
#include "g13.h"
|
|
|
|
|
|
|
|
|
|
#include <gcrypt.h>
|
2009-09-30 15:28:38 +00:00
|
|
|
|
#include <assuan.h>
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2017-03-07 20:21:23 +09:00
|
|
|
|
#include "../common/i18n.h"
|
|
|
|
|
#include "../common/sysutils.h"
|
|
|
|
|
#include "../common/gc-opt-flags.h"
|
|
|
|
|
#include "../common/asshelp.h"
|
2012-02-06 20:50:47 +01:00
|
|
|
|
#include "../common/init.h"
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 19:18:21 +09:00
|
|
|
|
#include "../common/exechelp.h"
|
2009-09-30 15:28:38 +00:00
|
|
|
|
#include "keyblob.h"
|
2009-10-14 17:06:10 +00:00
|
|
|
|
#include "server.h"
|
|
|
|
|
#include "runner.h"
|
|
|
|
|
#include "create.h"
|
2009-10-15 17:20:41 +00:00
|
|
|
|
#include "mount.h"
|
2016-02-23 14:32:46 +01:00
|
|
|
|
#include "suspend.h"
|
2009-10-15 17:20:41 +00:00
|
|
|
|
#include "mountinfo.h"
|
2015-10-21 08:38:10 +02:00
|
|
|
|
#include "backend.h"
|
|
|
|
|
#include "call-syshelp.h"
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum cmd_and_opt_values {
|
|
|
|
|
aNull = 0,
|
|
|
|
|
oQuiet = 'q',
|
|
|
|
|
oVerbose = 'v',
|
2009-10-19 09:18:46 +00:00
|
|
|
|
oRecipient = 'r',
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
aGPGConfList = 500,
|
|
|
|
|
aGPGConfTest,
|
|
|
|
|
aCreate,
|
|
|
|
|
aMount,
|
|
|
|
|
aUmount,
|
2016-02-23 14:32:46 +01:00
|
|
|
|
aSuspend,
|
|
|
|
|
aResume,
|
2009-10-14 17:06:10 +00:00
|
|
|
|
aServer,
|
2016-08-13 12:49:54 +02:00
|
|
|
|
aFindDevice,
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
oOptions,
|
|
|
|
|
oDebug,
|
|
|
|
|
oDebugLevel,
|
|
|
|
|
oDebugAll,
|
|
|
|
|
oDebugNone,
|
|
|
|
|
oDebugWait,
|
|
|
|
|
oDebugAllowCoreDump,
|
|
|
|
|
oLogFile,
|
|
|
|
|
oNoLogFile,
|
|
|
|
|
oAuditLog,
|
|
|
|
|
|
|
|
|
|
oOutput,
|
|
|
|
|
|
|
|
|
|
oAgentProgram,
|
2009-09-30 15:28:38 +00:00
|
|
|
|
oGpgProgram,
|
2015-10-21 08:38:10 +02:00
|
|
|
|
oType,
|
2009-09-30 15:28:38 +00:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
oDisplay,
|
|
|
|
|
oTTYname,
|
|
|
|
|
oTTYtype,
|
|
|
|
|
oLCctype,
|
|
|
|
|
oLCmessages,
|
|
|
|
|
oXauthority,
|
|
|
|
|
|
|
|
|
|
oStatusFD,
|
|
|
|
|
oLoggerFD,
|
|
|
|
|
|
|
|
|
|
oNoVerbose,
|
|
|
|
|
oNoSecmemWarn,
|
|
|
|
|
oNoGreeting,
|
|
|
|
|
oNoTTY,
|
|
|
|
|
oNoOptions,
|
|
|
|
|
oHomedir,
|
|
|
|
|
oWithColons,
|
|
|
|
|
oDryRun,
|
2009-10-13 19:17:24 +00:00
|
|
|
|
oNoDetach,
|
2024-01-09 19:52:04 +01:00
|
|
|
|
oNoMount,
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
oNoRandomSeedFile,
|
|
|
|
|
oFakedSystemTime
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2020-02-21 21:45:13 +01:00
|
|
|
|
static gpgrt_opt_t opts[] = {
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
ARGPARSE_group (300, N_("@Commands:\n ")),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_c (aCreate, "create", N_("Create a new file system container")),
|
|
|
|
|
ARGPARSE_c (aMount, "mount", N_("Mount a file system container") ),
|
|
|
|
|
ARGPARSE_c (aUmount, "umount", N_("Unmount a file system container") ),
|
2016-02-23 14:32:46 +01:00
|
|
|
|
ARGPARSE_c (aSuspend, "suspend", N_("Suspend a file system container") ),
|
|
|
|
|
ARGPARSE_c (aResume, "resume", N_("Resume a file system container") ),
|
2009-10-14 17:06:10 +00:00
|
|
|
|
ARGPARSE_c (aServer, "server", N_("Run in server mode")),
|
2016-08-13 12:49:54 +02:00
|
|
|
|
ARGPARSE_c (aFindDevice, "find-device", "@"),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
ARGPARSE_c (aGPGConfList, "gpgconf-list", "@"),
|
|
|
|
|
ARGPARSE_c (aGPGConfTest, "gpgconf-test", "@"),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_group (301, N_("@\nOptions:\n ")),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_s_s (oRecipient, "recipient", N_("|USER-ID|encrypt for USER-ID")),
|
2015-10-21 08:38:10 +02:00
|
|
|
|
ARGPARSE_s_s (oType, "type", N_("|NAME|use container format NAME")),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
|
|
|
|
|
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
|
|
|
|
|
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
|
|
|
|
|
ARGPARSE_s_n (oNoTTY, "no-tty", N_("don't use the terminal at all")),
|
2009-10-13 19:17:24 +00:00
|
|
|
|
ARGPARSE_s_n (oNoDetach, "no-detach", N_("do not detach from the console")),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
ARGPARSE_s_s (oLogFile, "log-file", N_("|FILE|write log output to FILE")),
|
|
|
|
|
ARGPARSE_s_n (oNoLogFile, "no-log-file", "@"),
|
|
|
|
|
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"),
|
2024-01-09 19:52:04 +01:00
|
|
|
|
ARGPARSE_s_n (oNoMount, "no-mount", N_("stop right before running mount")),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
ARGPARSE_s_n (oDryRun, "dry-run", N_("do not make any changes")),
|
|
|
|
|
|
2020-02-21 21:45:13 +01:00
|
|
|
|
ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2015-06-23 09:12:44 +02:00
|
|
|
|
ARGPARSE_s_s (oDebug, "debug", "@"),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
ARGPARSE_s_s (oDebugLevel, "debug-level",
|
|
|
|
|
N_("|LEVEL|set the debugging level to LEVEL")),
|
|
|
|
|
ARGPARSE_s_n (oDebugAll, "debug-all", "@"),
|
|
|
|
|
ARGPARSE_s_n (oDebugNone, "debug-none", "@"),
|
|
|
|
|
ARGPARSE_s_i (oDebugWait, "debug-wait", "@"),
|
|
|
|
|
ARGPARSE_s_n (oDebugAllowCoreDump, "debug-allow-core-dump", "@"),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_s_i (oStatusFD, "status-fd",
|
|
|
|
|
N_("|FD|write status info to this FD")),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_group (302, N_(
|
|
|
|
|
"@\n(See the man page for a complete listing of all commands and options)\n"
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_group (303, N_("@\nExamples:\n\n"
|
|
|
|
|
" blurb\n"
|
|
|
|
|
" blurb\n")),
|
|
|
|
|
|
|
|
|
|
/* Hidden options. */
|
|
|
|
|
ARGPARSE_s_n (oNoVerbose, "no-verbose", "@"),
|
2011-02-04 12:57:53 +01:00
|
|
|
|
ARGPARSE_s_n (oNoSecmemWarn, "no-secmem-warning", "@"),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
ARGPARSE_s_n (oNoGreeting, "no-greeting", "@"),
|
2020-02-21 21:45:13 +01:00
|
|
|
|
ARGPARSE_noconffile (oNoOptions, "no-options", "@"),
|
2011-02-04 12:57:53 +01:00
|
|
|
|
ARGPARSE_s_s (oHomedir, "homedir", "@"),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"),
|
2009-09-30 15:28:38 +00:00
|
|
|
|
ARGPARSE_s_s (oGpgProgram, "gpg-program", "@"),
|
2009-09-23 10:28:41 +00:00
|
|
|
|
ARGPARSE_s_s (oDisplay, "display", "@"),
|
|
|
|
|
ARGPARSE_s_s (oTTYname, "ttyname", "@"),
|
|
|
|
|
ARGPARSE_s_s (oTTYtype, "ttytype", "@"),
|
|
|
|
|
ARGPARSE_s_s (oLCctype, "lc-ctype", "@"),
|
|
|
|
|
ARGPARSE_s_s (oLCmessages, "lc-messages", "@"),
|
|
|
|
|
ARGPARSE_s_s (oXauthority, "xauthority", "@"),
|
|
|
|
|
ARGPARSE_s_s (oFakedSystemTime, "faked-system-time", "@"),
|
|
|
|
|
ARGPARSE_s_n (oWithColons, "with-colons", "@"),
|
|
|
|
|
ARGPARSE_s_n (oNoRandomSeedFile, "no-random-seed-file", "@"),
|
|
|
|
|
|
|
|
|
|
/* Command aliases. */
|
|
|
|
|
|
|
|
|
|
ARGPARSE_end ()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2015-06-23 09:12:44 +02:00
|
|
|
|
/* The list of supported debug flags. */
|
|
|
|
|
static struct debug_flags_s debug_flags [] =
|
|
|
|
|
{
|
|
|
|
|
{ DBG_MOUNT_VALUE , "mount" },
|
|
|
|
|
{ DBG_CRYPTO_VALUE , "crypto" },
|
|
|
|
|
{ DBG_MEMORY_VALUE , "memory" },
|
|
|
|
|
{ DBG_MEMSTAT_VALUE, "memstat" },
|
|
|
|
|
{ DBG_IPC_VALUE , "ipc" },
|
|
|
|
|
{ 0, NULL }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
/* The timer tick interval used by the idle task. */
|
|
|
|
|
#define TIMERTICK_INTERVAL_SEC (1)
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
/* It is possible that we are currently running under setuid permissions. */
|
|
|
|
|
static int maybe_setuid = 1;
|
|
|
|
|
|
|
|
|
|
/* Helper to implement --debug-level and --debug. */
|
|
|
|
|
static const char *debug_level;
|
|
|
|
|
static unsigned int debug_value;
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
/* Flag to indicate that a shutdown was requested. */
|
|
|
|
|
static int shutdown_pending;
|
|
|
|
|
|
|
|
|
|
/* The thread id of the idle task. */
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
static npth_t idle_task_thread;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
|
2015-09-14 18:49:32 +02:00
|
|
|
|
/* The container type as specified on the command line. */
|
|
|
|
|
static int cmdline_conttype;
|
|
|
|
|
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
static void set_cmd (enum cmd_and_opt_values *ret_cmd,
|
|
|
|
|
enum cmd_and_opt_values new_cmd );
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
static void start_idle_task (void);
|
|
|
|
|
static void join_idle_task (void);
|
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
static const char *
|
|
|
|
|
my_strusage( int level )
|
|
|
|
|
{
|
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
|
{
|
2020-02-21 21:45:13 +01:00
|
|
|
|
case 9: p = "GPL-3.0-or-later"; break;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
case 11: p = "@G13@ (@GNUPG@)";
|
2009-09-23 10:28:41 +00:00
|
|
|
|
break;
|
|
|
|
|
case 13: p = VERSION; break;
|
2020-02-21 21:45:13 +01:00
|
|
|
|
case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case 17: p = PRINTABLE_OS_NAME; break;
|
|
|
|
|
case 19: p = _("Please report bugs to <" PACKAGE_BUGREPORT ">.\n");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2013-11-18 14:09:47 +01:00
|
|
|
|
case 40: p = _("Usage: @G13@ [options] [files] (-h for help)");
|
2009-09-23 10:28:41 +00:00
|
|
|
|
break;
|
|
|
|
|
case 41:
|
2013-11-18 14:09:47 +01:00
|
|
|
|
p = _("Syntax: @G13@ [options] [files]\n"
|
2009-09-23 10:28:41 +00:00
|
|
|
|
"Create, mount or unmount an encrypted file system container\n");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 31: p = "\nHome: "; break;
|
2016-06-07 10:59:46 +02:00
|
|
|
|
case 32: p = gnupg_homedir (); break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
default: p = NULL; break;
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
wrong_args (const char *text)
|
|
|
|
|
{
|
2013-11-18 14:09:47 +01:00
|
|
|
|
fprintf (stderr, _("usage: %s [options] "), G13_NAME);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
fputs (text, stderr);
|
|
|
|
|
putc ('\n', stderr);
|
|
|
|
|
g13_exit (2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup the debugging. With a DEBUG_LEVEL of NULL only the active
|
|
|
|
|
debug flags are propagated to the subsystems. With DEBUG_LEVEL
|
|
|
|
|
set, a specific set of debug flags is set; and individual debugging
|
|
|
|
|
flags will be added on top. */
|
|
|
|
|
static void
|
|
|
|
|
set_debug (void)
|
|
|
|
|
{
|
2009-12-03 18:04:40 +00:00
|
|
|
|
int numok = (debug_level && digitp (debug_level));
|
|
|
|
|
int numlvl = numok? atoi (debug_level) : 0;
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
if (!debug_level)
|
|
|
|
|
;
|
2009-12-03 18:04:40 +00:00
|
|
|
|
else if (!strcmp (debug_level, "none") || (numok && numlvl < 1))
|
2009-09-23 10:28:41 +00:00
|
|
|
|
opt.debug = 0;
|
2009-12-03 18:04:40 +00:00
|
|
|
|
else if (!strcmp (debug_level, "basic") || (numok && numlvl <= 2))
|
2015-04-06 13:42:17 +02:00
|
|
|
|
opt.debug = DBG_IPC_VALUE|DBG_MOUNT_VALUE;
|
2009-12-03 18:04:40 +00:00
|
|
|
|
else if (!strcmp (debug_level, "advanced") || (numok && numlvl <= 5))
|
2015-04-06 13:42:17 +02:00
|
|
|
|
opt.debug = DBG_IPC_VALUE|DBG_MOUNT_VALUE;
|
2009-12-03 18:04:40 +00:00
|
|
|
|
else if (!strcmp (debug_level, "expert") || (numok && numlvl <= 8))
|
2015-04-06 13:42:17 +02:00
|
|
|
|
opt.debug = (DBG_IPC_VALUE|DBG_MOUNT_VALUE|DBG_CRYPTO_VALUE);
|
2009-12-03 18:04:40 +00:00
|
|
|
|
else if (!strcmp (debug_level, "guru") || numok)
|
|
|
|
|
{
|
|
|
|
|
opt.debug = ~0;
|
|
|
|
|
/* if (numok) */
|
|
|
|
|
/* opt.debug &= ~(DBG_HASHING_VALUE); */
|
|
|
|
|
}
|
2009-09-23 10:28:41 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("invalid debug-level '%s' given\n"), debug_level);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
g13_exit(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
opt.debug |= debug_value;
|
|
|
|
|
|
|
|
|
|
if (opt.debug && !opt.verbose)
|
|
|
|
|
opt.verbose = 1;
|
|
|
|
|
if (opt.debug)
|
|
|
|
|
opt.quiet = 0;
|
|
|
|
|
|
|
|
|
|
if (opt.debug & DBG_CRYPTO_VALUE )
|
|
|
|
|
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1);
|
|
|
|
|
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
|
2009-12-03 18:04:40 +00:00
|
|
|
|
|
|
|
|
|
if (opt.debug)
|
2015-06-23 09:12:44 +02:00
|
|
|
|
parse_debug_flag (NULL, &opt.debug, debug_flags);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd)
|
|
|
|
|
{
|
|
|
|
|
enum cmd_and_opt_values cmd = *ret_cmd;
|
|
|
|
|
|
|
|
|
|
if (!cmd || cmd == new_cmd)
|
|
|
|
|
cmd = new_cmd;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{
|
|
|
|
|
log_error (_("conflicting commands\n"));
|
|
|
|
|
g13_exit (2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*ret_cmd = cmd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2020-02-21 21:45:13 +01:00
|
|
|
|
main (int argc, char **argv)
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{
|
2020-02-21 21:45:13 +01:00
|
|
|
|
gpgrt_argparse_t pargs;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
int orig_argc;
|
|
|
|
|
char **orig_argv;
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
gpg_error_t err = 0;
|
2013-02-12 19:28:54 +01:00
|
|
|
|
/* const char *fname; */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
int may_coredump;
|
2020-02-21 21:45:13 +01:00
|
|
|
|
char *last_configname = NULL;
|
|
|
|
|
const char *configname = NULL;
|
|
|
|
|
int debug_argparser = 0;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
int no_more_options = 0;
|
|
|
|
|
char *logfile = NULL;
|
|
|
|
|
int greeting = 0;
|
|
|
|
|
int nogreeting = 0;
|
2013-02-12 19:28:54 +01:00
|
|
|
|
/* int debug_wait = 0; */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
int use_random_seed = 1;
|
2013-02-12 19:28:54 +01:00
|
|
|
|
/* int nodetach = 0; */
|
|
|
|
|
/* int nokeysetup = 0; */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
enum cmd_and_opt_values cmd = 0;
|
|
|
|
|
struct server_control_s ctrl;
|
|
|
|
|
strlist_t recipients = NULL;
|
|
|
|
|
|
|
|
|
|
/*mtrace();*/
|
|
|
|
|
|
2015-01-28 19:57:22 +01:00
|
|
|
|
early_system_init ();
|
2013-11-18 14:09:47 +01:00
|
|
|
|
gnupg_reopen_std (G13_NAME);
|
2020-02-21 21:45:13 +01:00
|
|
|
|
gpgrt_set_strusage (my_strusage);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
|
|
|
|
|
|
Call log_set_prefix() with human-readable labels.
* agent/preset-passphrase.c, agent/protect-tool.c, dirmngr/dirmngr.c
* dirmngr/t-http.c, g10/gpg.c, g10/gpgv.c, g13/g13-syshelp.c
* g13/g13.c, kbx/kbxutil.c, scd/scdaemon.c, sm/gpgsm.c
* tests/gpgscm/main.c, tools/gpg-check-pattern.c
* tools/gpg-connect-agent.c, tools/gpgconf.c, tools/gpgtar.c
* tools/symcryptrun.c: Invoke log_set_prefix() with
human-readable labels.
--
Some invocations of log_set_prefix() were done with raw numeric values
instead of values that humans can understand. Use symbolic
representations instead of numeric for better readability.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-12 01:37:57 -04:00
|
|
|
|
log_set_prefix (G13_NAME, GPGRT_LOG_WITH_PREFIX);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure that our subsystems are ready. */
|
2009-09-30 15:28:38 +00:00
|
|
|
|
i18n_init ();
|
2010-03-22 12:46:05 +00:00
|
|
|
|
init_common_subsystems (&argc, &argv);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
npth_init ();
|
2023-07-24 13:56:35 +09:00
|
|
|
|
gpgrt_set_syscall_clamp (npth_unprotect, npth_protect);
|
2009-09-30 15:28:38 +00:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
/* Take extra care of the random pool. */
|
|
|
|
|
gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
|
|
|
|
|
|
|
|
|
|
may_coredump = disable_core_dumps ();
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2015-09-14 18:49:32 +02:00
|
|
|
|
g13_init_signals ();
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2011-09-28 15:41:58 +02:00
|
|
|
|
dotlock_create (NULL, 0); /* Register locking cleanup. */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2009-11-05 02:18:31 +00:00
|
|
|
|
opt.session_env = session_env_new ();
|
|
|
|
|
if (!opt.session_env)
|
|
|
|
|
log_fatal ("error allocating session environment block: %s\n",
|
|
|
|
|
strerror (errno));
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
/* First check whether we have a config file on the commandline. */
|
|
|
|
|
orig_argc = argc;
|
|
|
|
|
orig_argv = argv;
|
|
|
|
|
pargs.argc = &argc;
|
|
|
|
|
pargs.argv = &argv;
|
2020-02-21 21:45:13 +01:00
|
|
|
|
pargs.flags= (ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION);
|
|
|
|
|
while (gpgrt_argparse (NULL, &pargs, opts))
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{
|
2020-02-21 21:45:13 +01:00
|
|
|
|
switch (pargs.r_opt)
|
|
|
|
|
{
|
|
|
|
|
case oDebug:
|
|
|
|
|
case oDebugAll:
|
|
|
|
|
debug_argparser++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case oHomedir:
|
|
|
|
|
gnupg_set_homedir (pargs.r.ret_str);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
2020-02-21 21:45:13 +01:00
|
|
|
|
/* Reset the flags. */
|
|
|
|
|
pargs.flags &= ~(ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
/* Initialize the secure memory. */
|
|
|
|
|
gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
|
|
|
|
|
maybe_setuid = 0;
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
/*
|
2020-02-21 21:45:13 +01:00
|
|
|
|
* Now we are now working under our real uid
|
|
|
|
|
*/
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2009-09-30 15:28:38 +00:00
|
|
|
|
/* Setup malloc hooks. */
|
|
|
|
|
{
|
|
|
|
|
struct assuan_malloc_hooks malloc_hooks;
|
|
|
|
|
|
|
|
|
|
malloc_hooks.malloc = gcry_malloc;
|
|
|
|
|
malloc_hooks.realloc = gcry_realloc;
|
|
|
|
|
malloc_hooks.free = gcry_free;
|
|
|
|
|
assuan_set_malloc_hooks (&malloc_hooks);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-09-30 15:28:38 +00:00
|
|
|
|
/* Prepare libassuan. */
|
|
|
|
|
assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
|
2016-09-05 10:55:10 +02:00
|
|
|
|
setup_libassuan_logging (&opt.debug, NULL);
|
2023-08-29 13:23:48 +02:00
|
|
|
|
assuan_control (ASSUAN_CONTROL_REINIT_SYSCALL_CLAMP, NULL);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
/* Setup a default control structure for command line mode. */
|
|
|
|
|
memset (&ctrl, 0, sizeof ctrl);
|
|
|
|
|
g13_init_default_ctrl (&ctrl);
|
2009-10-28 12:02:15 +00:00
|
|
|
|
ctrl.no_server = 1;
|
|
|
|
|
ctrl.status_fd = -1; /* No status output. */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2020-02-21 21:45:13 +01:00
|
|
|
|
/* The configuraton directories for use by gpgrt_argparser. */
|
|
|
|
|
gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ());
|
|
|
|
|
gpgrt_set_confdir (GPGRT_CONFDIR_USER, gnupg_homedir ());
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2020-02-21 21:45:13 +01:00
|
|
|
|
/* We are re-using the struct, thus the reset flag. We OR the
|
|
|
|
|
* flags so that the internal intialized flag won't be cleared. */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
argc = orig_argc;
|
|
|
|
|
argv = orig_argv;
|
|
|
|
|
pargs.argc = &argc;
|
|
|
|
|
pargs.argv = &argv;
|
2020-02-21 21:45:13 +01:00
|
|
|
|
pargs.flags |= (ARGPARSE_FLAG_RESET
|
|
|
|
|
| ARGPARSE_FLAG_KEEP
|
2024-02-20 11:40:49 +01:00
|
|
|
|
#if GPGRT_VERSION_NUMBER >= 0x013000 /* >= 1.48 */
|
|
|
|
|
| ARGPARSE_FLAG_COMMAND
|
|
|
|
|
#endif
|
2020-02-21 21:45:13 +01:00
|
|
|
|
| ARGPARSE_FLAG_SYS
|
|
|
|
|
| ARGPARSE_FLAG_USER);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
|
|
|
|
while (!no_more_options
|
2020-02-21 21:45:13 +01:00
|
|
|
|
&& gpgrt_argparser (&pargs, opts, G13_NAME EXTSEP_S "conf"))
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{
|
|
|
|
|
switch (pargs.r_opt)
|
|
|
|
|
{
|
2020-02-21 21:45:13 +01:00
|
|
|
|
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;
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
case aGPGConfList:
|
|
|
|
|
case aGPGConfTest:
|
2009-09-23 10:28:41 +00:00
|
|
|
|
set_cmd (&cmd, pargs.r_opt);
|
|
|
|
|
nogreeting = 1;
|
2013-02-12 19:28:54 +01:00
|
|
|
|
/* nokeysetup = 1; */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
case aServer:
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case aMount:
|
|
|
|
|
case aUmount:
|
2016-02-23 14:32:46 +01:00
|
|
|
|
case aSuspend:
|
|
|
|
|
case aResume:
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case aCreate:
|
2016-08-13 12:49:54 +02:00
|
|
|
|
case aFindDevice:
|
2009-09-23 10:28:41 +00:00
|
|
|
|
set_cmd (&cmd, pargs.r_opt);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case oOutput: opt.outfile = pargs.r.ret_str; break;
|
|
|
|
|
|
|
|
|
|
case oQuiet: opt.quiet = 1; break;
|
|
|
|
|
case oNoGreeting: nogreeting = 1; break;
|
|
|
|
|
case oNoTTY: break;
|
|
|
|
|
|
|
|
|
|
case oDryRun: opt.dry_run = 1; break;
|
|
|
|
|
|
|
|
|
|
case oVerbose:
|
|
|
|
|
opt.verbose++;
|
|
|
|
|
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
|
|
|
|
|
break;
|
|
|
|
|
case oNoVerbose:
|
|
|
|
|
opt.verbose = 0;
|
|
|
|
|
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case oLogFile: logfile = pargs.r.ret_str; break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
case oNoLogFile: logfile = NULL; break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2013-02-12 19:28:54 +01:00
|
|
|
|
case oNoDetach: /*nodetach = 1; */break;
|
2009-10-13 19:17:24 +00:00
|
|
|
|
|
2024-01-09 19:52:04 +01:00
|
|
|
|
case oNoMount: opt.no_mount = 1; break;
|
|
|
|
|
|
2015-06-23 09:12:44 +02:00
|
|
|
|
case oDebug:
|
|
|
|
|
if (parse_debug_flag (pargs.r.ret_str, &opt.debug, debug_flags))
|
|
|
|
|
{
|
|
|
|
|
pargs.r_opt = ARGPARSE_INVALID_ARG;
|
|
|
|
|
pargs.err = ARGPARSE_PRINT_ERROR;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case oDebugAll: debug_value = ~0; break;
|
|
|
|
|
case oDebugNone: debug_value = 0; break;
|
|
|
|
|
case oDebugLevel: debug_level = pargs.r.ret_str; break;
|
2013-02-12 19:28:54 +01:00
|
|
|
|
case oDebugWait: /*debug_wait = pargs.r.ret_int; */break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case oDebugAllowCoreDump:
|
|
|
|
|
may_coredump = enable_core_dumps ();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case oStatusFD: ctrl.status_fd = pargs.r.ret_int; break;
|
|
|
|
|
case oLoggerFD: log_set_fd (pargs.r.ret_int ); break;
|
|
|
|
|
|
2016-06-07 10:59:46 +02:00
|
|
|
|
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
case oAgentProgram: opt.agent_program = pargs.r.ret_str; break;
|
2009-09-30 15:28:38 +00:00
|
|
|
|
case oGpgProgram: opt.gpg_program = pargs.r.ret_str; break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case oDisplay: opt.display = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oTTYname: opt.ttyname = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oTTYtype: opt.ttytype = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oLCctype: opt.lc_ctype = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oLCmessages: opt.lc_messages = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oXauthority: opt.xauthority = xstrdup (pargs.r.ret_str); break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case oFakedSystemTime:
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
time_t faked_time = isotime2epoch (pargs.r.ret_str);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
if (faked_time == (time_t)(-1))
|
|
|
|
|
faked_time = (time_t)strtoul (pargs.r.ret_str, NULL, 10);
|
|
|
|
|
gnupg_set_time (faked_time, 0);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case oNoSecmemWarn: gcry_control (GCRYCTL_DISABLE_SECMEM_WARN); break;
|
|
|
|
|
|
|
|
|
|
case oNoRandomSeedFile: use_random_seed = 0; break;
|
|
|
|
|
|
|
|
|
|
case oRecipient: /* Store the encryption key. */
|
|
|
|
|
add_to_strlist (&recipients, pargs.r.ret_str);
|
|
|
|
|
break;
|
|
|
|
|
|
2015-10-21 08:38:10 +02:00
|
|
|
|
case oType:
|
|
|
|
|
if (!strcmp (pargs.r.ret_str, "help"))
|
|
|
|
|
{
|
|
|
|
|
be_parse_conttype_name (NULL);
|
|
|
|
|
g13_exit (0);
|
|
|
|
|
}
|
|
|
|
|
cmdline_conttype = be_parse_conttype_name (pargs.r.ret_str);
|
|
|
|
|
if (!cmdline_conttype)
|
|
|
|
|
{
|
|
|
|
|
pargs.r_opt = ARGPARSE_INVALID_ARG;
|
|
|
|
|
pargs.err = ARGPARSE_PRINT_ERROR;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
default:
|
2020-02-21 21:45:13 +01:00
|
|
|
|
if (configname)
|
|
|
|
|
pargs.err = ARGPARSE_PRINT_WARNING;
|
|
|
|
|
else
|
|
|
|
|
pargs.err = ARGPARSE_PRINT_ERROR;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 21:45:13 +01:00
|
|
|
|
gpgrt_argparse (NULL, &pargs, NULL);
|
|
|
|
|
|
|
|
|
|
/* Construct GPG arguments. */
|
2015-11-26 15:01:40 +01:00
|
|
|
|
{
|
|
|
|
|
strlist_t last;
|
2015-11-26 18:10:05 +01:00
|
|
|
|
last = append_to_strlist (&opt.gpg_arguments, "-z");
|
|
|
|
|
last = append_to_strlist (&last, "0");
|
|
|
|
|
last = append_to_strlist (&last, "--trust-model");
|
|
|
|
|
last = append_to_strlist (&last, "always");
|
2015-11-26 15:01:40 +01:00
|
|
|
|
(void) last;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 21:45:13 +01:00
|
|
|
|
if (!last_configname)
|
|
|
|
|
opt.config_filename = gpgrt_fnameconcat (gnupg_homedir (),
|
|
|
|
|
G13_NAME EXTSEP_S "conf",
|
|
|
|
|
NULL);
|
|
|
|
|
else
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{
|
2020-02-21 21:45:13 +01:00
|
|
|
|
opt.config_filename = last_configname;
|
|
|
|
|
last_configname = NULL;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (log_get_errorcount(0))
|
|
|
|
|
g13_exit(2);
|
|
|
|
|
|
|
|
|
|
/* Now that we have the options parsed we need to update the default
|
|
|
|
|
control structure. */
|
|
|
|
|
g13_init_default_ctrl (&ctrl);
|
2016-02-13 17:01:45 +01:00
|
|
|
|
ctrl.recipients = recipients;
|
|
|
|
|
recipients = NULL;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
if (nogreeting)
|
|
|
|
|
greeting = 0;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
if (greeting)
|
|
|
|
|
{
|
2009-10-14 17:06:10 +00:00
|
|
|
|
fprintf (stderr, "%s %s; %s\n",
|
2020-02-21 21:45:13 +01:00
|
|
|
|
gpgrt_strusage(11), gpgrt_strusage(13), gpgrt_strusage(14) );
|
|
|
|
|
fprintf (stderr, "%s\n", gpgrt_strusage(15));
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (may_coredump && !opt.quiet)
|
|
|
|
|
log_info (_("WARNING: program may create a core file!\n"));
|
|
|
|
|
|
2012-03-27 12:35:13 +02:00
|
|
|
|
/* Print a warning if an argument looks like an option. */
|
|
|
|
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i=0; i < argc; i++)
|
|
|
|
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
2016-02-13 17:01:45 +01:00
|
|
|
|
log_info (_("Note: '%s' is not considered an option\n"), argv[i]);
|
2012-03-27 12:35:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
if (logfile)
|
|
|
|
|
{
|
|
|
|
|
log_set_file (logfile);
|
2020-02-21 21:45:13 +01:00
|
|
|
|
log_set_prefix (NULL, (GPGRT_LOG_WITH_PREFIX
|
|
|
|
|
| GPGRT_LOG_WITH_TIME
|
|
|
|
|
| GPGRT_LOG_WITH_PID));
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gnupg_faked_time_p ())
|
|
|
|
|
{
|
|
|
|
|
gnupg_isotime_t tbuf;
|
|
|
|
|
|
|
|
|
|
log_info (_("WARNING: running with faked system time: "));
|
|
|
|
|
gnupg_get_isotime (tbuf);
|
|
|
|
|
dump_isotime (tbuf);
|
|
|
|
|
log_printf ("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print any pending secure memory warnings. */
|
|
|
|
|
gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
|
|
|
|
|
|
|
|
|
|
/* Setup the debug flags for all subsystems. */
|
|
|
|
|
set_debug ();
|
|
|
|
|
|
2015-09-14 18:49:32 +02:00
|
|
|
|
/* Install emergency cleanup handler. */
|
|
|
|
|
g13_install_emergency_cleanup ();
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
/* Terminate if we found any error until now. */
|
|
|
|
|
if (log_get_errorcount(0))
|
|
|
|
|
g13_exit (2);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
/* Set the standard GnuPG random seed file. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (use_random_seed)
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{
|
2016-06-07 10:59:46 +02:00
|
|
|
|
char *p = make_filename (gnupg_homedir (), "random_seed", NULL);
|
2009-09-23 10:28:41 +00:00
|
|
|
|
gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p);
|
|
|
|
|
xfree(p);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
/* Store given filename into FNAME. */
|
2013-02-12 19:28:54 +01:00
|
|
|
|
/* fname = argc? *argv : NULL; */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
|
|
|
|
|
/* Parse all given encryption keys. This does a lookup of the keys
|
|
|
|
|
and stops if any of the given keys was not found. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
#if 0 /* Currently not implemented. */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
if (!nokeysetup)
|
|
|
|
|
{
|
|
|
|
|
strlist_t sl;
|
|
|
|
|
int failed = 0;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2016-02-13 17:01:45 +01:00
|
|
|
|
for (sl = ctrl->recipients; sl; sl = sl->next)
|
2009-10-19 09:18:46 +00:00
|
|
|
|
if (check_encryption_key ())
|
2009-09-23 10:28:41 +00:00
|
|
|
|
failed = 1;
|
|
|
|
|
if (failed)
|
|
|
|
|
g13_exit (1);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
#endif /*0*/
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
/* Dispatch command. */
|
2012-01-03 17:08:01 +01:00
|
|
|
|
err = 0;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
switch (cmd)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
case aGPGConfList:
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{ /* List options and default values in the GPG Conf format. */
|
|
|
|
|
char *config_filename_esc = percent_escape (opt.config_filename, NULL);
|
|
|
|
|
|
|
|
|
|
printf ("gpgconf-g13.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);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case aGPGConfTest:
|
|
|
|
|
/* This is merely a dummy command to test whether the
|
|
|
|
|
configuration file is valid. */
|
|
|
|
|
break;
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
case aServer:
|
|
|
|
|
{
|
|
|
|
|
start_idle_task ();
|
2009-10-28 12:02:15 +00:00
|
|
|
|
ctrl.no_server = 0;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
err = g13_server (&ctrl);
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("server exited with error: %s <%s>\n",
|
|
|
|
|
gpg_strerror (err), gpg_strsource (err));
|
2009-10-15 17:20:41 +00:00
|
|
|
|
else
|
2016-02-13 17:01:45 +01:00
|
|
|
|
g13_request_shutdown ();
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2016-08-13 12:49:54 +02:00
|
|
|
|
case aFindDevice:
|
|
|
|
|
{
|
|
|
|
|
char *blockdev;
|
|
|
|
|
|
|
|
|
|
if (argc != 1)
|
|
|
|
|
wrong_args ("--find-device name");
|
|
|
|
|
|
|
|
|
|
err = call_syshelp_find_device (&ctrl, argv[0], &blockdev);
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error finding device '%s': %s <%s>\n",
|
|
|
|
|
argv[0], gpg_strerror (err), gpg_strsource (err));
|
|
|
|
|
else
|
|
|
|
|
puts (blockdev);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
case aCreate: /* Create a new container. */
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (argc != 1)
|
2009-09-23 10:28:41 +00:00
|
|
|
|
wrong_args ("--create filename");
|
2009-10-14 17:06:10 +00:00
|
|
|
|
start_idle_task ();
|
2016-02-13 17:01:45 +01:00
|
|
|
|
err = g13_create_container (&ctrl, argv[0]);
|
2009-09-30 15:28:38 +00:00
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error creating a new container: %s <%s>\n",
|
|
|
|
|
gpg_strerror (err), gpg_strsource (err));
|
2009-10-15 17:20:41 +00:00
|
|
|
|
else
|
2016-02-13 17:01:45 +01:00
|
|
|
|
g13_request_shutdown ();
|
2009-10-13 19:17:24 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case aMount: /* Mount a container. */
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (argc != 1 && argc != 2 )
|
2009-10-13 19:17:24 +00:00
|
|
|
|
wrong_args ("--mount filename [mountpoint]");
|
2009-10-14 17:06:10 +00:00
|
|
|
|
start_idle_task ();
|
2009-10-13 19:17:24 +00:00
|
|
|
|
err = g13_mount_container (&ctrl, argv[0], argc == 2?argv[1]:NULL);
|
|
|
|
|
if (err)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error mounting container '%s': %s <%s>\n",
|
2009-10-13 19:17:24 +00:00
|
|
|
|
*argv, gpg_strerror (err), gpg_strsource (err));
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2016-02-23 14:32:46 +01:00
|
|
|
|
case aUmount: /* Unmount a mounted container. */
|
|
|
|
|
{
|
|
|
|
|
if (argc != 1)
|
|
|
|
|
wrong_args ("--umount filename");
|
2016-08-14 20:17:51 +02:00
|
|
|
|
err = g13_umount_container (&ctrl, argv[0], NULL);
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error unmounting container '%s': %s <%s>\n",
|
|
|
|
|
*argv, gpg_strerror (err), gpg_strsource (err));
|
2016-02-23 14:32:46 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case aSuspend: /* Suspend a container. */
|
|
|
|
|
{
|
|
|
|
|
/* Fixme: Should we add a suspend all container option? */
|
|
|
|
|
if (argc != 1)
|
|
|
|
|
wrong_args ("--suspend filename");
|
|
|
|
|
err = g13_suspend_container (&ctrl, argv[0]);
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error suspending container '%s': %s <%s>\n",
|
|
|
|
|
*argv, gpg_strerror (err), gpg_strsource (err));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case aResume: /* Resume a suspended container. */
|
|
|
|
|
{
|
|
|
|
|
/* Fixme: Should we add a resume all container option? */
|
|
|
|
|
if (argc != 1)
|
|
|
|
|
wrong_args ("--resume filename");
|
|
|
|
|
err = g13_resume_container (&ctrl, argv[0]);
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error resuming container '%s': %s <%s>\n",
|
|
|
|
|
*argv, gpg_strerror (err), gpg_strsource (err));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
default:
|
2009-10-13 19:17:24 +00:00
|
|
|
|
log_error (_("invalid command (there is no implicit command)\n"));
|
|
|
|
|
break;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-21 08:38:10 +02:00
|
|
|
|
g13_deinit_default_ctrl (&ctrl);
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
if (!err)
|
|
|
|
|
join_idle_task ();
|
|
|
|
|
|
2009-09-23 10:28:41 +00:00
|
|
|
|
/* Cleanup. */
|
|
|
|
|
g13_exit (0);
|
|
|
|
|
return 8; /*NOTREACHED*/
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
/* Store defaults into the per-connection CTRL object. */
|
2009-09-23 10:28:41 +00:00
|
|
|
|
void
|
2015-10-21 08:38:10 +02:00
|
|
|
|
g13_init_default_ctrl (ctrl_t ctrl)
|
2009-09-23 10:28:41 +00:00
|
|
|
|
{
|
2015-09-14 18:49:32 +02:00
|
|
|
|
ctrl->conttype = cmdline_conttype? cmdline_conttype : CONTTYPE_ENCFS;
|
2009-09-23 10:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-10-21 08:38:10 +02:00
|
|
|
|
/* Release remaining resources allocated in the CTRL object. */
|
|
|
|
|
void
|
|
|
|
|
g13_deinit_default_ctrl (ctrl_t ctrl)
|
|
|
|
|
{
|
|
|
|
|
call_syshelp_release (ctrl);
|
2016-02-13 17:01:45 +01:00
|
|
|
|
FREE_STRLIST (ctrl->recipients);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Request a shutdown. This can be used when the process should
|
|
|
|
|
* finish instead of running the idle task. */
|
|
|
|
|
void
|
|
|
|
|
g13_request_shutdown (void)
|
|
|
|
|
{
|
|
|
|
|
shutdown_pending++;
|
2015-10-21 08:38:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
/* This function is called for each signal we catch. It is run in the
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
main context or the one of a NPth thread and thus it is not
|
2009-10-14 17:06:10 +00:00
|
|
|
|
restricted in what it may do. */
|
|
|
|
|
static void
|
|
|
|
|
handle_signal (int signo)
|
|
|
|
|
{
|
|
|
|
|
switch (signo)
|
|
|
|
|
{
|
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
|
|
|
|
case SIGHUP:
|
|
|
|
|
log_info ("SIGHUP received - re-reading configuration\n");
|
|
|
|
|
/* Fixme: Not yet implemented. */
|
|
|
|
|
break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
case SIGUSR1:
|
|
|
|
|
log_info ("SIGUSR1 received - printing internal information:\n");
|
2010-03-11 12:34:11 +00:00
|
|
|
|
/* Fixme: We need to see how to integrate pth dumping into our
|
|
|
|
|
logging system. */
|
|
|
|
|
/* pth_ctrl (PTH_CTRL_DUMPSTATE, log_get_stream ()); */
|
2009-10-15 17:20:41 +00:00
|
|
|
|
mountinfo_dump_all ();
|
2009-10-14 17:06:10 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SIGUSR2:
|
|
|
|
|
log_info ("SIGUSR2 received - no action defined\n");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SIGTERM:
|
|
|
|
|
if (!shutdown_pending)
|
|
|
|
|
log_info ("SIGTERM received - shutting down ...\n");
|
|
|
|
|
else
|
|
|
|
|
log_info ("SIGTERM received - still %u runners active\n",
|
|
|
|
|
runner_get_threads ());
|
|
|
|
|
shutdown_pending++;
|
|
|
|
|
if (shutdown_pending > 2)
|
|
|
|
|
{
|
|
|
|
|
log_info ("shutdown forced\n");
|
2020-02-21 21:45:13 +01:00
|
|
|
|
log_info ("%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13) );
|
2009-10-14 17:06:10 +00:00
|
|
|
|
g13_exit (0);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
case SIGINT:
|
|
|
|
|
log_info ("SIGINT received - immediate shutdown\n");
|
2020-02-21 21:45:13 +01:00
|
|
|
|
log_info( "%s %s stopped\n", gpgrt_strusage(11), gpgrt_strusage(13));
|
2009-10-14 17:06:10 +00:00
|
|
|
|
g13_exit (0);
|
|
|
|
|
break;
|
|
|
|
|
#endif /*!HAVE_W32_SYSTEM*/
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
default:
|
|
|
|
|
log_info ("signal %d received - no action defined\n", signo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This ticker function is called about every TIMERTICK_INTERVAL_SEC
|
|
|
|
|
seconds. */
|
|
|
|
|
static void
|
|
|
|
|
handle_tick (void)
|
|
|
|
|
{
|
|
|
|
|
/* log_debug ("TICK\n"); */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The idle task. We use a separate thread to do idle stuff and to
|
|
|
|
|
catch signals. */
|
|
|
|
|
static void *
|
|
|
|
|
idle_task (void *dummy_arg)
|
|
|
|
|
{
|
|
|
|
|
int signo; /* The number of a raised signal is stored here. */
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
int saved_errno;
|
|
|
|
|
struct timespec abstime;
|
|
|
|
|
struct timespec curtime;
|
|
|
|
|
struct timespec timeout;
|
|
|
|
|
int ret;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
(void)dummy_arg;
|
|
|
|
|
|
|
|
|
|
/* Create the event to catch the signals. */
|
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
npth_sigev_init ();
|
|
|
|
|
npth_sigev_add (SIGHUP);
|
|
|
|
|
npth_sigev_add (SIGUSR1);
|
|
|
|
|
npth_sigev_add (SIGUSR2);
|
|
|
|
|
npth_sigev_add (SIGINT);
|
|
|
|
|
npth_sigev_add (SIGTERM);
|
|
|
|
|
npth_sigev_fini ();
|
2009-10-14 17:06:10 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
npth_clock_gettime (&abstime);
|
|
|
|
|
abstime.tv_sec += TIMERTICK_INTERVAL_SEC;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
/* The shutdown flag allows us to terminate the idle task. */
|
|
|
|
|
if (shutdown_pending)
|
|
|
|
|
{
|
|
|
|
|
runner_cancel_all ();
|
|
|
|
|
|
|
|
|
|
if (!runner_get_threads ())
|
|
|
|
|
break; /* ready */
|
|
|
|
|
}
|
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
npth_clock_gettime (&curtime);
|
|
|
|
|
if (!(npth_timercmp (&curtime, &abstime, <)))
|
|
|
|
|
{
|
|
|
|
|
/* Timeout. */
|
|
|
|
|
handle_tick ();
|
|
|
|
|
npth_clock_gettime (&abstime);
|
|
|
|
|
abstime.tv_sec += TIMERTICK_INTERVAL_SEC;
|
|
|
|
|
}
|
|
|
|
|
npth_timersub (&abstime, &curtime, &timeout);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
ret = npth_pselect (0, NULL, NULL, NULL, &timeout, npth_sigev_sigmask());
|
|
|
|
|
saved_errno = errno;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
while (npth_sigev_get_pending(&signo))
|
|
|
|
|
handle_signal (signo);
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#else
|
|
|
|
|
ret = npth_eselect (0, NULL, NULL, NULL, &timeout, NULL, NULL);
|
|
|
|
|
saved_errno = errno;
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
#endif
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
if (ret == -1 && saved_errno != EINTR)
|
|
|
|
|
{
|
|
|
|
|
log_error (_("npth_pselect failed: %s - waiting 1s\n"),
|
|
|
|
|
strerror (saved_errno));
|
|
|
|
|
npth_sleep (1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
if (ret <= 0)
|
2016-02-13 17:01:45 +01:00
|
|
|
|
{
|
|
|
|
|
/* Interrupt or timeout. Will be handled when calculating the
|
|
|
|
|
next timeout. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
|
|
|
|
|
/* Here one would add processing of file descriptors. */
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 21:45:13 +01:00
|
|
|
|
log_info (_("%s %s stopped\n"), gpgrt_strusage(11), gpgrt_strusage(13));
|
2009-10-14 17:06:10 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Start the idle task. */
|
|
|
|
|
static void
|
|
|
|
|
start_idle_task (void)
|
|
|
|
|
{
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
npth_attr_t tattr;
|
|
|
|
|
npth_t thread;
|
|
|
|
|
sigset_t sigs; /* The set of signals we want to catch. */
|
|
|
|
|
int err;
|
|
|
|
|
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
/* These signals should always go to the idle task, so they need to
|
|
|
|
|
be blocked everywhere else. We assume start_idle_task is called
|
|
|
|
|
from the main thread before any other threads are created. */
|
|
|
|
|
sigemptyset (&sigs);
|
|
|
|
|
sigaddset (&sigs, SIGHUP);
|
|
|
|
|
sigaddset (&sigs, SIGUSR1);
|
|
|
|
|
sigaddset (&sigs, SIGUSR2);
|
|
|
|
|
sigaddset (&sigs, SIGINT);
|
|
|
|
|
sigaddset (&sigs, SIGTERM);
|
|
|
|
|
npth_sigmask (SIG_BLOCK, &sigs, NULL);
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#endif
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
npth_attr_init (&tattr);
|
|
|
|
|
npth_attr_setdetachstate (&tattr, NPTH_CREATE_JOINABLE);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
err = npth_create (&thread, &tattr, idle_task, NULL);
|
|
|
|
|
if (err)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
log_fatal ("error starting idle task: %s\n", strerror (err));
|
2009-10-14 17:06:10 +00:00
|
|
|
|
return; /*NOTREACHED*/
|
|
|
|
|
}
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
npth_setname_np (thread, "idle-task");
|
|
|
|
|
idle_task_thread = thread;
|
|
|
|
|
npth_attr_destroy (&tattr);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Wait for the idle task to finish. */
|
|
|
|
|
static void
|
|
|
|
|
join_idle_task (void)
|
|
|
|
|
{
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
/* FIXME: This assumes that a valid pthread_t is non-null. That is
|
|
|
|
|
not guaranteed. */
|
|
|
|
|
if (idle_task_thread)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
err = npth_join (idle_task_thread, NULL);
|
|
|
|
|
if (err)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
log_error ("waiting for idle task thread failed: %s\n",
|
Port to npth.
* configure.ac: Don't check for PTH but for NPTH.
(AH_BOTTOM): Remove PTH_SYSCALL_SOFT.
(have_pth): Rename to ...
(have_npth): ... this.
(USE_GNU_NPTH): Rename to ...
(USE_GNU_PTH): ... this.
* m4/npth.m4: New file.
* agent/Makefile.am, agent/cache.c, agent/call-pinentry.c,
agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c,
agent/trustlist.c, common/Makefile.am, common/estream.c,
common/exechelp-posix.c, common/exechelp-w32.c,
common/exechelp-w32ce.c, common/http.c, common/init.c,
common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c,
dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c,
dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am,
g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am,
scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c,
scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-03 22:12:37 +01:00
|
|
|
|
strerror (err));
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|