2003-08-05 19:11:04 +02:00
|
|
|
|
/* gpg-agent.c - The GnuPG Agent
|
2014-11-04 16:28:03 +01:00
|
|
|
|
* Copyright (C) 2000-2007, 2009-2010 Free Software Foundation, Inc.
|
|
|
|
|
* Copyright (C) 2000-2014 Werner Koch
|
2003-08-05 19:11:04 +02:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2007-07-04 21:49:40 +02:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-08-05 19:11:04 +02:00
|
|
|
|
* (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
|
2007-07-04 21:49:40 +02:00
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2003-08-05 19:11:04 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <fcntl.h>
|
2004-06-20 13:35:13 +02:00
|
|
|
|
#include <sys/stat.h>
|
2014-03-07 09:46:44 +01:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
# ifndef WINVER
|
|
|
|
|
# define WINVER 0x0500 /* Same as in common/sysutils.c */
|
|
|
|
|
# endif
|
|
|
|
|
# ifdef HAVE_WINSOCK2_H
|
|
|
|
|
# include <winsock2.h>
|
|
|
|
|
# endif
|
|
|
|
|
# include <aclapi.h>
|
|
|
|
|
# include <sddl.h>
|
|
|
|
|
#else /*!HAVE_W32_SYSTEM*/
|
2007-06-14 19:05:07 +02:00
|
|
|
|
# include <sys/socket.h>
|
|
|
|
|
# include <sys/un.h>
|
|
|
|
|
#endif /*!HAVE_W32_SYSTEM*/
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#include <unistd.h>
|
2010-04-14 13:24:02 +02:00
|
|
|
|
#ifdef HAVE_SIGNAL_H
|
|
|
|
|
# include <signal.h>
|
|
|
|
|
#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
|
|
|
|
#include <npth.h>
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2015-04-24 16:10:15 +02:00
|
|
|
|
#define GNUPG_COMMON_NEED_AFLOCAL
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#include "agent.h"
|
2007-10-01 16:48:39 +02:00
|
|
|
|
#include <assuan.h> /* Malloc hooks and socket wrappers. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
#include "sysutils.h"
|
2007-08-02 20:12:43 +02:00
|
|
|
|
#include "gc-opt-flags.h"
|
2009-03-19 08:09:31 +01:00
|
|
|
|
#include "exechelp.h"
|
2010-03-11 13:34:11 +01:00
|
|
|
|
#include "asshelp.h"
|
gpg: Remove cipher.h and put algo ids into a common file.
* common/openpgpdefs.h (cipher_algo_t, pubkey_algo_t, digest_algo_t)
(compress_algo_t): New.
* agent/gpg-agent.c: Remove ../g10/cipher.h. Add openpgpdefs.h.
* g10/cipher.h (DEK): Move to ...
* g10/dek.h: new file.
* g10/cipher.h (is_RSA, is_ELGAMAL, is_DSA)
(PUBKEY_MAX_NPKEY, PUBKEY_MAX_NSKEY, PUBKEY_MAX_NSIG, PUBKEY_MAX_NENC)
(PUBKEY_USAGE_SIG, PUBKEY_USAGE_ENC, PUBKEY_USAGE_CERT)
(PUBKEY_USAGE_AUTH, PUBKEY_USAGE_NONE): Move to
* g10/packet.h: here.
* g10/cipher.h: Remove. Remove from all files.
* g10/filter.h, g10/packet.h: Include dek.h.
* g10/Makefile.am (common_source): Remove cipher.h. Add dek.h.
Signed-off-by: Werner Koch <wk@gnupg.org>
2014-01-29 20:35:05 +01:00
|
|
|
|
#include "openpgpdefs.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */
|
2012-02-06 20:50:47 +01:00
|
|
|
|
#include "../common/init.h"
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
enum cmd_and_opt_values
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{ aNull = 0,
|
|
|
|
|
oCsh = 'c',
|
|
|
|
|
oQuiet = 'q',
|
|
|
|
|
oSh = 's',
|
|
|
|
|
oVerbose = 'v',
|
2004-02-18 17:57:38 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
oNoVerbose = 500,
|
2004-02-18 17:57:38 +01:00
|
|
|
|
aGPGConfList,
|
2006-10-23 16:02:13 +02:00
|
|
|
|
aGPGConfTest,
|
2010-05-03 17:23:10 +02:00
|
|
|
|
aUseStandardSocketP,
|
2003-08-05 19:11:04 +02:00
|
|
|
|
oOptions,
|
|
|
|
|
oDebug,
|
|
|
|
|
oDebugAll,
|
2004-02-18 17:57:38 +01:00
|
|
|
|
oDebugLevel,
|
2003-08-05 19:11:04 +02:00
|
|
|
|
oDebugWait,
|
2014-10-30 09:55:51 +01:00
|
|
|
|
oDebugQuickRandom,
|
2015-05-11 10:23:24 +02:00
|
|
|
|
oDebugPinentry,
|
2003-08-05 19:11:04 +02:00
|
|
|
|
oNoGreeting,
|
|
|
|
|
oNoOptions,
|
|
|
|
|
oHomedir,
|
|
|
|
|
oNoDetach,
|
|
|
|
|
oNoGrab,
|
|
|
|
|
oLogFile,
|
|
|
|
|
oServer,
|
|
|
|
|
oDaemon,
|
|
|
|
|
oBatch,
|
|
|
|
|
|
|
|
|
|
oPinentryProgram,
|
2007-02-14 17:27:55 +01:00
|
|
|
|
oPinentryTouchFile,
|
2015-09-16 21:24:14 +02:00
|
|
|
|
oPinentryInvisibleChar,
|
2003-08-05 19:11:04 +02:00
|
|
|
|
oDisplay,
|
|
|
|
|
oTTYname,
|
|
|
|
|
oTTYtype,
|
|
|
|
|
oLCctype,
|
|
|
|
|
oLCmessages,
|
2007-11-19 17:03:50 +01:00
|
|
|
|
oXauthority,
|
2003-08-05 19:11:04 +02:00
|
|
|
|
oScdaemonProgram,
|
2004-08-20 15:43:14 +02:00
|
|
|
|
oDefCacheTTL,
|
2005-06-07 21:09:18 +02:00
|
|
|
|
oDefCacheTTLSSH,
|
2004-08-20 15:43:14 +02:00
|
|
|
|
oMaxCacheTTL,
|
2005-06-16 10:12:03 +02:00
|
|
|
|
oMaxCacheTTLSSH,
|
2007-08-27 20:10:27 +02:00
|
|
|
|
oEnforcePassphraseConstraints,
|
2007-01-25 09:30:47 +01:00
|
|
|
|
oMinPassphraseLen,
|
2007-08-27 20:10:27 +02:00
|
|
|
|
oMinPassphraseNonalpha,
|
|
|
|
|
oCheckPassphrasePattern,
|
2007-08-28 19:48:13 +02:00
|
|
|
|
oMaxPassphraseDays,
|
|
|
|
|
oEnablePassphraseHistory,
|
2004-12-20 17:17:25 +01:00
|
|
|
|
oUseStandardSocket,
|
|
|
|
|
oNoUseStandardSocket,
|
2014-11-27 20:41:37 +01:00
|
|
|
|
oExtraSocket,
|
2015-06-11 09:36:27 +02:00
|
|
|
|
oBrowserSocket,
|
2007-08-28 19:48:13 +02:00
|
|
|
|
oFakedSystemTime,
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
oIgnoreCacheForSigning,
|
2004-05-03 15:37:38 +02:00
|
|
|
|
oAllowMarkTrusted,
|
2013-07-03 15:20:25 +02:00
|
|
|
|
oNoAllowMarkTrusted,
|
2004-12-21 20:05:15 +01:00
|
|
|
|
oAllowPresetPassphrase,
|
2011-03-03 18:35:08 +01:00
|
|
|
|
oAllowLoopbackPinentry,
|
2015-05-11 18:08:44 +02:00
|
|
|
|
oNoAllowExternalCache,
|
2015-06-09 14:07:00 +02:00
|
|
|
|
oAllowEmacsPinentry,
|
2003-08-05 19:11:04 +02:00
|
|
|
|
oKeepTTY,
|
2005-01-26 23:20:21 +01:00
|
|
|
|
oKeepDISPLAY,
|
2005-04-20 21:19:24 +02:00
|
|
|
|
oSSHSupport,
|
2014-03-07 09:46:44 +01:00
|
|
|
|
oPuttySupport,
|
2005-06-03 15:57:24 +02:00
|
|
|
|
oDisableScdaemon,
|
2013-05-21 13:10:00 +02:00
|
|
|
|
oDisableCheckOwnSocket,
|
2005-06-03 15:57:24 +02:00
|
|
|
|
oWriteEnvFile
|
2004-12-20 17:17:25 +01:00
|
|
|
|
};
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
|
2014-11-28 21:34:35 +01:00
|
|
|
|
#ifndef ENAMETOOLONG
|
|
|
|
|
# define ENAMETOOLONG EINVAL
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
static ARGPARSE_OPTS opts[] = {
|
2004-02-18 17:57:38 +01:00
|
|
|
|
|
2014-11-27 17:28:00 +01:00
|
|
|
|
ARGPARSE_c (aGPGConfList, "gpgconf-list", "@"),
|
|
|
|
|
ARGPARSE_c (aGPGConfTest, "gpgconf-test", "@"),
|
|
|
|
|
ARGPARSE_c (aUseStandardSocketP, "use-standard-socket-p", "@"),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_group (301, N_("@Options:\n ")),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_s_n (oDaemon, "daemon", N_("run in daemon mode (background)")),
|
|
|
|
|
ARGPARSE_s_n (oServer, "server", N_("run in server mode (foreground)")),
|
|
|
|
|
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
|
|
|
|
|
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")),
|
|
|
|
|
|
2015-06-23 09:12:44 +02:00
|
|
|
|
ARGPARSE_s_s (oDebug, "debug", "@"),
|
2014-11-27 17:28:00 +01:00
|
|
|
|
ARGPARSE_s_n (oDebugAll, "debug-all", "@"),
|
|
|
|
|
ARGPARSE_s_s (oDebugLevel, "debug-level", "@"),
|
|
|
|
|
ARGPARSE_s_i (oDebugWait," debug-wait", "@"),
|
2014-10-30 09:55:51 +01:00
|
|
|
|
ARGPARSE_s_n (oDebugQuickRandom, "debug-quick-random", "@"),
|
2015-05-11 10:23:24 +02:00
|
|
|
|
ARGPARSE_s_n (oDebugPinentry, "debug-pinentry", "@"),
|
2014-11-27 17:28:00 +01:00
|
|
|
|
|
|
|
|
|
ARGPARSE_s_n (oNoDetach, "no-detach", N_("do not detach from the console")),
|
|
|
|
|
ARGPARSE_s_n (oNoGrab, "no-grab", N_("do not grab keyboard and mouse")),
|
|
|
|
|
ARGPARSE_s_s (oLogFile, "log-file", N_("use a log file for the server")),
|
|
|
|
|
ARGPARSE_s_s (oPinentryProgram, "pinentry-program",
|
|
|
|
|
/* */ N_("|PGM|use PGM as the PIN-Entry program")),
|
|
|
|
|
ARGPARSE_s_s (oPinentryTouchFile, "pinentry-touch-file", "@"),
|
2015-09-16 21:24:14 +02:00
|
|
|
|
ARGPARSE_s_s (oPinentryInvisibleChar, "pinentry-invisible-char", "@"),
|
2014-11-27 17:28:00 +01:00
|
|
|
|
ARGPARSE_s_s (oScdaemonProgram, "scdaemon-program",
|
|
|
|
|
/* */ N_("|PGM|use PGM as the SCdaemon program") ),
|
|
|
|
|
ARGPARSE_s_n (oDisableScdaemon, "disable-scdaemon",
|
|
|
|
|
/* */ N_("do not use the SCdaemon") ),
|
|
|
|
|
ARGPARSE_s_n (oDisableCheckOwnSocket, "disable-check-own-socket", "@"),
|
2015-05-11 18:08:44 +02:00
|
|
|
|
|
|
|
|
|
ARGPARSE_s_s (oExtraSocket, "extra-socket",
|
|
|
|
|
/* */ N_("|NAME|accept some commands via NAME")),
|
|
|
|
|
|
2015-06-11 09:36:27 +02:00
|
|
|
|
ARGPARSE_s_s (oBrowserSocket, "browser-socket", "@"),
|
|
|
|
|
|
2014-11-27 17:28:00 +01:00
|
|
|
|
ARGPARSE_s_s (oFakedSystemTime, "faked-system-time", "@"),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_s_n (oBatch, "batch", "@"),
|
|
|
|
|
ARGPARSE_s_s (oHomedir, "homedir", "@"),
|
|
|
|
|
|
|
|
|
|
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_n (oKeepTTY, "keep-tty",
|
|
|
|
|
/* */ N_("ignore requests to change the TTY")),
|
|
|
|
|
ARGPARSE_s_n (oKeepDISPLAY, "keep-display",
|
|
|
|
|
/* */ N_("ignore requests to change the X display")),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_s_u (oDefCacheTTL, "default-cache-ttl",
|
|
|
|
|
N_("|N|expire cached PINs after N seconds")),
|
|
|
|
|
ARGPARSE_s_u (oDefCacheTTLSSH, "default-cache-ttl-ssh", "@" ),
|
|
|
|
|
ARGPARSE_s_u (oMaxCacheTTL, "max-cache-ttl", "@" ),
|
|
|
|
|
ARGPARSE_s_u (oMaxCacheTTLSSH, "max-cache-ttl-ssh", "@" ),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_s_n (oEnforcePassphraseConstraints, "enforce-passphrase-constraints",
|
|
|
|
|
/* */ "@"),
|
|
|
|
|
ARGPARSE_s_u (oMinPassphraseLen, "min-passphrase-len", "@"),
|
|
|
|
|
ARGPARSE_s_u (oMinPassphraseNonalpha, "min-passphrase-nonalpha", "@"),
|
|
|
|
|
ARGPARSE_s_s (oCheckPassphrasePattern, "check-passphrase-pattern", "@"),
|
|
|
|
|
ARGPARSE_s_u (oMaxPassphraseDays, "max-passphrase-days", "@"),
|
|
|
|
|
ARGPARSE_s_n (oEnablePassphraseHistory, "enable-passphrase-history", "@"),
|
|
|
|
|
|
|
|
|
|
ARGPARSE_s_n (oIgnoreCacheForSigning, "ignore-cache-for-signing",
|
|
|
|
|
/* */ N_("do not use the PIN cache when signing")),
|
2015-05-11 18:08:44 +02:00
|
|
|
|
ARGPARSE_s_n (oNoAllowExternalCache, "no-allow-external-cache",
|
|
|
|
|
/* */ N_("disallow the use of an external password cache")),
|
2014-11-27 17:28:00 +01:00
|
|
|
|
ARGPARSE_s_n (oNoAllowMarkTrusted, "no-allow-mark-trusted",
|
|
|
|
|
/* */ N_("disallow clients to mark keys as \"trusted\"")),
|
|
|
|
|
ARGPARSE_s_n (oAllowMarkTrusted, "allow-mark-trusted", "@"),
|
|
|
|
|
ARGPARSE_s_n (oAllowPresetPassphrase, "allow-preset-passphrase",
|
|
|
|
|
/* */ N_("allow presetting passphrase")),
|
|
|
|
|
ARGPARSE_s_n (oAllowLoopbackPinentry, "allow-loopback-pinentry",
|
2015-01-04 17:19:06 +01:00
|
|
|
|
N_("allow caller to override the pinentry")),
|
2015-06-09 14:07:00 +02:00
|
|
|
|
ARGPARSE_s_n (oAllowEmacsPinentry, "allow-emacs-pinentry",
|
|
|
|
|
/* */ N_("allow passphrase to be prompted through Emacs")),
|
2015-05-11 18:08:44 +02:00
|
|
|
|
|
2014-11-27 17:28:00 +01:00
|
|
|
|
ARGPARSE_s_n (oSSHSupport, "enable-ssh-support", N_("enable ssh support")),
|
|
|
|
|
ARGPARSE_s_n (oPuttySupport, "enable-putty-support",
|
2014-03-07 09:46:44 +01:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
2014-11-27 17:28:00 +01:00
|
|
|
|
/* */ N_("enable putty support")
|
2014-03-07 09:46:44 +01:00
|
|
|
|
#else
|
2014-11-27 17:28:00 +01:00
|
|
|
|
/* */ "@"
|
2014-03-07 09:46:44 +01:00
|
|
|
|
#endif
|
2014-11-27 17:28:00 +01:00
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
/* Dummy options for backward compatibility. */
|
|
|
|
|
ARGPARSE_o_s (oWriteEnvFile, "write-env-file", "@"),
|
|
|
|
|
ARGPARSE_s_n (oUseStandardSocket, "use-standard-socket", "@"),
|
|
|
|
|
ARGPARSE_s_n (oNoUseStandardSocket, "no-use-standard-socket", "@"),
|
|
|
|
|
|
|
|
|
|
{0} /* End of list */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2015-06-23 09:12:44 +02:00
|
|
|
|
/* The list of supported debug flags. */
|
|
|
|
|
static struct debug_flags_s debug_flags [] =
|
|
|
|
|
{
|
|
|
|
|
{ DBG_COMMAND_VALUE, "command" },
|
|
|
|
|
{ DBG_MPI_VALUE , "mpi" },
|
|
|
|
|
{ DBG_CRYPTO_VALUE , "crypto" },
|
|
|
|
|
{ DBG_MEMORY_VALUE , "memory" },
|
|
|
|
|
{ DBG_CACHE_VALUE , "cache" },
|
|
|
|
|
{ DBG_MEMSTAT_VALUE, "memstat" },
|
|
|
|
|
{ DBG_HASHING_VALUE, "hashing" },
|
|
|
|
|
{ DBG_IPC_VALUE , "ipc" },
|
|
|
|
|
{ 77, NULL } /* 77 := Do not exit on "help" or "?". */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-16 10:12:03 +02:00
|
|
|
|
#define DEFAULT_CACHE_TTL (10*60) /* 10 minutes */
|
|
|
|
|
#define DEFAULT_CACHE_TTL_SSH (30*60) /* 30 minutes */
|
|
|
|
|
#define MAX_CACHE_TTL (120*60) /* 2 hours */
|
2007-03-06 21:44:41 +01:00
|
|
|
|
#define MAX_CACHE_TTL_SSH (120*60) /* 2 hours */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
#define MIN_PASSPHRASE_LEN (8)
|
|
|
|
|
#define MIN_PASSPHRASE_NONALPHA (1)
|
2007-08-28 19:48:13 +02:00
|
|
|
|
#define MAX_PASSPHRASE_DAYS (0)
|
2004-03-16 11:48:42 +01:00
|
|
|
|
|
2007-07-04 11:34:28 +02:00
|
|
|
|
/* The timer tick used for housekeeping stuff. For Windows we use a
|
|
|
|
|
longer period as the SetWaitableTimer seems to signal earlier than
|
2010-12-02 19:40:03 +01:00
|
|
|
|
the 2 seconds. CHECK_OWN_SOCKET_INTERVAL defines how often we
|
|
|
|
|
check our own socket in standard socket mode. If that value is 0
|
|
|
|
|
we don't check at all. All values are in seconds. */
|
|
|
|
|
#if defined(HAVE_W32CE_SYSTEM)
|
|
|
|
|
# define TIMERTICK_INTERVAL (60)
|
|
|
|
|
# define CHECK_OWN_SOCKET_INTERVAL (0) /* Never */
|
|
|
|
|
#elif defined(HAVE_W32_SYSTEM)
|
|
|
|
|
# define TIMERTICK_INTERVAL (4)
|
2011-02-04 12:57:53 +01:00
|
|
|
|
# define CHECK_OWN_SOCKET_INTERVAL (60)
|
2007-07-04 11:34:28 +02:00
|
|
|
|
#else
|
2010-12-02 19:40:03 +01:00
|
|
|
|
# define TIMERTICK_INTERVAL (2)
|
|
|
|
|
# define CHECK_OWN_SOCKET_INTERVAL (60)
|
2007-07-04 11:34:28 +02:00
|
|
|
|
#endif
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2009-03-19 08:09:31 +01:00
|
|
|
|
|
2015-06-29 12:24:58 +02:00
|
|
|
|
/* Flag indicating that the ssh-agent subsystem has been enabled. */
|
|
|
|
|
static int ssh_support;
|
|
|
|
|
|
2014-03-07 09:46:44 +01:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
/* Flag indicating that support for Putty has been enabled. */
|
|
|
|
|
static int putty_support;
|
|
|
|
|
/* A magic value used with WM_COPYDATA. */
|
|
|
|
|
#define PUTTY_IPC_MAGIC 0x804e50ba
|
|
|
|
|
/* To avoid surprises we limit the size of the mapped IPC file to this
|
|
|
|
|
value. Putty currently (0.62) uses 8k, thus 16k should be enough
|
|
|
|
|
for the foreseeable future. */
|
|
|
|
|
#define PUTTY_IPC_MAXLEN 16384
|
|
|
|
|
#endif /*HAVE_W32_SYSTEM*/
|
|
|
|
|
|
2009-03-19 08:09:31 +01:00
|
|
|
|
/* The list of open file descriptors at startup. Note that this list
|
|
|
|
|
has been allocated using the standard malloc. */
|
|
|
|
|
static int *startup_fd_list;
|
|
|
|
|
|
|
|
|
|
/* The signal mask at startup and a flag telling whether it is valid. */
|
|
|
|
|
#ifdef HAVE_SIGPROCMASK
|
|
|
|
|
static sigset_t startup_signal_mask;
|
|
|
|
|
static int startup_signal_mask_valid;
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
/* Flag to indicate that a shutdown was requested. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static int shutdown_pending;
|
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
/* Counter for the currently running own socket checks. */
|
|
|
|
|
static int check_own_socket_running;
|
|
|
|
|
|
2013-05-21 13:10:00 +02:00
|
|
|
|
/* Flags to indicate that check_own_socket shall not be called. */
|
|
|
|
|
static int disable_check_own_socket;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* It is possible that we are currently running under setuid permissions */
|
|
|
|
|
static int maybe_setuid = 1;
|
|
|
|
|
|
2014-11-28 21:34:35 +01:00
|
|
|
|
/* Name of the communication socket used for native gpg-agent
|
|
|
|
|
requests. The second variable is either NULL or a malloced string
|
|
|
|
|
with the real socket name in case it has been redirected. */
|
2004-12-20 17:17:25 +01:00
|
|
|
|
static char *socket_name;
|
2014-11-28 21:34:35 +01:00
|
|
|
|
static char *redir_socket_name;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
/* Name of the optional extra socket used for native gpg-agent requests. */
|
|
|
|
|
static char *socket_name_extra;
|
2014-11-28 21:34:35 +01:00
|
|
|
|
static char *redir_socket_name_extra;
|
2014-11-27 20:41:37 +01:00
|
|
|
|
|
2015-06-11 09:36:27 +02:00
|
|
|
|
/* Name of the optional browser socket used for native gpg-agent requests. */
|
|
|
|
|
static char *socket_name_browser;
|
|
|
|
|
static char *redir_socket_name_browser;
|
|
|
|
|
|
2005-01-26 23:20:21 +01:00
|
|
|
|
/* Name of the communication socket used for ssh-agent-emulation. */
|
|
|
|
|
static char *socket_name_ssh;
|
2014-11-28 21:34:35 +01:00
|
|
|
|
static char *redir_socket_name_ssh;
|
2005-01-26 23:20:21 +01:00
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
/* We need to keep track of the server's nonces (these are dummies for
|
|
|
|
|
POSIX systems). */
|
|
|
|
|
static assuan_sock_nonce_t socket_nonce;
|
2014-11-27 20:41:37 +01:00
|
|
|
|
static assuan_sock_nonce_t socket_nonce_extra;
|
2015-06-11 09:36:27 +02:00
|
|
|
|
static assuan_sock_nonce_t socket_nonce_browser;
|
2007-10-01 16:48:39 +02:00
|
|
|
|
static assuan_sock_nonce_t socket_nonce_ssh;
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* Default values for options passed to the pinentry. */
|
|
|
|
|
static char *default_display;
|
|
|
|
|
static char *default_ttyname;
|
|
|
|
|
static char *default_ttytype;
|
|
|
|
|
static char *default_lc_ctype;
|
|
|
|
|
static char *default_lc_messages;
|
2007-11-19 17:03:50 +01:00
|
|
|
|
static char *default_xauthority;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
/* Name of a config file, which will be reread on a HUP if it is not NULL. */
|
|
|
|
|
static char *config_filename;
|
|
|
|
|
|
2004-02-18 17:57:38 +01:00
|
|
|
|
/* Helper to implement --debug-level */
|
|
|
|
|
static const char *debug_level;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-04-30 05:58:21 +02:00
|
|
|
|
/* Keep track of the current log file so that we can avoid updating
|
2004-10-22 11:39:47 +02:00
|
|
|
|
the log file after a SIGHUP if it didn't changed. Malloced. */
|
2004-04-30 05:58:21 +02:00
|
|
|
|
static char *current_logfile;
|
|
|
|
|
|
2005-04-20 21:19:24 +02:00
|
|
|
|
/* The handle_tick() function may test whether a parent is still
|
2005-05-18 12:48:06 +02:00
|
|
|
|
running. We record the PID of the parent here or -1 if it should be
|
2005-04-20 21:19:24 +02:00
|
|
|
|
watched. */
|
|
|
|
|
static pid_t parent_pid = (pid_t)(-1);
|
|
|
|
|
|
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
|
|
|
|
/* Number of active connections. */
|
|
|
|
|
static int active_connections;
|
|
|
|
|
|
2005-05-18 12:48:06 +02:00
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
/*
|
2011-02-04 12:57:53 +01:00
|
|
|
|
Local prototypes.
|
2005-02-03 18:40:02 +01:00
|
|
|
|
*/
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
static char *create_socket_name (char *standard_name, int with_homedir);
|
2015-06-29 21:26:09 +02:00
|
|
|
|
static gnupg_fd_t create_server_socket (char *name, int primary, int cygwin,
|
2014-11-28 21:34:35 +01:00
|
|
|
|
char **r_redir_name,
|
2007-10-01 16:48:39 +02:00
|
|
|
|
assuan_sock_nonce_t *nonce);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static void create_directories (void);
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
static void agent_init_default_ctrl (ctrl_t ctrl);
|
|
|
|
|
static void agent_deinit_default_ctrl (ctrl_t ctrl);
|
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
static void handle_connections (gnupg_fd_t listen_fd,
|
2014-11-27 20:41:37 +01:00
|
|
|
|
gnupg_fd_t listen_fd_extra,
|
2015-06-11 09:36:27 +02:00
|
|
|
|
gnupg_fd_t listen_fd_browser,
|
2007-10-01 16:48:39 +02:00
|
|
|
|
gnupg_fd_t listen_fd_ssh);
|
2008-10-29 18:24:27 +01:00
|
|
|
|
static void check_own_socket (void);
|
2014-10-03 11:58:58 +02:00
|
|
|
|
static int check_for_running_agent (int silent);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2005-05-18 12:48:06 +02:00
|
|
|
|
/* Pth wrapper function definitions. */
|
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
|
|
|
|
ASSUAN_SYSTEM_NPTH_IMPL;
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2005-05-18 12:48:06 +02:00
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
/*
|
2011-02-04 12:57:53 +01:00
|
|
|
|
Functions.
|
2005-02-03 18:40:02 +01:00
|
|
|
|
*/
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Allocate a string describing a library version by calling a GETFNC.
|
|
|
|
|
This function is expected to be called only once. GETFNC is
|
|
|
|
|
expected to have a semantic like gcry_check_version (). */
|
2008-11-18 19:01:03 +01:00
|
|
|
|
static char *
|
|
|
|
|
make_libversion (const char *libname, const char *(*getfnc)(const char*))
|
|
|
|
|
{
|
|
|
|
|
const char *s;
|
|
|
|
|
char *result;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2008-11-18 19:01:03 +01:00
|
|
|
|
if (maybe_setuid)
|
|
|
|
|
{
|
|
|
|
|
gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
|
|
|
|
|
maybe_setuid = 0;
|
|
|
|
|
}
|
|
|
|
|
s = getfnc (NULL);
|
|
|
|
|
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
|
|
|
|
|
strcpy (stpcpy (stpcpy (result, libname), " "), s);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Return strings describing this program. The case values are
|
|
|
|
|
described in common/argparse.c:strusage. The values here override
|
|
|
|
|
the default values given by strusage. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static const char *
|
|
|
|
|
my_strusage (int level)
|
|
|
|
|
{
|
2008-11-18 19:01:03 +01:00
|
|
|
|
static char *ver_gcry;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
const char *p;
|
2008-11-18 19:01:03 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
switch (level)
|
|
|
|
|
{
|
2013-11-18 14:09:47 +01:00
|
|
|
|
case 11: p = "@GPG_AGENT@ (@GNUPG@)";
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break;
|
|
|
|
|
case 13: p = VERSION; break;
|
|
|
|
|
case 17: p = PRINTABLE_OS_NAME; break;
|
2009-07-21 16:21:05 +02:00
|
|
|
|
/* TRANSLATORS: @EMAIL@ will get replaced by the actual bug
|
|
|
|
|
reporting address. This is so that we can change the
|
|
|
|
|
reporting address without breaking the translations. */
|
|
|
|
|
case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break;
|
|
|
|
|
|
2008-11-18 19:01:03 +01:00
|
|
|
|
case 20:
|
|
|
|
|
if (!ver_gcry)
|
|
|
|
|
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
|
|
|
|
|
p = ver_gcry;
|
|
|
|
|
break;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case 1:
|
2013-11-18 14:09:47 +01:00
|
|
|
|
case 40: p = _("Usage: @GPG_AGENT@ [options] (-h for help)");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
case 41: p = _("Syntax: @GPG_AGENT@ [options] [command [args]]\n"
|
|
|
|
|
"Secret key management for @GNUPG@\n");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
default: p = NULL;
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-02 08:48:09 +01:00
|
|
|
|
/* Setup the debugging. With the global variable DEBUG_LEVEL set to NULL
|
|
|
|
|
only the active debug flags are propagated to the subsystems. With
|
|
|
|
|
DEBUG_LEVEL set, a specific set of debug flags is set; thus overriding
|
|
|
|
|
all flags already set. Note that we don't fail here, because it is
|
|
|
|
|
important to keep gpg-agent running even after re-reading the
|
|
|
|
|
options due to a SIGHUP. */
|
2004-02-18 17:57:38 +01:00
|
|
|
|
static void
|
|
|
|
|
set_debug (void)
|
|
|
|
|
{
|
2009-12-03 19:04:40 +01:00
|
|
|
|
int numok = (debug_level && digitp (debug_level));
|
|
|
|
|
int numlvl = numok? atoi (debug_level) : 0;
|
|
|
|
|
|
2004-02-18 17:57:38 +01:00
|
|
|
|
if (!debug_level)
|
|
|
|
|
;
|
2009-12-03 19:04:40 +01:00
|
|
|
|
else if (!strcmp (debug_level, "none") || (numok && numlvl < 1))
|
2004-02-18 17:57:38 +01:00
|
|
|
|
opt.debug = 0;
|
2009-12-03 19:04:40 +01:00
|
|
|
|
else if (!strcmp (debug_level, "basic") || (numok && numlvl <= 2))
|
2015-04-06 13:42:17 +02:00
|
|
|
|
opt.debug = DBG_IPC_VALUE;
|
2009-12-03 19:04:40 +01:00
|
|
|
|
else if (!strcmp (debug_level, "advanced") || (numok && numlvl <= 5))
|
2015-04-06 13:42:17 +02:00
|
|
|
|
opt.debug = DBG_IPC_VALUE|DBG_COMMAND_VALUE;
|
2009-12-03 19:04:40 +01:00
|
|
|
|
else if (!strcmp (debug_level, "expert") || (numok && numlvl <= 8))
|
2015-04-06 13:42:17 +02:00
|
|
|
|
opt.debug = (DBG_IPC_VALUE|DBG_COMMAND_VALUE
|
2004-02-18 17:57:38 +01:00
|
|
|
|
|DBG_CACHE_VALUE);
|
2009-12-03 19:04:40 +01:00
|
|
|
|
else if (!strcmp (debug_level, "guru") || numok)
|
|
|
|
|
{
|
|
|
|
|
opt.debug = ~0;
|
|
|
|
|
/* Unless the "guru" string has been used we don't want to allow
|
|
|
|
|
hashing debugging. The rationale is that people tend to
|
|
|
|
|
select the highest debug value and would then clutter their
|
2011-02-04 12:57:53 +01:00
|
|
|
|
disk with debug files which may reveal confidential data. */
|
2009-12-03 19:04:40 +01:00
|
|
|
|
if (numok)
|
|
|
|
|
opt.debug &= ~(DBG_HASHING_VALUE);
|
|
|
|
|
}
|
2004-02-18 17:57:38 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("invalid debug-level '%s' given\n"), debug_level);
|
2004-02-18 17:57:38 +01:00
|
|
|
|
opt.debug = 0; /* Reset debugging, so that prior debug
|
|
|
|
|
statements won't have an undesired effect. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opt.debug && !opt.verbose)
|
|
|
|
|
opt.verbose = 1;
|
|
|
|
|
if (opt.debug && opt.quiet)
|
|
|
|
|
opt.quiet = 0;
|
|
|
|
|
|
|
|
|
|
if (opt.debug & DBG_MPI_VALUE)
|
|
|
|
|
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 2);
|
|
|
|
|
if (opt.debug & DBG_CRYPTO_VALUE )
|
|
|
|
|
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1);
|
|
|
|
|
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
|
2009-12-03 19:04:40 +01:00
|
|
|
|
|
|
|
|
|
if (opt.debug)
|
2015-06-23 09:12:44 +02:00
|
|
|
|
parse_debug_flag (NULL, &opt.debug, debug_flags);
|
2004-02-18 17:57:38 +01:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2004-02-18 17:57:38 +01:00
|
|
|
|
|
2014-11-28 21:34:35 +01:00
|
|
|
|
/* Helper for cleanup to remove one socket with NAME. REDIR_NAME is
|
|
|
|
|
the corresponding real name if the socket has been redirected. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static void
|
2014-11-28 21:34:35 +01:00
|
|
|
|
remove_socket (char *name, char *redir_name)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2005-01-26 23:20:21 +01:00
|
|
|
|
if (name && *name)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
char *p;
|
|
|
|
|
|
2014-11-28 21:34:35 +01:00
|
|
|
|
if (redir_name)
|
|
|
|
|
name = redir_name;
|
|
|
|
|
|
2010-04-14 13:24:02 +02:00
|
|
|
|
gnupg_remove (name);
|
2005-01-26 23:20:21 +01:00
|
|
|
|
p = strrchr (name, '/');
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (p)
|
2005-01-26 23:20:21 +01:00
|
|
|
|
{
|
|
|
|
|
*p = 0;
|
|
|
|
|
rmdir (name);
|
|
|
|
|
*p = '/';
|
|
|
|
|
}
|
|
|
|
|
*name = 0;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
}
|
2005-01-26 23:20:21 +01:00
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
|
|
|
|
/* Cleanup code for this program. This is either called has an atexit
|
|
|
|
|
handler or directly. */
|
2005-01-26 23:20:21 +01:00
|
|
|
|
static void
|
|
|
|
|
cleanup (void)
|
|
|
|
|
{
|
2010-10-01 22:33:53 +02:00
|
|
|
|
static int done;
|
|
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
|
return;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
done = 1;
|
2010-09-02 12:46:23 +02:00
|
|
|
|
deinitialize_module_cache ();
|
2014-11-28 21:34:35 +01:00
|
|
|
|
remove_socket (socket_name, redir_socket_name);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (opt.extra_socket > 1)
|
2014-11-28 21:34:35 +01:00
|
|
|
|
remove_socket (socket_name_extra, redir_socket_name_extra);
|
2015-06-11 09:36:27 +02:00
|
|
|
|
if (opt.browser_socket > 1)
|
|
|
|
|
remove_socket (socket_name_browser, redir_socket_name_browser);
|
2014-11-28 21:34:35 +01:00
|
|
|
|
remove_socket (socket_name_ssh, redir_socket_name_ssh);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Handle options which are allowed to be reset after program start.
|
|
|
|
|
Return true when the current option in PARGS could be handled and
|
|
|
|
|
false if not. As a special feature, passing a value of NULL for
|
2004-04-30 05:58:21 +02:00
|
|
|
|
PARGS, resets the options to the default. REREAD should be set
|
|
|
|
|
true if it is not the initial option parsing. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static int
|
2004-04-30 05:58:21 +02:00
|
|
|
|
parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
if (!pargs)
|
|
|
|
|
{ /* reset mode */
|
|
|
|
|
opt.quiet = 0;
|
|
|
|
|
opt.verbose = 0;
|
|
|
|
|
opt.debug = 0;
|
|
|
|
|
opt.no_grab = 0;
|
2015-05-11 10:23:24 +02:00
|
|
|
|
opt.debug_pinentry = 0;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
opt.pinentry_program = NULL;
|
2007-02-14 17:27:55 +01:00
|
|
|
|
opt.pinentry_touch_file = NULL;
|
2015-09-16 21:24:14 +02:00
|
|
|
|
xfree (opt.pinentry_invisible_char);
|
|
|
|
|
opt.pinentry_invisible_char = NULL;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
opt.scdaemon_program = NULL;
|
2004-03-16 11:48:42 +01:00
|
|
|
|
opt.def_cache_ttl = DEFAULT_CACHE_TTL;
|
2005-06-16 10:12:03 +02:00
|
|
|
|
opt.def_cache_ttl_ssh = DEFAULT_CACHE_TTL_SSH;
|
2004-08-20 15:43:14 +02:00
|
|
|
|
opt.max_cache_ttl = MAX_CACHE_TTL;
|
2007-03-06 21:44:41 +01:00
|
|
|
|
opt.max_cache_ttl_ssh = MAX_CACHE_TTL_SSH;
|
2007-08-27 20:10:27 +02:00
|
|
|
|
opt.enforce_passphrase_constraints = 0;
|
2007-01-25 09:30:47 +01:00
|
|
|
|
opt.min_passphrase_len = MIN_PASSPHRASE_LEN;
|
2007-08-27 20:10:27 +02:00
|
|
|
|
opt.min_passphrase_nonalpha = MIN_PASSPHRASE_NONALPHA;
|
|
|
|
|
opt.check_passphrase_pattern = NULL;
|
2007-08-28 19:48:13 +02:00
|
|
|
|
opt.max_passphrase_days = MAX_PASSPHRASE_DAYS;
|
|
|
|
|
opt.enable_passhrase_history = 0;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
opt.ignore_cache_for_signing = 0;
|
2013-07-03 15:20:25 +02:00
|
|
|
|
opt.allow_mark_trusted = 1;
|
2015-05-11 18:08:44 +02:00
|
|
|
|
opt.allow_external_cache = 1;
|
2015-06-09 14:07:00 +02:00
|
|
|
|
opt.allow_emacs_pinentry = 0;
|
2005-04-20 21:19:24 +02:00
|
|
|
|
opt.disable_scdaemon = 0;
|
2013-05-21 13:10:00 +02:00
|
|
|
|
disable_check_own_socket = 0;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pargs->r_opt)
|
|
|
|
|
{
|
|
|
|
|
case oQuiet: opt.quiet = 1; break;
|
|
|
|
|
case oVerbose: opt.verbose++; break;
|
|
|
|
|
|
2015-06-23 09:12:44 +02:00
|
|
|
|
case oDebug:
|
|
|
|
|
parse_debug_flag (pargs->r.ret_str, &opt.debug, debug_flags);
|
|
|
|
|
break;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oDebugAll: opt.debug = ~0; break;
|
2004-02-18 17:57:38 +01:00
|
|
|
|
case oDebugLevel: debug_level = pargs->r.ret_str; break;
|
2015-05-11 10:23:24 +02:00
|
|
|
|
case oDebugPinentry: opt.debug_pinentry = 1; break;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-04-30 05:58:21 +02:00
|
|
|
|
case oLogFile:
|
2004-10-22 11:39:47 +02:00
|
|
|
|
if (!reread)
|
|
|
|
|
return 0; /* not handeld */
|
|
|
|
|
if (!current_logfile || !pargs->r.ret_str
|
|
|
|
|
|| strcmp (current_logfile, pargs->r.ret_str))
|
2004-04-30 05:58:21 +02:00
|
|
|
|
{
|
|
|
|
|
log_set_file (pargs->r.ret_str);
|
|
|
|
|
xfree (current_logfile);
|
|
|
|
|
current_logfile = xtrystrdup (pargs->r.ret_str);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oNoGrab: opt.no_grab = 1; break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oPinentryProgram: opt.pinentry_program = pargs->r.ret_str; break;
|
2007-02-14 17:27:55 +01:00
|
|
|
|
case oPinentryTouchFile: opt.pinentry_touch_file = pargs->r.ret_str; break;
|
2015-09-16 21:24:14 +02:00
|
|
|
|
case oPinentryInvisibleChar:
|
|
|
|
|
xfree (opt.pinentry_invisible_char);
|
|
|
|
|
opt.pinentry_invisible_char = xtrystrdup (pargs->r.ret_str); break;
|
|
|
|
|
break;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oScdaemonProgram: opt.scdaemon_program = pargs->r.ret_str; break;
|
2005-04-20 21:19:24 +02:00
|
|
|
|
case oDisableScdaemon: opt.disable_scdaemon = 1; break;
|
2013-05-21 13:10:00 +02:00
|
|
|
|
case oDisableCheckOwnSocket: disable_check_own_socket = 1; break;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
case oDefCacheTTL: opt.def_cache_ttl = pargs->r.ret_ulong; break;
|
2005-06-07 21:09:18 +02:00
|
|
|
|
case oDefCacheTTLSSH: opt.def_cache_ttl_ssh = pargs->r.ret_ulong; break;
|
2004-08-20 15:43:14 +02:00
|
|
|
|
case oMaxCacheTTL: opt.max_cache_ttl = pargs->r.ret_ulong; break;
|
2005-06-16 10:12:03 +02:00
|
|
|
|
case oMaxCacheTTLSSH: opt.max_cache_ttl_ssh = pargs->r.ret_ulong; break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
|
|
|
|
case oEnforcePassphraseConstraints:
|
2007-08-27 20:10:27 +02:00
|
|
|
|
opt.enforce_passphrase_constraints=1;
|
|
|
|
|
break;
|
2007-01-25 09:30:47 +01:00
|
|
|
|
case oMinPassphraseLen: opt.min_passphrase_len = pargs->r.ret_ulong; break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
case oMinPassphraseNonalpha:
|
2007-08-27 20:10:27 +02:00
|
|
|
|
opt.min_passphrase_nonalpha = pargs->r.ret_ulong;
|
|
|
|
|
break;
|
|
|
|
|
case oCheckPassphrasePattern:
|
|
|
|
|
opt.check_passphrase_pattern = pargs->r.ret_str;
|
|
|
|
|
break;
|
2007-08-28 19:48:13 +02:00
|
|
|
|
case oMaxPassphraseDays:
|
2011-02-04 12:57:53 +01:00
|
|
|
|
opt.max_passphrase_days = pargs->r.ret_ulong;
|
2007-08-28 19:48:13 +02:00
|
|
|
|
break;
|
|
|
|
|
case oEnablePassphraseHistory:
|
|
|
|
|
opt.enable_passhrase_history = 1;
|
|
|
|
|
break;
|
2007-01-25 09:30:47 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oIgnoreCacheForSigning: opt.ignore_cache_for_signing = 1; break;
|
|
|
|
|
|
2004-05-03 15:37:38 +02:00
|
|
|
|
case oAllowMarkTrusted: opt.allow_mark_trusted = 1; break;
|
2013-07-03 15:20:25 +02:00
|
|
|
|
case oNoAllowMarkTrusted: opt.allow_mark_trusted = 0; break;
|
2004-05-03 15:37:38 +02:00
|
|
|
|
|
2004-12-21 20:05:15 +01:00
|
|
|
|
case oAllowPresetPassphrase: opt.allow_preset_passphrase = 1; break;
|
|
|
|
|
|
2011-03-03 18:35:08 +01:00
|
|
|
|
case oAllowLoopbackPinentry: opt.allow_loopback_pinentry = 1; break;
|
|
|
|
|
|
2015-05-11 18:08:44 +02:00
|
|
|
|
case oNoAllowExternalCache: opt.allow_external_cache = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
2015-06-09 14:07:00 +02:00
|
|
|
|
case oAllowEmacsPinentry: opt.allow_emacs_pinentry = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
default:
|
|
|
|
|
return 0; /* not handled */
|
|
|
|
|
}
|
2005-06-07 21:09:18 +02:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
return 1; /* handled */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-12-19 13:28:14 +01:00
|
|
|
|
/* Fixup some options after all have been processed. */
|
|
|
|
|
static void
|
|
|
|
|
finalize_rereadable_options (void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-04 11:34:28 +02:00
|
|
|
|
/* The main entry point. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
int
|
|
|
|
|
main (int argc, char **argv )
|
|
|
|
|
{
|
|
|
|
|
ARGPARSE_ARGS pargs;
|
|
|
|
|
int orig_argc;
|
|
|
|
|
char **orig_argv;
|
|
|
|
|
FILE *configfp = NULL;
|
|
|
|
|
char *configname = NULL;
|
|
|
|
|
const char *shell;
|
|
|
|
|
unsigned configlineno;
|
|
|
|
|
int parse_debug = 0;
|
|
|
|
|
int default_config =1;
|
|
|
|
|
int pipe_server = 0;
|
|
|
|
|
int is_daemon = 0;
|
|
|
|
|
int nodetach = 0;
|
|
|
|
|
int csh_style = 0;
|
|
|
|
|
char *logfile = NULL;
|
|
|
|
|
int debug_wait = 0;
|
2004-02-18 17:57:38 +01:00
|
|
|
|
int gpgconf_list = 0;
|
2004-04-06 09:36:44 +02:00
|
|
|
|
gpg_error_t err;
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
struct assuan_malloc_hooks malloc_hooks;
|
2007-06-14 19:05:07 +02:00
|
|
|
|
|
2015-01-28 19:57:22 +01:00
|
|
|
|
early_system_init ();
|
|
|
|
|
|
2009-03-19 08:09:31 +01:00
|
|
|
|
/* Before we do anything else we save the list of currently open
|
|
|
|
|
file descriptors and the signal mask. This info is required to
|
|
|
|
|
do the exec call properly. */
|
|
|
|
|
startup_fd_list = get_all_open_fds ();
|
|
|
|
|
#ifdef HAVE_SIGPROCMASK
|
|
|
|
|
if (!sigprocmask (SIG_UNBLOCK, NULL, &startup_signal_mask))
|
|
|
|
|
startup_signal_mask_valid = 1;
|
|
|
|
|
#endif /*HAVE_SIGPROCMASK*/
|
|
|
|
|
|
|
|
|
|
/* Set program name etc. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
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()
|
|
|
|
|
somewhere after the option parsing */
|
2015-04-24 15:49:18 +02:00
|
|
|
|
log_set_prefix (GPG_AGENT_NAME, GPGRT_LOG_WITH_PREFIX|GPGRT_LOG_WITH_PID);
|
2004-02-18 17:57:38 +01:00
|
|
|
|
|
2007-06-14 19:05:07 +02:00
|
|
|
|
/* Make sure that our subsystems are ready. */
|
2008-12-09 09:58:02 +01:00
|
|
|
|
i18n_init ();
|
2010-03-22 13:46:05 +01:00
|
|
|
|
init_common_subsystems (&argc, &argv);
|
2004-02-18 17:57:38 +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_init ();
|
2004-12-19 14:38:24 +01:00
|
|
|
|
|
2004-04-06 09:36:44 +02:00
|
|
|
|
/* Check that the libraries are suitable. Do it here because
|
|
|
|
|
the option parsing may need services of the library. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
|
|
|
|
|
{
|
2007-04-20 18:59:37 +02:00
|
|
|
|
log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt",
|
2003-08-05 19:11:04 +02:00
|
|
|
|
NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
malloc_hooks.malloc = gcry_malloc;
|
|
|
|
|
malloc_hooks.realloc = gcry_realloc;
|
|
|
|
|
malloc_hooks.free = gcry_free;
|
|
|
|
|
assuan_set_malloc_hooks (&malloc_hooks);
|
2010-04-14 13:24:02 +02:00
|
|
|
|
assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
|
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
|
|
|
|
assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
|
2009-10-16 20:35:03 +02:00
|
|
|
|
assuan_sock_init ();
|
2010-03-11 13:34:11 +01:00
|
|
|
|
setup_libassuan_logging (&opt.debug);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2007-04-20 18:59:37 +02:00
|
|
|
|
setup_libgcrypt_logging ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
|
|
|
|
|
|
2011-08-10 14:11:30 +02:00
|
|
|
|
disable_core_dumps ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-12-20 17:17:25 +01:00
|
|
|
|
/* Set default options. */
|
2004-04-30 05:58:21 +02:00
|
|
|
|
parse_rereadable_options (NULL, 0); /* Reset them to default values. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
shell = getenv ("SHELL");
|
|
|
|
|
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
|
|
|
|
|
csh_style = 1;
|
2004-12-20 17:17:25 +01:00
|
|
|
|
|
2004-12-21 11:03:00 +01:00
|
|
|
|
opt.homedir = default_homedir ();
|
2004-12-20 17:17:25 +01:00
|
|
|
|
|
2005-05-31 22:03:04 +02:00
|
|
|
|
/* Record some of the original environment strings. */
|
2009-07-07 12:02:41 +02:00
|
|
|
|
{
|
|
|
|
|
const char *s;
|
|
|
|
|
int idx;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char *names[] =
|
2009-07-07 12:02:41 +02:00
|
|
|
|
{ "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL };
|
|
|
|
|
|
|
|
|
|
err = 0;
|
|
|
|
|
opt.startup_env = session_env_new ();
|
|
|
|
|
if (!opt.startup_env)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
for (idx=0; !err && names[idx]; idx++)
|
|
|
|
|
{
|
|
|
|
|
s = getenv (names[idx]);
|
|
|
|
|
if (s)
|
|
|
|
|
err = session_env_setenv (opt.startup_env, names[idx], s);
|
|
|
|
|
}
|
|
|
|
|
if (!err)
|
|
|
|
|
{
|
2012-11-20 19:01:13 +01:00
|
|
|
|
s = gnupg_ttyname (0);
|
2009-07-07 12:02:41 +02:00
|
|
|
|
if (s)
|
|
|
|
|
err = session_env_setenv (opt.startup_env, "GPG_TTY", s);
|
|
|
|
|
}
|
|
|
|
|
if (err)
|
|
|
|
|
log_fatal ("error recording startup environment: %s\n",
|
|
|
|
|
gpg_strerror (err));
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-07-07 12:02:41 +02:00
|
|
|
|
/* Fixme: Better use the locale function here. */
|
|
|
|
|
opt.startup_lc_ctype = getenv ("LC_CTYPE");
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (opt.startup_lc_ctype)
|
2009-07-07 12:02:41 +02:00
|
|
|
|
opt.startup_lc_ctype = xstrdup (opt.startup_lc_ctype);
|
|
|
|
|
opt.startup_lc_messages = getenv ("LC_MESSAGES");
|
|
|
|
|
if (opt.startup_lc_messages)
|
|
|
|
|
opt.startup_lc_messages = xstrdup (opt.startup_lc_messages);
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-12-20 17:17:25 +01:00
|
|
|
|
/* Check whether we have a config file on the commandline */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
orig_argc = argc;
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
opt.homedir = pargs.r.ret_str;
|
2014-10-30 09:55:51 +01:00
|
|
|
|
else if (pargs.r_opt == oDebugQuickRandom)
|
|
|
|
|
{
|
|
|
|
|
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-08-29 15:12:01 +02:00
|
|
|
|
/* Initialize the secure memory. */
|
|
|
|
|
gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
maybe_setuid = 0;
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
/*
|
|
|
|
|
Now we are now working under our real uid
|
2003-08-05 19:11:04 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (default_config)
|
2014-05-07 18:18:27 +02:00
|
|
|
|
configname = make_filename (opt.homedir, GPG_AGENT_NAME EXTSEP_S "conf",
|
|
|
|
|
NULL );
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
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 )
|
2014-10-10 15:29:42 +02:00
|
|
|
|
log_info (_("Note: no default option file '%s'\n"),
|
2003-08-05 19:11:04 +02:00
|
|
|
|
configname );
|
2010-10-01 22:33:53 +02:00
|
|
|
|
/* Save the default conf file name so that
|
|
|
|
|
reread_configuration is able to test whether the
|
|
|
|
|
config file has been created in the meantime. */
|
|
|
|
|
xfree (config_filename);
|
|
|
|
|
config_filename = configname;
|
|
|
|
|
configname = NULL;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("option file '%s': %s\n"),
|
2003-08-05 19:11:04 +02:00
|
|
|
|
configname, strerror(errno) );
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
xfree (configname);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
configname = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (parse_debug && configname )
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info (_("reading options from '%s'\n"), configname );
|
2003-08-05 19:11:04 +02:00
|
|
|
|
default_config = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (optfile_parse( configfp, configname, &configlineno, &pargs, opts) )
|
|
|
|
|
{
|
2004-04-30 05:58:21 +02:00
|
|
|
|
if (parse_rereadable_options (&pargs, 0))
|
2003-08-05 19:11:04 +02:00
|
|
|
|
continue; /* Already handled */
|
|
|
|
|
switch (pargs.r_opt)
|
|
|
|
|
{
|
2004-02-18 17:57:38 +01:00
|
|
|
|
case aGPGConfList: gpgconf_list = 1; break;
|
2006-10-23 16:02:13 +02:00
|
|
|
|
case aGPGConfTest: gpgconf_list = 2; break;
|
2010-05-03 17:23:10 +02:00
|
|
|
|
case aUseStandardSocketP: gpgconf_list = 3; break;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oBatch: opt.batch=1; break;
|
|
|
|
|
|
|
|
|
|
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;
|
2014-05-07 08:51:11 +02:00
|
|
|
|
case oNoGreeting: /* Dummy option. */ break;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oNoVerbose: opt.verbose = 0; break;
|
|
|
|
|
case oNoOptions: break; /* no-options */
|
|
|
|
|
case oHomedir: opt.homedir = pargs.r.ret_str; break;
|
|
|
|
|
case oNoDetach: nodetach = 1; break;
|
|
|
|
|
case oLogFile: logfile = pargs.r.ret_str; break;
|
|
|
|
|
case oCsh: csh_style = 1; break;
|
|
|
|
|
case oSh: csh_style = 0; break;
|
|
|
|
|
case oServer: pipe_server = 1; break;
|
|
|
|
|
case oDaemon: is_daemon = 1; break;
|
|
|
|
|
|
|
|
|
|
case oDisplay: default_display = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oTTYname: default_ttyname = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oTTYtype: default_ttytype = xstrdup (pargs.r.ret_str); break;
|
|
|
|
|
case oLCctype: default_lc_ctype = xstrdup (pargs.r.ret_str); break;
|
2004-04-06 09:36:44 +02:00
|
|
|
|
case oLCmessages: default_lc_messages = xstrdup (pargs.r.ret_str);
|
2012-01-14 22:20:39 +01:00
|
|
|
|
break;
|
2007-11-19 17:03:50 +01:00
|
|
|
|
case oXauthority: default_xauthority = xstrdup (pargs.r.ret_str);
|
2004-04-06 09:36:44 +02:00
|
|
|
|
break;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2015-06-17 12:59:29 +02:00
|
|
|
|
case oUseStandardSocket:
|
|
|
|
|
case oNoUseStandardSocket:
|
|
|
|
|
obsolete_option (configname, configlineno, "use-standard-socket");
|
|
|
|
|
break;
|
2004-12-20 17:17:25 +01:00
|
|
|
|
|
2007-08-28 19:48:13 +02:00
|
|
|
|
case oFakedSystemTime:
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
time_t faked_time = isotime2epoch (pargs.r.ret_str);
|
2007-08-28 19:48:13 +02: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;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case oKeepTTY: opt.keep_tty = 1; break;
|
|
|
|
|
case oKeepDISPLAY: opt.keep_display = 1; break;
|
|
|
|
|
|
2015-06-29 12:24:58 +02:00
|
|
|
|
case oSSHSupport:
|
|
|
|
|
ssh_support = 1;
|
|
|
|
|
break;
|
2014-03-07 09:46:44 +01:00
|
|
|
|
case oPuttySupport:
|
|
|
|
|
# ifdef HAVE_W32_SYSTEM
|
|
|
|
|
putty_support = 1;
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
case oExtraSocket:
|
|
|
|
|
opt.extra_socket = 1; /* (1 = points into argv) */
|
|
|
|
|
socket_name_extra = pargs.r.ret_str;
|
|
|
|
|
break;
|
|
|
|
|
|
2015-06-11 09:36:27 +02:00
|
|
|
|
case oBrowserSocket:
|
|
|
|
|
opt.browser_socket = 1; /* (1 = points into argv) */
|
|
|
|
|
socket_name_browser = pargs.r.ret_str;
|
|
|
|
|
break;
|
|
|
|
|
|
2014-10-30 09:55:51 +01:00
|
|
|
|
case oDebugQuickRandom:
|
|
|
|
|
/* Only used by the first stage command line parser. */
|
|
|
|
|
break;
|
|
|
|
|
|
2015-06-17 12:59:29 +02:00
|
|
|
|
case oWriteEnvFile:
|
|
|
|
|
obsolete_option (configname, configlineno, "write-env-file");
|
|
|
|
|
break;
|
2005-01-26 23:20:21 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
default : pargs.err = configfp? 1:2; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (configfp)
|
|
|
|
|
{
|
|
|
|
|
fclose( configfp );
|
|
|
|
|
configfp = NULL;
|
|
|
|
|
/* Keep a copy of the name so that it can be read on SIGHUP. */
|
2010-10-01 22:33:53 +02:00
|
|
|
|
if (config_filename != configname)
|
|
|
|
|
{
|
|
|
|
|
xfree (config_filename);
|
|
|
|
|
config_filename = configname;
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
configname = NULL;
|
|
|
|
|
goto next_pass;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
xfree (configname);
|
|
|
|
|
configname = NULL;
|
|
|
|
|
if (log_get_errorcount(0))
|
|
|
|
|
exit(2);
|
|
|
|
|
|
2014-12-19 13:28:14 +01:00
|
|
|
|
finalize_rereadable_options ();
|
|
|
|
|
|
2014-04-15 16:40:48 +02:00
|
|
|
|
/* Turn the homedir into an absolute one. */
|
|
|
|
|
opt.homedir = make_absfilename (opt.homedir, NULL);
|
|
|
|
|
|
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] == '-')
|
2014-10-10 15:29:42 +02:00
|
|
|
|
log_info (_("Note: '%s' is not considered an option\n"), argv[i]);
|
2012-03-27 12:35:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-14 10:32:55 +02:00
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
|
/* gpg-agent usually does not output any messages because it runs in
|
|
|
|
|
the background. For log files it is acceptable to have messages
|
|
|
|
|
always encoded in utf-8. We switch here to utf-8, so that
|
|
|
|
|
commands like --help still give native messages. It is far
|
|
|
|
|
easier to switch only once instead of for every message and it
|
|
|
|
|
actually helps when more then one thread is active (avoids an
|
|
|
|
|
extra copy step). */
|
|
|
|
|
bind_textdomain_codeset (PACKAGE_GT, "UTF-8");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (!pipe_server && !is_daemon && !gpgconf_list)
|
|
|
|
|
{
|
|
|
|
|
/* We have been called without any options and thus we merely
|
|
|
|
|
check whether an agent is already running. We do this right
|
|
|
|
|
here so that we don't clobber a logfile with this check but
|
|
|
|
|
print the status directly to stderr. */
|
|
|
|
|
opt.debug = 0;
|
|
|
|
|
set_debug ();
|
2014-10-03 11:58:58 +02:00
|
|
|
|
check_for_running_agent (0);
|
2010-10-14 10:32:55 +02:00
|
|
|
|
agent_exit (0);
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-18 17:57:38 +01:00
|
|
|
|
set_debug ();
|
2010-10-14 10:32:55 +02:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (atexit (cleanup))
|
|
|
|
|
{
|
|
|
|
|
log_error ("atexit failed\n");
|
|
|
|
|
cleanup ();
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-02 12:46:23 +02:00
|
|
|
|
initialize_module_cache ();
|
2007-06-14 19:05:07 +02:00
|
|
|
|
initialize_module_call_pinentry ();
|
2004-12-19 18:44:20 +01:00
|
|
|
|
initialize_module_call_scd ();
|
2007-06-14 19:05:07 +02:00
|
|
|
|
initialize_module_trustlist ();
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2004-12-19 18:44:20 +01:00
|
|
|
|
/* Try to create missing directories. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
create_directories ();
|
|
|
|
|
|
|
|
|
|
if (debug_wait && pipe_server)
|
|
|
|
|
{
|
|
|
|
|
log_debug ("waiting for debugger - my pid is %u .....\n",
|
|
|
|
|
(unsigned int)getpid());
|
2007-06-20 13:16:42 +02:00
|
|
|
|
gnupg_sleep (debug_wait);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
log_debug ("... okay\n");
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-05-03 17:23:10 +02:00
|
|
|
|
if (gpgconf_list == 3)
|
2010-05-04 17:21:47 +02:00
|
|
|
|
{
|
2014-10-03 11:58:58 +02:00
|
|
|
|
/* We now use the standard socket always - return true for
|
|
|
|
|
backward compatibility. */
|
|
|
|
|
agent_exit (0);
|
2010-05-04 17:21:47 +02:00
|
|
|
|
}
|
2010-05-03 17:23:10 +02:00
|
|
|
|
else if (gpgconf_list == 2)
|
2006-10-23 16:02:13 +02:00
|
|
|
|
agent_exit (0);
|
2010-05-03 17:23:10 +02:00
|
|
|
|
else if (gpgconf_list)
|
2004-03-23 13:21:29 +01:00
|
|
|
|
{
|
|
|
|
|
char *filename;
|
2007-06-18 22:15:01 +02:00
|
|
|
|
char *filename_esc;
|
2004-03-23 13:21:29 +01:00
|
|
|
|
|
|
|
|
|
/* List options and default values in the GPG Conf format. */
|
2014-05-07 18:18:27 +02:00
|
|
|
|
filename = make_filename (opt.homedir, GPG_AGENT_NAME EXTSEP_S "conf",
|
|
|
|
|
NULL );
|
2007-06-19 11:11:11 +02:00
|
|
|
|
filename_esc = percent_escape (filename, NULL);
|
2007-06-18 22:15:01 +02:00
|
|
|
|
|
2014-05-07 18:18:27 +02:00
|
|
|
|
es_printf ("%s-%s.conf:%lu:\"%s\n",
|
|
|
|
|
GPGCONF_NAME, GPG_AGENT_NAME,
|
|
|
|
|
GC_OPT_FLAG_DEFAULT, filename_esc);
|
2004-03-23 13:21:29 +01:00
|
|
|
|
xfree (filename);
|
2007-06-18 22:15:01 +02:00
|
|
|
|
xfree (filename_esc);
|
2004-03-16 19:59:35 +01:00
|
|
|
|
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("verbose:%lu:\n"
|
2004-03-16 11:48:42 +01:00
|
|
|
|
"quiet:%lu:\n"
|
2004-03-17 14:01:16 +01:00
|
|
|
|
"debug-level:%lu:\"none:\n"
|
2004-03-16 11:48:42 +01:00
|
|
|
|
"log-file:%lu:\n",
|
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME,
|
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME,
|
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
|
2004-04-30 05:58:21 +02:00
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME );
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("default-cache-ttl:%lu:%d:\n",
|
2004-03-16 11:48:42 +01:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, DEFAULT_CACHE_TTL );
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("default-cache-ttl-ssh:%lu:%d:\n",
|
2007-03-06 21:44:41 +01:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, DEFAULT_CACHE_TTL_SSH );
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("max-cache-ttl:%lu:%d:\n",
|
2007-03-06 21:44:41 +01:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL );
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("max-cache-ttl-ssh:%lu:%d:\n",
|
2007-03-06 21:44:41 +01:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL_SSH );
|
2011-02-04 12:57:53 +01:00
|
|
|
|
es_printf ("enforce-passphrase-constraints:%lu:\n",
|
2007-08-27 20:10:27 +02:00
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("min-passphrase-len:%lu:%d:\n",
|
2007-03-06 21:44:41 +01:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MIN_PASSPHRASE_LEN );
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("min-passphrase-nonalpha:%lu:%d:\n",
|
2011-02-04 12:57:53 +01:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
|
2007-08-27 20:10:27 +02:00
|
|
|
|
MIN_PASSPHRASE_NONALPHA);
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("check-passphrase-pattern:%lu:\n",
|
2007-08-27 20:10:27 +02:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME);
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("max-passphrase-days:%lu:%d:\n",
|
2011-02-04 12:57:53 +01:00
|
|
|
|
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
|
2007-08-28 19:48:13 +02:00
|
|
|
|
MAX_PASSPHRASE_DAYS);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
es_printf ("enable-passphrase-history:%lu:\n",
|
2007-08-28 19:48:13 +02:00
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
es_printf ("no-grab:%lu:\n",
|
2004-03-16 11:48:42 +01:00
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("ignore-cache-for-signing:%lu:\n",
|
2004-05-03 15:37:38 +02:00
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2015-05-11 18:08:44 +02:00
|
|
|
|
es_printf ("no-allow-external-cache:%lu:\n",
|
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2013-07-03 15:20:25 +02:00
|
|
|
|
es_printf ("no-allow-mark-trusted:%lu:\n",
|
2004-03-16 11:48:42 +01:00
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("disable-scdaemon:%lu:\n",
|
2005-04-20 21:19:24 +02:00
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2015-06-29 12:24:58 +02:00
|
|
|
|
es_printf ("enable-ssh-support:%lu:\n", GC_OPT_FLAG_NONE);
|
2014-03-07 09:46:44 +01:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
es_printf ("enable-putty-support:%lu:\n", GC_OPT_FLAG_NONE);
|
|
|
|
|
#endif
|
2015-01-04 17:19:06 +01:00
|
|
|
|
es_printf ("allow-loopback-pinentry:%lu:\n",
|
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2015-06-09 14:07:00 +02:00
|
|
|
|
es_printf ("allow-emacs-pinentry:%lu:\n",
|
|
|
|
|
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
|
2004-02-18 17:57:38 +01:00
|
|
|
|
|
|
|
|
|
agent_exit (0);
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-04-16 11:46:54 +02:00
|
|
|
|
/* Now start with logging to a file if this is desired. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (logfile)
|
|
|
|
|
{
|
|
|
|
|
log_set_file (logfile);
|
2015-04-24 15:49:18 +02:00
|
|
|
|
log_set_prefix (NULL, (GPGRT_LOG_WITH_PREFIX
|
|
|
|
|
| GPGRT_LOG_WITH_TIME
|
|
|
|
|
| GPGRT_LOG_WITH_PID));
|
2004-04-30 05:58:21 +02:00
|
|
|
|
current_logfile = xstrdup (logfile);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure that we have a default ttyname. */
|
2012-11-20 19:01:13 +01:00
|
|
|
|
if (!default_ttyname && gnupg_ttyname (1))
|
2014-02-19 11:03:31 +01:00
|
|
|
|
default_ttyname = xstrdup (gnupg_ttyname (1));
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (!default_ttytype && getenv ("TERM"))
|
|
|
|
|
default_ttytype = xstrdup (getenv ("TERM"));
|
2004-12-15 15:15:54 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
if (pipe_server)
|
2011-02-04 12:57:53 +01:00
|
|
|
|
{
|
2006-11-20 17:49:41 +01:00
|
|
|
|
/* This is the simple pipe based server */
|
|
|
|
|
ctrl_t ctrl;
|
|
|
|
|
|
|
|
|
|
ctrl = xtrycalloc (1, sizeof *ctrl);
|
|
|
|
|
if (!ctrl)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error allocating connection control data: %s\n",
|
|
|
|
|
strerror (errno) );
|
|
|
|
|
agent_exit (1);
|
|
|
|
|
}
|
2009-07-07 12:02:41 +02:00
|
|
|
|
ctrl->session_env = session_env_new ();
|
|
|
|
|
if (!ctrl->session_env)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error allocating session environment block: %s\n",
|
|
|
|
|
strerror (errno) );
|
|
|
|
|
xfree (ctrl);
|
|
|
|
|
agent_exit (1);
|
|
|
|
|
}
|
2006-11-20 17:49:41 +01:00
|
|
|
|
agent_init_default_ctrl (ctrl);
|
2007-10-01 16:48:39 +02:00
|
|
|
|
start_command_handler (ctrl, GNUPG_INVALID_FD, GNUPG_INVALID_FD);
|
2006-11-20 17:49:41 +01:00
|
|
|
|
agent_deinit_default_ctrl (ctrl);
|
|
|
|
|
xfree (ctrl);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else if (!is_daemon)
|
2004-09-09 09:27:57 +02:00
|
|
|
|
; /* NOTREACHED */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
else
|
2004-09-09 09:27:57 +02:00
|
|
|
|
{ /* Regular server mode */
|
2007-10-01 16:48:39 +02:00
|
|
|
|
gnupg_fd_t fd;
|
2014-11-27 20:41:37 +01:00
|
|
|
|
gnupg_fd_t fd_extra = GNUPG_INVALID_FD;
|
2015-06-11 09:36:27 +02:00
|
|
|
|
gnupg_fd_t fd_browser = GNUPG_INVALID_FD;
|
2014-11-27 20:41:37 +01:00
|
|
|
|
gnupg_fd_t fd_ssh = GNUPG_INVALID_FD;
|
2015-11-27 17:53:52 +01:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
2003-08-05 19:11:04 +02:00
|
|
|
|
pid_t pid;
|
2015-11-27 17:53:52 +01:00
|
|
|
|
#endif
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
/* Remove the DISPLAY variable so that a pinentry does not
|
|
|
|
|
default to a specific display. There is still a default
|
2005-02-23 22:06:32 +01:00
|
|
|
|
display when gpg-agent was started using --display or a
|
2005-05-31 22:03:04 +02:00
|
|
|
|
client requested this using an OPTION command. Note, that we
|
|
|
|
|
don't do this when running in reverse daemon mode (i.e. when
|
|
|
|
|
exec the program given as arguments). */
|
2004-12-14 15:49:21 +01:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
2005-05-31 22:03:04 +02:00
|
|
|
|
if (!opt.keep_display && !argc)
|
2010-04-14 13:24:02 +02:00
|
|
|
|
gnupg_unsetenv ("DISPLAY");
|
2004-12-14 15:49:21 +01:00
|
|
|
|
#endif
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2015-07-01 03:39:40 +02:00
|
|
|
|
/* Remove the INSIDE_EMACS variable so that a pinentry does not
|
|
|
|
|
always try to interact with Emacs. The variable is set when
|
|
|
|
|
a client requested this using an OPTION command. */
|
|
|
|
|
gnupg_unsetenv ("INSIDE_EMACS");
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
/* Create the sockets. */
|
2014-11-27 20:41:37 +01:00
|
|
|
|
socket_name = create_socket_name (GPG_AGENT_SOCK_NAME, 1);
|
2015-06-29 21:26:09 +02:00
|
|
|
|
fd = create_server_socket (socket_name, 1, 0,
|
2014-11-28 21:34:35 +01:00
|
|
|
|
&redir_socket_name, &socket_nonce);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
|
|
|
|
|
if (opt.extra_socket)
|
|
|
|
|
{
|
|
|
|
|
socket_name_extra = create_socket_name (socket_name_extra, 0);
|
|
|
|
|
opt.extra_socket = 2; /* Indicate that it has been malloced. */
|
2015-06-29 21:26:09 +02:00
|
|
|
|
fd_extra = create_server_socket (socket_name_extra, 0, 0,
|
2014-11-28 21:34:35 +01:00
|
|
|
|
&redir_socket_name_extra,
|
2014-11-27 20:41:37 +01:00
|
|
|
|
&socket_nonce_extra);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-11 09:36:27 +02:00
|
|
|
|
if (opt.browser_socket)
|
|
|
|
|
{
|
|
|
|
|
socket_name_browser = create_socket_name (socket_name_browser, 0);
|
|
|
|
|
opt.browser_socket = 2; /* Indicate that it has been malloced. */
|
2015-06-29 21:26:09 +02:00
|
|
|
|
fd_browser = create_server_socket (socket_name_browser, 0, 0,
|
2015-06-11 09:36:27 +02:00
|
|
|
|
&redir_socket_name_browser,
|
|
|
|
|
&socket_nonce_browser);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 12:24:58 +02:00
|
|
|
|
if (ssh_support)
|
2014-01-16 02:00:17 +01:00
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
socket_name_ssh = create_socket_name (GPG_AGENT_SSH_SOCK_NAME, 1);
|
2015-06-29 21:26:09 +02:00
|
|
|
|
fd_ssh = create_server_socket (socket_name_ssh, 0, 1,
|
2014-11-28 21:34:35 +01:00
|
|
|
|
&redir_socket_name_ssh,
|
|
|
|
|
&socket_nonce_ssh);
|
2014-01-16 02:00:17 +01:00
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2005-04-20 21:19:24 +02:00
|
|
|
|
/* If we are going to exec a program in the parent, we record
|
|
|
|
|
the PID, so that the child may check whether the program is
|
|
|
|
|
still alive. */
|
|
|
|
|
if (argc)
|
|
|
|
|
parent_pid = getpid ();
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
fflush (NULL);
|
2004-12-20 17:17:25 +01:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
2014-03-07 09:46:44 +01:00
|
|
|
|
(void)csh_style;
|
|
|
|
|
(void)nodetach;
|
2004-12-20 17:17:25 +01:00
|
|
|
|
#else /*!HAVE_W32_SYSTEM*/
|
2003-08-05 19:11:04 +02:00
|
|
|
|
pid = fork ();
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (pid == (pid_t)-1)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
log_fatal ("fork failed: %s\n", strerror (errno) );
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else if (pid)
|
2004-04-16 11:46:54 +02:00
|
|
|
|
{ /* We are the parent */
|
2014-10-03 11:58:58 +02:00
|
|
|
|
char *infostr_ssh_sock, *infostr_ssh_valid;
|
2009-03-25 15:58:31 +01:00
|
|
|
|
|
|
|
|
|
/* Close the socket FD. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
close (fd);
|
2009-03-25 15:58:31 +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
|
|
|
|
/* The signal mask might not be correct right now and thus
|
|
|
|
|
we restore it. That is not strictly necessary but some
|
|
|
|
|
programs falsely assume a cleared signal mask. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-03-19 08:09:31 +01:00
|
|
|
|
#ifdef HAVE_SIGPROCMASK
|
|
|
|
|
if (startup_signal_mask_valid)
|
|
|
|
|
{
|
|
|
|
|
if (sigprocmask (SIG_SETMASK, &startup_signal_mask, NULL))
|
|
|
|
|
log_error ("error restoring signal mask: %s\n",
|
|
|
|
|
strerror (errno));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
log_info ("no saved signal mask\n");
|
2011-02-04 12:57:53 +01:00
|
|
|
|
#endif /*HAVE_SIGPROCMASK*/
|
2009-03-19 08:09:31 +01:00
|
|
|
|
|
2014-10-03 11:58:58 +02:00
|
|
|
|
/* Create the SSH info string if enabled. */
|
2015-06-29 12:24:58 +02:00
|
|
|
|
if (ssh_support)
|
2005-01-26 23:20:21 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&infostr_ssh_sock, "SSH_AUTH_SOCK=%s",
|
|
|
|
|
socket_name_ssh) < 0)
|
|
|
|
|
{
|
|
|
|
|
log_error ("out of core\n");
|
|
|
|
|
kill (pid, SIGTERM);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2012-12-10 14:45:26 +01:00
|
|
|
|
if (asprintf (&infostr_ssh_valid, "gnupg_SSH_AUTH_SOCK_by=%lu",
|
|
|
|
|
(unsigned long)getpid()) < 0)
|
|
|
|
|
{
|
|
|
|
|
log_error ("out of core\n");
|
|
|
|
|
kill (pid, SIGTERM);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2005-01-26 23:20:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
*socket_name = 0; /* Don't let cleanup() remove the socket -
|
2003-08-05 19:11:04 +02:00
|
|
|
|
the child should do this from now on */
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (opt.extra_socket)
|
|
|
|
|
*socket_name_extra = 0;
|
2015-06-11 09:36:27 +02:00
|
|
|
|
if (opt.browser_socket)
|
|
|
|
|
*socket_name_browser = 0;
|
2015-06-29 12:24:58 +02:00
|
|
|
|
if (ssh_support)
|
2005-01-26 23:20:21 +01:00
|
|
|
|
*socket_name_ssh = 0;
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (argc)
|
2005-02-03 18:40:02 +01:00
|
|
|
|
{ /* Run the program given on the commandline. */
|
2015-06-29 12:24:58 +02:00
|
|
|
|
if (ssh_support && (putenv (infostr_ssh_sock)
|
|
|
|
|
|| putenv (infostr_ssh_valid)))
|
2005-01-26 23:20:21 +01:00
|
|
|
|
{
|
|
|
|
|
log_error ("failed to set environment: %s\n",
|
|
|
|
|
strerror (errno) );
|
|
|
|
|
kill (pid, SIGTERM );
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2009-03-19 08:09:31 +01:00
|
|
|
|
|
|
|
|
|
/* Close all the file descriptors except the standard
|
|
|
|
|
ones and those open at startup. We explicitly don't
|
|
|
|
|
close 0,1,2 in case something went wrong collecting
|
|
|
|
|
them at startup. */
|
|
|
|
|
close_all_fds (3, startup_fd_list);
|
|
|
|
|
|
|
|
|
|
/* Run the command. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
execvp (argv[0], argv);
|
|
|
|
|
log_error ("failed to run the command: %s\n", strerror (errno));
|
|
|
|
|
kill (pid, SIGTERM);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-02-03 18:40:02 +01:00
|
|
|
|
/* Print the environment string, so that the caller can use
|
2003-08-05 19:11:04 +02:00
|
|
|
|
shell's eval to set it */
|
|
|
|
|
if (csh_style)
|
|
|
|
|
{
|
2015-06-29 12:24:58 +02:00
|
|
|
|
if (ssh_support)
|
2005-01-26 23:20:21 +01:00
|
|
|
|
{
|
|
|
|
|
*strchr (infostr_ssh_sock, '=') = ' ';
|
2012-01-03 11:13:30 +01:00
|
|
|
|
es_printf ("setenv %s;\n", infostr_ssh_sock);
|
2005-01-26 23:20:21 +01:00
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-06-29 12:24:58 +02:00
|
|
|
|
if (ssh_support)
|
2005-01-26 23:20:21 +01:00
|
|
|
|
{
|
2010-08-18 21:25:15 +02:00
|
|
|
|
es_printf ("%s; export SSH_AUTH_SOCK;\n",
|
|
|
|
|
infostr_ssh_sock);
|
2005-01-26 23:20:21 +01:00
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2015-06-29 12:24:58 +02:00
|
|
|
|
if (ssh_support)
|
2005-01-26 23:20:21 +01:00
|
|
|
|
{
|
2008-05-27 14:03:50 +02:00
|
|
|
|
xfree (infostr_ssh_sock);
|
2012-12-10 14:45:26 +01:00
|
|
|
|
xfree (infostr_ssh_valid);
|
2005-01-26 23:20:21 +01:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
exit (0);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2005-02-03 18:40:02 +01:00
|
|
|
|
/*NOTREACHED*/
|
|
|
|
|
} /* End parent */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
/*
|
2004-04-16 11:46:54 +02:00
|
|
|
|
This is the child
|
|
|
|
|
*/
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-04-16 11:46:54 +02:00
|
|
|
|
/* Detach from tty and put process into a new session */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (!nodetach )
|
2011-02-04 12:57:53 +01:00
|
|
|
|
{
|
2003-08-05 19:11:04 +02:00
|
|
|
|
int i;
|
2004-04-16 11:46:54 +02:00
|
|
|
|
unsigned int oldflags;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-04-16 11:46:54 +02:00
|
|
|
|
/* Close stdin, stdout and stderr unless it is the log stream */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
for (i=0; i <= 2; i++)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-10-22 11:39:47 +02:00
|
|
|
|
if (!log_test_fd (i) && i != fd )
|
2006-11-09 17:09:46 +01:00
|
|
|
|
{
|
|
|
|
|
if ( ! close (i)
|
|
|
|
|
&& open ("/dev/null", i? O_WRONLY : O_RDONLY) == -1)
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("failed to open '%s': %s\n",
|
2006-11-09 17:09:46 +01:00
|
|
|
|
"/dev/null", strerror (errno));
|
|
|
|
|
cleanup ();
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
if (setsid() == -1)
|
|
|
|
|
{
|
|
|
|
|
log_error ("setsid() failed: %s\n", strerror(errno) );
|
|
|
|
|
cleanup ();
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2004-04-16 11:46:54 +02:00
|
|
|
|
|
|
|
|
|
log_get_prefix (&oldflags);
|
2015-04-24 15:49:18 +02:00
|
|
|
|
log_set_prefix (NULL, oldflags | GPGRT_LOG_RUN_DETACHED);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
opt.running_detached = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chdir("/"))
|
|
|
|
|
{
|
|
|
|
|
log_error ("chdir to / failed: %s\n", strerror (errno));
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-18 12:48:06 +02:00
|
|
|
|
{
|
|
|
|
|
struct sigaction sa;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2005-05-18 12:48:06 +02:00
|
|
|
|
sa.sa_handler = SIG_IGN;
|
|
|
|
|
sigemptyset (&sa.sa_mask);
|
|
|
|
|
sa.sa_flags = 0;
|
|
|
|
|
sigaction (SIGPIPE, &sa, NULL);
|
|
|
|
|
}
|
2004-12-14 15:49:21 +01:00
|
|
|
|
#endif /*!HAVE_W32_SYSTEM*/
|
|
|
|
|
|
2009-03-25 15:58:31 +01:00
|
|
|
|
log_info ("%s %s started\n", strusage(11), strusage(13) );
|
2015-06-11 09:36:27 +02:00
|
|
|
|
handle_connections (fd, fd_extra, fd_browser, fd_ssh);
|
2007-10-01 16:48:39 +02:00
|
|
|
|
assuan_sock_close (fd);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-14 19:05:07 +02:00
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Exit entry point. This function should be called instead of a
|
|
|
|
|
plain exit. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
void
|
|
|
|
|
agent_exit (int rc)
|
|
|
|
|
{
|
|
|
|
|
/*FIXME: update_random_seed_file();*/
|
2010-10-01 22:33:53 +02:00
|
|
|
|
|
|
|
|
|
/* We run our cleanup handler because that may close cipher contexts
|
|
|
|
|
stored in secure memory and thus this needs to be done before we
|
|
|
|
|
explicitly terminate secure memory. */
|
|
|
|
|
cleanup ();
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#if 1
|
|
|
|
|
/* at this time a bit annoying */
|
|
|
|
|
if (opt.debug & DBG_MEMSTAT_VALUE)
|
|
|
|
|
{
|
|
|
|
|
gcry_control( GCRYCTL_DUMP_MEMORY_STATS );
|
|
|
|
|
gcry_control( GCRYCTL_DUMP_RANDOM_STATS );
|
|
|
|
|
}
|
|
|
|
|
if (opt.debug)
|
|
|
|
|
gcry_control (GCRYCTL_DUMP_SECMEM_STATS );
|
|
|
|
|
#endif
|
|
|
|
|
gcry_control (GCRYCTL_TERM_SECMEM );
|
|
|
|
|
rc = rc? rc : log_get_errorcount(0)? 2 : 0;
|
|
|
|
|
exit (rc);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-07 12:02:41 +02:00
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Each thread has its own local variables conveyed by a control
|
|
|
|
|
structure usually identified by an argument named CTRL. This
|
|
|
|
|
function is called immediately after allocating the control
|
|
|
|
|
structure. Its purpose is to setup the default values for that
|
2014-11-27 20:41:37 +01:00
|
|
|
|
structure. Note that some values may have already been set. */
|
2006-11-20 17:49:41 +01:00
|
|
|
|
static void
|
|
|
|
|
agent_init_default_ctrl (ctrl_t ctrl)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2014-03-07 09:46:44 +01:00
|
|
|
|
assert (ctrl->session_env);
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* Note we ignore malloc errors because we can't do much about it
|
|
|
|
|
and the request will fail anyway shortly after this
|
|
|
|
|
initialization. */
|
2009-07-07 12:02:41 +02:00
|
|
|
|
session_env_setenv (ctrl->session_env, "DISPLAY", default_display);
|
|
|
|
|
session_env_setenv (ctrl->session_env, "GPG_TTY", default_ttyname);
|
|
|
|
|
session_env_setenv (ctrl->session_env, "TERM", default_ttytype);
|
|
|
|
|
session_env_setenv (ctrl->session_env, "XAUTHORITY", default_xauthority);
|
|
|
|
|
session_env_setenv (ctrl->session_env, "PINENTRY_USER_DATA", NULL);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (ctrl->lc_ctype)
|
2008-05-27 14:03:50 +02:00
|
|
|
|
xfree (ctrl->lc_ctype);
|
|
|
|
|
ctrl->lc_ctype = default_lc_ctype? xtrystrdup (default_lc_ctype) : NULL;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (ctrl->lc_messages)
|
2008-05-27 14:03:50 +02:00
|
|
|
|
xfree (ctrl->lc_messages);
|
|
|
|
|
ctrl->lc_messages = default_lc_messages? xtrystrdup (default_lc_messages)
|
|
|
|
|
/**/ : NULL;
|
2011-04-21 15:40:48 +02:00
|
|
|
|
ctrl->cache_ttl_opt_preset = CACHE_TTL_OPT_PRESET;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Release all resources allocated by default in the control
|
|
|
|
|
structure. This is the counterpart to agent_init_default_ctrl. */
|
2006-11-20 17:49:41 +01:00
|
|
|
|
static void
|
|
|
|
|
agent_deinit_default_ctrl (ctrl_t ctrl)
|
|
|
|
|
{
|
2009-07-07 12:02:41 +02:00
|
|
|
|
session_env_release (ctrl->session_env);
|
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
if (ctrl->lc_ctype)
|
2008-05-27 14:03:50 +02:00
|
|
|
|
xfree (ctrl->lc_ctype);
|
2006-11-20 17:49:41 +01:00
|
|
|
|
if (ctrl->lc_messages)
|
2008-05-27 14:03:50 +02:00
|
|
|
|
xfree (ctrl->lc_messages);
|
2006-11-20 17:49:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-07 12:02:41 +02:00
|
|
|
|
|
2014-12-19 13:07:09 +01:00
|
|
|
|
/* Because the ssh protocol does not send us information about the
|
|
|
|
|
current TTY setting, we use this function to use those from startup
|
2015-11-16 12:41:46 +01:00
|
|
|
|
or those explicitly set. This is also used for the restricted mode
|
2014-12-19 13:07:09 +01:00
|
|
|
|
where we ignore requests to change the environment. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
agent_copy_startup_env (ctrl_t ctrl)
|
|
|
|
|
{
|
|
|
|
|
static const char *names[] =
|
|
|
|
|
{"GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL};
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
int idx;
|
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
|
|
for (idx=0; !err && names[idx]; idx++)
|
|
|
|
|
if ((value = session_env_getenv (opt.startup_env, names[idx])))
|
|
|
|
|
err = session_env_setenv (ctrl->session_env, names[idx], value);
|
|
|
|
|
|
|
|
|
|
if (!err && !ctrl->lc_ctype && opt.startup_lc_ctype)
|
|
|
|
|
if (!(ctrl->lc_ctype = xtrystrdup (opt.startup_lc_ctype)))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
|
|
|
|
|
if (!err && !ctrl->lc_messages && opt.startup_lc_messages)
|
|
|
|
|
if (!(ctrl->lc_messages = xtrystrdup (opt.startup_lc_messages)))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error setting default session environment: %s\n",
|
|
|
|
|
gpg_strerror (err));
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* Reread parts of the configuration. Note, that this function is
|
|
|
|
|
obviously not thread-safe and should only be called from the PTH
|
2011-02-04 12:57:53 +01:00
|
|
|
|
signal handler.
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
Fixme: Due to the way the argument parsing works, we create a
|
|
|
|
|
memory leak here for all string type arguments. There is currently
|
|
|
|
|
no clean way to tell whether the memory for the argument has been
|
|
|
|
|
allocated or points into the process' original arguments. Unless
|
|
|
|
|
we have a mechanism to tell this, we need to live on with this. */
|
|
|
|
|
static void
|
|
|
|
|
reread_configuration (void)
|
|
|
|
|
{
|
|
|
|
|
ARGPARSE_ARGS pargs;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
unsigned int configlineno = 0;
|
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
|
|
if (!config_filename)
|
|
|
|
|
return; /* No config file. */
|
|
|
|
|
|
|
|
|
|
fp = fopen (config_filename, "r");
|
|
|
|
|
if (!fp)
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info (_("option file '%s': %s\n"),
|
2010-10-01 22:33:53 +02:00
|
|
|
|
config_filename, strerror(errno) );
|
2003-08-05 19:11:04 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-30 05:58:21 +02:00
|
|
|
|
parse_rereadable_options (NULL, 1); /* Start from the default values. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
memset (&pargs, 0, sizeof pargs);
|
|
|
|
|
dummy = 0;
|
|
|
|
|
pargs.argc = &dummy;
|
|
|
|
|
pargs.flags = 1; /* do not remove the args */
|
|
|
|
|
while (optfile_parse (fp, config_filename, &configlineno, &pargs, opts) )
|
|
|
|
|
{
|
|
|
|
|
if (pargs.r_opt < -1)
|
|
|
|
|
pargs.err = 1; /* Print a warning. */
|
|
|
|
|
else /* Try to parse this option - ignore unchangeable ones. */
|
2004-04-30 05:58:21 +02:00
|
|
|
|
parse_rereadable_options (&pargs, 1);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
fclose (fp);
|
2014-12-19 13:28:14 +01:00
|
|
|
|
finalize_rereadable_options ();
|
2004-02-18 17:57:38 +01:00
|
|
|
|
set_debug ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-14 17:27:55 +01:00
|
|
|
|
/* Return the file name of the socket we are using for native
|
|
|
|
|
requests. */
|
|
|
|
|
const char *
|
|
|
|
|
get_agent_socket_name (void)
|
|
|
|
|
{
|
|
|
|
|
const char *s = socket_name;
|
|
|
|
|
|
|
|
|
|
return (s && *s)? s : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-18 12:33:12 +02:00
|
|
|
|
/* Return the file name of the socket we are using for SSH
|
|
|
|
|
requests. */
|
|
|
|
|
const char *
|
|
|
|
|
get_agent_ssh_socket_name (void)
|
|
|
|
|
{
|
|
|
|
|
const char *s = socket_name_ssh;
|
|
|
|
|
|
|
|
|
|
return (s && *s)? s : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2007-11-27 09:01:19 +01:00
|
|
|
|
/* Under W32, this function returns the handle of the scdaemon
|
|
|
|
|
notification event. Calling it the first time creates that
|
|
|
|
|
event. */
|
2010-04-14 13:24:02 +02:00
|
|
|
|
#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM)
|
2007-11-27 09:01:19 +01:00
|
|
|
|
void *
|
|
|
|
|
get_agent_scd_notify_event (void)
|
|
|
|
|
{
|
2012-01-19 22:27:44 +01:00
|
|
|
|
static HANDLE the_event = INVALID_HANDLE_VALUE;
|
2007-11-27 09:01:19 +01:00
|
|
|
|
|
2012-01-19 22:27:44 +01:00
|
|
|
|
if (the_event == INVALID_HANDLE_VALUE)
|
2007-11-27 09:01:19 +01:00
|
|
|
|
{
|
2008-10-14 20:18:21 +02:00
|
|
|
|
HANDLE h, h2;
|
2007-11-27 09:01:19 +01:00
|
|
|
|
SECURITY_ATTRIBUTES sa = { sizeof (SECURITY_ATTRIBUTES), NULL, TRUE};
|
|
|
|
|
|
2010-03-22 13:46:05 +01:00
|
|
|
|
/* We need to use a manual reset event object due to the way our
|
2008-10-14 20:18:21 +02:00
|
|
|
|
w32-pth wait function works: If we would use an automatic
|
|
|
|
|
reset event we are not able to figure out which handle has
|
|
|
|
|
been signaled because at the time we single out the signaled
|
|
|
|
|
handles using WFSO the event has already been reset due to
|
|
|
|
|
the WFMO. */
|
|
|
|
|
h = CreateEvent (&sa, TRUE, FALSE, NULL);
|
|
|
|
|
if (!h)
|
2007-11-27 09:01:19 +01:00
|
|
|
|
log_error ("can't create scd notify event: %s\n", w32_strerror (-1) );
|
2008-10-14 20:18:21 +02:00
|
|
|
|
else if (!DuplicateHandle (GetCurrentProcess(), h,
|
|
|
|
|
GetCurrentProcess(), &h2,
|
2011-02-04 12:57:53 +01:00
|
|
|
|
EVENT_MODIFY_STATE|SYNCHRONIZE, TRUE, 0))
|
2008-10-14 20:18:21 +02:00
|
|
|
|
{
|
|
|
|
|
log_error ("setting syncronize for scd notify event failed: %s\n",
|
|
|
|
|
w32_strerror (-1) );
|
|
|
|
|
CloseHandle (h);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CloseHandle (h);
|
|
|
|
|
the_event = h2;
|
|
|
|
|
}
|
2007-11-27 09:01:19 +01:00
|
|
|
|
}
|
2008-10-14 20:18:21 +02:00
|
|
|
|
|
2007-11-27 09:01:19 +01:00
|
|
|
|
return the_event;
|
|
|
|
|
}
|
2010-04-14 13:24:02 +02:00
|
|
|
|
#endif /*HAVE_W32_SYSTEM && !HAVE_W32CE_SYSTEM*/
|
2007-11-27 09:01:19 +01:00
|
|
|
|
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2014-10-03 11:58:58 +02:00
|
|
|
|
/* Create a name for the socket in the home directory as using
|
|
|
|
|
STANDARD_NAME. We also check for valid characters as well as
|
|
|
|
|
against a maximum allowed length for a unix domain socket is done.
|
|
|
|
|
The function terminates the process in case of an error. Returns:
|
|
|
|
|
Pointer to an allocated string with the absolute name of the socket
|
|
|
|
|
used. */
|
2005-02-03 18:40:02 +01:00
|
|
|
|
static char *
|
2014-11-27 20:41:37 +01:00
|
|
|
|
create_socket_name (char *standard_name, int with_homedir)
|
2005-02-03 18:40:02 +01:00
|
|
|
|
{
|
2014-10-03 11:58:58 +02:00
|
|
|
|
char *name;
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (with_homedir)
|
|
|
|
|
name = make_filename (opt.homedir, standard_name, NULL);
|
|
|
|
|
else
|
|
|
|
|
name = make_filename (standard_name, NULL);
|
2005-02-03 18:40:02 +01:00
|
|
|
|
if (strchr (name, PATHSEP_C))
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (("'%s' are not allowed in the socket name\n"), PATHSEP_S);
|
2005-02-03 18:40:02 +01:00
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
/* Create a Unix domain socket with NAME. Returns the file descriptor
|
2014-11-27 20:41:37 +01:00
|
|
|
|
or terminates the process in case of an error. Note that this
|
|
|
|
|
function needs to be used for the regular socket first (indicated
|
2014-12-01 10:45:06 +01:00
|
|
|
|
by PRIMARY) and only then for the extra and the ssh sockets. If
|
|
|
|
|
the socket has been redirected the name of the real socket is
|
2015-06-29 21:26:09 +02:00
|
|
|
|
stored as a malloced string at R_REDIR_NAME. If CYGWIN is set a
|
|
|
|
|
Cygwin compatible socket is created (Windows only). */
|
2007-10-01 16:48:39 +02:00
|
|
|
|
static gnupg_fd_t
|
2015-06-29 21:26:09 +02:00
|
|
|
|
create_server_socket (char *name, int primary, int cygwin,
|
2014-11-28 21:34:35 +01:00
|
|
|
|
char **r_redir_name, assuan_sock_nonce_t *nonce)
|
2005-02-03 18:40:02 +01:00
|
|
|
|
{
|
2014-11-28 21:34:35 +01:00
|
|
|
|
struct sockaddr *addr;
|
|
|
|
|
struct sockaddr_un *unaddr;
|
2005-02-03 18:40:02 +01:00
|
|
|
|
socklen_t len;
|
2007-10-01 16:48:39 +02:00
|
|
|
|
gnupg_fd_t fd;
|
2005-02-03 18:40:02 +01:00
|
|
|
|
int rc;
|
|
|
|
|
|
2014-11-28 21:34:35 +01:00
|
|
|
|
xfree (*r_redir_name);
|
|
|
|
|
*r_redir_name = NULL;
|
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
fd = assuan_sock_new (AF_UNIX, SOCK_STREAM, 0);
|
|
|
|
|
if (fd == ASSUAN_INVALID_FD)
|
2005-02-03 18:40:02 +01:00
|
|
|
|
{
|
|
|
|
|
log_error (_("can't create socket: %s\n"), strerror (errno));
|
2014-11-28 21:34:35 +01:00
|
|
|
|
*name = 0; /* Inhibit removal of the socket by cleanup(). */
|
2005-02-03 18:40:02 +01:00
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 21:26:09 +02:00
|
|
|
|
if (cygwin)
|
|
|
|
|
assuan_sock_set_flag (fd, "cygwin", 1);
|
|
|
|
|
|
2014-11-28 21:34:35 +01:00
|
|
|
|
unaddr = xmalloc (sizeof *unaddr);
|
|
|
|
|
addr = (struct sockaddr*)unaddr;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int redirected;
|
|
|
|
|
|
|
|
|
|
if (assuan_sock_set_sockaddr_un (name, addr, &redirected))
|
|
|
|
|
{
|
|
|
|
|
if (errno == ENAMETOOLONG)
|
|
|
|
|
log_error (_("socket name '%s' is too long\n"), name);
|
|
|
|
|
else
|
|
|
|
|
log_error ("error preparing socket '%s': %s\n",
|
|
|
|
|
name, gpg_strerror (gpg_error_from_syserror ()));
|
|
|
|
|
*name = 0; /* Inhibit removal of the socket by cleanup(). */
|
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
|
|
|
|
if (redirected)
|
|
|
|
|
{
|
|
|
|
|
*r_redir_name = xstrdup (unaddr->sun_path);
|
|
|
|
|
if (opt.verbose)
|
|
|
|
|
log_info ("redirecting socket '%s' to '%s'\n", name, *r_redir_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
len = SUN_LEN (unaddr);
|
|
|
|
|
rc = assuan_sock_bind (fd, addr, len);
|
2010-04-26 16:51:38 +02:00
|
|
|
|
|
|
|
|
|
/* Our error code mapping on W32CE returns EEXIST thus we also test
|
|
|
|
|
for this. */
|
2014-10-03 11:58:58 +02:00
|
|
|
|
if (rc == -1
|
2010-04-26 16:51:38 +02:00
|
|
|
|
&& (errno == EADDRINUSE
|
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
|| errno == EEXIST
|
|
|
|
|
#endif
|
|
|
|
|
))
|
2005-02-03 18:40:02 +01:00
|
|
|
|
{
|
2014-11-28 21:34:35 +01:00
|
|
|
|
/* Check whether a gpg-agent is already running. We do this
|
|
|
|
|
test only if this is the primary socket. For secondary
|
|
|
|
|
sockets we assume that a test for gpg-agent has already been
|
|
|
|
|
done and reuse the requested socket. Testing the ssh-socket
|
|
|
|
|
is not possible because at this point, though we know the new
|
|
|
|
|
Assuan socket, the Assuan server and thus the ssh-agent
|
|
|
|
|
server is not yet operational; this would lead to a hang. */
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (primary && !check_for_running_agent (1))
|
2007-06-21 20:44:48 +02:00
|
|
|
|
{
|
2015-04-24 15:49:18 +02:00
|
|
|
|
log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX);
|
2010-10-13 17:57:08 +02:00
|
|
|
|
log_set_file (NULL);
|
2007-06-21 20:44:48 +02:00
|
|
|
|
log_error (_("a gpg-agent is already running - "
|
2007-10-01 16:48:39 +02:00
|
|
|
|
"not starting a new one\n"));
|
2007-06-21 20:44:48 +02:00
|
|
|
|
*name = 0; /* Inhibit removal of the socket by cleanup(). */
|
2007-10-01 16:48:39 +02:00
|
|
|
|
assuan_sock_close (fd);
|
2007-06-21 20:44:48 +02:00
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
2014-11-28 21:34:35 +01:00
|
|
|
|
gnupg_remove (unaddr->sun_path);
|
|
|
|
|
rc = assuan_sock_bind (fd, addr, len);
|
2005-02-03 18:40:02 +01:00
|
|
|
|
}
|
2014-11-28 21:34:35 +01:00
|
|
|
|
if (rc != -1 && (rc=assuan_sock_get_nonce (addr, len, nonce)))
|
2007-10-01 16:48:39 +02:00
|
|
|
|
log_error (_("error getting nonce for the socket\n"));
|
2005-02-03 18:40:02 +01:00
|
|
|
|
if (rc == -1)
|
|
|
|
|
{
|
2007-06-19 11:11:11 +02:00
|
|
|
|
/* We use gpg_strerror here because it allows us to get strings
|
|
|
|
|
for some W32 socket error codes. */
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("error binding socket to '%s': %s\n"),
|
2014-11-28 21:34:35 +01:00
|
|
|
|
unaddr->sun_path,
|
|
|
|
|
gpg_strerror (gpg_error_from_syserror ()));
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
assuan_sock_close (fd);
|
2014-10-03 11:58:58 +02:00
|
|
|
|
*name = 0; /* Inhibit removal of the socket by cleanup(). */
|
2005-02-03 18:40:02 +01:00
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
if (listen (FD2INT(fd), 5 ) == -1)
|
2005-02-03 18:40:02 +01:00
|
|
|
|
{
|
|
|
|
|
log_error (_("listen() failed: %s\n"), strerror (errno));
|
2014-11-28 21:34:35 +01:00
|
|
|
|
*name = 0; /* Inhibit removal of the socket by cleanup(). */
|
2007-10-01 16:48:39 +02:00
|
|
|
|
assuan_sock_close (fd);
|
2005-02-03 18:40:02 +01:00
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
if (opt.verbose)
|
2014-11-28 21:34:35 +01:00
|
|
|
|
log_info (_("listening on socket '%s'\n"), unaddr->sun_path);
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
|
|
|
|
return fd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Check that the directory for storing the private keys exists and
|
|
|
|
|
create it if not. This function won't fail as it is only a
|
|
|
|
|
convenience function and not strictly necessary. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static void
|
|
|
|
|
create_private_keys_directory (const char *home)
|
|
|
|
|
{
|
|
|
|
|
char *fname;
|
|
|
|
|
struct stat statbuf;
|
|
|
|
|
|
|
|
|
|
fname = make_filename (home, GNUPG_PRIVATE_KEYS_DIR, NULL);
|
|
|
|
|
if (stat (fname, &statbuf) && errno == ENOENT)
|
|
|
|
|
{
|
2010-04-14 13:24:02 +02:00
|
|
|
|
if (gnupg_mkdir (fname, "-rwx"))
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("can't create directory '%s': %s\n"),
|
2004-12-13 16:49:56 +01:00
|
|
|
|
fname, strerror (errno) );
|
2003-08-05 19:11:04 +02:00
|
|
|
|
else if (!opt.quiet)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info (_("directory '%s' created\n"), fname);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
xfree (fname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create the directory only if the supplied directory name is the
|
|
|
|
|
same as the default one. This way we avoid to create arbitrary
|
|
|
|
|
directories when a non-default home directory is used. To cope
|
|
|
|
|
with HOME, we compare only the suffix if we see that the default
|
|
|
|
|
homedir does start with a tilde. We don't stop here in case of
|
|
|
|
|
problems because other functions will throw an error anyway.*/
|
|
|
|
|
static void
|
|
|
|
|
create_directories (void)
|
|
|
|
|
{
|
|
|
|
|
struct stat statbuf;
|
2007-06-26 15:48:44 +02:00
|
|
|
|
const char *defhome = standard_homedir ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
char *home;
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
home = make_filename (opt.homedir, NULL);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if ( stat (home, &statbuf) )
|
|
|
|
|
{
|
|
|
|
|
if (errno == ENOENT)
|
|
|
|
|
{
|
2007-06-26 15:48:44 +02:00
|
|
|
|
if (
|
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
( !compare_filenames (home, defhome) )
|
|
|
|
|
#else
|
|
|
|
|
(*defhome == '~'
|
2003-08-05 19:11:04 +02:00
|
|
|
|
&& (strlen (home) >= strlen (defhome+1)
|
|
|
|
|
&& !strcmp (home + strlen(home)
|
|
|
|
|
- strlen (defhome+1), defhome+1)))
|
|
|
|
|
|| (*defhome != '~' && !strcmp (home, defhome) )
|
2007-06-26 15:48:44 +02:00
|
|
|
|
#endif
|
2003-08-05 19:11:04 +02:00
|
|
|
|
)
|
|
|
|
|
{
|
2010-04-14 13:24:02 +02:00
|
|
|
|
if (gnupg_mkdir (home, "-rwx"))
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("can't create directory '%s': %s\n"),
|
2004-12-13 16:49:56 +01:00
|
|
|
|
home, strerror (errno) );
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
if (!opt.quiet)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info (_("directory '%s' created\n"), home);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
create_private_keys_directory (home);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("stat() failed for '%s': %s\n"), home, strerror (errno));
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else if ( !S_ISDIR(statbuf.st_mode))
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error (_("can't use '%s' as home directory\n"), home);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else /* exists and is a directory. */
|
|
|
|
|
{
|
|
|
|
|
create_private_keys_directory (home);
|
|
|
|
|
}
|
|
|
|
|
xfree (home);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-20 21:19:24 +02:00
|
|
|
|
/* This is the worker for the ticker. It is called every few seconds
|
|
|
|
|
and may only do fast operations. */
|
|
|
|
|
static void
|
|
|
|
|
handle_tick (void)
|
|
|
|
|
{
|
2008-10-29 18:24:27 +01:00
|
|
|
|
static time_t last_minute;
|
|
|
|
|
|
|
|
|
|
if (!last_minute)
|
|
|
|
|
last_minute = time (NULL);
|
|
|
|
|
|
2005-06-03 15:57:24 +02:00
|
|
|
|
/* Check whether the scdaemon has died and cleanup in this case. */
|
2005-05-21 20:49:00 +02:00
|
|
|
|
agent_scd_check_aliveness ();
|
|
|
|
|
|
|
|
|
|
/* If we are running as a child of another process, check whether
|
2006-02-09 19:29:31 +01:00
|
|
|
|
the parent is still alive and shutdown if not. */
|
2005-04-20 21:19:24 +02:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
|
|
|
|
if (parent_pid != (pid_t)(-1))
|
|
|
|
|
{
|
|
|
|
|
if (kill (parent_pid, 0))
|
|
|
|
|
{
|
|
|
|
|
shutdown_pending = 2;
|
|
|
|
|
log_info ("parent process died - shutting down\n");
|
|
|
|
|
log_info ("%s %s stopped\n", strusage(11), strusage(13) );
|
|
|
|
|
cleanup ();
|
|
|
|
|
agent_exit (0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /*HAVE_W32_SYSTEM*/
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-11-26 10:42:56 +01:00
|
|
|
|
/* Code to be run from time to time. */
|
2010-11-29 07:49:44 +01:00
|
|
|
|
#if CHECK_OWN_SOCKET_INTERVAL > 0
|
2010-11-26 10:42:56 +01:00
|
|
|
|
if (last_minute + CHECK_OWN_SOCKET_INTERVAL <= time (NULL))
|
2008-10-29 18:24:27 +01:00
|
|
|
|
{
|
|
|
|
|
check_own_socket ();
|
|
|
|
|
last_minute = time (NULL);
|
|
|
|
|
}
|
2010-11-29 07:49:44 +01:00
|
|
|
|
#endif
|
2008-10-29 18:24:27 +01:00
|
|
|
|
|
2005-04-20 21:19:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-27 09:01:19 +01:00
|
|
|
|
/* A global function which allows us to call the reload stuff from
|
|
|
|
|
other places too. This is only used when build for W32. */
|
2007-07-04 11:34:28 +02:00
|
|
|
|
void
|
|
|
|
|
agent_sighup_action (void)
|
|
|
|
|
{
|
2007-11-27 09:01:19 +01:00
|
|
|
|
log_info ("SIGHUP received - "
|
|
|
|
|
"re-reading configuration and flushing cache\n");
|
2015-02-04 10:09:28 +01:00
|
|
|
|
|
2007-07-04 11:34:28 +02:00
|
|
|
|
agent_flush_cache ();
|
|
|
|
|
reread_configuration ();
|
|
|
|
|
agent_reload_trustlist ();
|
2015-02-04 10:09:28 +01:00
|
|
|
|
/* We flush the module name cache so that after installing a
|
|
|
|
|
"pinentry" binary that one can be used in case the
|
|
|
|
|
"pinentry-basic" fallback was in use. */
|
|
|
|
|
gnupg_module_name_flush_some ();
|
2007-07-04 11:34:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* A helper function to handle SIGUSR2. */
|
2007-11-27 09:01:19 +01:00
|
|
|
|
static void
|
|
|
|
|
agent_sigusr2_action (void)
|
|
|
|
|
{
|
|
|
|
|
if (opt.verbose)
|
2008-12-18 17:34:28 +01:00
|
|
|
|
log_info ("SIGUSR2 received - updating card event counter\n");
|
2007-11-27 09:01:19 +01:00
|
|
|
|
/* Nothing to check right now. We only increment a counter. */
|
|
|
|
|
bump_card_eventcounter ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* The signal handler for this program. It is expected to be run in
|
|
|
|
|
its own trhead and not in the context of a signal handler. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static void
|
|
|
|
|
handle_signal (int signo)
|
|
|
|
|
{
|
|
|
|
|
switch (signo)
|
|
|
|
|
{
|
2004-12-13 16:49:56 +01:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case SIGHUP:
|
2007-07-04 11:34:28 +02:00
|
|
|
|
agent_sighup_action ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case SIGUSR1:
|
2005-05-21 20:49:00 +02:00
|
|
|
|
log_info ("SIGUSR1 received - printing internal information:\n");
|
2010-03-11 13:34:11 +01:00
|
|
|
|
/* Fixme: We need to see how to integrate pth dumping into our
|
|
|
|
|
logging system. */
|
|
|
|
|
/* pth_ctrl (PTH_CTRL_DUMPSTATE, log_get_stream ()); */
|
2005-06-07 21:09:18 +02:00
|
|
|
|
agent_query_dump_state ();
|
2005-06-03 15:57:24 +02:00
|
|
|
|
agent_scd_dump_state ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case SIGUSR2:
|
2007-11-27 09:01:19 +01:00
|
|
|
|
agent_sigusr2_action ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SIGTERM:
|
|
|
|
|
if (!shutdown_pending)
|
|
|
|
|
log_info ("SIGTERM received - shutting down ...\n");
|
|
|
|
|
else
|
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_info ("SIGTERM received - still %i open connections\n",
|
|
|
|
|
active_connections);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
shutdown_pending++;
|
|
|
|
|
if (shutdown_pending > 2)
|
|
|
|
|
{
|
|
|
|
|
log_info ("shutdown forced\n");
|
|
|
|
|
log_info ("%s %s stopped\n", strusage(11), strusage(13) );
|
|
|
|
|
cleanup ();
|
|
|
|
|
agent_exit (0);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
case SIGINT:
|
|
|
|
|
log_info ("SIGINT received - immediate shutdown\n");
|
|
|
|
|
log_info( "%s %s stopped\n", strusage(11), strusage(13));
|
|
|
|
|
cleanup ();
|
|
|
|
|
agent_exit (0);
|
|
|
|
|
break;
|
2004-12-13 16:49:56 +01:00
|
|
|
|
#endif
|
2003-08-05 19:11:04 +02:00
|
|
|
|
default:
|
|
|
|
|
log_info ("signal %d received - no action defined\n", signo);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#endif
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
/* Check the nonce on a new connection. This is a NOP unless we we
|
|
|
|
|
are using our Unix domain socket emulation under Windows. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static int
|
2007-10-01 16:48:39 +02:00
|
|
|
|
check_nonce (ctrl_t ctrl, assuan_sock_nonce_t *nonce)
|
|
|
|
|
{
|
|
|
|
|
if (assuan_sock_check_nonce (ctrl->thread_startup.fd, nonce))
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
log_info (_("error reading nonce on fd %d: %s\n"),
|
2007-10-01 16:48:39 +02:00
|
|
|
|
FD2INT(ctrl->thread_startup.fd), strerror (errno));
|
|
|
|
|
assuan_sock_close (ctrl->thread_startup.fd);
|
|
|
|
|
xfree (ctrl);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-03-07 09:46:44 +01:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
/* The window message processing function for Putty. Warning: This
|
|
|
|
|
code runs as a native Windows thread. Use of our own functions
|
|
|
|
|
needs to be bracket with pth_leave/pth_enter. */
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
|
putty_message_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
|
{
|
|
|
|
|
int ret = 0;
|
|
|
|
|
int w32rc;
|
|
|
|
|
COPYDATASTRUCT *cds;
|
|
|
|
|
const char *mapfile;
|
|
|
|
|
HANDLE maphd;
|
|
|
|
|
PSID mysid = NULL;
|
|
|
|
|
PSID mapsid = NULL;
|
|
|
|
|
void *data = NULL;
|
|
|
|
|
PSECURITY_DESCRIPTOR psd = NULL;
|
|
|
|
|
ctrl_t ctrl = NULL;
|
|
|
|
|
|
|
|
|
|
if (msg != WM_COPYDATA)
|
|
|
|
|
{
|
|
|
|
|
return DefWindowProc (hwnd, msg, wparam, lparam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cds = (COPYDATASTRUCT*)lparam;
|
|
|
|
|
if (cds->dwData != PUTTY_IPC_MAGIC)
|
|
|
|
|
return 0; /* Ignore data with the wrong magic. */
|
|
|
|
|
mapfile = cds->lpData;
|
|
|
|
|
if (!cds->cbData || mapfile[cds->cbData - 1])
|
|
|
|
|
return 0; /* Ignore empty and non-properly terminated strings. */
|
|
|
|
|
|
2015-04-06 13:42:17 +02:00
|
|
|
|
if (DBG_IPC)
|
2014-03-07 09:46:44 +01:00
|
|
|
|
{
|
|
|
|
|
npth_protect ();
|
|
|
|
|
log_debug ("ssh map file '%s'", mapfile);
|
|
|
|
|
npth_unprotect ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
maphd = OpenFileMapping (FILE_MAP_ALL_ACCESS, FALSE, mapfile);
|
2015-04-06 13:42:17 +02:00
|
|
|
|
if (DBG_IPC)
|
2014-03-07 09:46:44 +01:00
|
|
|
|
{
|
|
|
|
|
npth_protect ();
|
|
|
|
|
log_debug ("ssh map handle %p\n", maphd);
|
|
|
|
|
npth_unprotect ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!maphd || maphd == INVALID_HANDLE_VALUE)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
npth_protect ();
|
|
|
|
|
|
|
|
|
|
mysid = w32_get_user_sid ();
|
|
|
|
|
if (!mysid)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error getting my sid\n");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
w32rc = GetSecurityInfo (maphd, SE_KERNEL_OBJECT,
|
|
|
|
|
OWNER_SECURITY_INFORMATION,
|
|
|
|
|
&mapsid, NULL, NULL, NULL,
|
|
|
|
|
&psd);
|
|
|
|
|
if (w32rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error getting sid of ssh map file: rc=%d", w32rc);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 13:42:17 +02:00
|
|
|
|
if (DBG_IPC)
|
2014-03-07 09:46:44 +01:00
|
|
|
|
{
|
|
|
|
|
char *sidstr;
|
|
|
|
|
|
|
|
|
|
if (!ConvertSidToStringSid (mysid, &sidstr))
|
|
|
|
|
sidstr = NULL;
|
|
|
|
|
log_debug (" my sid: '%s'", sidstr? sidstr: "[error]");
|
|
|
|
|
LocalFree (sidstr);
|
|
|
|
|
if (!ConvertSidToStringSid (mapsid, &sidstr))
|
|
|
|
|
sidstr = NULL;
|
|
|
|
|
log_debug ("ssh map file sid: '%s'", sidstr? sidstr: "[error]");
|
|
|
|
|
LocalFree (sidstr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!EqualSid (mysid, mapsid))
|
|
|
|
|
{
|
|
|
|
|
log_error ("ssh map file has a non-matching sid\n");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = MapViewOfFile (maphd, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
2015-04-06 13:42:17 +02:00
|
|
|
|
if (DBG_IPC)
|
2014-03-07 09:46:44 +01:00
|
|
|
|
log_debug ("ssh IPC buffer at %p\n", data);
|
|
|
|
|
if (!data)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
/* log_printhex ("request:", data, 20); */
|
|
|
|
|
|
|
|
|
|
ctrl = xtrycalloc (1, sizeof *ctrl);
|
|
|
|
|
if (!ctrl)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error allocating connection control data: %s\n",
|
|
|
|
|
strerror (errno) );
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
ctrl->session_env = session_env_new ();
|
|
|
|
|
if (!ctrl->session_env)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error allocating session environment block: %s\n",
|
|
|
|
|
strerror (errno) );
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
agent_init_default_ctrl (ctrl);
|
|
|
|
|
if (!serve_mmapped_ssh_request (ctrl, data, PUTTY_IPC_MAXLEN))
|
|
|
|
|
ret = 1; /* Valid ssh message has been constructed. */
|
|
|
|
|
agent_deinit_default_ctrl (ctrl);
|
|
|
|
|
/* log_printhex (" reply:", data, 20); */
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
xfree (ctrl);
|
|
|
|
|
if (data)
|
|
|
|
|
UnmapViewOfFile (data);
|
|
|
|
|
xfree (mapsid);
|
|
|
|
|
if (psd)
|
|
|
|
|
LocalFree (psd);
|
|
|
|
|
xfree (mysid);
|
|
|
|
|
CloseHandle (maphd);
|
|
|
|
|
|
|
|
|
|
npth_unprotect ();
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
#endif /*HAVE_W32_SYSTEM*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
/* The thread handling Putty's IPC requests. */
|
|
|
|
|
static void *
|
|
|
|
|
putty_message_thread (void *arg)
|
|
|
|
|
{
|
|
|
|
|
WNDCLASS wndwclass = {0, putty_message_proc, 0, 0,
|
|
|
|
|
NULL, NULL, NULL, NULL, NULL, "Pageant"};
|
|
|
|
|
HWND hwnd;
|
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
|
|
if (opt.verbose)
|
|
|
|
|
log_info ("putty message loop thread started\n");
|
|
|
|
|
|
|
|
|
|
/* The message loop runs as thread independent from our nPth system.
|
|
|
|
|
This also means that we need to make sure that we switch back to
|
|
|
|
|
our system before calling any no-windows function. */
|
|
|
|
|
npth_unprotect ();
|
|
|
|
|
|
|
|
|
|
/* First create a window to make sure that a message queue exists
|
|
|
|
|
for this thread. */
|
|
|
|
|
if (!RegisterClass (&wndwclass))
|
|
|
|
|
{
|
|
|
|
|
npth_protect ();
|
|
|
|
|
log_error ("error registering Pageant window class");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
hwnd = CreateWindowEx (0, "Pageant", "Pageant", 0,
|
|
|
|
|
0, 0, 0, 0,
|
|
|
|
|
HWND_MESSAGE, /* hWndParent */
|
|
|
|
|
NULL, /* hWndMenu */
|
|
|
|
|
NULL, /* hInstance */
|
|
|
|
|
NULL); /* lpParm */
|
|
|
|
|
if (!hwnd)
|
|
|
|
|
{
|
|
|
|
|
npth_protect ();
|
|
|
|
|
log_error ("error creating Pageant window");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (GetMessage(&msg, NULL, 0, 0))
|
|
|
|
|
{
|
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Back to nPth. */
|
|
|
|
|
npth_protect ();
|
|
|
|
|
|
|
|
|
|
if (opt.verbose)
|
|
|
|
|
log_info ("putty message loop thread stopped\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif /*HAVE_W32_SYSTEM*/
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static void *
|
2015-06-11 09:43:32 +02:00
|
|
|
|
do_start_connection_thread (ctrl_t ctrl)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2006-11-20 17:49:41 +01:00
|
|
|
|
agent_init_default_ctrl (ctrl);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (opt.verbose)
|
2011-02-04 12:57:53 +01:00
|
|
|
|
log_info (_("handler 0x%lx for fd %d started\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
|
|
|
|
(unsigned long) npth_self(), FD2INT(ctrl->thread_startup.fd));
|
2004-05-11 21:11:53 +02:00
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
start_command_handler (ctrl, GNUPG_INVALID_FD, ctrl->thread_startup.fd);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (opt.verbose)
|
2011-02-04 12:57:53 +01:00
|
|
|
|
log_info (_("handler 0x%lx for fd %d terminated\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
|
|
|
|
(unsigned long) npth_self(), FD2INT(ctrl->thread_startup.fd));
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
agent_deinit_default_ctrl (ctrl);
|
|
|
|
|
xfree (ctrl);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
/* This is the standard connection thread's main function. */
|
|
|
|
|
static void *
|
|
|
|
|
start_connection_thread_std (void *arg)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = arg;
|
|
|
|
|
|
2015-06-11 09:43:32 +02:00
|
|
|
|
if (check_nonce (ctrl, &socket_nonce))
|
|
|
|
|
{
|
|
|
|
|
log_error ("handler 0x%lx nonce check FAILED\n",
|
|
|
|
|
(unsigned long) npth_self());
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return do_start_connection_thread (ctrl);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This is the extra socket connection thread's main function. */
|
|
|
|
|
static void *
|
|
|
|
|
start_connection_thread_extra (void *arg)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = arg;
|
|
|
|
|
|
2015-06-11 09:43:32 +02:00
|
|
|
|
if (check_nonce (ctrl, &socket_nonce_extra))
|
|
|
|
|
{
|
|
|
|
|
log_error ("handler 0x%lx nonce check FAILED\n",
|
|
|
|
|
(unsigned long) npth_self());
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
ctrl->restricted = 1;
|
2015-06-11 09:43:32 +02:00
|
|
|
|
return do_start_connection_thread (ctrl);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-06-11 09:36:27 +02:00
|
|
|
|
/* This is the browser socket connection thread's main function. */
|
|
|
|
|
static void *
|
|
|
|
|
start_connection_thread_browser (void *arg)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = arg;
|
|
|
|
|
|
2015-06-11 09:43:32 +02:00
|
|
|
|
if (check_nonce (ctrl, &socket_nonce_browser))
|
|
|
|
|
{
|
|
|
|
|
log_error ("handler 0x%lx nonce check FAILED\n",
|
|
|
|
|
(unsigned long) npth_self());
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-11 09:36:27 +02:00
|
|
|
|
ctrl->restricted = 2;
|
2015-06-11 09:43:32 +02:00
|
|
|
|
return do_start_connection_thread (ctrl);
|
2015-06-11 09:36:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
/* This is the ssh connection thread's main function. */
|
2005-01-26 23:20:21 +01:00
|
|
|
|
static void *
|
|
|
|
|
start_connection_thread_ssh (void *arg)
|
|
|
|
|
{
|
2006-11-20 17:49:41 +01:00
|
|
|
|
ctrl_t ctrl = arg;
|
2005-01-26 23:20:21 +01:00
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
if (check_nonce (ctrl, &socket_nonce_ssh))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
agent_init_default_ctrl (ctrl);
|
2005-01-26 23:20:21 +01:00
|
|
|
|
if (opt.verbose)
|
2005-06-03 15:57:24 +02:00
|
|
|
|
log_info (_("ssh handler 0x%lx for fd %d started\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
|
|
|
|
(unsigned long) npth_self(), FD2INT(ctrl->thread_startup.fd));
|
2005-01-26 23:20:21 +01:00
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
start_command_handler_ssh (ctrl, ctrl->thread_startup.fd);
|
2005-01-26 23:20:21 +01:00
|
|
|
|
if (opt.verbose)
|
2005-06-03 15:57:24 +02:00
|
|
|
|
log_info (_("ssh handler 0x%lx for fd %d terminated\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
|
|
|
|
(unsigned long) npth_self(), FD2INT(ctrl->thread_startup.fd));
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
agent_deinit_default_ctrl (ctrl);
|
|
|
|
|
xfree (ctrl);
|
2005-01-26 23:20:21 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2007-06-14 19:05:07 +02:00
|
|
|
|
/* Connection handler loop. Wait for connection requests and spawn a
|
2005-02-03 18:40:02 +01:00
|
|
|
|
thread after accepting a connection. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static void
|
2014-11-27 20:41:37 +01:00
|
|
|
|
handle_connections (gnupg_fd_t listen_fd,
|
|
|
|
|
gnupg_fd_t listen_fd_extra,
|
2015-06-11 09:36:27 +02:00
|
|
|
|
gnupg_fd_t listen_fd_browser,
|
2014-11-27 20:41:37 +01:00
|
|
|
|
gnupg_fd_t listen_fd_ssh)
|
2003-08-05 19:11:04 +02: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_t tattr;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
struct sockaddr_un paddr;
|
2005-02-03 18:40:02 +01:00
|
|
|
|
socklen_t plen;
|
2005-01-26 23:20:21 +01:00
|
|
|
|
fd_set fdset, read_fdset;
|
|
|
|
|
int ret;
|
2007-10-01 16:48:39 +02:00
|
|
|
|
gnupg_fd_t fd;
|
2007-07-04 11:34:28 +02:00
|
|
|
|
int nfd;
|
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;
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
HANDLE events[2];
|
2014-06-25 20:25:28 +02:00
|
|
|
|
unsigned int events_set;
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#endif
|
2014-11-27 20:41:37 +01:00
|
|
|
|
struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
void *(*func) (void *arg);
|
|
|
|
|
gnupg_fd_t l_fd;
|
|
|
|
|
} listentbl[] = {
|
2015-06-11 09:36:27 +02:00
|
|
|
|
{ "std", start_connection_thread_std },
|
|
|
|
|
{ "extra", start_connection_thread_extra },
|
|
|
|
|
{ "browser", start_connection_thread_browser },
|
|
|
|
|
{ "ssh", start_connection_thread_ssh }
|
2014-11-27 20:41:37 +01:00
|
|
|
|
};
|
|
|
|
|
|
2003-08-05 19:11:04 +02: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
|
|
|
|
ret = npth_attr_init(&tattr);
|
2012-01-24 17:37:01 +01:00
|
|
|
|
if (ret)
|
|
|
|
|
log_fatal ("error allocating thread attributes: %s\n",
|
2012-01-25 14:59:01 +01:00
|
|
|
|
strerror (ret));
|
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_setdetachstate (&tattr, NPTH_CREATE_DETACHED);
|
2008-12-17 20:42:17 +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
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
|
|
|
|
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 ();
|
2004-12-13 16:49:56 +01:00
|
|
|
|
#else
|
2010-04-14 13:24:02 +02:00
|
|
|
|
# ifdef HAVE_W32CE_SYSTEM
|
2007-11-27 09:01:19 +01:00
|
|
|
|
/* Use a dummy event. */
|
2007-07-04 11:34:28 +02:00
|
|
|
|
sigs = 0;
|
|
|
|
|
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
|
2010-04-14 13:24:02 +02:00
|
|
|
|
# else
|
2012-01-19 22:27:44 +01:00
|
|
|
|
events[0] = get_agent_scd_notify_event ();
|
|
|
|
|
events[1] = INVALID_HANDLE_VALUE;
|
2007-11-27 09:01:19 +01:00
|
|
|
|
# endif
|
2004-12-13 16:49:56 +01:00
|
|
|
|
#endif
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2014-03-07 09:46:44 +01:00
|
|
|
|
/* On Windows we need to fire up a separate thread to listen for
|
|
|
|
|
requests from Putty (an SSH client), so we can replace Putty's
|
|
|
|
|
Pageant (its ssh-agent implementation). */
|
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
if (putty_support)
|
|
|
|
|
{
|
|
|
|
|
npth_t thread;
|
|
|
|
|
|
|
|
|
|
ret = npth_create (&thread, &tattr, putty_message_thread, NULL);
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error spawning putty message loop: %s\n", strerror (ret));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /*HAVE_W32_SYSTEM*/
|
|
|
|
|
|
2010-11-11 16:07:37 +01:00
|
|
|
|
/* Set a flag to tell call-scd.c that it may enable event
|
|
|
|
|
notifications. */
|
|
|
|
|
opt.sigusr2_enabled = 1;
|
|
|
|
|
|
2005-01-26 23:20:21 +01:00
|
|
|
|
FD_ZERO (&fdset);
|
2007-10-01 16:48:39 +02:00
|
|
|
|
FD_SET (FD2INT (listen_fd), &fdset);
|
|
|
|
|
nfd = FD2INT (listen_fd);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (listen_fd_extra != GNUPG_INVALID_FD)
|
|
|
|
|
{
|
|
|
|
|
FD_SET ( FD2INT(listen_fd_extra), &fdset);
|
|
|
|
|
if (FD2INT (listen_fd_extra) > nfd)
|
|
|
|
|
nfd = FD2INT (listen_fd_extra);
|
|
|
|
|
}
|
2015-06-11 09:36:27 +02:00
|
|
|
|
if (listen_fd_browser != GNUPG_INVALID_FD)
|
|
|
|
|
{
|
|
|
|
|
FD_SET ( FD2INT(listen_fd_browser), &fdset);
|
|
|
|
|
if (FD2INT (listen_fd_browser) > nfd)
|
|
|
|
|
nfd = FD2INT (listen_fd_browser);
|
|
|
|
|
}
|
2007-10-01 16:48:39 +02:00
|
|
|
|
if (listen_fd_ssh != GNUPG_INVALID_FD)
|
2007-07-04 11:34:28 +02:00
|
|
|
|
{
|
2007-10-01 16:48:39 +02:00
|
|
|
|
FD_SET ( FD2INT(listen_fd_ssh), &fdset);
|
|
|
|
|
if (FD2INT (listen_fd_ssh) > nfd)
|
|
|
|
|
nfd = FD2INT (listen_fd_ssh);
|
2007-07-04 11:34:28 +02:00
|
|
|
|
}
|
2005-01-26 23:20:21 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
listentbl[0].l_fd = listen_fd;
|
|
|
|
|
listentbl[1].l_fd = listen_fd_extra;
|
2015-06-11 09:36:27 +02:00
|
|
|
|
listentbl[2].l_fd = listen_fd_browser;
|
|
|
|
|
listentbl[3].l_fd = listen_fd_ssh;
|
2014-11-27 20:41:37 +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_clock_gettime (&abstime);
|
|
|
|
|
abstime.tv_sec += TIMERTICK_INTERVAL;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
2008-12-17 20:42:17 +01:00
|
|
|
|
/* Shutdown test. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (shutdown_pending)
|
|
|
|
|
{
|
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 (active_connections == 0)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break; /* ready */
|
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
/* Do not accept new connections but keep on running the
|
|
|
|
|
loop to cope with the timer events. */
|
|
|
|
|
FD_ZERO (&fdset);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-03 18:40:02 +01:00
|
|
|
|
/* POSIX says that fd_set should be implemented as a structure,
|
|
|
|
|
thus a simple assignment is fine to copy the entire set. */
|
2005-01-26 23:20:21 +01:00
|
|
|
|
read_fdset = fdset;
|
2005-02-03 18:40:02 +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_clock_gettime (&curtime);
|
|
|
|
|
if (!(npth_timercmp (&curtime, &abstime, <)))
|
|
|
|
|
{
|
|
|
|
|
/* Timeout. */
|
|
|
|
|
handle_tick ();
|
|
|
|
|
npth_clock_gettime (&abstime);
|
|
|
|
|
abstime.tv_sec += TIMERTICK_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
npth_timersub (&abstime, &curtime, &timeout);
|
2010-11-29 07:49:44 +01:00
|
|
|
|
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#ifndef HAVE_W32_SYSTEM
|
2012-01-25 14:44:34 +01:00
|
|
|
|
ret = npth_pselect (nfd+1, &read_fdset, NULL, NULL, &timeout,
|
|
|
|
|
npth_sigev_sigmask ());
|
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
|
|
|
|
saved_errno = errno;
|
2005-04-20 21:19:24 +02:00
|
|
|
|
|
2012-01-25 12:11:41 +01:00
|
|
|
|
{
|
|
|
|
|
int signo;
|
|
|
|
|
while (npth_sigev_get_pending (&signo))
|
|
|
|
|
handle_signal (signo);
|
|
|
|
|
}
|
2012-01-19 22:27:44 +01:00
|
|
|
|
#else
|
2012-01-25 14:44:34 +01:00
|
|
|
|
ret = npth_eselect (nfd+1, &read_fdset, NULL, NULL, &timeout,
|
|
|
|
|
events, &events_set);
|
2012-01-19 22:27:44 +01:00
|
|
|
|
saved_errno = errno;
|
2005-02-03 18:40:02 +01:00
|
|
|
|
|
2012-01-19 22:27:44 +01:00
|
|
|
|
/* This is valid even if npth_eselect returns an error. */
|
|
|
|
|
if (events_set & 1)
|
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
|
|
|
|
agent_sigusr2_action ();
|
2007-11-27 09:01:19 +01:00
|
|
|
|
#endif
|
2005-01-26 23:20:21 +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
|
|
|
|
if (ret == -1 && saved_errno != EINTR)
|
|
|
|
|
{
|
|
|
|
|
log_error (_("npth_pselect failed: %s - waiting 1s\n"),
|
|
|
|
|
strerror (saved_errno));
|
|
|
|
|
npth_sleep (1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (ret <= 0)
|
|
|
|
|
/* Interrupt or timeout. Will be handled when calculating the
|
|
|
|
|
next timeout. */
|
|
|
|
|
continue;
|
2005-06-03 15:57:24 +02:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (!shutdown_pending)
|
|
|
|
|
{
|
|
|
|
|
int idx;
|
2006-11-20 17:49:41 +01:00
|
|
|
|
ctrl_t ctrl;
|
2014-11-27 20:41:37 +01:00
|
|
|
|
npth_t thread;
|
2006-11-20 17:49:41 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
for (idx=0; idx < DIM(listentbl); idx++)
|
2009-07-07 12:02:41 +02:00
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (listentbl[idx].l_fd == GNUPG_INVALID_FD)
|
|
|
|
|
continue;
|
|
|
|
|
if (!FD_ISSET (FD2INT (listentbl[idx].l_fd), &read_fdset))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
plen = sizeof paddr;
|
|
|
|
|
fd = INT2FD (npth_accept (FD2INT(listentbl[idx].l_fd),
|
|
|
|
|
(struct sockaddr *)&paddr, &plen));
|
|
|
|
|
if (fd == GNUPG_INVALID_FD)
|
2005-06-03 15:57:24 +02:00
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
log_error ("accept failed for %s: %s\n",
|
|
|
|
|
listentbl[idx].name, strerror (errno));
|
2005-06-03 15:57:24 +02:00
|
|
|
|
}
|
2014-11-27 20:41:37 +01:00
|
|
|
|
else if ( !(ctrl = xtrycalloc (1, sizeof *ctrl)))
|
2005-06-03 15:57:24 +02:00
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
log_error ("error allocating connection data for %s: %s\n",
|
|
|
|
|
listentbl[idx].name, strerror (errno) );
|
2007-10-01 16:48:39 +02:00
|
|
|
|
assuan_sock_close (fd);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
}
|
|
|
|
|
else if ( !(ctrl->session_env = session_env_new ()))
|
|
|
|
|
{
|
|
|
|
|
log_error ("error allocating session env block for %s: %s\n",
|
|
|
|
|
listentbl[idx].name, strerror (errno) );
|
2006-11-20 17:49:41 +01:00
|
|
|
|
xfree (ctrl);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
assuan_sock_close (fd);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ctrl->thread_startup.fd = fd;
|
|
|
|
|
ret = npth_create (&thread, &tattr,
|
|
|
|
|
listentbl[idx].func, ctrl);
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error spawning connection handler for %s:"
|
|
|
|
|
" %s\n", listentbl[idx].name, strerror (ret));
|
|
|
|
|
assuan_sock_close (fd);
|
|
|
|
|
xfree (ctrl);
|
|
|
|
|
}
|
2005-06-03 15:57:24 +02:00
|
|
|
|
}
|
2014-11-27 20:41:37 +01:00
|
|
|
|
fd = GNUPG_INVALID_FD;
|
2005-06-03 15:57:24 +02:00
|
|
|
|
}
|
2014-11-27 20:41:37 +01:00
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup ();
|
2005-02-03 18:40:02 +01:00
|
|
|
|
log_info (_("%s %s stopped\n"), strusage(11), strusage(13));
|
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_destroy (&tattr);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2004-09-09 09:27:57 +02:00
|
|
|
|
|
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
|
|
|
|
|
/* Helper for check_own_socket. */
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2008-10-29 18:24:27 +01:00
|
|
|
|
check_own_socket_pid_cb (void *opaque, const void *buffer, size_t length)
|
|
|
|
|
{
|
|
|
|
|
membuf_t *mb = opaque;
|
|
|
|
|
put_membuf (mb, buffer, length);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The thread running the actual check. We need to run this in a
|
|
|
|
|
separate thread so that check_own_thread can be called from the
|
|
|
|
|
timer tick. */
|
|
|
|
|
static void *
|
|
|
|
|
check_own_socket_thread (void *arg)
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
char *sockname = arg;
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
assuan_context_t ctx = NULL;
|
2008-10-29 18:24:27 +01:00
|
|
|
|
membuf_t mb;
|
|
|
|
|
char *buffer;
|
|
|
|
|
|
|
|
|
|
check_own_socket_running++;
|
|
|
|
|
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
rc = assuan_new (&ctx);
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-05 13:06:45 +01:00
|
|
|
|
rc = assuan_socket_connect (ctx, sockname, (pid_t)(-1), 0);
|
2008-10-29 18:24:27 +01:00
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("can't connect my own socket: %s\n", gpg_strerror (rc));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
init_membuf (&mb, 100);
|
|
|
|
|
rc = assuan_transact (ctx, "GETINFO pid", check_own_socket_pid_cb, &mb,
|
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
|
put_membuf (&mb, "", 1);
|
|
|
|
|
buffer = get_membuf (&mb, NULL);
|
|
|
|
|
if (rc || !buffer)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
log_error ("sending command \"%s\" to my own socket failed: %s\n",
|
2008-10-29 18:24:27 +01:00
|
|
|
|
"GETINFO pid", gpg_strerror (rc));
|
|
|
|
|
rc = 1;
|
|
|
|
|
}
|
|
|
|
|
else if ( (pid_t)strtoul (buffer, NULL, 10) != getpid ())
|
|
|
|
|
{
|
|
|
|
|
log_error ("socket is now serviced by another server\n");
|
|
|
|
|
rc = 1;
|
|
|
|
|
}
|
2009-03-03 10:02:58 +01:00
|
|
|
|
else if (opt.verbose > 1)
|
2008-10-29 18:24:27 +01:00
|
|
|
|
log_error ("socket is still served by this server\n");
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
xfree (buffer);
|
|
|
|
|
|
|
|
|
|
leave:
|
2010-05-03 17:23:10 +02:00
|
|
|
|
xfree (sockname);
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
if (ctx)
|
|
|
|
|
assuan_release (ctx);
|
2008-10-29 18:24:27 +01:00
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
/* We may not remove the socket as it is now in use by another
|
|
|
|
|
server. Setting the name to empty does this. */
|
|
|
|
|
if (socket_name)
|
|
|
|
|
*socket_name = 0;
|
|
|
|
|
if (socket_name_ssh)
|
|
|
|
|
*socket_name_ssh = 0;
|
|
|
|
|
shutdown_pending = 2;
|
|
|
|
|
log_info ("this process is useless - shutting down\n");
|
|
|
|
|
}
|
|
|
|
|
check_own_socket_running--;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Check whether we are still listening on our own socket. In case
|
|
|
|
|
another gpg-agent process started after us has taken ownership of
|
2010-11-26 10:42:56 +01:00
|
|
|
|
our socket, we would linger around without any real task. Thus we
|
2008-10-29 18:24:27 +01:00
|
|
|
|
better check once in a while whether we are really needed. */
|
|
|
|
|
static void
|
|
|
|
|
check_own_socket (void)
|
|
|
|
|
{
|
|
|
|
|
char *sockname;
|
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_t thread;
|
|
|
|
|
npth_attr_t tattr;
|
|
|
|
|
int err;
|
2008-10-29 18:24:27 +01:00
|
|
|
|
|
2013-05-21 13:10:00 +02:00
|
|
|
|
if (disable_check_own_socket)
|
|
|
|
|
return;
|
|
|
|
|
|
2008-10-29 18:24:27 +01:00
|
|
|
|
if (check_own_socket_running || shutdown_pending)
|
|
|
|
|
return; /* Still running or already shutting down. */
|
|
|
|
|
|
2013-11-18 14:09:47 +01:00
|
|
|
|
sockname = make_filename (opt.homedir, GPG_AGENT_SOCK_NAME, NULL);
|
2008-10-29 18:24:27 +01:00
|
|
|
|
if (!sockname)
|
|
|
|
|
return; /* Out of memory. */
|
|
|
|
|
|
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_attr_init (&tattr);
|
|
|
|
|
if (err)
|
|
|
|
|
return;
|
|
|
|
|
npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED);
|
|
|
|
|
err = npth_create (&thread, &tattr, check_own_socket_thread, sockname);
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error spawning check_own_socket_thread: %s\n", strerror (err));
|
|
|
|
|
npth_attr_destroy (&tattr);
|
2008-10-29 18:24:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-09-09 09:27:57 +02:00
|
|
|
|
/* Figure out whether an agent is available and running. Prints an
|
2014-10-03 11:58:58 +02:00
|
|
|
|
error if not. If SILENT is true, no messages are printed.
|
|
|
|
|
Returns 0 if the agent is running. */
|
2004-12-20 17:17:25 +01:00
|
|
|
|
static int
|
2014-10-03 11:58:58 +02:00
|
|
|
|
check_for_running_agent (int silent)
|
2004-09-09 09:27:57 +02:00
|
|
|
|
{
|
2014-10-03 11:58:58 +02:00
|
|
|
|
gpg_error_t err;
|
|
|
|
|
char *sockname;
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
assuan_context_t ctx = NULL;
|
2004-09-09 09:27:57 +02:00
|
|
|
|
|
2014-10-03 11:58:58 +02:00
|
|
|
|
sockname = make_filename (opt.homedir, GPG_AGENT_SOCK_NAME, NULL);
|
2004-09-09 09:27:57 +02:00
|
|
|
|
|
2014-10-03 11:58:58 +02:00
|
|
|
|
err = assuan_new (&ctx);
|
|
|
|
|
if (!err)
|
|
|
|
|
err = assuan_socket_connect (ctx, sockname, (pid_t)(-1), 0);
|
|
|
|
|
xfree (sockname);
|
|
|
|
|
if (err)
|
2004-09-09 09:27:57 +02:00
|
|
|
|
{
|
2014-10-03 11:58:58 +02:00
|
|
|
|
if (!silent)
|
|
|
|
|
log_error (_("no gpg-agent running in this session\n"));
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
|
|
|
|
|
if (ctx)
|
|
|
|
|
assuan_release (ctx);
|
2004-12-20 17:17:25 +01:00
|
|
|
|
return -1;
|
2004-09-09 09:27:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-06-21 20:44:48 +02:00
|
|
|
|
if (!opt.quiet && !silent)
|
2004-09-09 09:27:57 +02:00
|
|
|
|
log_info ("gpg-agent running and available\n");
|
|
|
|
|
|
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-agent.c (parse_rereadable_options): Don't set global assuan
log file (there ain't one anymore).
(main): Update to new API.
(check_own_socket_pid_cb): Return gpg_error_t instead of int.
(check_own_socket_thread, check_for_running_agent): Create assuan
context before connecting to server.
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(write_and_clear_outbuf): Use gpg_error_t instead of
assuan_error_t.
(cmd_geteventcounter, cmd_istrusted, cmd_listtrusted)
(cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc)
(cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey)
(cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase)
(cmd_get_confirmation, cmd_learn, cmd_passwd)
(cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval)
(cmd_updatestartuptty, cmd_killagent, cmd_reloadagent)
(cmd_getinfo, option_handler): Return gpg_error_t instead of int.
(post_cmd_notify): Change type of ERR to gpg_error_t from int.
(io_monitor): Add hook argument. Use symbols for constants.
(register_commands): Change return type of HANDLER to gpg_error_t.
(start_command_handler): Allocate assuan context before starting
server.
* call-pinentry.c: Include "scdaemon.h" before <assuan.h> because
of GPG_ERR_SOURCE_DEFAULT check.
(unlock_pinentry): Call assuan_release instead of
assuan_disconnect.
(getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int.
(start_pinentry): Allocate assuan context before connecting to
server.
* call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb)
(membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru)
(pass_data_thru): Change return type to gpg_error_t.
(start_scd): Allocate assuan context before connecting to server.
common/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* call-agent.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb)
(learn_status_cb, inq_writecert_parms, inq_writekey_parms)
(scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of
int.
* gpg.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(main): Update to new Assuan API.
* server.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys)
(cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t
instead of int.
(register_commands): Allocate assuan context before starting
server.
(gpg_server): Allocate assuan_context before starting server.
scd/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* command.c: Include "scdaemon.h" before <assuan.h> because of
GPG_ERR_SOURCE_DEFAULT check.
(option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert)
(cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt)
(cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey)
(cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock)
(cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu)
(cmd_killscd): Return gpg_error_t instead of int.
(scd_command_handler): Allocate assuan context before starting server.
* scdaemon.c (main): Update to new Assuan API.
sm/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.c (main): Update to new assuan API.
* server.c: Include "gpgsm.h" before <assuan.h> due to check for
GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h.
(option_handler, cmd_recipient, cmd_signer, cmd_encrypt)
(cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export)
(cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys)
(cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey)
(cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int.
(register_commands): Same for member HANDLER in table.
(gpgsm_server): Allocate assuan context before starting server.
* sm/call-dirmngr.c:
* call-dirmngr.c (prepare_dirmngr): Check for CTX and error before
setting LDAPSERVER.
(start_dirmngr_ext): Allocate assuan context before starting
server.
(inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb)
(run_command_cb, run_command_inq_cb, run_command_status_cb):
Return gpg_error_t instead of int.
tools/
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
2009-09-23 02:01:25 +02:00
|
|
|
|
assuan_release (ctx);
|
2004-12-20 17:17:25 +01:00
|
|
|
|
return 0;
|
2004-09-09 09:27:57 +02:00
|
|
|
|
}
|