Search the web
Sign In
New User? Sign Up
gbuffy · GBuffy Tool Discussion
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
IMAP/ssl support   Message List  
Reply | Forward Message #10 of 231 |
Re: IMAP/ssl support

On Mon, Nov 19, 2001 at 11:15:08AM -0800, Brandon Long wrote:
> Sounds good. If you want, you can either post those patches, or you can
> finish them off, both are good.

Someone at work wanted them, so I've added in the GUI related
bits to the config dialog.

I've yet to tackle autoconf; partially because I can tell a
small number of users "add -lssl -lcrypto to the end of LIBS in the
Makefile", and partially because I'm scared of autoconf.

I'm also a little unsure what to do in the absence of OpenSSL;
my worry is that someone will have a .gbuffyrc that includes
"type = imaps" and then recompile gbuffy without openssl
support. I suspect that in this case, gbuffy should either:

detect imaps in the config, complain loudly, and abort;

detect imaps in the config, complain loudly, and ignore
the imaps entries in the config file, but otherwise
leave them alone.

I'll ponder overnight & do the something approprate in the morning
(unless the boss notices and gets cross)

Anyhow, I've attached the diff and stuck them on the web:

mike@lindt:~$ cvs rdiff -u -r GBUFFY_2_4 gbuffy > public_html/gbuffy.diff
cvs rdiff: Diffing gbuffy
cvs rdiff: Diffing gbuffy/libcompface
mike@lindt:~$ chmod 0660 public_html/gbuffy.diff

You should also be able to view the diffs at
http://www.urgle.com/~mike/gbuffy.diff

Cheers,
Mike

--
Mike Bristow, embonpointful, but not managerial, damnit.


Mon Nov 19, 2001 7:31 pm

mike@...
Send Email Send Email

Index: gbuffy/ChangeLog
diff -u gbuffy/ChangeLog:1.1.1.1 gbuffy/ChangeLog:1.2
--- gbuffy/ChangeLog:1.1.1.1 Mon Nov 19 16:43:48 2001
+++ gbuffy/ChangeLog Mon Nov 19 19:02:07 2001
@@ -1,3 +1,6 @@
+2001-11-19 Mike Bristow <mike@...>
+ * preliminary support for IMAP/SSL
+
2001-05-15 Brandon Long <blong@pulp>

