1 /* $NetBSD: verify.c,v 1.1.1.1 2009/06/23 10:08:48 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* verify 3 6 /* SUMMARY 7 /* update verify database 8 /* SYNOPSIS 9 /* #include <verify.h> 10 /* 11 /* int verify_append(queue_id, stats, recipient, relay, dsn, 12 /* verify_status) 13 /* const char *queue_id; 14 /* MSG_STATS *stats; 15 /* RECIPIENT *recipient; 16 /* const char *relay; 17 /* DSN *dsn; 18 /* int verify_status; 19 /* DESCRIPTION 20 /* This module implements an impedance adaptor between the 21 /* verify_clnt interface and the interface expected by the 22 /* bounce/defer/sent modules. 23 /* 24 /* verify_append() updates the address verification database 25 /* and logs the action to the mailer logfile. 26 /* 27 /* Arguments: 28 /* .IP queue_id 29 /* The message queue id. 30 /* .IP stats 31 /* Time stamps from different message delivery stages 32 /* and session reuse count. 33 /* .IP recipient 34 /* Recipient information. See recipient_list(3). 35 /* .IP relay 36 /* Name of the host we're talking to. 37 /* .IP dsn 38 /* Delivery status information. See dsn(3). 39 /* The action is one of "deliverable" or "undeliverable". 40 /* .IP verify_status 41 /* One of the following recipient verification status codes: 42 /* .RS 43 /* .IP DEL_REQ_RCPT_STAT_OK 44 /* Successful delivery. 45 /* .IP DEL_REQ_RCPT_STAT_DEFER 46 /* Temporary delivery error. 47 /* .IP DEL_REQ_RCPT_STAT_BOUNCE 48 /* Hard delivery error. 49 /* .RE 50 /* DIAGNOSTICS 51 /* A non-zero result means the operation failed. 52 /* 53 /* Fatal: out of memory. 54 /* BUGS 55 /* Should be replaced by routines with an attribute-value based 56 /* interface instead of an interface that uses a rigid argument list. 57 /* LICENSE 58 /* .ad 59 /* .fi 60 /* The Secure Mailer license must be distributed with this software. 61 /* AUTHOR(S) 62 /* Wietse Venema 63 /* IBM T.J. Watson Research 64 /* P.O. Box 704 65 /* Yorktown Heights, NY 10598, USA 66 /*--*/ 67 68 /* System library. */ 69 70 #include <sys_defs.h> 71 #include <string.h> 72 73 #ifdef STRCASECMP_IN_STRINGS_H 74 #include <strings.h> 75 #endif 76 77 /* Utility library. */ 78 79 #include <msg.h> 80 #include <vstring.h> 81 82 /* Global library. */ 83 84 #include <mail_params.h> 85 #include <mail_proto.h> 86 #include <verify_clnt.h> 87 #include <log_adhoc.h> 88 #include <verify.h> 89 90 /* verify_append - update address verification database */ 91 92 int verify_append(const char *queue_id, MSG_STATS *stats, 93 RECIPIENT *recipient, const char *relay, 94 DSN *dsn, int vrfy_stat) 95 { 96 int req_stat; 97 DSN my_dsn = *dsn; 98 99 /* 100 * Impedance adaptor between bounce/defer/sent and verify_clnt. 101 * 102 * XXX No DSN check; this routine is called from bounce/defer/sent, which 103 * know what the DSN initial digit should look like. 104 * 105 * XXX vrfy_stat is competely redundant because of dsn. 106 */ 107 if (var_verify_neg_cache || vrfy_stat == DEL_RCPT_STAT_OK) { 108 req_stat = verify_clnt_update(recipient->orig_addr, vrfy_stat, 109 my_dsn.reason); 110 if (req_stat == VRFY_STAT_OK && strcasecmp(recipient->address, 111 recipient->orig_addr) != 0) 112 req_stat = verify_clnt_update(recipient->address, vrfy_stat, 113 my_dsn.reason); 114 } else { 115 my_dsn.action = "undeliverable-but-not-cached"; 116 req_stat = VRFY_STAT_OK; 117 } 118 if (req_stat == VRFY_STAT_OK) { 119 log_adhoc(queue_id, stats, recipient, relay, dsn, my_dsn.action); 120 req_stat = 0; 121 } else { 122 msg_warn("%s: %s service failure", queue_id, var_verify_service); 123 req_stat = -1; 124 } 125 return (req_stat); 126 } 127