[comp.mail.elm] Problem decrypting

lmb@vicom.COM (Larry Blair) (12/29/88)

I have a problem using the encryption feature on my Sun 3, SunOS 3.5.1.
There's no problem sending encrypted mail, but when you try do decrypt
when reading a message, the cursor goes to HOME after printing the
"please enter decryption key:" message, and then the tty modes are
completely screwed up and, if I'm using a vt100, the terminal needs to
be reset.

I tried to fix it myself, but the problem appears to be one of interaction
between curses and getpass.  Short of writing my own getpass, which I may
do if no one has a fix, I don't see how to cure the problem.
-- 
Larry Blair   ames!vsi1!lmb   lmb@vicom.com

rob@pbhyf.PacBell.COM (Rob Bernardo) (12/31/88)

In article <1330@vsi1.COM>, lmb@vicom.COM (Larry Blair) writes:
> I have a problem using the encryption feature on my Sun 3, SunOS 3.5.1.
> There's no problem sending encrypted mail, but when you try do decrypt
> when reading a message, the cursor goes to HOME after printing the
> "please enter decryption key:" message, and then the tty modes are
> completely screwed up and, if I'm using a vt100, the terminal needs to
> be reset.
> 
> I tried to fix it myself, but the problem appears to be one of interaction
> between curses and getpass.  Short of writing my own getpass, which I may
> do if no one has a fix, I don't see how to cure the problem.

Actually I've seen what I think is the same problem in ELM 2.2 (although
it could be different as some problems with encryption key prompting
have been cleared up in ELM 2.2). It turns out to be a problem only when
using an external pager.

What happens is that ELM opens a pipe (roughly speaking - its more 
complex than this) to the external pager and ELM reads lines of the 
message from the mailfile and writes them to the pipe. When ELM comes 
across an encrypted section it prompts for the encryption key. To do 
this (whether or not elm resorts to using getpass() or anything else) 
it must ensure that echoing is off, i.e. there has to be an ioctl(2) 
to change the terminal settings. Now in the other fork, the pager may 
be fiddling with the terminal settings too (e.g. the pager less puts 
you in raw mode). Furthermore the external pager may be writing the 
the screen as well: clearing the screen or writing the last fed line. 
In any case, both processes are writing to the screen and changing the 
terminal settings asynchronously. And so the prompting for the 
encryption key can get screwed up as well as the final terminal 
settings.  

The latter may have a solution - ELM must reset *all* terminal settings
with ioctl() after using an external pager, not just the few it thinks
it needs to change for raw mode toggling.

I see no simple solution for the former problem. Perhaps when ELM 
first reads a mailfile, it notes which messages have encryption 
notations, so that when being displayed with an external pager it 
would know to prompt for the encryption key *prior* to the 
forking/piping of the external pager. 
-- 
Rob Bernardo, Pacific Bell UNIX/C Reusable Code Library
Email:     ...![backbone]!pacbell!pbhyf!rob   OR  rob@pbhyf.PacBell.COM
Office:    (415) 823-2417  Room 4E750A, San Ramon Valley Administrative Center
Residence: (415) 827-4301  R Bar JB, Concord, California