On Thu, Jun 24, 1999 at 11:11:19PM -0400, Adam Lazur wrote:
> I've looked at still attempting to move my email over to imap, and am
> a little weary of sending my password over the internet in
> plaintext. Is there a method currently available in mutt to setup a
> secure tunnel (via ssh) to the imapd before I open an imap mailbox?
>
> I gave the manual a look, but can't think of a way to get it to
> work. Any help would be appreciated.
I wrote a patch to implement this. There was brief talk about adding it
to the unstable branch, but I don't think it happened. Anyway, here's
the patch. Someone suggested that it be integrated into the compressed
folder patch, which sounds like a good idea to me - they both work on
folders that need some sort of special handling.
David
--
David Shaw | [EMAIL PROTECTED] | WWW http://www.jabberwocky.com/
+---------------------------------------------------------------------------+
"There are two major products that come out of Berkeley: LSD and UNIX.
We don't believe this to be a coincidence." - Jeremy S. Anderson
Hi all,
I like to read my mail via IMAP, but I'm reluctant to send my password in
the clear when I do it. (Especially now that I have a cable modem where
everyone can sniff their neighbors!)
What I needed was something like fetchmail's "preconnect" option - which
is a command run right before the mailbox is opened. Lots of people use a
preconnect command to set up an encrypted tunnel (via ssh or the like)
right before getting their mail.
I tried to figure out a nice generalized way to add this to mutt, and
here's my idea: a folder-prehook. The regular folder-hook is triggered
after the folder is opened, but the folder-prehook is triggered right
before.
Here's how I'm using it:
folder-prehook '{localhost:1500}' 'push `ssh -n -f -L1500:my.imap.server:143
my.imap.server sleep 5 > /dev/null 2>&1`'
The ssh command just sets up a tunnel from the local port 1500 to the
remote machine's port 143 (IMAP). It then runs a sleep on the remote
system for 5 seconds to hold the connection open long enough for mutt to
start opening the IMAP folder. Once mutt has used the tunnel, it won't
close until mutt exits (even though the "sleep 5" has finished). When mutt
exits, the tunnel will collapse automatically.
I'll admit the "push" thing is a bit of a hack - it does work though.
Since the ssh command doesn't generate any output, push will just
immediately return (which is will do right after the folder opens - but
the ssh command in backticks runs before the folder opening).
If anyone has any ideas for how to make this better, let me know.
David
--
David Shaw | [EMAIL PROTECTED] | WWW http://www.jabberwocky.com/
+---------------------------------------------------------------------------+
"There are two major products that come out of Berkeley: LSD and UNIX.
We don't believe this to be a coincidence." - Jeremy S. Anderson
--- mutt-0.95.5/curs_main.c Wed Mar 3 14:36:41 1999
+++ mutt-0.95.5.hack/curs_main.c Thu May 27 14:50:08 1999
@@ -886,6 +886,8 @@
break;
}
+ mutt_folder_prehook (buf);
+
mutt_expand_path (buf, sizeof (buf));
if (mx_get_magic (buf) <= 0)
{
--- mutt-0.95.5/hook.c Thu Jan 7 04:14:41 1999
+++ mutt-0.95.5.hack/hook.c Thu May 27 14:50:08 1999
@@ -62,7 +62,7 @@
goto error;
}
- mutt_extract_token (&command, s, (data & (M_FOLDERHOOK | M_SENDHOOK)) ?
M_TOKEN_SPACE : 0);
+ mutt_extract_token (&command, s, (data & (M_FOLDERHOOK | M_FOLDERPREHOOK |
+M_SENDHOOK)) ? M_TOKEN_SPACE : 0);
if (!command.data)
{
@@ -76,7 +76,7 @@
goto error;
}
- if (data & (M_FOLDERHOOK | M_MBOXHOOK))
+ if (data & (M_FOLDERHOOK | M_FOLDERPREHOOK | M_MBOXHOOK))
{
strfcpy (path, pattern.data, sizeof (path));
mutt_expand_path (path, sizeof (path));
@@ -115,7 +115,7 @@
ptr->rx.not == not &&
!mutt_strcmp (pattern.data, ptr->rx.pattern))
{
- if (data & (M_FOLDERHOOK | M_SENDHOOK))
+ if (data & (M_FOLDERHOOK | M_FOLDERPREHOOK | M_SENDHOOK))
{
/* folder-hook and send-hook allow multiple commands with the same
pattern, so if we've already seen this pattern/command pair, just
@@ -184,6 +184,38 @@
FREE (&pattern.data);
FREE (&command.data);
return (-1);
+}
+
+void mutt_folder_prehook (char *path)
+{
+ HOOK *tmp = Hooks;
+ BUFFER err, token;
+ char buf[STRING];
+
+ err.data = buf;
+ err.dsize = sizeof (buf);
+ memset (&token, 0, sizeof (token));
+ for (; tmp; tmp = tmp->next)
+ {
+ if(!tmp->command)
+ continue;
+
+ if (tmp->type & M_FOLDERPREHOOK)
+ {
+ if ((regexec (tmp->rx.rx, path, 0, NULL, 0) == 0) ^ tmp->rx.not)
+ {
+ if (mutt_parse_rc_line (tmp->command, &token, &err) == -1)
+ {
+ mutt_error ("%s", err.data);
+ FREE (&token.data);
+ sleep (1); /* pause a moment to let the user see the error */
+ return;
+ }
+ }
+ }
+ }
+
+ FREE (&token.data);
}
void mutt_folder_hook (char *path)
--- mutt-0.95.5/init.h Thu Apr 22 05:52:35 1999
+++ mutt-0.95.5.hack/init.h Thu May 27 14:50:42 1999
@@ -341,6 +342,7 @@
{ "fcc-hook", mutt_parse_hook, M_FCCHOOK },
{ "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK },
{ "folder-hook", mutt_parse_hook, M_FOLDERHOOK },
+ { "folder-prehook", mutt_parse_hook, M_FOLDERPREHOOK },
{ "hdr_order", parse_list, UL &HeaderOrderList },
{ "ignore", parse_ignore, 0 },
{ "lists", parse_list, UL &MailLists },
--- mutt-0.95.5/mutt.h Thu Apr 22 05:52:35 1999
+++ mutt-0.95.5.hack/mutt.h Thu May 27 14:50:42 1999
@@ -143,6 +143,7 @@
#ifdef _PGPPATH
#define M_PGPHOOK (1<<5)
#endif
+#define M_FOLDERPREHOOK (1<<6)
/* tree characters for linearize_tree and print_enriched_string */
#define M_TREE_LLCORNER 1