diff options
author | martin <martin> | 2006-06-15 20:52:05 +0000 |
---|---|---|
committer | martin <martin> | 2006-06-15 20:52:05 +0000 |
commit | 53b24556011f712b9ad559eda0f29f6c753049b9 (patch) | |
tree | 908d19c2f0bd1da266c775a7766d8992e0b032e2 /mail/mini_sendmail/patches | |
parent | 98574fa1445ba3682dffba92eee4328eb1772082 (diff) | |
download | pkgsrc-53b24556011f712b9ad559eda0f29f6c753049b9.tar.gz |
Add code to allow multiple -s options, so it can try several mail relays.
Diffstat (limited to 'mail/mini_sendmail/patches')
-rw-r--r-- | mail/mini_sendmail/patches/patch-aa | 112 |
1 files changed, 107 insertions, 5 deletions
diff --git a/mail/mini_sendmail/patches/patch-aa b/mail/mini_sendmail/patches/patch-aa index 31887615ccf..f8d80f13519 100644 --- a/mail/mini_sendmail/patches/patch-aa +++ b/mail/mini_sendmail/patches/patch-aa @@ -1,8 +1,65 @@ -$NetBSD: patch-aa,v 1.7 2005/06/29 22:01:19 is Exp $ +$NetBSD: patch-aa,v 1.8 2006/06/15 20:52:05 martin Exp $ --- mini_sendmail.c.orig 2005-06-29 19:37:15.000000000 +0200 -+++ mini_sendmail.c -@@ -134,6 +134,8 @@ main( int argc, char** argv ) ++++ mini_sendmail.c 2006-06-15 22:42:04.000000000 +0200 +@@ -66,8 +66,13 @@ static char* argv0; + static char* fake_from; + static int parse_message, verbose; + #ifdef DO_MINUS_SP +-static char* server; + static short port; ++struct server_entry { ++ const char *server; ++ short port; ++ struct server_entry *next; ++}; ++struct server_entry *servers; + #endif /* DO_MINUS_SP */ + static int timeout; + static int sockfd1, sockfd2; +@@ -84,7 +89,7 @@ static char* make_received( char* from, + #endif /* DO_RECEIVED */ + static void parse_for_recipients( char* message ); + static void add_recipient( char* recipient, int len ); +-static int open_client_socket( void ); ++static int open_client_socket( const char *server, short port ); + static int read_response( void ); + static void send_command( char* command ); + static void send_data( char* data ); +@@ -106,13 +111,15 @@ main( int argc, char** argv ) + char from[1000]; + int status; + char buf[2000]; ++#ifdef DO_MINUS_SP ++ struct server_entry *cur_server; ++#endif + + /* Parse args. */ + argv0 = argv[0]; + fake_from = (char*) 0; + parse_message = 0; + #ifdef DO_MINUS_SP +- server = "127.0.0.1"; + port = SMTP_PORT; + #endif /* DO_MINUS_SP */ + verbose = 0; +@@ -125,15 +132,21 @@ main( int argc, char** argv ) + else if ( strcmp( argv[argn], "-t" ) == 0 ) + parse_message = 1; + #ifdef DO_MINUS_SP +- else if ( strncmp( argv[argn], "-s", 2 ) == 0 && argv[argn][2] != '\0' ) +- server = &(argv[argn][2]); +- else if ( strncmp( argv[argn], "-p", 2 ) == 0 && argv[argn][2] != '\0' ) ++ else if ( strncmp( argv[argn], "-s", 2 ) == 0 && argv[argn][2] != '\0' ) { ++ cur_server = malloc(sizeof(struct server_entry)); ++ cur_server->server = &(argv[argn][2]); ++ cur_server->port = port; ++ cur_server->next = servers; ++ servers = cur_server; ++ } else if ( strncmp( argv[argn], "-p", 2 ) == 0 && argv[argn][2] != '\0' ) + port = atoi( &(argv[argn][2]) ); + #endif /* DO_MINUS_SP */ + else if ( strncmp( argv[argn], "-T", 2 ) == 0 && argv[argn][2] != '\0' ) timeout = atoi( &(argv[argn][2]) ); else if ( strcmp( argv[argn], "-v" ) == 0 ) verbose = 1; @@ -11,7 +68,30 @@ $NetBSD: patch-aa,v 1.7 2005/06/29 22:01:19 is Exp $ else if ( strcmp( argv[argn], "-i" ) == 0 ) ; /* ignore */ else if ( strcmp( argv[argn], "-oi" ) == 0 ) -@@ -507,14 +509,24 @@ parse_for_recipients( char* message ) +@@ -186,8 +199,21 @@ main( int argc, char** argv ) + + (void) signal( SIGALRM, sigcatch ); + ++ if (!servers) { ++ static const char default_server[] = "127.0.0.1"; ++ servers = malloc(sizeof(struct server_entry)); ++ servers->server = default_server; ++ servers->port = port; ++ servers->next = NULL; ++ } ++ + (void) alarm( timeout ); +- sockfd1 = open_client_socket(); ++ for (cur_server = servers; cur_server; cur_server = cur_server->next) { ++ sockfd1 = open_client_socket(cur_server->server, cur_server->port); ++ if (sockfd1 >= 0) break; ++ } ++ if (sockfd1 == -1) ++ show_error("could not open SMTP socket"); + + sockfd2 = dup( sockfd1 ); + sockrfp = fdopen( sockfd1, "r" ); +@@ -507,14 +533,24 @@ parse_for_recipients( char* message ) switch ( *cp ) { case '\n': @@ -43,7 +123,7 @@ $NetBSD: patch-aa,v 1.7 2005/06/29 22:01:19 is Exp $ } break; case ',': -@@ -532,25 +544,46 @@ static void +@@ -532,25 +568,46 @@ static void add_recipient( char* recipient, int len ) { char buf[1000]; @@ -97,3 +177,25 @@ $NetBSD: patch-aa,v 1.7 2005/06/29 22:01:19 is Exp $ send_command( buf ); status = read_response(); if ( status != 250 && status != 251 ) +@@ -569,7 +626,7 @@ add_recipient( char* recipient, int len + #endif + + static int +-open_client_socket( void ) ++open_client_socket(const char *server, short port) + { + #ifdef USE_IPV6 + struct sockaddr_in6 sa; +@@ -744,10 +801,10 @@ open_client_socket( void ) + + sockfd = socket( sock_family, sock_type, sock_protocol ); + if ( sockfd < 0 ) +- show_error( "socket" ); ++ return -1; + + if ( connect( sockfd, (struct sockaddr*) &sa, sa_len ) < 0 ) +- show_error( "connect" ); ++ return -1; + + return sockfd; + } |