%n elm %v 2.4.25 %c * %l * %b * %d * %f * %t elm-2.4.25.tgz %w Misc %% %setup patch -u -p1 <<'ENDPATCH' diff -ru2N elm-2.4.25/Configure elm-MCC/Configure --- elm-2.4.25/Configure Mon May 30 16:55:55 1994 +++ elm-MCC/Configure Tue Aug 27 18:37:38 1996 @@ -19,8 +19,4 @@ export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$) -if test ! -t 0; then - echo "Say 'sh Configure', not 'sh /dev/null 2>&1 && \ @@ -269,4 +265,28 @@ d_bsd='' CONFIG='' +bin='/usr/bin' +d_berknames='define' +d_flock='undef' +d_index='define' +d_ispell='define' +d_mime='define' +d_mmdf='define' +d_newauto='undef' +d_passnames='define' +d_savegrpmboxid='undef' +d_setgid='undef' +defcharset='ISO-8859-1' +defdispcharset='ISO-8859-1' +defencoding='7bit' +has_flock='undef' +ispell_path='ispell' +ldflags='-Wl,-warn-common' +lib='/usr/share/elm' +maildir='/var/mail' +mailermode='555' +mailgrp='root' +nametype='bsd' +optimize='-O6 -fomit-frame-pointer' +prefshell='/bin/bash' : set package name package=elm2 @@ -1942,5 +1962,5 @@ $echo $n "Extracting names from $* for later perusal...$c" nm $nm_opts $* 2>/dev/null >libc.tmp -$sed -n -e 's/^.* [ATDS] *[_.]*//p' -e 's/^.* [ATDS] //p' libc.list +$sed -n -e 's/^.* [WATDS] *[_.]*//p' -e 's/^.* [WATDS] //p' libc.list if $contains '^printf$' libc.list >/dev/null 2>&1; then echo done @@ -2345,5 +2365,5 @@ if $contains flock libc.list >/dev/null 2>&1; then echo 'flock() found.' - if $contains EWOULDBLOCK /usr/include/errno.h > /dev/null 2>&1; then + if $contains EWOULDBLOCK /usr/include/asm/errno.h > /dev/null 2>&1; then has_flock="$define" echo 'flock locking available.' @@ -2361,5 +2381,5 @@ fi -if $contains F_SETLK /usr/include/sys/fcntl.h >/dev/null 2>&1; then +if $contains F_SETLK /usr/include/asm/fcntl.h >/dev/null 2>&1; then echo 'F_SETLK found, fcntl locking available' has_fcntl="$define" @@ -2599,5 +2619,5 @@ ;; *) case "$mydomain" in - '') dflt='.UUCP';; + '') dflt='';; *) dflt="$mydomain";; esac @@ -3650,5 +3670,5 @@ esac ;; -*) mailermode=755 +*) mailermode=555 d_savegrpmboxid="$undef" ;; @@ -4078,12 +4098,6 @@ : see if stdarg.h is in includepath echo " " -i_stdarg=`loc stdarg.h "" /usr/include $includepath` -if $test -n "$i_stdarg"; then echo "Found " i_stdarg="$define" -else - echo "Did not find " - i_stdarg="$undef" -fi : see if unistd.h is in includepath @@ -4437,5 +4451,5 @@ echo "ar appears to generate random libraries itself." orderlib=false - ranlib=":" + ranlib="ranlib" else if test -f /usr/bin/ranlib; then diff -ru2N elm-2.4.25/config.h.SH elm-MCC/config.h.SH --- elm-2.4.25/config.h.SH Mon May 30 16:55:57 1994 +++ elm-MCC/config.h.SH Tue Aug 27 19:09:20 1996 @@ -31,4 +31,9 @@ #define BIN "$bin" /**/ +/* PGP_PATH: + * Full pathname to the PGP executable. + */ +#define PGP_PATH "/usr/bin/pgp" + /* CPPSTDIN: * This symbol contains the first part of the string which will invoke diff -ru2N elm-2.4.25/doc/Makefile.SH elm-MCC/doc/Makefile.SH --- elm-2.4.25/doc/Makefile.SH Thu Mar 10 17:20:29 1994 +++ elm-MCC/doc/Makefile.SH Tue Aug 27 18:37:38 1996 @@ -80,6 +80,6 @@ # Variables # Variables established by Configure -CHMOD = $chmod -CP = $cp +CHMOD = echo +CP = install -m 444 DEST = $bin ECHO = $echo diff -ru2N elm-2.4.25/doc/elm-help.0 elm-MCC/doc/elm-help.0 --- elm-2.4.25/doc/elm-help.0 Mon Apr 12 03:13:09 1993 +++ elm-MCC/doc/elm-help.0 Tue Aug 27 19:12:28 1996 @@ -5,4 +5,6 @@ | Pipe current message or tagged messages to a system command + \ Pipe current message or tagged messages + through PGP to a system command ! Shell escape $ Resynchronize folder @@ -33,4 +35,5 @@ K Decrement current message by one k, Advance to previous undeleted message + ^K Mail a PGP public key to someone l Limit messages by specified criteria ^L Redraw screen @@ -39,4 +42,6 @@ then increment o Change ELM options + P Print current message or tagged messages + after piping through PGP p Print current message or tagged messages q Quit, maybe prompting for deleting, storing, diff -ru2N elm-2.4.25/filter/Makefile.SH elm-MCC/filter/Makefile.SH --- elm-2.4.25/filter/Makefile.SH Sun Jun 6 17:35:08 1993 +++ elm-MCC/filter/Makefile.SH Tue Aug 27 18:37:38 1996 @@ -17,5 +17,5 @@ : if mailermode is not 2755 then we dont need the chgrp : set chgrp to a null command in this case -if test "$mailermode" = 755; then +if test "$mailermode" = 555; then chgrp=":" fi @@ -60,5 +60,5 @@ CHGRP = $chgrp CHMOD = $chmod -CP = $cp +CP = install -s DEST = $bin ECHO = $echo diff -ru2N elm-2.4.25/hdrs/defs.h elm-MCC/hdrs/defs.h --- elm-2.4.25/hdrs/defs.h Mon Dec 4 15:50:56 1995 +++ elm-MCC/hdrs/defs.h Tue Aug 27 19:15:55 1996 @@ -272,4 +272,12 @@ #define CM_REMAIL (1<<4) /* Add Sender: and Orig-To: headers */ #define CM_DECODE (1<<5) /* prompt for key if message is encrypted */ +#define CM_ONLY_HEADER (1<<6) /* only copy header */ +#define PGP_MESSAGE 32768 /* indicates that we have a pgp message */ +#define PGP_KEY 65536 /* indicates that we have received a pgp key */ +#define PGP_SIG 131072 /* indicates that we have a signed message */ +#define PGP_MASK (PGP_MESSAGE|PGP_KEY|PGP_SIG) +#define PGP_SHOW_HDR 262144 /* indicates that we want to see headers */ +/* All of pgpelm's strings are not yet in the catalog */ +#define NO_SUCH_MSG 9999 #define EXECUTE_ACCESS 1 /* These five are */ diff -ru2N elm-2.4.25/hdrs/headers.h elm-MCC/hdrs/headers.h --- elm-2.4.25/hdrs/headers.h Thu Sep 1 19:42:40 1994 +++ elm-MCC/hdrs/headers.h Tue Aug 27 20:00:02 1996 @@ -284,2 +284,3 @@ extern JMP_BUF GetPromptBuf; /* setjmp buffer */ extern int InGetPrompt; /* set if in GetPrompt() in read() */ +#define copy_message pgp_copy_message diff -ru2N elm-2.4.25/hdrs/mime.h elm-MCC/hdrs/mime.h --- elm-2.4.25/hdrs/mime.h Sat Nov 7 20:50:23 1992 +++ elm-MCC/hdrs/mime.h Tue Aug 27 19:17:21 1996 @@ -39,4 +39,7 @@ #define MIME_CONTENTENCOD "Content-Transfer-Encoding:" #define MIME_HEADER_CONTENTENCOD "Content-Transfer-Encoding" +#define MIME_HEADER_PGP_PUBLIC_KEY "application/X-pgp-public-key" +#define MIME_HEADER_PGP_MESSAGE "application/X-pgp-message" +#define MIME_HEADER_PGP_SIGNED_MESSAGE "application/X-pgp-signed-message" /* Encoding types */ diff -ru2N elm-2.4.25/hdrs/patchlevel.h elm-MCC/hdrs/patchlevel.h --- elm-2.4.25/hdrs/patchlevel.h Mon Dec 4 15:50:56 1995 +++ elm-MCC/hdrs/patchlevel.h Wed Aug 28 19:09:57 1996 @@ -1 +1,2 @@ #define PATCHLEVEL "25" +#define PGP_PATCHLEVEL "3a" diff -ru2N elm-2.4.25/lib/opt_utils.c elm-MCC/lib/opt_utils.c --- elm-2.4.25/lib/opt_utils.c Mon May 30 16:31:56 1994 +++ elm-MCC/lib/opt_utils.c Tue Aug 27 18:37:39 1996 @@ -87,5 +87,6 @@ #endif -#ifndef GETHOSTNAME +#include +#if ! defined( GETHOSTNAME) && ! defined(__linux__) gethostname(cur_hostname,size) /* get name of current host */ @@ -138,5 +139,5 @@ int size; { - char buf[64]; + char buf[128]; FILE *fp; char *p; diff -ru2N elm-2.4.25/lib/strftime.c elm-MCC/lib/strftime.c --- elm-2.4.25/lib/strftime.c Mon May 16 00:05:33 1994 +++ elm-MCC/lib/strftime.c Tue Aug 27 19:26:25 1996 @@ -126,4 +126,5 @@ */ +#if 0 #include "headers.h" @@ -857,2 +858,3 @@ } #endif /* TEST_STRFTIME */ +#endif diff -ru2N elm-2.4.25/lib/strstr.c elm-MCC/lib/strstr.c --- elm-2.4.25/lib/strstr.c Sat Oct 3 22:42:30 1992 +++ elm-MCC/lib/strstr.c Tue Aug 27 19:27:12 1996 @@ -24,4 +24,5 @@ **/ +#if 0 #include "headers.h" @@ -70,2 +71,3 @@ return (ptr); } +#endif diff -ru2N elm-2.4.25/src/Makefile.SH elm-MCC/src/Makefile.SH --- elm-2.4.25/src/Makefile.SH Thu Dec 24 21:42:05 1992 +++ elm-MCC/src/Makefile.SH Tue Aug 27 18:37:39 1996 @@ -48,5 +48,5 @@ CHGRP = $chgrp CHMOD = $chmod -CP = $cp +CP = install -s DEST = $bin ECHO = $echo diff -ru2N elm-2.4.25/src/elm.c elm-MCC/src/elm.c --- elm-2.4.25/src/elm.c Mon May 30 16:26:14 1994 +++ elm-MCC/src/elm.c Tue Aug 27 19:51:07 1996 @@ -319,4 +319,20 @@ break; + case '\\' : if (!access_keys()) + break; + PutLine0(LINES-3, strlen(Prompt), + "Pipe though PGP filter to a command"); + fflush(stdout); + if (message_count < 1) { + error(catgets(elm_msg_cat, ElmSet, ElmNoMailToPipe, + "No mail to pipe!")); + fflush(stdin); + } else { + softkeys_off(); + redraw += do_pgp_pipe(); + softkeys_on(); + } + break; + #ifdef ALLOW_SUBSHELL case '!' : Writechar('!'); @@ -451,4 +467,5 @@ "Display message")); if(current > 0) { + headers[current-1]->status |= PGP_SHOW_HDR; fflush(stdout); j = filter; @@ -465,4 +482,14 @@ break; + case ctrl('K'):if (!access_keys()) { + error("No PGP key ring found."); + break; + } + PutLine0(LINES-3, strlen(Prompt), + "Mail PGP public key"); + send_msg("","","",FALSE,-1,FALSE); + redraw++; + break; + case 'm' : PutLine0(LINES-3, strlen(Prompt), catgets(elm_msg_cat, ElmSet, ElmMail, @@ -529,6 +556,20 @@ "No mail to print!")); fflush(stdin); - } else if (print_msg(TRUE) != 0) + } else if (print_msg(TRUE, 0) != 0) redraw++; + break; + case 'P' : if (!access_keys()) + break; + PutLine0(LINES-3, strlen(Prompt), + catgets(elm_msg_cat, ElmSet, ElmPrintMail, + "Print mail")); + fflush(stdout); + if (message_count < 1) { + error(catgets(elm_msg_cat, ElmSet, ElmNoMailToPrint, + "No mail to print!")); + fflush(stdin); + } + print_msg(TRUE,1); /* the screen always needs redrawing */ + redraw++; break; diff -ru2N elm-2.4.25/src/fileio.c elm-MCC/src/fileio.c --- elm-2.4.25/src/fileio.c Tue Aug 30 15:08:09 1994 +++ elm-MCC/src/fileio.c Tue Aug 27 20:25:05 1996 @@ -121,5 +121,5 @@ } -copy_message(prefix, +old_copy_message(prefix, dest_file, cm_options) @@ -162,4 +162,5 @@ int remail = cm_options & CM_REMAIL; int decode = cm_options & CM_DECODE; + int only_header = cm_options & CM_ONLY_HEADER; int end_header = 0; int sender_added = 0; @@ -177,5 +178,5 @@ "ELM [seek] failed trying to read %d bytes into file."), current_header->offset); - return; + return -1; } @@ -359,4 +360,6 @@ /* Process checks that occur after the header area */ + if (only_header) + continue; /* perform encryption checks */ if (buffer[0] == '[' && decode) { @@ -416,4 +419,5 @@ copy_write_error_exit(); } + return 0; } @@ -562,2 +566,118 @@ #endif + +pgp_copy_message(prefix, dest_file, cm_options) +char *prefix; +FILE *dest_file; +int cm_options; +{ + FILE *TempFile; + char tempfilename[SLEN]; + char Cmd[VERY_LONG_STRING]; + char alttempfilename[SLEN]; + int i; + register struct header_rec *current_header = headers[current-1]; + + /* Copy the message to a temp file, if it's a PGP message. + * Otherwise simply run copy_message. + */ + + /* don't treat pgp key-only message specially; we've already scanned it */ + + switch (current_header->status & PGP_MASK) { + case 0: + case PGP_KEY: + return old_copy_message(prefix,dest_file,cm_options); + default: + break; + } + + if (access_keys() == 0) { + dprint(1, (debugfile, + "ERROR: Found PGP message, and can't access the PGP keyring")); + error1(catgets(elm_msg_cat, ElmSet, 9999, + "Found PGP message, and can't access the PGP keyring")); + return old_copy_message(prefix,dest_file,cm_options); + } + + /* OK, now that we know it's a PGP message, copy it to a tempfile, + then run PGP on it, then do the normal thing. */ + + sprintf(tempfilename,"%smesg.%d",temp_dir,getpid()); + if ((TempFile=fopen(tempfilename,"w")) == NULL) { + dprint(1, (debugfile, + "Failure opening file for PGP message: %s", tempfilename)); + error1(catgets(elm_msg_cat, ElmSet, 9999, + "Failure opening file for PGP message: %s", tempfilename)); + return old_copy_message(prefix,dest_file,cm_options); + } + if (old_copy_message("",TempFile,cm_options) < 0) { + unlink(tempfilename); + return -1; + } + fclose(TempFile); + + strcpy(alttempfilename,tempfilename); + strcat(alttempfilename,".pgp"); + /* don't let others peek at the plaintext -- set umask! */ + sprintf(Cmd, "umask 0; %s -f +verbose=0 <%s >%s", + PGP_PATH,tempfilename,alttempfilename); + if (system_call(Cmd, SY_ENAB_SIGINT) == 0) { + if (!(cm_options & CM_REMOVE_HEADER)) { + old_copy_message(prefix,dest_file,CM_ONLY_HEADER); + fputc('\n', dest_file); + } + /* then copy the decoded file to the new file */ + if ((TempFile=fopen(alttempfilename,"r")) == NULL) { + fputs("\nError with PGP temp file!\n",stderr); + /* try to remove the pgp plain text before exiting */ + unlink(tempfilename); + unlink(alttempfilename); + emergency_exit(); + } + { + char junk[LONG_STRING]; + while (mail_gets(junk,LONG_STRING,TempFile) != 0) + fprintf(dest_file,"%s%s",prefix,junk); + } + fclose(TempFile); + } else { + /* err - pgp returned an error code for some reason + * lets give the undecoded message then :) + */ + old_copy_message(prefix,dest_file,cm_options); + } + unlink(alttempfilename); /* now get rid of the temp file */ + unlink(tempfilename); /* also remove temp file */ + return 0; +} + +/* Look for the keys in the current directory + * and in the directory indicated by pgppath. + * Return 1 if keys are found, otherwise 0. + */ + +access_keys() +{ + /* if your filenames are > 1k, then you are in trouble */ + char *Temp, *End, Filename[1024]; + + if ((Temp = getenv("PGPPATH")) + && *Temp) { + strcpy(Filename, Temp); + if (Filename[strlen(Filename) - 1] != '/') + strcat(Filename, "/"); + } else { + if (!(Temp = getenv("HOME"))) + return(0); + strcpy(Filename, Temp); + if (Filename[strlen(Filename) - 1] != '/') + strcat(Filename, "/"); + strcat(Filename, ".pgp/"); + } + + strcat(Filename,"pubring.pgp"); + if (access(Filename,0) == 0) + return(1); + return(0); +} diff -ru2N elm-2.4.25/src/help.c elm-MCC/src/help.c --- elm-2.4.25/src/help.c Mon May 30 16:42:49 1994 +++ elm-MCC/src/help.c Tue Aug 27 20:32:04 1996 @@ -129,4 +129,9 @@ break; + case '\\': + s = + "\\ = Pipe the current message or tagged messages through PGP to a command."; + break; + case '#': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpDebugAll, "# = Debug - display all information known about current message."); @@ -246,4 +251,8 @@ break; + case ctrl('K'): + s = "^K = Mail a PGP public key to someone."; + break; + case 'l': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpLimitDisplay, @@ -267,4 +276,8 @@ "o = Go to the options submenu."); break; + + case 'P': + s = "P = Print the current message or tagged messages after piping through PGP."; + break; case 'p': s = catgets(elm_msg_cat, ElmSet, ElmHelpPrint, diff -ru2N elm-2.4.25/src/init.c elm-MCC/src/init.c --- elm-2.4.25/src/init.c Mon May 30 16:31:57 1994 +++ elm-MCC/src/init.c Tue Aug 27 20:50:30 1996 @@ -200,5 +200,5 @@ char buffer[SLEN], *cp; - sprintf(version_buff, "%s PL%s", VERSION, PATCHLEVEL); + sprintf(version_buff, "%s PL%s PGP%s", VERSION, PATCHLEVEL, PGP_PATCHLEVEL); def_ans_yes = catgets(elm_msg_cat, ElmSet, ElmYes, "y"); def_ans_no = catgets(elm_msg_cat, ElmSet, ElmNo, "n"); diff -ru2N elm-2.4.25/src/lock.c elm-MCC/src/lock.c --- elm-2.4.25/src/lock.c Sun May 15 23:02:12 1994 +++ elm-MCC/src/lock.c Tue Aug 27 18:37:39 1996 @@ -472,4 +472,5 @@ case FLOCKING_OK: + errno = 0; goto EXIT_RETRY_LOOP; diff -ru2N elm-2.4.25/src/mailmsg1.c elm-MCC/src/mailmsg1.c --- elm-2.4.25/src/mailmsg1.c Tue Jul 20 02:46:14 1993 +++ elm-MCC/src/mailmsg1.c Tue Aug 27 20:55:39 1996 @@ -62,4 +62,5 @@ cc[VERY_LONG_STRING], expanded_to[VERY_LONG_STRING], expanded_reply_to[LONG_STRING], + keyid[LONG_STRING], expanded_cc[VERY_LONG_STRING], user_defined_header[SLEN], bcc[VERY_LONG_STRING], expanded_bcc[VERY_LONG_STRING], @@ -263,4 +264,9 @@ } + if (form_letter == -1) { + if (get_keyid(keyid) == 0) + return(0); + } + MoveCursor(LINES,0); /* so you know you've hit ! */ @@ -501,3 +507,40 @@ return(ret); +} + +int get_keyid(keyid) +char *keyid; +{ + char ch, msgbuf[SLEN]; + + /** get the subject and return non-zero if all okay... **/ + int prompt_line; + + prompt_line = mail_only ? 4 : LINES; + + if (user_level == 0) + PutLine0(prompt_line,0, "Name of user whose key will be sent: "); + else + PutLine0(prompt_line,0, "Send key of user: "); + + CleartoEOLN(); + + /* default is to send user's own key */ + strcpy(keyid, username); + + if (optionally_enter(keyid, -1, -1, FALSE, FALSE) == -1) { + /** User hit the BREAK key! **/ + MoveCursor(prompt_line,0); + CleartoEOLN(); + error(catgets(elm_msg_cat, ElmSet, ElmMailNotSent, "Mail not sent.")); + return(0); + } + + if (strlen(keyid) == 0) { /* no key entered -- send whole keyring */ + PutLine0(prompt_line,0,"Sending: Entire key ring"); + CleartoEOLN(); + strcpy(keyid,"\"\""); + } + + return(1); /** everything is cruising along okay **/ } diff -ru2N elm-2.4.25/src/mailmsg2.c elm-MCC/src/mailmsg2.c --- elm-2.4.25/src/mailmsg2.c Mon Dec 4 15:50:56 1995 +++ elm-MCC/src/mailmsg2.c Tue Aug 27 22:17:19 1996 @@ -252,4 +252,5 @@ long ftell(); +int pgp_encoded; #ifdef SITE_HIDING char *get_ctime_date(); @@ -265,4 +266,5 @@ expanded_cc[VERY_LONG_STRING], user_defined_header[SLEN], bcc[VERY_LONG_STRING], expanded_bcc[VERY_LONG_STRING], + keyid[LONG_STRING], precedence[SLEN], expires_days[SLEN]; @@ -332,4 +334,7 @@ **/ + /* If form = -1 then it means send our public keyring to them */ + + char Cmd[VERY_LONG_STRING]; FILE *reply, *real_reply; /* second is post-input buffer */ char *whole_msg_file, *tempnam(); @@ -356,5 +361,5 @@ /** if possible, let's try to recall the last message? **/ - if (! batch_only && copy_msg != FORM && user_level != 0) + if (! batch_only && copy_msg != FORM && user_level != 0 && (form != -1)) retransmit = recall_last_msg(filename, copy_msg, &cancelled_msg, &already_has_text); @@ -363,5 +368,15 @@ if (! retransmit) - { + if (form == -1) { + sprintf(Cmd,"%s -kxa +verbose=0 %s %s", PGP_PATH, keyid, filename); + if (system_call(Cmd,SY_ENAB_SIGHUP) != 0) { + char error[VERY_LONG_STRING]; + sprintf(error, "Could not get PGP public key of %s", keyid); + set_error(error); + return(need_redraw); + } + strcat(filename,".asc"); + reply = fopen(filename,"a"); + } else { unlink(filename); /* we don't care if it fails since the open() will catch it*/ if ( ( (filename_handle = open(filename, O_RDWR|O_CREAT|O_EXCL,0600)) == -1) || @@ -384,6 +399,6 @@ } - - (void) elm_chown(filename, userid, groupid); + if (form != -1) + (void) elm_chown(filename, userid, groupid); /* copy the message from standard input */ @@ -394,5 +409,5 @@ /** if there is an included file, copy it into the temp file **/ - if (*included_file) { + if (*included_file && (form != -1)) { FILE *input; if ((input = fopen(included_file,"r")) == NULL) { @@ -443,5 +458,8 @@ precedence[0] = '\0'; } - else if (copy_msg && ! retransmit) { /* if retransmit we have it! */ + else if (copy_msg && ! retransmit) /* if retransmit we have it! */ + if (form == -1) + already_has_text = TRUE; + else { if (attribution[0]) { fprintf(reply, attribution, headers[current-1]->from); @@ -491,5 +509,5 @@ /* ask the user to confirm transmission of the message */ - if (!batch_only) { + if (!batch_only && (form != -1)) { ch = (edit_message? 'e' : '\0'); if (verify_transmission(filename, &form, &need_redraw, @@ -805,4 +823,5 @@ bad_cmd = FALSE; /* nothing to complain about yet */ + pgp_encoded = 0; for (;;) { @@ -813,6 +832,10 @@ prompt_mssg = catgets(elm_msg_cat, ElmSet, ElmVfyPromptPleaseChoose, "Please choose one of the following options by parenthesized letter: s"); - strcpy(prompt_menu, catgets(elm_msg_cat, ElmSet, ElmVfyMenuUser0, - "e)dit message, edit h)eaders, s)end it, or f)orget it.")); + if (access_keys()) + strcpy(prompt_menu, catgets(elm_msg_cat, ElmSet, NO_SUCH_MSG, + "e)dit message, edit h)eaders, s)end it, p)gp encode it, or f)orget it.")); + else + strcpy(prompt_menu, catgets(elm_msg_cat, ElmSet, ElmVfyMenuUser0, + "e)dit message, edit h)eaders, s)end it, or f)orget it.")); } else { prompt_mssg = catgets(elm_msg_cat, ElmSet, ElmVfyPromptAndNow, @@ -837,4 +860,6 @@ strcat(prompt_menu, catgets(elm_msg_cat, ElmSet, ElmVfyMenuVfyCpy, "h)eaders, c)opy, ")); + if (access_keys()) + strcat(prompt_menu, "p)gp, "); #ifdef ISPELL strcat(prompt_menu, catgets(elm_msg_cat, ElmSet, ElmVfyMenuIspell, @@ -892,4 +917,25 @@ /*NOTREACHED*/ + case 'p': + /* if they dont have pgp keys then they cant use this option! */ + if (!access_keys()) { + bad_cmd = TRUE; + break; + } + + /* can't run pgp on the same message twice! */ + if (pgp_encoded) { + error ("Can't run PGP on the same message twice!"); + if (sleepmsg > 0) + sleep(sleepmsg); + break; + } + + pgpmenu(filename,form_p); + printf("\n\n\n"); + prev_form = *form_p + 1; /* force build of prompt strings */ + bad_cmd = FALSE; /* nothing to complain about yet */ + break; + case 'f': if (did_prompt) @@ -1190,5 +1236,5 @@ #endif /* !NO_XHEADER */ - if (form) + if (form == YES) fprintf(filedesc, "Content-Type: mailform\n"); #ifdef MIME @@ -1202,6 +1248,13 @@ #ifdef MIME fprintf(filedesc, "%s\n", MIME_HEADER); - fprintf(filedesc, "%s text/plain; charset=%s\n", - MIME_CONTENTTYPE, charset); + if (pgp_encoded) + fprintf(filedesc, "%s %s\n", MIME_CONTENTTYPE, + MIME_HEADER_PGP_MESSAGE); + else if (form == -1) + fprintf(filedesc, "%s %s\n", MIME_CONTENTTYPE, + MIME_HEADER_PGP_PUBLIC_KEY); + else if ((form != -1) && (!pgp_encoded)) + fprintf(filedesc, "%s text/plain; charset=%s\n", + MIME_CONTENTTYPE, charset); fprintf(filedesc, "Content-Transfer-Encoding: %s\n", (!strincmp ("us-ascii", charset) @@ -1451,2 +1504,123 @@ } +pgpmenu(filename, form_p) +char *filename; +char *form_p; +{ + char *prompt_mssg; /* message to display prompting for cmd */ + char prompt_menu[SLEN]; /* menu of available commands */ + int bad_cmd; /* set TRUE to bitch about user's entry */ + int did_prompt; /* TRUE if cmd prompted for and entered */ + int prev_form; /* "*form_p" value last time thru loop */ + int cmd; /* command to perform */ + int x_coord, y_coord; + char Cmd[VERY_LONG_STRING]; + char pgp_to[VERY_LONG_STRING]; /* username buffer for passing to PGP */ + prev_form = *form_p + 1; /* force build of prompt strings */ + bad_cmd = FALSE; /* nothing to complain about yet */ + + /* note that strip_parens returns a ptr to a static buffer, */ + /* and strip_commas alters the input string */ + strcpy(pgp_to, strip_parens(expanded_to)); + strip_commas(pgp_to); + remove_possible_trailing_spaces(pgp_to); + + for (;;) { + /* build up prompt and menu strings */ + if (prev_form == *form_p) { + ; /* not changed - no need to rebuild the strings */ + } else if (user_level == 0) { + prompt_mssg = catgets(elm_msg_cat, ElmSet, NO_SUCH_MSG, + "Choose one of the following options by parenthesized letter: x"); + strcpy(prompt_menu, catgets(elm_msg_cat, ElmSet, NO_SUCH_MSG, + "pgp e)ncrypt message, s)ign message, b)oth, e(x)it menu")); + } else { + prompt_mssg = catgets(elm_msg_cat, ElmSet, NO_SUCH_MSG, + "And now: x"); + strcpy(prompt_menu, catgets(elm_msg_cat, ElmSet, NO_SUCH_MSG, + "pgp e)ncrypt, s)ign, b)oth or e(x)it")); + } + prev_form = *form_p; + + /* complain if last entry was bad */ + if (bad_cmd) { + Write_to_screen("%c??", 1, 07); + if (sleepmsg > 0) + sleep((sleepmsg + 1) / 2); + bad_cmd = FALSE; + } + + /* if we don't have a cmd, display prompt and get response from user */ + MoveCursor(LINES-2, 0); + CleartoEOS(); + PutLine0(LINES-2, 0, prompt_mssg); + GetXYLocation(&x_coord, &y_coord); + y_coord--; /* backspace over default answer */ + Centerline(LINES-1, prompt_menu); + + /* in case an error caused us to repeat this loop */ + show_last_error(); + + fflush(stdin); + fflush(stdout); + Raw(ON); /* double check... testing only... */ + MoveCursor(x_coord, y_coord); + cmd = ReadCh(); + cmd = tolower(cmd); + did_prompt = TRUE; + + /* handle command */ + switch (cmd) { + + case '\n': + case '\r': + case 'x': + if (did_prompt) + Write_to_screen("Exit", 0); + return(1); + + case 'e': + if (did_prompt) + Write_to_screen("Encrypt message\n\n", 0); + sprintf(Cmd,"%s -weat +verbose=0 %s %s %s", + PGP_PATH, filename, pgp_to, cc); + if (system_call(Cmd, SY_ENAB_SIGINT) == 0) { + strcat(filename,".asc"); + pgp_encoded++; + return(0); + } + error("PGP FAILED!"); + break; + + case 'b': + if (did_prompt) + Write_to_screen("Encrypt and sign message\n\n", 0); + sprintf(Cmd,"%s -sweat +verbose=0 %s %s %s", + PGP_PATH, filename, pgp_to, cc); + if (system_call(Cmd, SY_ENAB_SIGINT) == 0) { + strcat(filename,".asc"); + pgp_encoded++; + return(0); + } + error("PGP FAILED!"); + break; + + case 's': + if (did_prompt) + Write_to_screen("Sign message\n\n", 0); + sprintf(Cmd,"%s -staw +verbose=0 +clearsig=on %s", + PGP_PATH, filename); + if (system_call(Cmd, SY_ENAB_SIGINT) == 0) { + strcat(filename,".asc"); + pgp_encoded++; + return(0); + } + error("PGP FAILED!"); + break; + + default: + bad_cmd = TRUE; + break; + } + } +} diff -ru2N elm-2.4.25/src/newmbox.c elm-MCC/src/newmbox.c --- elm-2.4.25/src/newmbox.c Mon Dec 4 15:50:56 1995 +++ elm-MCC/src/newmbox.c Wed Aug 28 18:33:19 1996 @@ -999,6 +999,18 @@ } } - if (in_header == FALSE && first_word(buffer, START_ENCODE)) - current_header->encrypted = 1; + if (in_header == FALSE) { + if (first_word(buffer, START_ENCODE)) + current_header->encrypted = 1; + else if (first_word(buffer, "-----BEGIN PGP")) { + if (first_word(buffer, "-----BEGIN PGP MESSAGE")) + current_header->status |= MIME_MESSAGE|PGP_MESSAGE; + else if (first_word(buffer, "-----BEGIN PGP PUBLIC KEY BLOCK")) + current_header->status |= MIME_MESSAGE|PGP_KEY; + /* could be "PGP SIGNED MESSAGE" or "PGP SIGNATURE" */ + else if (first_word(buffer, "-----BEGIN PGP SIGN")) + current_header->status |= MIME_MESSAGE|PGP_SIG; + else current_header->status |= MIME_MESSAGE|PGP_MESSAGE; + } + } fbytes += (long) line_bytes; content_remaining -= (long) line_bytes; diff -ru2N elm-2.4.25/src/screen.c elm-MCC/src/screen.c --- elm-2.4.25/src/screen.c Wed Jan 20 03:02:41 1993 +++ elm-MCC/src/screen.c Wed Aug 28 18:37:56 1996 @@ -468,7 +468,9 @@ C = Company Confidential message U = Urgent (or Priority) message - P = Private message + P = Private message (or PGP encoded) A = Action associated with message F = Form letter + K = PGP public key + S = PGP signed message M = MIME compliant Message (only displayed, when metamail is needed) @@ -493,4 +495,7 @@ else if (status & ACTION) mybuffer[1] = 'A'; else if (status & FORM_LETTER) mybuffer[1] = 'F'; + else if (status & PGP_MESSAGE) mybuffer[1] = 'P'; + else if (status & PGP_KEY) mybuffer[1] = 'K'; + else if (status & PGP_SIG) mybuffer[1] = 'S'; #ifdef MIME else if ((status & MIME_MESSAGE) && diff -ru2N elm-2.4.25/src/showmsg.c elm-MCC/src/showmsg.c --- elm-2.4.25/src/showmsg.c Tue Aug 30 15:09:44 1994 +++ elm-MCC/src/showmsg.c Wed Aug 28 19:15:54 1996 @@ -163,6 +163,10 @@ val = 0, /* return val */ buf_len, /* line length */ + i, /* used as a flag */ + pgp_message = 0, /* a pgp encoded message? */ err; /* place holder for errno */ struct header_rec *current_header = headers[number-1]; + char fname[STRING]; + FILE *fpout; #ifdef SIGTSTP SIGHAND_TYPE (*oldstop)(), (*oldcont)(); @@ -203,9 +207,9 @@ ((current_header->status & MIME_NEEDDECOD) || (current_header->status & MIME_NOTPLAIN)) && - !getenv("NOMETAMAIL") ) { - char fname[STRING], Cmd[SLEN], line[VERY_LONG_STRING]; + !getenv("NOMETAMAIL") && + ((current_header->status & PGP_MASK) == 0)) { + char Cmd[SLEN]; int code, err; long lines = current_header->lines; - FILE *fpout; if (fseek(mailfile, current_header->offset, 0) != -1) { @@ -227,4 +231,6 @@ Raw(ON); /* Finally raw on and switch screen */ return(0); + } else { + (void) unlink (fname); } } @@ -232,4 +238,39 @@ #endif + if (current_header->status & (PGP_MESSAGE|PGP_SIG)) + pgp_message++; + + /* handle pgp key(s) */ + if (current_header->status & PGP_KEY) { + char buffer[SLEN]; + int ret; + int old_raw; + + MoveCursor(LINES,0); + CleartoEOLN(); + if (( old_raw = RawState()) == ON) + Raw(OFF); + if (cursor_control) + transmit_functions(OFF); + printf("(** This message contains a PGP public key **)\n"); + sprintf(buffer, "%s -Ih|%s -fka +verbose=0 +interactive=on", + readmsg, PGP_PATH); + ret = system_call(buffer, SY_ENAB_SIGINT|SY_DUMPSTATE); + SetXYLocation(0,40); + PutLine0(LINES, 0, + "\n\nPress any key to see message: "); + + Raw(ON | NO_TITE); + (void) getchar(); + printf("\r\n"); + Raw(OFF | NO_TITE); + if (old_raw == ON) + Raw(ON); + if (cursor_control) + transmit_functions(ON); + /* Don't return here -- if the message contains both a public + * key & text, you want to see the text, right? */ + } + if (fseek(mailfile, current_header->offset, 0) == -1) { err = errno; @@ -242,4 +283,40 @@ return(val); } + if (pgp_message) { + sprintf(fname,"%spgp.%d.%d", temp_dir, getpid(), getuid()); + if ((fpout = fopen(fname, "w")) != NULL) { + ClearScreen(); + copy_message("",fpout, + (current_header->status & PGP_SHOW_HDR) + ? 0 : CM_REMOVE_HEADER); + fclose(fpout); + PutLine0(LINES,0, + "Press any key to see message: "); + (void) ReadCh(); + } else { + fputs("\nError reading message\n",stderr); + emergency_exit(); + } + if ((fpout = fopen(fname, "r")) == NULL) { + fputs("\nError opening pgp file for reading\n", stderr); + unlink(fname); + emergency_exit(); + } + + /* since we cant use the headers to calculate the number + * of lines...we might as well count them :) + */ + lines = 0; + for(;;) { + char junk[VERY_LONG_STRING]; + if (fgets(junk,VERY_LONG_STRING, fpout) == 0) + break; + lines++; + } + rewind(fpout); + clearerr(fpout); + } + /* there, that wasnt too painful was it? */ + if(current_header->encrypted) getkey(OFF); @@ -267,4 +344,6 @@ error_description(err)); Raw(ON); + if (pgp_message) + unlink(fname); return(val); } @@ -279,4 +358,6 @@ error_description(err)); Raw(ON); + if (pgp_message) + unlink(fname); return(val); @@ -342,4 +423,6 @@ Raw(OFF); + if (pgp_message) + unlink(fname); return(val); /* pager may have already touched the screen */ } @@ -494,5 +577,6 @@ while (lines > 0 && pipe_abort == FALSE) { - if ((buf_len = mail_gets(buffer, VERY_LONG_STRING, mailfile)) == 0) { + if ((buf_len = mail_gets(buffer, VERY_LONG_STRING, + pgp_message ? fpout : mailfile)) == 0) { dprint(1, (debugfile, @@ -582,4 +666,8 @@ } + if(pgp_message) { + fclose(fpout); + unlink(fname); + } /* If we are to prompt for a user input command and we don't * already have one */ diff -ru2N elm-2.4.25/src/showmsg_c.c elm-MCC/src/showmsg_c.c --- elm-2.4.25/src/showmsg_c.c Fri Mar 11 21:25:27 1994 +++ elm-MCC/src/showmsg_c.c Wed Aug 28 19:21:32 1996 @@ -111,4 +111,13 @@ break; + case '\\' : if (!access_keys()) + break; + put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmPipe, + "Pipe though pgp to a command"), TRUE); + (void) do_pgp_pipe(); /* do pipe - ignore return val */ + ClearScreen(); + build_bottom(); + break; + #ifdef ALLOW_SUBSHELL case '!' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmSystemCall, @@ -210,5 +219,11 @@ case 'p' : put_cmd_name(catgets(elm_msg_cat, ElmSet, ElmPrintMessage, "Print message"), FALSE); - (void) print_msg(FALSE); + (void) print_msg(FALSE,0); + break; + case 'P' : if (!access_keys()) + break; + put_cmd_name(catgets(elm_msg_cat, ElmSet, + ElmPrintMessage, "Print message"), FALSE); + (void) print_msg(FALSE,1); break; diff -ru2N elm-2.4.25/src/syscall.c elm-MCC/src/syscall.c --- elm-2.4.25/src/syscall.c Tue Aug 30 15:09:43 1994 +++ elm-MCC/src/syscall.c Tue Sep 10 10:30:50 1996 @@ -343,4 +343,5 @@ (void) remove_folder_state_file(); + dprint(2, (debugfile, "System Call exited with status %d\n", stat)); return(stat); } @@ -365,5 +366,55 @@ return(0); } + + MoveCursor(LINES,0); + CleartoEOLN(); + if (( old_raw = RawState()) == ON) + Raw(OFF); + + if (cursor_control) + transmit_functions(OFF); + + sprintf(buffer, "%s -Ih| %s", readmsg, command); + ret = system_call(buffer, SY_USER_SHELL|SY_ENAB_SIGINT|SY_DUMPSTATE); + + SetXYLocation(0, 40); /* a location not near the next request, so an absolute is used */ + PutLine0(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmPressAnyKeyToReturn, + "\n\nPress any key to return to ELM: ")); + + Raw(ON | NO_TITE); + (void) getchar(); + printf("\r\n"); + Raw(OFF | NO_TITE); /* Done even if old_raw == ON, to get ti/te right */ + if (old_raw == ON) + Raw(ON); + if (cursor_control) transmit_functions(ON); + + if (ret != 0) + error1(catgets(elm_msg_cat, ElmSet, ElmReturnCodeWas, + "Return code was %d."), ret); + return(1); +} + +int +do_pgp_pipe() +{ + /** pipe the current message or tagged messages to + the specified sequence.. **/ + + char command[SLEN], buffer[SLEN], *prompt; + register int ret; + int old_raw; + + prompt = catgets(elm_msg_cat, ElmSet, ElmPipeTo, "Pipe to: "); + PutLine0(LINES-2, 0, prompt); + command[0] = '\0'; + (void) optionally_enter(command, LINES-2, strlen(prompt), FALSE, FALSE); + if (command[0] == '\0') { + MoveCursor(LINES-2,0); + CleartoEOLN(); + return(0); + } + MoveCursor(LINES,0); CleartoEOLN(); @@ -374,5 +425,6 @@ transmit_functions(OFF); - sprintf(buffer, "%s -Ih|%s", readmsg, command); + sprintf(buffer, "%s -Ih|%s -f +verbose=0 | %s", readmsg, + PGP_PATH, command); ret = system_call(buffer, SY_USER_SHELL|SY_ENAB_SIGINT|SY_DUMPSTATE); @@ -396,6 +448,7 @@ } -int print_msg(pause_on_scroll) +int print_msg(pause_on_scroll,pass_through_pgp) int pause_on_scroll; +int pass_through_pgp; { /* @@ -447,8 +500,17 @@ if (in_string(printout, "%s")) { sprintf(printbuffer, printout, filename); - sprintf(buffer,"(%s -Ip > %s; %s 2>&1) > /dev/null", - readmsg, filename, printbuffer); + if (pass_through_pgp) + sprintf(buffer, + "(%s -Ip | %s -f +verbose=0 > %s; %s 2>&1) > /dev/null", + readmsg, PGP_PATH, filename, printbuffer); + else + sprintf(buffer,"(%s -Ip > %s; %s 2>&1) > /dev/null", + readmsg, filename, printbuffer); } else { - sprintf(buffer,"%s -Ip | %s", readmsg, printout); + if (pass_through_pgp) + sprintf(buffer,"%s -Ip | %s -f +verbose=0 | %s", + readmsg, PGP_PATH, printout); + else + sprintf(buffer,"%s -Ip | %s", readmsg, printout); } @@ -685,3 +747,2 @@ return unlink(folder_state_fname); } - diff -ru2N elm-2.4.25/utils/Makefile.SH elm-MCC/utils/Makefile.SH --- elm-2.4.25/utils/Makefile.SH Thu Mar 10 17:20:29 1994 +++ elm-MCC/utils/Makefile.SH Tue Aug 27 18:37:39 1996 @@ -59,10 +59,11 @@ CC = $cc CCFLAGS = $ccflags $xencf -CHMOD = $chmod -CP = $cp +CHMOD = echo +CP = install -s -m 555 DEST = $bin ECHO = $echo LFLAGS = $ldflags $xenlf LIB = $lib +PLIB = /usr/libexec LIB2 = $libs LIBS = $termlib $dbm @@ -103,5 +104,5 @@ $(DEST)/printmail \ $(DEST)/readmsg \ - $(LIB)/prlong + $(PLIB)/prlong # List of remotely install programs @@ -214,7 +215,7 @@ $(LN) $(DEST)/frm $(DEST)/nfrm $(LN) $(DEST)/newmail $(DEST)/wnewmail - -$(MV) $(LIB)/prlong $(DEST)/prlong.old - -$(RM) $(LIB)/prlong.old - $(CP) prlong $(LIB) + -$(MV) $(PLIB)/prlong $(DEST)/prlong.old + -$(RM) $(PLIB)/prlong.old + $(CP) prlong $(PLIB) $(CHMOD) a+rx $(INSTALL_LIST) @@ -416,5 +417,5 @@ $(LN) $? $@ -$(LIB)/prlong: $(BIN)/prlong +$(PLIB)/prlong: $(BIN)/prlong -$(MV) $@ $@.old -$(RM) $@.old diff -ru2N elm-2.4.25/utils/checkalias.SH elm-MCC/utils/checkalias.SH --- elm-2.4.25/utils/checkalias.SH Mon Apr 12 02:11:06 1993 +++ elm-MCC/utils/checkalias.SH Tue Aug 27 18:37:39 1996 @@ -29,5 +29,5 @@ elmalias -en \$@ | \\ - $lib/prlong -w 78 -1 "Expands to: " -l " " -f ", " + /usr/libexec/prlong -w 78 -1 "Expands to: " -l " " -f ", " exit \$? ENDPATCH rm -f config.sh ./Configure -d