/*
* Copyright (C) 1996-1997 Michael R. Elkins <me@mutt.org>
* Copyright (C) 1999-2000,2002-2004,2006 Thomas Roessler <roessler@does-not-exist.org>
* Copyright (C) 2001 Thomas Roessler <roessler@does-not-exist.org>
* Oliver Ehli <elmy@acm.org>
* Copyright (C) 2003 Werner Koch <wk@gnupg.org>
* Copyright (C) 2004 g10code GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "mutt.h"
#include "mutt_curses.h"
#include "mime.h"
#include "copy.h"
#include "mutt_crypt.h"
#include "mutt_idna.h"
#ifdef USE_AUTOCRYPT
#include "autocrypt.h"
#endif
#include <sys/wait.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <ctype.h>
#include <locale.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
/* print the current time to avoid spoofing of the signature output */
void crypt_current_time(STATE *s, char *app_name)
{
time_t t;
char p[STRING], tmp[STRING];
if (!WithCrypto)
return;
if (option (OPTCRYPTTIMESTAMP))
{
t = time(NULL);
strftime (p, sizeof (p), _(" (current time: %c)"), localtime (&t));
}
else
*p = '\0';
snprintf (tmp, sizeof (tmp), _("[-- %s output follows%s --]\n"), NONULL(app_name), p);
state_attach_puts (tmp, s);
}
void crypt_forget_passphrase (void)
{
if ((WithCrypto & APPLICATION_PGP))
crypt_pgp_void_passphrase ();
if ((WithCrypto & APPLICATION_SMIME))
crypt_smime_void_passphrase ();
if (WithCrypto)
mutt_message _("Passphrase(s) forgotten.");
}
#if defined(HAVE_SETRLIMIT) && (!defined(DEBUG))
static void disable_coredumps (void)
{
struct rlimit rl = {0, 0};
static short done = 0;
if (!done)
{
setrlimit (RLIMIT_CORE, &rl);
done = 1;
}
}
#endif /* HAVE_SETRLIMIT */
int crypt_valid_passphrase(int flags)
{
int ret = 0;
# if defined(HAVE_SETRLIMIT) &&(!defined(DEBUG))
disable_coredumps ();
# endif
if ((WithCrypto & APPLICATION_PGP) && (flags & APPLICATION_PGP))