aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-02-26 09:39:11 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-02-26 09:39:11 +0800
commit4b098b1a425fc966c96a61c1c24acb2a2f5645a9 (patch)
tree7c0903ae6db6a2bcaa56f58e80dc8234b738e20e /mail
parent42904d799377d856cb13363eb2f1530b71d8762f (diff)
downloadgsoc2013-evolution-4b098b1a425fc966c96a61c1c24acb2a2f5645a9.tar.gz
gsoc2013-evolution-4b098b1a425fc966c96a61c1c24acb2a2f5645a9.tar.zst
gsoc2013-evolution-4b098b1a425fc966c96a61c1c24acb2a2f5645a9.zip
New function to force the removal of a given password.
2001-02-25 Jeffrey Stedfast <fejj@ximian.com> * session.c (mail_session_forget_password): New function to force the removal of a given password. * openpgp-utils.c (openpgp_decrypt): On failure, forget the passphrase. (openpgp_encrypt): Here too. (cleaned this up a bit too) (openpgp_clearsign): And here. (openpgp_sign): Again... svn path=/trunk/; revision=8390
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/mail-session.h6
-rw-r--r--mail/openpgp-utils.c95
-rw-r--r--mail/session.c11
4 files changed, 82 insertions, 39 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 5b06e15d96..7434ea30e2 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,14 @@
2001-02-25 Jeffrey Stedfast <fejj@ximian.com>
+ * session.c (mail_session_forget_password): New function to force
+ the removal of a given password.
+
+ * openpgp-utils.c (openpgp_decrypt): On failure, forget the
+ passphrase.
+ (openpgp_encrypt): Here too. (cleaned this up a bit too)
+ (openpgp_clearsign): And here.
+ (openpgp_sign): Again...
+
* mail-callbacks.c (composer_postpone_cb): Abort if the message is
NULL (which is valid if an error occured).
(composer_send_cb): Same.
diff --git a/mail/mail-session.h b/mail/mail-session.h
index a2ce0b1a10..bde6c8d186 100644
--- a/mail/mail-session.h
+++ b/mail/mail-session.h
@@ -25,12 +25,12 @@
#include <gnome.h>
#include <bonobo.h>
-#include <camel/camel.h>
+#include <camel/camel-session.h>
#ifdef __cplusplus
extern "C" {
#pragma }
-#endif /* __cplusplus }*/
+#endif /* __cplusplus */
void mail_session_init (void);
void mail_session_enable_interaction (gboolean enable);
@@ -40,6 +40,8 @@ void mail_session_forget_passwords (BonoboUIComponent *uih, void *user_data,
const char *path);
void mail_session_remember_password (const char *url);
+void mail_session_forget_password (const char *key);
+
void mail_session_set_password (const char *url, const char *password);
extern CamelSession *session;
diff --git a/mail/openpgp-utils.c b/mail/openpgp-utils.c
index bb57036e60..d5ab123e09 100644
--- a/mail/openpgp-utils.c
+++ b/mail/openpgp-utils.c
@@ -61,24 +61,29 @@ static const gchar *pgp_path = NULL;
static PgpType pgp_type = PGP_TYPE_NONE;
-static gchar *
-pgp_get_passphrase (const gchar *userid)
+static const gchar *
+pgp_get_type_as_string (PgpType type)
{
- gchar *passphrase, *prompt, *type = NULL;
-
switch (pgp_type) {
case PGP_TYPE_GPG:
- type = "GnuPG";
- break;
+ return "GnuPG";
case PGP_TYPE_PGP5:
- type = "PGP5";
- break;
+ return "PGP5";
case PGP_TYPE_PGP2:
- type = "PGP2.x";
- break;
+ return "PGP2.x";
default:
g_assert_not_reached ();
+ return NULL;
}
+}
+
+static gchar *
+pgp_get_passphrase (const gchar *userid)
+{
+ gchar *passphrase, *prompt;
+ const char *type;
+
+ type = pgp_get_type_as_string (pgp_type);
if (userid)
prompt = g_strdup_printf (_("Please enter your %s passphrase for %s"),
@@ -87,13 +92,22 @@ pgp_get_passphrase (const gchar *userid)
prompt = g_strdup_printf (_("Please enter your %s passphrase"),
type);
- /* User the userid as a key if possible, else be generic and use the type */
+ /* Use the userid as a key if possible, else be generic and use the type */
passphrase = mail_session_request_dialog (prompt, TRUE, userid ? userid : type, FALSE);
g_free (prompt);
return passphrase;
}
+static void
+pgp_forget_passphrase (const char *key)
+{
+ if (!key)
+ key = pgp_get_type_as_string (pgp_type);
+
+ mail_session_forget_password (key);
+}
+
/**
* openpgp_init:
@@ -447,6 +461,8 @@ openpgp_decrypt (const gchar *ciphertext, gint cipherlen, gint *outlen, CamelExc
}
if (pipe (passwd_fds) < 0) {
+ g_free (passphrase);
+ pgp_forget_passphrase (NULL);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Couldn't create pipe to GPG/PGP: %s"),
g_strerror (errno));
@@ -503,6 +519,7 @@ openpgp_decrypt (const gchar *ciphertext, gint cipherlen, gint *outlen, CamelExc
"%s", diagnostics);
g_free (plaintext);
g_free (diagnostics);
+ pgp_forget_passphrase (NULL);
return NULL;
}
@@ -553,24 +570,36 @@ openpgp_encrypt (const gchar *in, gint inlen, const GPtrArray *recipients,
}
if (pipe (passwd_fds) < 0) {
- g_free (passphrase);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Couldn't create pipe to GPG/PGP: %s"),
g_strerror (errno));
+
+ if (sign) {
+ g_free (passphrase);
+ pgp_forget_passphrase (NULL);
+ }
+
return NULL;
}
- argv = g_ptr_array_new ();
- switch (pgp_type) {
- case PGP_TYPE_GPG:
- if (recipients->len == 0) {
+ /* check to make sure we have recipients */
+ if (recipients->len == 0) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("No recipients specified"));
+
+ if (sign) {
g_free (passphrase);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("No recipients specified"));
- return NULL;
+ pgp_forget_passphrase (NULL);
}
- recipient_list = g_ptr_array_new ();
+ return NULL;
+ }
+
+ argv = g_ptr_array_new ();
+ recipient_list = g_ptr_array_new ();
+
+ switch (pgp_type) {
+ case PGP_TYPE_GPG:
for (r = 0; r < recipients->len; r++) {
char *buf, *recipient;
@@ -608,14 +637,6 @@ openpgp_encrypt (const gchar *in, gint inlen, const GPtrArray *recipients,
}
break;
case PGP_TYPE_PGP5:
- if (recipients->len == 0) {
- g_free (passphrase);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("No recipients specified"));
- return NULL;
- }
-
- recipient_list = g_ptr_array_new ();
for (r = 0; r < recipients->len; r++) {
char *buf, *recipient;
@@ -647,14 +668,6 @@ openpgp_encrypt (const gchar *in, gint inlen, const GPtrArray *recipients,
}
break;
case PGP_TYPE_PGP2:
- if (recipients->len == 0) {
- g_free (passphrase);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("No recipients specified"));
- return NULL;
- }
-
- recipient_list = g_ptr_array_new ();
for (r = 0; r < recipients->len; r++) {
char *buf, *recipient;
@@ -703,6 +716,8 @@ openpgp_encrypt (const gchar *in, gint inlen, const GPtrArray *recipients,
"%s", diagnostics);
g_free (ciphertext);
ciphertext = NULL;
+ if (sign)
+ pgp_forget_passphrase (NULL);
}
if (recipient_list) {
@@ -754,10 +769,13 @@ openpgp_clearsign (const gchar *plaintext, const gchar *userid,
}
if (pipe (passwd_fds) < 0) {
- g_free (passphrase);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Couldn't create pipe to GPG/PGP: %s"),
g_strerror (errno));
+
+ g_free (passphrase);
+ pgp_forget_passphrase (userid);
+
return NULL;
}
@@ -857,6 +875,7 @@ openpgp_clearsign (const gchar *plaintext, const gchar *userid,
"%s", diagnostics);
g_free (ciphertext);
ciphertext = NULL;
+ pgp_forget_passphrase (userid);
}
g_free (diagnostics);
@@ -904,6 +923,7 @@ openpgp_sign (const gchar *in, gint inlen, const gchar *userid,
if (pipe (passwd_fds) < 0) {
g_free (passphrase);
+ pgp_forget_passphrase (userid);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Couldn't create pipe to GPG/PGP: %s"),
g_strerror (errno));
@@ -1007,6 +1027,7 @@ openpgp_sign (const gchar *in, gint inlen, const gchar *userid,
"%s", diagnostics);
g_free (ciphertext);
ciphertext = NULL;
+ pgp_forget_passphrase (userid);
}
g_free (diagnostics);
diff --git a/mail/session.c b/mail/session.c
index 53c694206b..d8aeaa30ba 100644
--- a/mail/session.c
+++ b/mail/session.c
@@ -169,6 +169,17 @@ mail_session_remember_password (const char *url)
g_hash_table_foreach (passwords, maybe_remember_password, (void *) url);
}
+void
+mail_session_forget_password (const char *key)
+{
+ gpointer okey, value;
+
+ if (g_hash_table_lookup_extended (passwords, key, &okey, &value)) {
+ g_hash_table_remove (passwords, key);
+ g_free (okey);
+ g_free (value);
+ }
+}
/* ******************** */
='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/vietnamese?h=gnome-3.24&id=479d487f0145cf1c6b055c0575361c5350c135ac'>Update KDE to the latest official release, KDE 3.1.3lofi2003-07-292-1/+63 * Fix PLISTlioux2003-06-131-1/+17 * Update to KDE 3.1.2lioux2003-05-201-1/+1 * Add a NO_VIET_KDE knob to avoid the KDE I18N bits -- otherwise it is hard toobrien2003-05-091-0/+2 * BROKEN: Does not compilekris2003-05-071-0/+2 * Repo-move KDE I18N hebrew, hungarian, & vietnamese messages to theirwill2003-04-144-5/+72 * Clear moonlight beckons.ade2003-03-0730-15/+15 * Upgrade kde-i18n to 3.1. Note that the following modules did not get awill2003-01-292-38/+34 * Perl script to convert the text in the VIQR encoding to another Vietnameseobrien2002-11-136-0/+68 * o Rollback PORTCOMMENT modifications while this feature's implementationlioux2002-11-1126-26/+13 * Use PORTCOMMENT.obrien2002-11-0726-13/+26 * Add a missing directorykris2002-10-281-0/+1 * Get the dependencies correct for XF4.obrien2002-10-171-1/+1 * revert last commit. This builds fine here, and I've never seen oneobrien2002-10-171-2/+0 * Unmark broken. Please have the decentcy to notify the maintainer of a buildobrien2002-10-171-2/+0 * 1. Removed comments from pkg-plist files per will's request.alane2002-10-112-3/+27 * BROKEN: Does not compilekris2002-10-061-0/+2 * BROKEN: Missing dependencieskris2002-10-061-0/+2 * Don't gratuitously add -O.obrien2002-09-091-2/+2 * 'union wait' was depreciated by the time of Net/2.obrien2002-09-091-13/+24 * Catch up with lossage of 'union wait' in 5-CURRENT.obrien2002-09-092-21/+34 * Fix corrupted comment line.obrien2002-09-091-1/+1 * I have no idea what bsd.port.mk change broke this port, but be moreobrien2002-09-091-0/+1 * Update to 3.0.3. Not much changed here: [1] i18n PKGNAMEs converted towill2002-08-253-4/+4 * 1. Changed the lib depends on gettext to a build depends. This will meanalane2002-08-031-2/+2 * Bump PORTREVISION. KDE is fragile enough in its dependencies; we don'talane2002-08-021-0/+1 * Chase shlib rev of devel/gettextade2002-08-021-1/+1 * Fix MASTER_SITE_SUBDIR.will2002-07-101-1/+1 * Update to 3.0.2 -- full log available in ports/x11/kde3/Makefile,v 1.51.will2002-07-053-5/+12 * Upgrade to KDE 3.0.1. The delay in this upgrade is mainly due to thewill2002-06-163-2/+32 * Please welcome Qt3/KDE3 to our ports tree. This includes work since thewill2002-04-227-128/+154 * gettext upgrade uber-patch (stage 3)ade2002-04-131-1/+2 * Stage 1 of gettext update.ade2002-03-161-1/+1 * Add WWW.demon2001-12-281-0/+2 * Update to 2.2.2.demon2001-12-133-9/+16 * Note the standard these utilities conform to.obrien2001-11-2815-35/+133 * Unicode TrueType Font with UHoai Vietnamese encodingobrien2001-11-288-0/+60 * VISCII->Unicode conversionobrien2001-11-286-0/+36 * Upgrade to 2.2.1.demon2001-10-276-26/+23 * Sort entries.knu2001-09-211-3/+2 * Set DIST_SUBDIR=KDEdemon2001-09-112-1/+2 * MAINTAINER -> kde@FreeBSD.orgdemon2001-09-011-1/+1 * Our -man package does not understand .PN and .MS. So use .B (bold) untilobrien2001-08-232-18/+158 * Fix installation in a slightly different way.demon2001-08-212-6/+8 * Remove two languages not presented in new version.demon2001-08-201-3/+1 * Forgot to remove debug comment.demon2001-08-161-1/+1 * Upgrade to 2.2.demon2001-08-165-8/+31 * Note that VNterm adheres to RFC 1456 (VISCII and VIQR encodings)obrien2001-07-151-0/+6 * Remove Ukrainian from BATCH builds.demon2001-07-051-1/+1 * Exclude de, fr, ja, ru, zh_CN, zh_TW from bento's package.demon2001-04-171-1/+1 * Use `cp' rather than `ln' as WRKDIR and FILESDIR can be on different devices.obrien2001-04-171-1/+1 * Sort languages by name.demon2001-04-131-10/+10 * Examine LINGUAS variable before BATCH.demon2001-04-111-5/+5 * Allow to override MAINTAINER and CATEGORIES (in slave ports).demon2001-04-101-2/+2 * Add the ability to select which languages to install via dialog(1)-baseddemon2001-04-102-0/+87 * Update to 2.1.1demon2001-04-063-13/+2 * Change dot file to .vnelvisrc from .exrc.obrien2001-04-051-8/+26 * Default to Vietnamese processing.obrien2001-04-051-0/+5 * Overhaul QT/KDE support:will2001-04-031-2/+2 * Install new manpage.obrien2001-03-261-0/+2 * Add FreeBSD ID.obrien2001-03-261-0/+1 * Grr. a local cc(1) option got added by mistake.obrien2001-03-261-3/+3 * Sigh. This code is based on vnlibs. Thus I need to fix the Pascal'ismobrien2001-03-261-0/+8 * Respect CFLAGS.obrien2001-03-261-0/+11 * Add a man page.obrien2001-03-261-0/+65 * Minor tweak.obrien2001-03-261-2/+2 * Add reference to vnconvert(1).obrien2001-03-263-0/+3 * unbreak post-install script.sf2001-03-191-1/+1 * Use full path to `mkfontdir'.obrien2001-03-131-1/+1 * Make sure teTeX is installed before installing this port.obrien2001-03-131-0/+3 * Update to the 20010210 version. This fixes occasional core dumps in apps.obrien2001-03-092-2/+2 * New port: localized messages and documentation for KDE2.demon2001-03-025-0/+38 * Add aliases.obrien2001-02-163-0/+15 * Make this build when it is in the full /usr/ports tree and "vi-" is prependedobrien2001-02-121-1/+1 * Use the new libviet port in building.obrien2001-02-123-16/+15 * Use the new libviet port in building.obrien2001-02-113-14/+17 * Update vnterm so it is based on the X11R6.5.1 Xterm rather than the X11R5 one.obrien2001-02-1123-191/+1411 * Fix prefix bogon.obrien2001-02-111-0/+1 * These X fonts allow you to display Vietnamese characters in an Xterm andobrien2001-02-118-0/+134 * VIQR<->VISCII conversion and VISCII ctype-like routinesobrien2001-02-106-0/+49 * teTeX Vietnamese language + font supportobrien2001-02-078-0/+475 * Style fixes in ports/vietnamese.olgeni2001-02-061-1/+1 * Converts Vietnamese text files between popular formats.obrien2001-01-066-0/+40 * Add $FreeBSD$, which help me in problem reports.obrien2000-11-221-0/+1 * Fix curses clear() usage.obrien2000-11-033-0/+54 * Change PKGDIR from pkg/ to . Also fix places where ${PKGDIR} isasami2000-10-081-1/+1 * Add dependency to mkfontdir:XFree86-4-clients when XFREE86_VERSION=4.asami2000-09-121-1/+8 * Back out the previous commit. That one has a problem which occurs onknu2000-08-281-5/+1