Postfix3.3.1
verify.c
[詳解]
1 /*++
2 /* NAME
3 /* verify 3
4 /* SUMMARY
5 /* update verify database
6 /* SYNOPSIS
7 /* #include <verify.h>
8 /*
9 /* int verify_append(queue_id, stats, recipient, relay, dsn,
10 /* verify_status)
11 /* const char *queue_id;
12 /* MSG_STATS *stats;
13 /* RECIPIENT *recipient;
14 /* const char *relay;
15 /* DSN *dsn;
16 /* int verify_status;
17 /* DESCRIPTION
18 /* This module implements an impedance adaptor between the
19 /* verify_clnt interface and the interface expected by the
20 /* bounce/defer/sent modules.
21 /*
22 /* verify_append() updates the address verification database
23 /* and logs the action to the mailer logfile.
24 /*
25 /* Arguments:
26 /* .IP queue_id
27 /* The message queue id.
28 /* .IP stats
29 /* Time stamps from different message delivery stages
30 /* and session reuse count.
31 /* .IP recipient
32 /* Recipient information. See recipient_list(3).
33 /* .IP relay
34 /* Name of the host we're talking to.
35 /* .IP dsn
36 /* Delivery status information. See dsn(3).
37 /* The action is one of "deliverable" or "undeliverable".
38 /* .IP verify_status
39 /* One of the following recipient verification status codes:
40 /* .RS
41 /* .IP DEL_REQ_RCPT_STAT_OK
42 /* Successful delivery.
43 /* .IP DEL_REQ_RCPT_STAT_DEFER
44 /* Temporary delivery error.
45 /* .IP DEL_REQ_RCPT_STAT_BOUNCE
46 /* Hard delivery error.
47 /* .RE
48 /* DIAGNOSTICS
49 /* A non-zero result means the operation failed.
50 /*
51 /* Fatal: out of memory.
52 /* BUGS
53 /* Should be replaced by routines with an attribute-value based
54 /* interface instead of an interface that uses a rigid argument list.
55 /* LICENSE
56 /* .ad
57 /* .fi
58 /* The Secure Mailer license must be distributed with this software.
59 /* AUTHOR(S)
60 /* Wietse Venema
61 /* IBM T.J. Watson Research
62 /* P.O. Box 704
63 /* Yorktown Heights, NY 10598, USA
64 /*
65 /* Wietse Venema
66 /* Google, Inc.
67 /* 111 8th Avenue
68 /* New York, NY 10011, USA
69 /*--*/
70 
71 /* System library. */
72 
73 #include <sys_defs.h>
74 #include <string.h>
75 
76 /* Utility library. */
77 
78 #include <msg.h>
79 #include <vstring.h>
80 #include <stringops.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  if (recipient->orig_addr[0])
109  req_stat = verify_clnt_update(recipient->orig_addr, vrfy_stat,
110  my_dsn.reason);
111  /* Two verify updates for one verify request! */
112  if (req_stat == VRFY_STAT_OK
113  && strcmp(recipient->address, recipient->orig_addr) != 0)
114  req_stat = verify_clnt_update(recipient->address, vrfy_stat,
115  my_dsn.reason);
116  } else {
117  my_dsn.action = "undeliverable-but-not-cached";
118  req_stat = VRFY_STAT_OK;
119  }
120  if (req_stat == VRFY_STAT_OK) {
121  log_adhoc(queue_id, stats, recipient, relay, dsn, my_dsn.action);
122  req_stat = 0;
123  } else {
124  msg_warn("%s: %s service failure", queue_id, var_verify_service);
125  req_stat = -1;
126  }
127  return (req_stat);
128 }
const char * orig_addr
const char * address
const char * action
Definition: dsn.h:19
const char * reason
Definition: dsn.h:20
char * var_verify_service
Definition: mail_params.c:310
int verify_append(const char *queue_id, MSG_STATS *stats, RECIPIENT *recipient, const char *relay, DSN *dsn, int vrfy_stat)
Definition: verify.c:92
void msg_warn(const char *fmt,...)
Definition: msg.c:215
void log_adhoc(const char *id, MSG_STATS *stats, RECIPIENT *recipient, const char *relay, DSN *dsn, const char *status)
Definition: log_adhoc.c:82
int var_verify_neg_cache
Definition: mail_params.c:328
Definition: dsn.h:17
int verify_clnt_update(const char *addr, int addr_status, const char *why)
Definition: verify_clnt.c:138
#define DEL_RCPT_STAT_OK
#define VRFY_STAT_OK
Definition: verify_clnt.h:33