From f8f226f65276f1c645eff2d6edb48c8d6caf2256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 4 Oct 2003 23:31:05 +0000 Subject: Version bump. New 'default' keyword for indentities (Vitezslav Batrla). Documentation updates. --- NEWS | 7 +++++++ README | 31 ++++++++++++++++++++++--------- configure.ac | 2 +- esmtp.1 | 5 ++++- esmtprc.5 | 5 +++-- lexer.l | 2 ++ message.c | 6 ------ parser.y | 45 +++++++++++++++++++++++++++++++-------------- smtp.c | 18 ++++++++++++------ 9 files changed, 82 insertions(+), 39 deletions(-) diff --git a/NEWS b/NEWS index 45cece6..11e06af 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,13 @@ News ~~~~ + * Version 0.4.2 (under development): + + * Fixed a bug which prevented to send mail when libesmtp had no + openssl support (Tomas Kondor). + + * New 'default' keyword for identities (Vitezslav Batrla). + * Version 0.4.1 (2004-07-14): * Packaging fixes. diff --git a/README b/README index 9e3c896..f2b9e12 100644 --- a/README +++ b/README @@ -22,22 +22,35 @@ Configuration ~~~~~~~~~~~~~ -* Sample configuration file -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Sample configuration files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a simple configuration file for a quick start: -------------------------------------- hostname = mail.myisp.com:25 -username = "myusername" -password = "mysecret" +username = "myself" +password = "secret" starttls = enabled -identity = myself@somewhere.com - hostname = smtp.somewhere.com:25 - username = "myself" - password = "secret" - starttls = enabled +mda "/usr/bin/procmail -d %T" +-------------------------------------- + + If you have more than one SMTP account you have them automatically chosen for + you: + +-------------------------------------- +identity myself@myisp.com + hostname mail.myisp.com:25 + username "myself" + password "secret" + starttls enabled + default + +identity myself@anotherisp.com + hostname smtp.anotherisp.com:25 + username "myself" + password "secret" mda "/usr/bin/procmail -d %T" -------------------------------------- diff --git a/configure.ac b/configure.ac index 285a0c1..21ae6a0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.53) -AC_INIT(esmtp, 0.4.1) +AC_INIT(esmtp, 0.4.2) AC_CONFIG_SRCDIR(Makefile.am) AM_INIT_AUTOMAKE(1.7 dist-bzip2) AM_MAINTAINER_MODE diff --git a/esmtp.1 b/esmtp.1 index 52bf591..0e0ed46 100644 --- a/esmtp.1 +++ b/esmtp.1 @@ -126,7 +126,10 @@ recipient for delivery status notifications and may also appear in a Return-Path: header. This address is also used to select from different identities in the -configuration file. +configuration file. + +If no envelope sender is specified in the command line then the default +identity's address is used. .TP \fB\-G\fR (ignored) diff --git a/esmtprc.5 b/esmtprc.5 index 00ccccf..2bf6a01 100644 --- a/esmtprc.5 +++ b/esmtprc.5 @@ -84,8 +84,9 @@ An identity is a set of options associated with a given address. For example: Identities are be selected by the address specified in the \fB\-f\fR flag. You can have as many you like. -The options up to the first \fBidentity\fR option constitute the default -identity. +The options in the global section (up to the first \fBidentity\fR option) +constitute the default identity. If no options in the global section are given +then the first defined identity is taken as the default one. Note that the default identity settings are not shared by the other identities. Everything (username, password, etc.) must be specified for every identity even diff --git a/lexer.l b/lexer.l index d655807..1a269f8 100644 --- a/lexer.l +++ b/lexer.l @@ -68,6 +68,8 @@ disabled { return DISABLED; } enabled { return ENABLED; } required { return REQUIRED; } +default { return DEFAULT; } + (#.*)?\\?\n { lineno++; } /* newline is ignored */ -?[0-9]+/[^a-zA-Z] { yylval.number = atoi(yytext); return NUMBER; } diff --git a/message.c b/message.c index 9191218..0162bca 100644 --- a/message.c +++ b/message.c @@ -335,13 +335,7 @@ unsigned message_parse_headers(message_t *message) start = stop; if(line[0] == '\n') - { - printf("size: %d\n", message->buffer_size); - printf("start: %d\n", message->buffer_start); - printf("stop: %d\n", message->buffer_stop); - return count; - } } } diff --git a/parser.y b/parser.y index 61eb173..fdbb769 100644 --- a/parser.y +++ b/parser.y @@ -20,20 +20,33 @@ #include "xmalloc.h" -/* parser reads these */ +/** Path name of dot file */ +static const char *rcfile = NULL; -static const char *rcfile = NULL; /* path name of dot file */ - -/* parser sets these */ -int yydebug; /* in case we didn't generate with -- debug */ +int yydebug; /**< in case we didn't generate with -- debug */ static identity_t *identity = NULL; +/** + * Utility macro to set the default identity, if one isn't set yet. + * + * It's necessary for compatability with older configurations files where the + * default identity was defined in a global section, instead of defined by the + * 'default' or the first defined identity, if no 'default' keyword is given. + */ +#define SET_DEFAULT_IDENTITY \ +do { \ + if(!default_identity) \ + default_identity = identity; \ +} while(0) + /* using Bison, this arranges that yydebug messages will show actual tokens */ extern char * yytext; #define YYPRINT(fp, type, val) fprintf(fp, " = \"%s\"", yytext) void yyerror (const char *s); + + %} %union { @@ -41,7 +54,7 @@ void yyerror (const char *s); char *sval; } -%token IDENTITY HOSTNAME USERNAME PASSWORD STARTTLS CERTIFICATE_PASSPHRASE MDA +%token IDENTITY DEFAULT HOSTNAME USERNAME PASSWORD STARTTLS CERTIFICATE_PASSPHRASE MDA %token MAP @@ -80,14 +93,15 @@ statement_list : statement ; /* future global options should also have the form SET optmap */ -statement : HOSTNAME map STRING { identity->host = xstrdup($3); } - | USERNAME map STRING { identity->user = xstrdup($3); } - | PASSWORD map STRING { identity->pass = xstrdup($3); } - | STARTTLS map DISABLED { identity->starttls = Starttls_DISABLED; } - | STARTTLS map ENABLED { identity->starttls = Starttls_ENABLED; } - | STARTTLS map REQUIRED { identity->starttls = Starttls_REQUIRED; } - | CERTIFICATE_PASSPHRASE map STRING { identity->certificate_passphrase = xstrdup($3); } +statement : HOSTNAME map STRING { identity->host = xstrdup($3); SET_DEFAULT_IDENTITY; } + | USERNAME map STRING { identity->user = xstrdup($3); SET_DEFAULT_IDENTITY; } + | PASSWORD map STRING { identity->pass = xstrdup($3); SET_DEFAULT_IDENTITY; } + | STARTTLS map DISABLED { identity->starttls = Starttls_DISABLED; SET_DEFAULT_IDENTITY; } + | STARTTLS map ENABLED { identity->starttls = Starttls_ENABLED; SET_DEFAULT_IDENTITY; } + | STARTTLS map REQUIRED { identity->starttls = Starttls_REQUIRED; SET_DEFAULT_IDENTITY; } + | CERTIFICATE_PASSPHRASE map STRING { identity->certificate_passphrase = xstrdup($3); SET_DEFAULT_IDENTITY; } | MDA map STRING { mda = xstrdup($3); } + | DEFAULT { default_identity = identity; } ; %% @@ -174,10 +188,13 @@ void rcfile_parse(const char *_rcfile) success: /* Configuration file opened */ - identity = default_identity; + identity = identity_new(); + identity_add(identity); yyparse(); /* parse entire file */ + SET_DEFAULT_IDENTITY; + fclose(yyin); /* not checking this should be safe, file mode was r */ rcfile = NULL; diff --git a/smtp.c b/smtp.c index b358f46..14f1df6 100644 --- a/smtp.c +++ b/smtp.c @@ -80,7 +80,7 @@ identity_t *identity_lookup(const char *address) identity_t *identity; identity = list_entry(ptr, identity_t, list); - if(!strcmp(identity->address, address)) + if(identity->address && !strcmp(identity->address, address)) return identity; } } @@ -90,13 +90,11 @@ identity_t *identity_lookup(const char *address) void identities_init(void) { - default_identity = identity_new(); } void identities_cleanup(void) { - if(default_identity) - identity_free(default_identity); + default_identity = NULL; if(!list_empty(&identities)) { @@ -389,8 +387,16 @@ void smtp_send(message_t *msg) goto failure; /* Set the reverse path for the mail envelope. (NULL is ok) */ - if(!smtp_set_reverse_path (message, msg->reverse_path)) - goto failure; + if(msg->reverse_path) + { + if(!smtp_set_reverse_path (message, msg->reverse_path)) + goto failure; + } + else + { + if(!smtp_set_reverse_path (message, identity->address)) + goto failure; + } /* Open the message file and set the callback to read it. */ if(!smtp_set_messagecb (message, message_cb, msg)) -- cgit v1.2.3-2-g168b