* gbuffy.c: oops, register poll first
Index: gbuffy/config.c
diff -u gbuffy/config.c:1.1.1.1 gbuffy/config.c:1.3
--- gbuffy/config.c:1.1.1.1 Mon Nov 19 16:43:49 2001
+++ gbuffy/config.c Mon Nov 19 17:57:57 2001
@@ -147,6 +147,9 @@
case GB_EXTERNAL:
tmp = PLMakeString ("external");
break;
+ case GB_IMAPS:
+ tmp = PLMakeString("imaps");
+ break;
default:
tmp = PLMakeString ("mbox");
break;
@@ -266,6 +269,8 @@
box->type = GB_NNTP;
else if (!strcmp (s, "external"))
box->type = GB_EXTERNAL;
+ else if (!strcmp (s, "imaps"))
+ box->type = GB_IMAPS;
}
tmp = PLGetDictionaryEntry (boxdict, path);
if (tmp != NULL)
Index: gbuffy/gbconfig.c
diff -u gbuffy/gbconfig.c:1.1.1.1 gbuffy/gbconfig.c:1.2
--- gbuffy/gbconfig.c:1.1.1.1 Mon Nov 19 16:43:49 2001
+++ gbuffy/gbconfig.c Mon Nov 19 18:04:21 2001
@@ -81,13 +81,14 @@
/* g_print ("-I- Select received for row %d\n", row); */
box = (BOX_INFO *) gtk_clist_get_row_data (GTK_CLIST (clist), row);
box->selected = TRUE;
- if (box->type == GB_IMAP || box->type == GB_NNTP)
+ if (box->type == GB_IMAP || box->type == GB_NNTP || box->type == GB_IMAPS)
{
gtk_widget_show (ServerLabel);
gtk_widget_show (ServerEntry);
gtk_entry_set_text (GTK_ENTRY (ServerEntry),
box->server ? box->server :
- (box->type == GB_IMAP) ? "imap" : DefaultNewserver);
+ (box->type == GB_IMAP || box->type == GB_IMAPS) ? "imap" :
+ DefaultNewserver);
gtk_widget_show (PortLabel);
gtk_widget_show (PortEntry);
if (box->port)
@@ -98,7 +99,8 @@
}
else
gtk_entry_set_text (GTK_ENTRY (PortEntry),
- (box->type == GB_IMAP) ? "143" : "119");
+ (box->type == GB_IMAP) ? "143" :
+ (box->type == GB_IMAPS) ? "993" : "119");
gtk_widget_show (LoginLabel);
gtk_widget_show (LoginEntry);
gtk_entry_set_text (GTK_ENTRY (LoginEntry),
@@ -151,7 +153,7 @@
if (box->newsrc)
FREE (&box->newsrc);
box->port = 0;
- if (box->type == GB_IMAP || box->type == GB_NNTP)
+ if (box->type == GB_IMAP || box->type == GB_NNTP || box->type == GB_IMAPS)
{
box->login = strdup (gtk_entry_get_text (GTK_ENTRY (LoginEntry)));
box->server = strdup (gtk_entry_get_text (GTK_ENTRY (ServerEntry)));
@@ -181,16 +183,17 @@
enum BOXTYPE type;

type = GPOINTER_TO_INT (data);
- if (type == GB_IMAP || type == GB_NNTP)
+ if (type == GB_IMAP || type == GB_NNTP || type == GB_IMAPS)
{
gtk_widget_show (ServerLabel);
gtk_widget_show (ServerEntry);
gtk_entry_set_text (GTK_ENTRY (ServerEntry),
- (type == GB_IMAP) ? "imap" : "news");
+ (type == GB_IMAP || type == GB_IMAPS) ? "imap" : "news");
gtk_widget_show (PortLabel);
gtk_widget_show (PortEntry);
gtk_entry_set_text (GTK_ENTRY (PortEntry),
- (type == GB_IMAP) ? "143" : "119");
+ (type == GB_IMAP) ? "143" :
+ (type == GB_IMAPS) ? "993" : "119");
gtk_widget_show (LoginLabel);
gtk_widget_show (LoginEntry);
gtk_entry_set_text (GTK_ENTRY (LoginEntry), NONULL (Username));
@@ -218,7 +221,7 @@
if (box->selected)
{
box->type = type;
- if (type == GB_IMAP || type == GB_NNTP)
+ if (type == GB_IMAP || type == GB_NNTP || type == GB_IMAPS)
{
if (box->login)
gtk_entry_set_text (GTK_ENTRY (LoginEntry), box->login);
Index: gbuffy/gbuffy.c
diff -u gbuffy/gbuffy.c:1.1.1.1 gbuffy/gbuffy.c:1.2
--- gbuffy/gbuffy.c:1.1.1.1 Mon Nov 19 16:43:49 2001
+++ gbuffy/gbuffy.c Mon Nov 19 16:58:06 2001
@@ -60,7 +60,8 @@
{ "mh", dir_folder_count, 0 },
{ "imap", imap_folder_count, 1 },
{ "nntp", nntp_folder_count, 1 },
- { "external", external_folder_count, 0 }
+ { "external", external_folder_count, 0 },
+ { "imaps", imap_folder_count, 1 }
};

void gbuffy_exit (GtkWidget *widget, gpointer data)
Index: gbuffy/gbuffy.h
diff -u gbuffy/gbuffy.h:1.1.1.1 gbuffy/gbuffy.h:1.2
--- gbuffy/gbuffy.h:1.1.1.1 Mon Nov 19 16:43:49 2001
+++ gbuffy/gbuffy.h Mon Nov 19 16:58:06 2001
@@ -20,7 +20,7 @@
#define HUGE_STRING 5120

enum BOXTYPE {UNKNOWN = -1, GB_MBOX = 0, GB_MMDF, GB_MAILDIR, GB_MH, GB_IMAP,
- GB_NNTP, GB_EXTERNAL, GB_MAX};
+ GB_NNTP, GB_EXTERNAL, GB_IMAPS, GB_MAX};

enum {
GB_DETACH_PROCESS = 1
Index: gbuffy/imap.c
diff -u gbuffy/imap.c:1.1.1.1 gbuffy/imap.c:1.5
--- gbuffy/imap.c:1.1.1.1 Mon Nov 19 16:43:49 2001
+++ gbuffy/imap.c Mon Nov 19 18:02:59 2001
@@ -226,7 +226,8 @@
strfcpy (user, NONULL(Username), sizeof (user));
pass[0]=0;
/* prompt for username/password */
- snprintf (buf, sizeof (buf), " Login for IMAP Server %s:%d ",
+ snprintf (buf, sizeof (buf), " Login for %s Server %s:%d ",
+ (ibox->type == GB_IMAPS ? "IMAP/SSL" : "IMAP"),
conn->server, conn->port);
if (!password_prompt_dialog (buf, user, sizeof (user), pass, sizeof (pass)))
{
@@ -512,6 +513,9 @@

if (conn->uses == 0)
{
+ if (ibox->type == GB_IMAPS) {
+ conn-> connection_flags |= CONNECTION_FLAGS_SSL;
+ }
if (imap_open_connection (ibox, conn) < 0)
return (-1);
/* For this application, this is only an "in use" variable */
@@ -537,6 +541,8 @@
conn->uses = 0;
return (-1);
}
+
+/* g_print("-I- read '%s' from server\n", buf); */

if (buf[0] == '*')
{
Index: gbuffy/msocket.c
diff -u gbuffy/msocket.c:1.1.1.1 gbuffy/msocket.c:1.2
--- gbuffy/msocket.c:1.1.1.1 Mon Nov 19 16:43:49 2001
+++ gbuffy/msocket.c Mon Nov 19 16:46:11 2001
@@ -1,4 +1,4 @@
-static const char rcsid[]="$Id: msocket.c,v 1.1.1.1 2001/11/19 16:43:49 root
Exp $";
+static const char rcsid[]="$Id: msocket.c,v 1.2 2001/11/19 16:46:11 mike Exp
$";
/*
* Copyright (C) 1998 Michael R. Elkins <me@...>
* Copyright (C) 1998 Brandon C. Long <blong@...>
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <openssl/ssl.h>

/* support for multiple socket connections */

@@ -38,8 +39,13 @@
int msocket_readchar (CONNECTION *conn, char *c)
{
if (conn->bufpos >= conn->available)
- {
- conn->available = read (conn->fd, conn->inbuf, LONG_STRING-1);
+ {
+ if ( conn->connection_flags & CONNECTION_FLAGS_SSL )
+ {
+ conn->available = SSL_read(conn->ssl, conn->inbuf, LONG_STRING-1);
+ } else {
+ conn->available = read (conn->fd, conn->inbuf, LONG_STRING-1);
+ }
conn->bufpos = 0;
if (conn->available <= 0)
{
@@ -64,7 +70,7 @@
for (i = 0; i < buflen; i++)
{
if (msocket_readchar (conn, &ch) != 1)
- return (-1);
+ return (-1);
if (ch == '\n')
break;
buf[i] = ch;
@@ -86,7 +92,12 @@
int msocket_write (CONNECTION *conn, const char *buf)
{
dprint (1,(debugfile,"msocket_write():%s", buf));
- return (write (conn->fd, buf, strlen (buf)));
+ if ( conn->connection_flags & CONNECTION_FLAGS_SSL )
+ {
+ return (SSL_write(conn->ssl, buf, strlen(buf)));
+ } else {
+ return (write (conn->fd, buf, strlen (buf)));
+ }
}

CONNECTION *msocket_select_connection (char *host, int port, int flags)
@@ -107,6 +118,9 @@
conn->bufpos = 0;
conn->available = 0;
conn->uses = 0;
+ conn->ctx = NULL;
+ conn->ssl = NULL;
+ conn->connection_flags = CONNECTION_FLAGS_NONE;
conn->server = safe_strdup (host);
conn->port = port;
conn->next = Connections;
@@ -143,6 +157,45 @@
/* mutt_perror ("connect"); */
close (conn->fd);
}
+ if (conn->connection_flags & CONNECTION_FLAGS_SSL )
+ {
+ int ssl_ret;
+
+ SSL_library_init();
+ SSL_load_error_strings();
+
+ conn->ctx = SSL_CTX_new(SSLv23_client_method());
+ if (conn->ctx == NULL)
+ {
+ close(conn->fd);
+ return -1;
+ }

+ conn->ssl = SSL_new(conn->ctx);
+ if (conn->ssl == NULL)
+ {
+ SSL_CTX_free(conn->ctx);
+ close(conn->fd);
+ return -1;
+ }
+
+ if ( (SSL_set_fd(conn->ssl, conn->fd)) <= 0)
+ {
+ SSL_shutdown(conn->ssl);
+ SSL_free(conn->ssl);
+ SSL_CTX_free(conn->ctx);
+ close(conn->fd);
+ return -1;
+ }
+ if ( ssl_ret = SSL_connect(conn->ssl) <= 0)
+ {
+ SSL_shutdown(conn->ssl);
+ SSL_free(conn->ssl);
+ SSL_CTX_free(conn->ctx);
+ close(conn->fd);
+ return -1;
+ }
+ }
return 0;
+
}
Index: gbuffy/msocket.h
diff -u gbuffy/msocket.h:1.1.1.1 gbuffy/msocket.h:1.2
--- gbuffy/msocket.h:1.1.1.1 Mon Nov 19 16:43:49 2001
+++ gbuffy/msocket.h Mon Nov 19 16:46:11 2001
@@ -1,4 +1,4 @@
-/* $Id: msocket.h,v 1.1.1.1 2001/11/19 16:43:49 root Exp $ */
+/* $Id: msocket.h,v 1.2 2001/11/19 16:46:11 mike Exp $ */
/*
* Copyright (C) 1998 Brandon Long <blong@...>
*
@@ -20,13 +20,17 @@

#ifndef _MSOCKET_H_
#define _MSOCKET_H_ 1
+#include <openssl/ssl.h>

typedef struct _connection
{
int uses;

char *server;
- int port;
+ int port;
+#define CONNECTION_FLAGS_NONE 0
+#define CONNECTION_FLAGS_SSL 1
+ char connection_flags;

int fd;
char inbuf[LONG_STRING];
@@ -34,6 +38,8 @@
int available;

void *data;
+ SSL_CTX *ctx;
+ SSL *ssl;

struct _connection *next;
} CONNECTION;


Forward
Message #10 of 231 |
Expand Messages Author Sort by Date

Hi, I've kludged together some imaps support for gbuffy, basically by adding the ability to do TLS/SSL connections to the mscocket functions...
Mike Bristow
mikebristowuk
Offline Send Email
Nov 19, 2001
1:49 pm

... Sounds good. If you want, you can either post those patches, or you can finish them off, both are good. Brandon -- "Its much more fun to be sand than oil...
Brandon Long
blong42
Offline Send Email
Nov 19, 2001
7:15 pm

... Someone at work wanted them, so I've added in the GUI related bits to the config dialog. I've yet to tackle autoconf; partially because I can tell a small...
Mike Bristow
mike@...
Send Email
Nov 19, 2001
7:32 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help