home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-12 | 49.8 KB | 1,871 lines |
- head 1.28;
- access;
- symbols;
- locks
- simons:1.28; strict;
- comment @ * @;
-
-
- 1.28
- date 93.10.12.13.02.36; author simons; state Exp;
- branches;
- next 1.27;
-
- 1.27
- date 93.10.06.12.42.50; author simons; state Exp;
- branches;
- next 1.26;
-
- 1.26
- date 93.10.06.12.19.18; author simons; state Exp;
- branches;
- next 1.25;
-
- 1.25
- date 93.09.25.02.37.43; author simons; state Stab;
- branches;
- next 1.24;
-
- 1.24
- date 93.09.24.22.53.41; author simons; state Stab;
- branches;
- next 1.23;
-
- 1.23
- date 93.09.14.22.06.02; author simons; state Stab;
- branches;
- next 1.22;
-
- 1.22
- date 93.09.14.17.28.15; author simons; state Exp;
- branches;
- next 1.21;
-
- 1.21
- date 93.09.13.17.29.49; author simons; state Exp;
- branches;
- next 1.20;
-
- 1.20
- date 93.09.08.23.08.16; author simons; state Exp;
- branches;
- next 1.19;
-
- 1.19
- date 93.09.08.23.03.48; author simons; state Exp;
- branches;
- next 1.18;
-
- 1.18
- date 93.09.04.15.32.26; author simons; state Stab;
- branches;
- next 1.17;
-
- 1.17
- date 93.09.03.14.35.08; author simons; state Stab;
- branches;
- next 1.16;
-
- 1.16
- date 93.09.03.02.05.51; author simons; state Exp;
- branches;
- next 1.15;
-
- 1.15
- date 93.09.03.01.33.35; author simons; state Exp;
- branches;
- next 1.14;
-
- 1.14
- date 93.08.28.18.45.46; author simons; state Stab;
- branches;
- next 1.13;
-
- 1.13
- date 93.08.28.17.59.56; author simons; state Stab;
- branches;
- next 1.12;
-
- 1.12
- date 93.08.23.15.48.02; author simons; state Exp;
- branches;
- next 1.11;
-
- 1.11
- date 93.08.23.15.21.19; author simons; state Exp;
- branches;
- next 1.10;
-
- 1.10
- date 93.08.23.13.47.36; author simons; state Exp;
- branches;
- next 1.9;
-
- 1.9
- date 93.08.23.13.12.32; author simons; state Exp;
- branches;
- next 1.8;
-
- 1.8
- date 93.08.23.13.05.01; author simons; state Exp;
- branches;
- next 1.7;
-
- 1.7
- date 93.08.22.17.53.02; author simons; state Stab;
- branches;
- next 1.6;
-
- 1.6
- date 93.08.22.17.48.33; author simons; state Stab;
- branches;
- next 1.5;
-
- 1.5
- date 93.08.22.17.46.12; author simons; state Stab;
- branches;
- next 1.4;
-
- 1.4
- date 93.08.22.17.38.34; author simons; state stab;
- branches;
- next 1.3;
-
- 1.3
- date 93.08.22.17.12.11; author simons; state Stab;
- branches;
- next 1.2;
-
- 1.2
- date 93.08.21.19.32.47; author simons; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 93.08.21.19.28.43; author simons; state Exp;
- branches;
- next ;
-
-
- desc
- @This is a replacement for the UUCP command >sendmail<.
- PGPSendMail reads the incoming message from standard input,
- checks if a key for the receipients is availabe and if, sends
- the encrypted messagt to the original sendmail for handling.
- @
-
-
- 1.28
- log
- @The confirmation of encryption can now be controlled by the
- ConfirmEncryption keyword in the uulib:config file.
- @
- text
- @/*
- * $Filename: PGPSendMail.c $
- * $Revision: 1.27 $
- * $Date: 1993/10/06 12:42:50 $
- *
- * This is a replacement for the UUCP command >sendmail<.
- * PGPSendMail reads the incoming message from standard input,
- * checks if a key for the receipients is availabe and if, sends
- * the encrypted messagt to the original sendmail for handling.
- *
- * © Copyright 1993 Peter Simons, Germany
- * All Rights Reserved
- *
- * $Id: PGPSendMail.c,v 1.27 1993/10/06 12:42:50 simons Exp simons $
- *
- * ------------------------------ log history ----------------------------
- * $Log: PGPSendMail.c,v $
- * Revision 1.27 1993/10/06 12:42:50 simons
- * The name of the program handling the mail after encryption is now
- * determined using the config-file or the appropiate env/local variable.
- *
- * Revision 1.25 1993/09/25 02:37:43 simons
- * PGPSendMail terminates immediatly, when OS 2.04 is not available.
- *
- * Revision 1.24 1993/09/24 22:53:41 simons
- * Moved TruncFile() to system.c.
- * Added call to ConfirmEncryption(), to let the user decide if the mail
- * should be encrypted or not.
- *
- * Revision 1.23 1993/09/14 22:06:02 simons
- * Thanks to my own cres.o and _main() routine, the commandline is now
- * provided to sendmail correctly.
- *
- * Revision 1.22 1993/09/14 17:28:15 simons
- * Changed code to work with the new startup-main().
- *
- * Revision 1.21 1993/09/13 17:29:49 simons
- * Minor optimizations in logfile handling.
- *
- * Revision 1.20 1993/09/08 23:08:16 simons
- * The log message "Not all receipients have..." is not debug level 1.
- *
- * Revision 1.19 1993/09/08 23:03:48 simons
- * FindKey() now calls a self-written routine stristr() instead of
- * strstr(), because the latter routine compared the strings case-
- * significant.
- *
- * Revision 1.18 1993/09/04 15:32:26 simons
- * Corrected a few typing mistakes.
- *
- * Revision 1.17 1993/09/03 14:35:08 simons
- * Added configfile support. Used keywords are UULib, Debug and LockDir.
- * LogLevel is controlled by the configfile. Default is 0.
- * Added various debug-messages.
- *
- * Revision 1.16 1993/09/03 02:05:51 simons
- * Changed style of log-messages to fit better with the uucp package.
- * Added a few log-messages.
- * Set the debug value to 255 per default. Future versions might use an
- * entry in a configfile.
- *
- * Revision 1.15 1993/09/03 01:33:35 simons
- * Added logfile support.
- * Straightened code concerning Amiga specific includes.
- *
- * Revision 1.14 1993/08/28 18:45:46 simons
- * Added alias-expansion support.
- *
- * Revision 1.13 1993/08/28 17:59:56 simons
- * PGPSendMail does not support the 'Bcc:'-line.
- *
- * Revision 1.12 1993/08/23 15:48:02 simons
- * Removed bug in ArrayToLine(): The contents of argvline had been trashed!
- * Removed some debugging output, as the routines are save now.
- *
- * Revision 1.11 1993/08/23 15:21:19 simons
- * Added a kludge to let PGPSendMail understand PGP-key-aliases. FindKey()
- * now searches for "pub " or "pub ". This may break with other versions
- * of PGP or on other systems. However, it works fine. :-)
- * Reduced the required amount of stack from 8k+ to less than 1200 byte.
- *
- * Revision 1.10 1993/08/23 13:47:36 simons
- * PGPSendMail now perfectly understands multiple line headers.
- *
- * Revision 1.9 1993/08/23 13:12:32 simons
- * Moved "PGPKey.lst"-file to "UULIB:".
- * Known bugs: - PGP aliases are not recognized! If someone has generated
- * his key with another address than usenet, and created
- * an alias later, he will not be found in the keyfile,
- * because FindKey() only test lines beginning with "pub".
- *
- * Revision 1.8 1993/08/23 13:05:01 simons
- * PGPSendMail now checks wether a public key for each receipient is
- * available and sends the message unencrypted if not.
- * The commandline is now preserved, even under error-condition.
- * Known Bugs: - If the "To:" and "Cc:" lines are split over several
- * lines, SplitAddresses() won't recognize them correctly.
- *
- * Revision 1.7 1993/08/22 17:53:02 simons
- * Known bugs: - If sendmail is called under an error-condition, the
- * original commandline is lost. Will be fixed soon.
- *
- * Revision 1.6 1993/08/22 17:48:33 simons
- * Changed a few situations from fatal to non-fatal errors.
- *
- * Revision 1.5 1993/08/22 17:46:12 simons
- * Error conditions are handled much better. If anything goes wrong, the
- * original mail is sent to sendmail instead of the failed encrypted
- * version.
- *
- * Revision 1.4 1993/08/22 17:38:34 simons
- * PGPSendMail now calls sendmail with exactly the same parameters he
- * has been called with.
- * Known bugs: - currently does not correct the "Lines:" keyword
- *
- * Revision 1.3 1993/08/22 17:12:11 simons
- * PGPSendMail works basically.
- * Known bugs: - Aliases aren't expanded before PGPSendMail tries to
- * determine the receipient. Hence the addresses won't be
- * found in the keyring.
- * - When sending (and encrypting) mail for multiple
- * receipients, PGP does not return any warning if one of
- * the receipients has no public key available, is just
- * skips him. Though you should only use PGPSendmail with
- * receipients having a key available. I'll try to modify
- *
- * Revision 1.2 1993/08/21 19:32:47 simons
- * The UUCP-message stuff is already working. I wrote a set of routines,
- * that seperate the receipients of a message out of the header and
- * skip anything but the address of them.
- * Using the address for identifying the user seems to be more reliable
- * than trying to get the realname.
- * At the moment I have to use unbuffered IO, because I have to reset
- * the position in the readfile several times, what is not supported
- * with my routines yet.
- *
- * Revision 1.1 1993/08/21 19:28:43 simons
- * Initial revision
- */
-
-
-
- /**************************************************************************
- * *
- * Sektion: Macros, Definitions, Includes, Structures *
- * *
- **************************************************************************/
-
- /************************************* Includes ***********/
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <string.h>
- #include <ctype.h>
-
- #include <proto/dos.h>
- #include <exec/execbase.h>
- #include <dos/dos.h>
-
- #include "expandalias.h"
- #include "SC:Sources/uucp.lib/include/config.h"
- #include "SC:Sources/uucp.lib/include/log.h"
-
- /************************************* Defines ************/
- #define PGP "PGP -fesa <%s >%s %s +batchmode"
- #define START_SENDMAIL "%s <%s %s"
- #define PGPKEYLIST "PGPKeys.lst"
-
- #define HEADER_ID "X-AutoEncrypt: PGPSendMail 1.x\n"
- #define BODY_ID "Automatically encrypted message-body follows:\n\n"
-
- #define MAX_RECEIPIENTS 256 /* max. number of receipients */
- #define LINEBUFFER 1024 /* max. line length */
- #define IOBUFSIZE BUFSIZ*10 /* size of internal IO buffer */
-
- #define CONFIRMENCRYPTION "ConfirmEncryption"
-
- #define my_ulog(level, name, msg) OpenLog(); ulog(level, name, msg); CloseLog();
- #define my_ulog2(level, msg) OpenLog(); ulog(level, msg); CloseLog();
-
- /************************************* Prototypes *********/
- void NonFatalError(char *);
- void error(char *, int);
- int getline(FILE *,char []);
- int CopyUntilEOF(FILE *, FILE *);
- char **FindReceipients(FILE *);
- char *FindHeaderEntry(FILE *, char *);
- void ParseAddressLines(char **receipients);
- void SplitAddressLine(char *line, char *receipients[]);
- int TruncFile(char *, int);
- char *ArrayToLine(char *array[]);
- int FindKey(char *key, char *keylist);
- int CheckKeyAvailability(char *receipients[]);
- char *stristr(char *, char *);
- int ConfirmEncryption(void);
-
- /************************************* global Variables ***/
- FILE *pipe1 = NULL, *pipe2 = NULL, *file = NULL;
- char PIPE1[L_tmpnam], PIPE2[L_tmpnam], FILENAME[L_tmpnam];
- char *argvline, *cmdbuf;
-
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.27 1993/10/06 12:42:50 simons Exp simons $";
-
- /**************************************************************************
- * *
- * Sektion: Hauptprogramm *
- * *
- **************************************************************************/
-
- int main(char *argv)
- {
- extern struct ExecBase *SysBase;
- char **receipients, *dummy;
- int body_pos;
-
- if (SysBase->LibNode.lib_Version < 37)
- error("Kickstart 2.04 or later is required!", 20);
-
- if((cmdbuf = malloc(LINEBUFFER*4)) == NULL)
- error("Couldn't allocate my buffer!", 10);
-
-
- /* Determine loglevel. */
-
- if ((dummy = FindConfig(DEBUGNAME)) == NULL)
- LogLevel = 0;
- else
- LogLevel = atoi(dummy);
-
-
- /*
- * Copy the passed arguments into an global Variable, so
- * NonFatalError() can access them.
- */
-
- argvline = argv;
-
-
- /*
- * Make unique filenames for the temporary files
- * and open them.
- */
-
- tmpnam(PIPE1);
- tmpnam(PIPE2);
- tmpnam(FILENAME);
-
- if ((file = fopen(FILENAME, "w+")) == NULL)
- error("Can't open temporary file!", 10);
-
-
- /*
- * Copy standard input to a temporary file for security reasons.
- */
-
- if (CopyUntilEOF(stdin, file) == 0)
- error("Can't write to my temporary file!", 10);
- my_ulog(2, "PGPSendMail, original mail in '%s'", FILENAME);
-
-
- /* Find receipients to determine who to encrypt to. */
-
- receipients = FindReceipients(file);
- if (receipients == NULL || *receipients == NULL)
- NonFatalError("Can't determine receipient of message");
- else
- my_ulog(2, "PGPSendMail, receipients (with aliases): %s", ArrayToLine(receipients));
-
- receipients = ExpandAliases(receipients);
- if (receipients == NULL || *receipients == NULL)
- NonFatalError("Can't determine receipient of message");
- else
- my_ulog(2, "PGPSendMail, receipients (aliases expanded): %s", ArrayToLine(receipients));
-
- if ((CheckKeyAvailability(receipients)) == 0) {
- my_ulog2(1, "Not all receipients have a valid public key");
- NonFatalError("");
- }
-
- if ( !(dummy = FindConfig(CONFIRMENCRYPTION)) || *dummy == 'y' || *dummy == 'Y' ) {
- if (!(ConfirmEncryption()))
- NonFatalError("Encryption denied by user");
- }
-
-
- /* Copy messagebody for encryption. */
-
- fseek(file, 0L, SEEK_SET);
- fflush(file);
-
- while((body_pos = getline(file, cmdbuf)) > 1)
- ;
- body_pos = ftell(file);
-
- if ((pipe1 = fopen(PIPE1, "w")) == NULL)
- NonFatalError("Can't open temporary file!");
- if (CopyUntilEOF(file, pipe1) == 0)
- NonFatalError("Can't write to my temporary file!");
- my_ulog(2, "PGPSendMail, copied message-body to '%s' for encryption", PIPE1);
-
-
- /* Encrypt message body. */
-
- sprintf(cmdbuf, PGP, PIPE1, PIPE2, ArrayToLine(receipients));
- my_ulog(1, "PGPSendMail, starting `%s'", cmdbuf);
- fprintf(stderr, "%s\n", cmdbuf);
- fclose(pipe1); pipe1 = NULL;
- if (system(cmdbuf) != 0)
- NonFatalError("PGP failed somehow");
- remove(PIPE1); /* Free some memory up. */
-
-
- /* Insert encrytpted message instead of text-body */
-
- if ((pipe2 = fopen(PIPE2, "r")) == NULL)
- NonFatalError("Can't open temporary file!");
- my_ulog(2, "PGPSendMail, copying modified mail to '%s'", FILENAME);
- fseek(file, body_pos, SEEK_SET);
- fflush(file);
- fprintf(file, BODY_ID);
- fflush(file);
- if (CopyUntilEOF(pipe2, file) == 0)
- error("Can't write to my temporary file!", 10);
- body_pos = ftell(file);
-
- fclose(pipe2); pipe2 = NULL; remove(PIPE2);
- fclose(file); file = NULL; /* Free up some memory. */
-
- if (TruncFile(FILENAME, body_pos) == 0)
- error("Truncating the original failed.", 10);
- my_ulog(-1, "PGPSendMail, succesfully encrypted a mail for %s", ArrayToLine(receipients));
-
-
- /* Call SendMail to handle the message. */
-
- sprintf(cmdbuf, START_SENDMAIL, GetConfigProgram(SENDMAIL), FILENAME, argvline);
- my_ulog(2, "PGPSendMail, starting '%s'", cmdbuf);
- body_pos = system(cmdbuf);
-
-
- /* Delete temporary files and leave. */
-
- remove(FILENAME);
- return body_pos; /* Return the code, given by sendmail. */
- }
-
-
- /**************************************************************************
- * *
- * Unterprogramme *
- * *
- **************************************************************************/
-
- void NonFatalError(char *message)
- {
- if (strlen(message) > 0) {
- my_ulog(-1, "PGPSendMail, %s", message);
- fprintf(stderr, "PGPSendMail: %s\n", message);
- }
-
- fclose(pipe1); remove(PIPE1);
- fclose(pipe2); remove(PIPE2);
- fclose(file);
-
- sprintf(cmdbuf, START_SENDMAIL, GetConfigProgram(SENDMAIL), FILENAME, argvline);
- my_ulog(2, "PGPSendMail, starting '%s'", cmdbuf);
- system(cmdbuf);
-
- remove(FILENAME);
- exit(0);
- }
-
- void error(char *message, int errorcode)
- {
- my_ulog(-1, "PGPSendMail, %s", message);
- fprintf(stderr, "PGPSendMail: %s\n", message);
- exit(errorcode);
- }
-
- int getline(FILE *file, char *buffer)
- {
- int c, i = 0;
-
- do {
- c = fgetc(file);
- *buffer = c;
- i++; buffer++;
- } while (i < LINEBUFFER && c != EOF && c != '\n');
-
- if (i >= LINEBUFFER)
- error("Buffer overflow!", 10);
-
- if (c == EOF && i == 1) {
- *(buffer-1) = '\0';
- return EOF;
- }
-
- if (c == '\n') {
- *buffer = '\0';
- return i;
- }
-
- }
-
-
- int CopyUntilEOF(FILE *in, FILE *out)
- {
- char *buffer;
- int len;
-
- if ((buffer = malloc(IOBUFSIZE)) == NULL)
- return 0;
-
- if (in != stdin)
- lseek(fileno(in), ftell(in), 0);
- if (out != stdout)
- lseek(fileno(out), ftell(out), 0);
-
- while ((len = read(fileno(in), buffer, IOBUFSIZE)) > 0)
- if (write(fileno(out), buffer, len) == -1) {
- free(buffer);
- return 0;
- }
-
- free(buffer);
- return 1;
- }
-
- char **FindReceipients(FILE *fh)
- {
- char **receipients, *line;
-
- if ((receipients = malloc(sizeof(char *[MAX_RECEIPIENTS]))) == NULL)
- NonFatalError("Couldn't allocate my buffer!");
- *receipients = NULL;
-
- if ((line = FindHeaderEntry(fh, "To: ")) != NULL)
- SplitAddressLine(line, receipients);
- if ((line = FindHeaderEntry(fh, "Cc: ")) != NULL)
- SplitAddressLine(line, receipients);
- ParseAddressLines(receipients);
-
- return receipients;
- }
-
- char *FindHeaderEntry(FILE *fh, char *entry)
- {
- char *line, *line_tmp;
- int len;
-
- if ((line = malloc(LINEBUFFER*4)) == NULL)
- return NULL;
- fflush(file);
- len = fseek(fh, 0L, SEEK_SET);
-
- len = getline(fh, line);
- while (len != 1 && len != EOF) {
- if (!strnicmp(line, entry, strlen(entry))) {
- line_tmp = line;
-
- /*
- * If the last character in the line is a ',',
- * change the '\n' to ' ' and append the next
- * line.
- */
-
- do {
- line_tmp = line_tmp+len-2;
- while (isspace(*line_tmp))
- line_tmp--;
- if (*line_tmp == ',') {
- *(line_tmp+1) = ' ';
- line_tmp += 2;
- len = getline(fh, line_tmp);
- }
- else
- return &line[strlen(entry)];
- } while (1); /* Forever! */
- }
- len = getline(fh, line);
- }
- free(line);
- return NULL;
- }
-
- void SplitAddressLine(char *line, char *receipients[])
- {
- int brackets, i;
-
- if (line == NULL || receipients == NULL)
- return;
-
- while (*receipients != NULL)
- receipients++;
-
- *receipients++ = line;
-
- for (i = 0, brackets = 0; line[i] != '\n'; i++) {
- if (line[i] == '(' && (i == 0 || isspace(line[i-1])))
- brackets = 1;
- if (line[i] == ')' && (line[i+1] == ',' || line[i+1] == '\n' || isspace(line[i+1])))
- brackets = 0;
- if (line[i] == ',' && brackets == 0) {
- line[i++] = '\0';
- while (isspace(line[i]))
- i++;
- *receipients++ = &line[i];
- }
- }
- line[i] = '\0';
- *receipients = NULL;
- }
-
-
- void ParseAddressLines(char **receipients)
- {
- char line[LINEBUFFER];
- int brackets, i, z;
-
- while (*receipients != NULL) {
- strcpy(line, *receipients);
- for (i = 0, z = 0, brackets = 0; line[i] != '\0'; i++) {
- if (line[i] == '(' && (i == 0 || isspace(line[i-1])))
- brackets++;
- if (line[i] == ')' && (line[i+1] == '\0' || isspace(line[i+1])))
- brackets--;
- if (line[i] == '<' && brackets == 0) {
- i++;
- while (1) { /* Forever! */
- if (line[i] == '>' && (line[i+1] == '\0' || isspace(line[i+1])))
- break;
- (*receipients)[z++] = line[i++];
- }
- (*receipients)[z] = '\0';
- break;
- }
- }
- if (z == 0) { /* No <address> occured. */
- i = 0;
- while (!isspace((*receipients)[i]))
- i++;
- (*receipients)[i] = '\0';
- }
- receipients++;
- }
- }
-
-
- char *ArrayToLine(char *array[])
- {
- char *line;
-
- if ((line = malloc(LINEBUFFER)) == NULL)
- return NULL;
- line[0] = '\0';
-
- while (*array != NULL) {
- strcat(line, *array);
- strcat(line, " ");
- array++;
- }
- return line;
- }
-
- int CheckKeyAvailability(char *receipients[])
- {
- FILE *fh;
- char *keylist, *filename;
- int filelength;
-
- if (*receipients == NULL)
- return 0; /* No receipient found! */
-
- filename = MakeConfigPath(UULIB, PGPKEYLIST);
- LockFile(filename);
-
- if ((fh = fopen(filename, "r")) == NULL) {
- UnLockFile(filename);
- return 0; /* Couldn't open keylist! */
- }
- fseek(fh, 0L, SEEK_END); filelength = ftell(fh);
- /* Determine filelength. */
-
-
- /* Allocate buffer and read keylist. */
-
- if (keylist = malloc(filelength+1)) {
- lseek(fileno(fh), 0, 0);
- if ((read(fileno(fh), keylist, filelength)) == -1) {
- fclose(fh); /* Couldn't read keylist. */
- UnLockFile(filename);
- free(keylist);
- return 0;
- }
- else { /* Read went fine. */
- fclose(fh);
- UnLockFile(filename);
- keylist[filelength] = '\0';
-
- while (*receipients != NULL) {
- if (FindKey(*receipients, keylist) == 0) {
- free(keylist);
- my_ulog(1, "PGPSendMail, No key available for <%s>", *receipients);
- return 0; /* Key is not in keylist. */
- }
- receipients++;
- }
- }
- }
- free(keylist);
- return 1; /* Everything is fine. */
- }
-
- int FindKey(char *key, char *keylist)
- {
- char line[LINEBUFFER];
- int i;
-
- while (*keylist != '\0') {
-
- /* Is this a valid key-line? */
-
- if (!strnicmp(keylist, "pub ", strlen("pub "))
- || !strnicmp(keylist, " ", strlen(" ")))
- {
- for(i = 0; keylist[i] != '\n'; i++)
- line[i] = keylist[i];
- line[i] = '\0';
- if (stristr(line, key))
- return 1;
- }
-
-
- /* Find end of line or end of buffer. */
-
- while (*keylist != '\n' && *keylist != '\0')
- keylist++;
- keylist++;
- }
- return 0;
- }
-
- char *stristr(char *line, char *key)
- {
- int i, cmplen = strlen(key), end = strlen(line)-cmplen;
-
- for (i = 0; i <= end; i++)
- if (strnicmp(&line[i], key, cmplen) == NULL)
- return &line[i];
- return NULL;
- }
-
- @
-
-
- 1.27
- log
- @The name of the program handling the mail after encryption is now
- determined using the config-file or the appropiate env/local variable.
- @
- text
- @d3 2
- a4 2
- * $Revision: 1.25 $
- * $Date: 1993/09/25 02:37:43 $
- d14 1
- a14 1
- * $Id: PGPSendMail.c,v 1.25 1993/09/25 02:37:43 simons Stab simons $
- d18 4
- d176 2
- d202 1
- a202 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.25 1993/09/25 02:37:43 simons Stab simons $";
- d213 1
- a213 2
- char **receipients;
- char *debuglevel;
- d225 1
- a225 1
- if ((debuglevel = FindConfig(DEBUGNAME)) == NULL)
- d228 1
- a228 1
- LogLevel = atoi(debuglevel);
- d280 5
- a284 2
- if (!(ConfirmEncryption()))
- NonFatalError("Encryption denied by user");
- @
-
-
- 1.26
- log
- @Changed format of RCS-Header.
- @
- text
- @d162 1
- a162 1
- #define START_SENDMAIL "sendmail <%s %s"
- d328 1
- a328 1
- sprintf(cmdbuf, START_SENDMAIL, FILENAME, argvline);
- d357 1
- a357 1
- sprintf(cmdbuf, START_SENDMAIL, FILENAME, argvline);
- @
-
-
- 1.25
- log
- @PGPSendMail terminates immediatly, when OS 2.04 is not available.
- @
- text
- @d1 135
- a135 132
- /**
- ** $Filename: PGPSendMail.c $
- ** $Revision: 1.24 $
- ** $Date: 1993/09/24 22:53:41 $
- **
- ** This is a replacement for the UUCP command >sendmail<.
- ** PGPSendMail reads the incoming message from standard input,
- ** checks if a key for the receipients is availabe and if, sends
- ** the encrypted messagt to the original sendmail for handling.
- **
- ** © Copyright 1993 Peter Simons, Germany
- ** All Rights Reserved
- **
- ** $Id: PGPSendMail.c,v 1.24 1993/09/24 22:53:41 simons Stab simons $
- **
- ** ------------------------------ log history ----------------------------
- ** $Log: PGPSendMail.c,v $
- ** Revision 1.24 1993/09/24 22:53:41 simons
- ** Moved TruncFile() to system.c.
- ** Added call to ConfirmEncryption(), to let the user decide if the mail
- ** should be encrypted or not.
- **
- ** Revision 1.23 1993/09/14 22:06:02 simons
- ** Thanks to my own cres.o and _main() routine, the commandline is now
- ** provided to sendmail correctly.
- **
- ** Revision 1.22 1993/09/14 17:28:15 simons
- ** Changed code to work with the new startup-main().
- **
- ** Revision 1.21 1993/09/13 17:29:49 simons
- ** Minor optimizations in logfile handling.
- **
- ** Revision 1.20 1993/09/08 23:08:16 simons
- ** The log message "Not all receipients have..." is not debug level 1.
- **
- ** Revision 1.19 1993/09/08 23:03:48 simons
- ** FindKey() now calls a self-written routine stristr() instead of
- ** strstr(), because the latter routine compared the strings case-
- ** significant.
- **
- ** Revision 1.18 1993/09/04 15:32:26 simons
- ** Corrected a few typing mistakes.
- **
- ** Revision 1.17 1993/09/03 14:35:08 simons
- ** Added configfile support. Used keywords are UULib, Debug and LockDir.
- ** LogLevel is controlled by the configfile. Default is 0.
- ** Added various debug-messages.
- **
- ** Revision 1.16 1993/09/03 02:05:51 simons
- ** Changed style of log-messages to fit better with the uucp package.
- ** Added a few log-messages.
- ** Set the debug value to 255 per default. Future versions might use an
- ** entry in a configfile.
- **
- ** Revision 1.15 1993/09/03 01:33:35 simons
- ** Added logfile support.
- ** Straightened code concerning Amiga specific includes.
- **
- ** Revision 1.14 1993/08/28 18:45:46 simons
- ** Added alias-expansion support.
- **
- ** Revision 1.13 1993/08/28 17:59:56 simons
- ** PGPSendMail does not support the 'Bcc:'-line.
- **
- ** Revision 1.12 1993/08/23 15:48:02 simons
- ** Removed bug in ArrayToLine(): The contents of argvline had been trashed!
- ** Removed some debugging output, as the routines are save now.
- **
- ** Revision 1.11 1993/08/23 15:21:19 simons
- ** Added a kludge to let PGPSendMail understand PGP-key-aliases. FindKey()
- ** now searches for "pub " or "pub ". This may break with other versions
- ** of PGP or on other systems. However, it works fine. :-)
- ** Reduced the required amount of stack from 8k+ to less than 1200 byte.
- **
- ** Revision 1.10 1993/08/23 13:47:36 simons
- ** PGPSendMail now perfectly understands multiple line headers.
- **
- ** Revision 1.9 1993/08/23 13:12:32 simons
- ** Moved "PGPKey.lst"-file to "UULIB:".
- ** Known bugs: - PGP aliases are not recognized! If someone has generated
- ** his key with another address than usenet, and created
- ** an alias later, he will not be found in the keyfile,
- ** because FindKey() only test lines beginning with "pub".
- **
- ** Revision 1.8 1993/08/23 13:05:01 simons
- ** PGPSendMail now checks wether a public key for each receipient is
- ** available and sends the message unencrypted if not.
- ** The commandline is now preserved, even under error-condition.
- ** Known Bugs: - If the "To:" and "Cc:" lines are split over several
- ** lines, SplitAddresses() won't recognize them correctly.
- **
- ** Revision 1.7 1993/08/22 17:53:02 simons
- ** Known bugs: - If sendmail is called under an error-condition, the
- ** original commandline is lost. Will be fixed soon.
- **
- ** Revision 1.6 1993/08/22 17:48:33 simons
- ** Changed a few situations from fatal to non-fatal errors.
- **
- ** Revision 1.5 1993/08/22 17:46:12 simons
- ** Error conditions are handled much better. If anything goes wrong, the
- ** original mail is sent to sendmail instead of the failed encrypted
- ** version.
- **
- ** Revision 1.4 1993/08/22 17:38:34 simons
- ** PGPSendMail now calls sendmail with exactly the same parameters he
- ** has been called with.
- ** Known bugs: - currently does not correct the "Lines:" keyword
- **
- ** Revision 1.3 1993/08/22 17:12:11 simons
- ** PGPSendMail works basically.
- ** Known bugs: - Aliases aren't expanded before PGPSendMail tries to
- ** determine the receipient. Hence the addresses won't be
- ** found in the keyring.
- ** - When sending (and encrypting) mail for multiple
- ** receipients, PGP does not return any warning if one of
- ** the receipients has no public key available, is just
- ** skips him. Though you should only use PGPSendmail with
- ** receipients having a key available. I'll try to modify
- **
- ** Revision 1.2 1993/08/21 19:32:47 simons
- ** The UUCP-message stuff is already working. I wrote a set of routines,
- ** that seperate the receipients of a message out of the header and
- ** skip anything but the address of them.
- ** Using the address for identifying the user seems to be more reliable
- ** than trying to get the realname.
- ** At the moment I have to use unbuffered IO, because I have to reset
- ** the position in the readfile several times, what is not supported
- ** with my routines yet.
- **
- ** Revision 1.1 1993/08/21 19:28:43 simons
- ** Initial revision
- **/
- d196 1
- a196 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.24 1993/09/24 22:53:41 simons Stab simons $";
- @
-
-
- 1.24
- log
- @Moved TruncFile() to system.c.
- Added call to ConfirmEncryption(), to let the user decide if the mail
- should be encrypted or not.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.23 $
- ** $Date: 1993/09/14 22:06:02 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.23 1993/09/14 22:06:02 simons Stab simons $
- d18 5
- d149 2
- d152 1
- a152 1
- #include <proto/dos.h>
- d189 3
- a191 3
- FILE *pipe1 = NULL, *pipe2 = NULL, *file = NULL;
- char PIPE1[L_tmpnam], PIPE2[L_tmpnam], FILENAME[L_tmpnam];
- char *argvline, *cmdbuf;
- d193 1
- a193 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.23 1993/09/14 22:06:02 simons Stab simons $";
- d203 1
- d207 3
- @
-
-
- 1.23
- log
- @Thanks to my own cres.o and _main() routine, the commandline is now
- provided to sendmail correctly.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.22 $
- ** $Date: 1993/09/14 17:28:15 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.22 1993/09/14 17:28:15 simons Exp simons $
- d18 4
- d179 1
- d186 1
- a186 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.22 1993/09/14 17:28:15 simons Exp simons $";
- d261 3
- a525 16
-
- int TruncFile(char *filename, int pos)
- /*
- * Function: This routine truncates a file at a given positition.
- * Comment : AmigaDOS v2.04+ is required.
- */
- {
- BPTR fh;
-
- if ((fh = Open(FILENAME, MODE_OLDFILE)) == NULL)
- return 0;
-
- pos = SetFileSize(fh, pos, OFFSET_BEGINNING);
- Close(fh);
- return (pos == -1) ? 0 : 1;
- }
- @
-
-
- 1.22
- log
- @Changed code to work with the new startup-main().
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.21 $
- ** $Date: 1993/09/13 17:29:49 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.21 1993/09/13 17:29:49 simons Exp simons $
- d18 3
- d181 1
- a181 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.21 1993/09/13 17:29:49 simons Exp simons $";
- @
-
-
- 1.21
- log
- @Minor optimizations in logfile handling.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.20 $
- ** $Date: 1993/09/08 23:08:16 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.20 1993/09/08 23:08:16 simons Exp simons $
- d18 3
- d178 1
- a178 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.20 1993/09/08 23:08:16 simons Exp simons $";
- d186 1
- a186 1
- int main(int argc, char *argv[])
- d209 1
- a209 1
- argvline = ArrayToLine(&argv[1]);
- @
-
-
- 1.20
- log
- @The log message "Not all receipients have..." is not debug level 1.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.19 $
- ** $Date: 1993/09/08 23:03:48 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.19 1993/09/08 23:03:48 simons Exp simons $
- d18 3
- d152 2
- a153 1
- #define my_ulog(level, name, msg) OpenLog(); ulog(level, name, msg); CloseLog()
- d175 1
- a175 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.19 1993/09/08 23:03:48 simons Exp simons $";
- d246 1
- a246 3
- OpenLog();
- ulog(1, "Not all receipients have a valid public key");
- CloseLog();
- @
-
-
- 1.19
- log
- @FindKey() now calls a self-written routine stristr() instead of
- strstr(), because the latter routine compared the strings case-
- significant.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.18 $
- ** $Date: 1993/09/04 15:32:26 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.18 1993/09/04 15:32:26 simons Stab simons $
- d18 5
- d171 1
- a171 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.18 1993/09/04 15:32:26 simons Stab simons $";
- d241 6
- a246 2
- if ((CheckKeyAvailability(receipients)) == 0)
- NonFatalError("Not all receipients have a valid public key");
- @
-
-
- 1.18
- log
- @Corrected a few typing mistakes.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.17 $
- ** $Date: 1993/09/03 14:35:08 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.17 1993/09/03 14:35:08 simons Stab simons $
- d18 3
- d159 1
- d166 1
- a166 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.17 1993/09/03 14:35:08 simons Stab simons $";
- a587 3
- if(line == NULL)
- NonFatalError("Couldn't allocate my buffer!");
-
- d598 1
- a598 1
- if (strstr(line, key))
- d610 10
- @
-
-
- 1.17
- log
- @Added configfile support. Used keywords are UULib, Debug and LockDir.
- LogLevel is controlled by the configfile. Default is 0.
- Added varius debug-messages.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.16 $
- ** $Date: 1993/09/03 02:05:51 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.16 1993/09/03 02:05:51 simons Exp simons $
- d18 5
- d162 1
- a162 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.16 1993/09/03 02:05:51 simons Exp simons $";
- d280 1
- @
-
-
- 1.16
- log
- @Changed style of log-messages to fit better with the uucp package.
- Added a few log-messages.
- Set the debug value to 255 per default. Future versions might use an
- entry in a configfile.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.15 $
- ** $Date: 1993/09/03 01:33:35 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.15 1993/09/03 01:33:35 simons Exp simons $
- d18 6
- d117 5
- d125 10
- a134 10
- #define PGP "PGP -fesa <%s >%s %s +batchmode"
- #define SENDMAIL "sendmail <%s %s"
- #define PGPKEYLIST "UULIB:PGPKeys.lst"
-
- #define HEADER_ID "X-AutoEncrypt: PGPSendMail 1.x\n"
- #define BODY_ID "Automatically encrypted message-body follows:\n\n"
-
- #define MAX_RECEIPIENTS 256 /* max. number of receipients */
- #define LINEBUFFER 1024 /* max. line length */
- #define IOBUFSIZE BUFSIZ*10 /* size of internal IO buffer */
- a138 5
- #ifdef AMIGA
- #include <proto/dos.h>
- #endif
- #include "expandalias.h"
-
- d157 1
- a157 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.15 1993/09/03 01:33:35 simons Exp simons $";
- d168 1
- a170 2
- LogLevel = 255;
-
- d175 8
- d208 1
- a208 1
- if (CopyUntilEOF(stdin, file) == NULL)
- d210 1
- d218 2
- d224 2
- d227 1
- a227 1
- if ((CheckKeyAvailability(receipients)) == NULL)
- d241 1
- a241 1
- if (CopyUntilEOF(file, pipe1) == NULL)
- d243 1
- d252 1
- a252 1
- if (system(cmdbuf) != NULL)
- d261 1
- d266 1
- a266 1
- if (CopyUntilEOF(pipe2, file) == NULL)
- d273 1
- a273 1
- if (TruncFile(FILENAME, body_pos) == NULL)
- d279 2
- a280 1
- sprintf(cmdbuf, SENDMAIL, FILENAME, argvline);
- d308 2
- a309 1
- sprintf(cmdbuf, SENDMAIL, FILENAME, argvline);
- d527 1
- a527 1
- char *keylist;
- d532 6
- a537 1
- if ((fh = fopen(PGPKEYLIST, "r")) == NULL)
- d539 1
- d550 1
- d556 1
- d560 1
- a560 1
- if (FindKey(*receipients, keylist) == NULL) {
- @
-
-
- 1.15
- log
- @Added logfile support.
- Straightened code concerning Amiga specific includes.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.14 $
- ** $Date: 1993/08/28 18:45:46 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.14 1993/08/28 18:45:46 simons Stab simons $
- d18 4
- d151 1
- a151 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.14 1993/08/28 18:45:46 simons Stab simons $";
- d164 2
- d203 1
- a203 1
- NonFatalError("Can't determine receipient of message!");
- d207 1
- a207 1
- NonFatalError("Can't determine receipient of message!");
- d210 1
- a210 1
- NonFatalError("Not all receipients have a valid public key!");
- d230 1
- a230 1
- my_ulog(-1, "PGPSendMail, starting `%s'", cmdbuf);
- d234 1
- a234 1
- NonFatalError("PGP failed somehow!");
- d279 2
- a280 4
- OpenLog();
- my_ulog(-1, "PGPRMail, %s", message);
- fprintf(stderr, "PGPRMail: %s\n", message);
- CloseLog();
- d296 2
- a297 4
- OpenLog();
- my_ulog(-1, "PGPRMail, %s", message);
- fprintf(stderr, "PGPRMail: %s\n", message);
- CloseLog();
- d355 1
- a355 1
- NonFatalError("Failed allocating my buffers!");
- d532 1
- @
-
-
- 1.14
- log
- @Added alias-expansion support.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.13 $
- ** $Date: 1993/08/28 17:59:56 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.13 1993/08/28 17:59:56 simons Exp simons $
- d18 3
- d107 1
- a107 5
-
- #ifdef AMIGA
- #include <dos/exall.h>
- #include <utility/tagitem.h>
- #endif
- d121 2
- d147 1
- a147 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.13 1993/08/28 17:59:56 simons Exp simons $";
- d224 1
- d254 1
- a254 1
- system(cmdbuf);
- d260 1
- a260 1
- return 0;
- d272 6
- a277 2
- if (strlen(message) > 0)
- fprintf(stderr, "PGPSendMail: %s\n", message);
- d292 2
- d295 1
- @
-
-
- 1.13
- log
- @PGPSendMail does not support the 'Bcc:'-line.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.12 $
- ** $Date: 1993/08/23 15:48:02 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.12 1993/08/23 15:48:02 simons Exp simons $
- d18 3
- d126 1
- d146 1
- a146 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.12 1993/08/23 15:48:02 simons Exp simons $";
- d195 4
- @
-
-
- 1.12
- log
- @Removed bug in ArrayToLine(): The contents of argvline had been trashed!
- Removed some debugging output, as the routines are save now.
- @
- text
- @a0 8
- echo; /* Execute to compile with SAS/C v6.x
-
- SC PGPSendMail.c DEFINE=AMIGA STARTUP=cres DEBUG=FF LINK STRICT PARAMETERS=REGISTERS ; NOSTACKCHECK STRINGMERGE OPTIMIZE OPTIMIZERSIZE NOOPTIMIZERINLINE OPTIMIZERCOMPLEXITY=5 OPTIMIZERDEPTH=5 OPTIMIZERRECURDEPTH=5
- delete PGPSendMail.lnk PGPSendMail.o
- quit
-
- */
-
- d3 2
- a4 2
- ** $Revision: 1.11 $
- ** $Date: 1993/08/23 15:21:19 $
- d14 1
- a14 1
- ** $Id: PGPSendMail.c,v 1.11 1993/08/23 15:21:19 simons Exp simons $
- d18 4
- a102 1
- #include <dos/dos.h>
- a104 1
- #include <proto/dos.h>
- d120 4
- d142 1
- a151 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.11 1993/08/23 15:21:19 simons Exp simons $";
- @
-
-
- 1.11
- log
- @Added a kludge to let PGPSendMail understand PGP-key-aliases. FindKey()
- now searches for "pub " or "pub ". This may break with other versions
- of PGP or on other systems. However, it works fine. :-)
- Reduced the required amount of stack from 8k+ to less than 1200 byte.
- @
- text
- @d11 2
- a12 2
- ** $Revision: 1.10 $
- ** $Date: 1993/08/23 13:47:36 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.10 1993/08/23 13:47:36 simons Exp simons $
- d26 6
- d153 1
- a153 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.10 1993/08/23 13:47:36 simons Exp simons $";
- d471 1
- a471 1
- char line[LINEBUFFER];
- d473 2
- @
-
-
- 1.10
- log
- @PGPSendMail now perfectly understands multiple line headers.
- @
- text
- @d3 1
- a3 1
- SC PGPSendMail.c DEFINE=AMIGA STARTUP=cres DEBUG=FF LINK STRICT PARAMETERS=REGISTERS NOSTACKCHECK STRINGMERGE ; OPTIMIZE OPTIMIZERSIZE NOOPTIMIZERINLINE OPTIMIZERCOMPLEXITY=5 OPTIMIZERDEPTH=5 OPTIMIZERRECURDEPTH=5
- d11 2
- a12 2
- ** $Revision: 1.9 $
- ** $Date: 1993/08/23 13:12:32 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.9 1993/08/23 13:12:32 simons Exp simons $
- d26 3
- d136 1
- a136 1
- char *argvline;
- d147 2
- a148 2
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.9 1993/08/23 13:12:32 simons Exp simons $";
- char **receipients, cmdbuf[LINEBUFFER*4];
- d151 4
- d228 5
- a232 1
- body_pos = ftell(file); fclose(file); file = NULL;
- a238 2
- fclose(pipe2); remove(PIPE2); /* Free some memory up. */
- fclose(file);
- a257 2
- char cmdbuf[LINEBUFFER*4];
-
- d335 4
- a338 4
- line = FindHeaderEntry(fh, "To: ");
- SplitAddressLine(line, receipients);
- line = FindHeaderEntry(fh, "Cc: ");
- SplitAddressLine(line, receipients);
- d388 3
- d465 1
- a465 1
- char *line;
- a466 2
- if((line = malloc(LINEBUFFER)) == NULL)
- return NULL;
- d501 1
- a501 1
- fclose(fh); fh = NULL;
- d522 3
- d529 3
- a531 1
- if (!strnicmp(keylist, "pub ", strlen("pub "))) {
- d548 1
- @
-
-
- 1.9
- log
- @Moved "PGPKey.lst"-file to "UULIB:".
- Known bugs: - PGP aliases are not recognized! If someone has generated
- his key with another address than usenet, and created
- an alias later, he will not be found in the keyfile,
- because FindKey() only test lines beginning with "pub".
- @
- text
- @d11 2
- a12 2
- ** $Revision: 1.8 $
- ** $Date: 1993/08/23 13:05:01 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.8 1993/08/23 13:05:01 simons Exp simons $
- d26 7
- d38 1
- a38 1
- ** lines, SplitAddresses won't recognize them correctly.
- d113 1
- a113 1
- #define LINEBUFFER 256 /* max. line length */
- d144 1
- a144 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.8 1993/08/23 13:05:01 simons Exp simons $";
- d249 1
- a249 1
- char cmdbuf[LINEBUFFER];
- d339 1
- a339 1
- char *line;
- d342 1
- a342 1
- if ((line = malloc(LINEBUFFER)) == NULL)
- d349 22
- a370 2
- if (!strnicmp(line, entry, strlen(entry)))
- return &line[strlen(entry)];
- @
-
-
- 1.8
- log
- @PGPSendMail now checks wether a public key for each receipient is
- available and sends the message unencrypted if not.
- The commandline is now preserved, even under error-condition.
- Known Bugs: - If the "To:" and "Cc:" lines are split over several
- lines, SplitAddresses won't recognize them correctly.
- @
- text
- @d11 2
- a12 2
- ** $Revision: 1.7 $
- ** $Date: 1993/08/22 17:53:02 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.7 1993/08/22 17:53:02 simons Stab simons $
- d26 7
- d100 1
- a100 1
- #define PGPKEYLIST "UUMAIL:PGPKeys.lst"
- d137 1
- a137 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.7 1993/08/22 17:53:02 simons Stab simons $";
- @
-
-
- 1.7
- log
- @Known bugs: - If sendmail is called under an error-condition, the
- original commandline is lost. Will be fixed soon.
- @
- text
- @d11 2
- a12 2
- ** $Revision: 1.6 $
- ** $Date: 1993/08/22 17:48:33 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.6 1993/08/22 17:48:33 simons Stab simons $
- d26 4
- d93 1
- d113 2
- d119 1
- d130 1
- a130 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.6 1993/08/22 17:48:33 simons Stab simons $";
- d135 8
- d166 1
- a166 1
- if (*receipients == NULL)
- d169 2
- d216 1
- a216 1
- sprintf(cmdbuf, SENDMAIL, FILENAME, ArrayToLine(&argv[1]));
- d244 1
- a244 1
- sprintf(cmdbuf, SENDMAIL, FILENAME, "");
- d435 66
- @
-
-
- 1.6
- log
- @Changed a few situations from fatal to non-fatal errors.
- @
- text
- @d11 2
- a12 2
- ** $Revision: 1.5 $
- ** $Date: 1993/08/22 17:46:12 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.5 1993/08/22 17:46:12 simons Stab simons $
- d26 3
- d122 1
- a122 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.5 1993/08/22 17:46:12 simons Stab simons $";
- d217 2
- d226 1
- a226 1
- sprintf(cmdbuf, SENDMAIL, FILENAME, ArrayToLine(&argv[1]));
- @
-
-
- 1.5
- log
- @Error conditions are handled much better. If anything goes wrong, the
- original mail is sent to sendmail instead of the failed encrypted
- version.
- @
- text
- @d11 2
- a12 2
- ** $Revision: 1.4 $
- ** $Date: 1993/08/22 17:38:34 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.4 1993/08/22 17:38:34 simons stab simons $
- d26 5
- d119 1
- a119 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.4 1993/08/22 17:38:34 simons stab simons $";
- d179 1
- a179 1
- error("Can't open temporary file!", 10);
- @
-
-
- 1.4
- log
- @PGPSendMail now calls sendmail with exactly the same parameters he
- has been called with.
- Known bugs: - currently does not correct the "Lines:" keyword
- @
- text
- @d11 2
- a12 2
- ** $Revision: 1.3 $
- ** $Date: 1993/08/22 17:12:11 $
- d22 1
- a22 1
- ** $Id: PGPSendMail.c,v 1.3 1993/08/22 17:12:11 simons Stab simons $
- d26 5
- d114 1
- a114 1
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.3 1993/08/22 17:12:11 simons Stab simons $";
- d180 1
- a180 1
- NonFatalError("Can't write to my temporary file!");
- d183 1
- a183 1
- NonFatalError("Truncating the original failed.");
- d214 1
- a214 1
- fclose(file); remove(FILENAME);
- d216 4
- a219 1
- fprintf(stderr, "Calling sendmail with unmodified file!\n");
- @
-
-
- 1.3
- log
- @PGPSendMail works basically.
- Known bugs: - Aliases aren't expanded before PGPSendMail tries to
- determine the receipient. Hence the addresses won't be
- found in the keyring.
- - When sending (and encrypting) mail for multiple
- receipients, PGP does not return any warning if one of
- the receipients has no public key available, is just
- skips him. Though you should only use PGPSendmail with
- receipients having a key available. I'll try to modify
- @
- text
- @d11 2
- a12 2
- ** $Revision$
- ** $Date$
- d22 1
- a22 1
- ** $Id$
- d26 11
- d94 1
- d109 2
- a110 2
- static const char __RCSId[] = "$Id$"
- char **receipients, line[LINEBUFFER*4], cmdbuf[LINEBUFFER*4];
- d146 1
- a146 1
- while((body_pos = getline(file, line)) > 1)
- d158 1
- a158 8
- line[0] = '\0';
- while (*receipients != NULL) {
- strcat(line, *receipients);
- strcat(line, " ");
- receipients++;
- }
-
- sprintf(cmdbuf, PGP, PIPE1, PIPE2, line);
- d185 1
- a185 2
- fprintf(stderr, "%s\n", cmdbuf);
- sprintf(cmdbuf, SENDMAIL, FILENAME, "");
- d191 1
- a191 1
- /* remove(FILENAME); */
- d381 16
- @
-
-
- 1.2
- log
- @The UUCP-message stuff is already working. I wrote a set of routines,
- that seperate the receipients of a message out of the header and
- skip anything but the address of them.
- Using the address for identifying the user seems to be more reliable
- than trying to get the realname.
- At the moment I have to use unbuffered IO, because I have to reset
- the position in the readfile several times, what is not supported
- with my routines yet.
- @
- text
- @d3 1
- a3 1
- SC PGPSendMail.c STARTUP=cres DEBUG=FF LINK STRICT PARAMETERS=REGISTERS NOSTACKCHECK STRINGMERGE ; OPTIMIZE OPTIMIZERSIZE NOOPTIMIZERINLINE OPTIMIZERCOMPLEXITY=5 OPTIMIZERDEPTH=5 OPTIMIZERRECURDEPTH=5
- d22 1
- a22 1
- ** $Id $
- d26 10
- d55 6
- d64 1
- a64 1
- #define RMAIL "SendMail <%s %s"
- d67 1
- d77 1
- a77 1
- int CopyUntilEOF(int, int);
- d82 1
- d85 1
- a85 1
- FILE *pipe1, *pipe2, *file;
- d97 3
- a99 2
- static const char __RCSId[] = "$Id: PGPSendMail.c,v 1.1 1993/08/21 19:28:43 simons Exp simons $";
- char **receipients;
- a109 4
- if ((pipe1 = fopen(PIPE1, "w")) == NULL)
- error("Can't open temporary file!", 10);
- if ((pipe2 = fopen(PIPE2, "w")) == NULL)
- error("Can't open temporary file!", 10);
- d118 1
- a118 1
- if (CopyUntilEOF(fileno(stdin), fileno(file)) == NULL)
- d122 2
- d125 8
- d134 13
- d148 3
- a150 1
- printf("%s\n", *receipients++);
- d153 7
- d161 1
- a161 1
- /* Delete temporary files. */
- d163 21
- a183 1
- fprintf(stderr, "Calling sendmail with modified file!\n");
- d185 1
- a185 3
- fclose(pipe1); remove(PIPE1);
- fclose(pipe2); remove(PIPE2);
- fclose(file); remove(FILENAME);
- d187 2
- a188 1
- return 0; /* flag contains the return code of rmail */
- d243 1
- a243 1
- int CopyUntilEOF(int in, int out)
- d251 7
- a257 2
- while ((len = read(in, buffer, IOBUFSIZE)) > 0)
- if (write(out, buffer, len) == -1) {
- d290 1
- d360 17
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d25 3
- a27 1
- ** $Log$
- d79 1
- a79 1
- static const char __RCSId[] = "$Id$";
- @
-