Postfix3.3.1
全て データ構造 ファイル 関数 変数 型定義 マクロ定義
smtpd_xforward.c
[詳解]
1 /*++
2 /* NAME
3 /* smtpd_xforward 3
4 /* SUMMARY
5 /* maintain XCLIENT information
6 /* SYNOPSIS
7 /* #include "smtpd.h"
8 /*
9 /* void smtpd_xforward_init(state)
10 /* SMTPD_STATE *state;
11 /*
12 /* void smtpd_xforward_preset(state)
13 /* SMTPD_STATE *state;
14 /*
15 /* void smtpd_xforward_reset(state)
16 /* SMTPD_STATE *state;
17 /* DESCRIPTION
18 /* smtpd_xforward_init() zeroes the attributes for storage of
19 /* XFORWARD command parameters.
20 /*
21 /* smtpd_xforward_preset() takes the result from smtpd_xforward_init()
22 /* and sets all fields to the same "unknown" value that regular
23 /* client attributes would have.
24 /*
25 /* smtpd_xforward_reset() restores the state from smtpd_xforward_init().
26 /* LICENSE
27 /* .ad
28 /* .fi
29 /* The Secure Mailer license must be distributed with this software.
30 /* AUTHOR(S)
31 /* Wietse Venema
32 /* IBM T.J. Watson Research
33 /* P.O. Box 704
34 /* Yorktown Heights, NY 10598, USA
35 /*--*/
36 
37 /* System library. */
38 
39 #include <sys_defs.h>
40 
41 /* Utility library. */
42 
43 #include <mymalloc.h>
44 #include <msg.h>
45 
46 /* Global library. */
47 
48 #include <mail_proto.h>
49 
50 /* Application-specific. */
51 
52 #include <smtpd.h>
53 
54 /* smtpd_xforward_init - initialize xforward attributes */
55 
57 {
58  state->xforward.flags = 0;
59  state->xforward.name = 0;
60  state->xforward.addr = 0;
61  state->xforward.port = 0;
62  state->xforward.namaddr = 0;
63  state->xforward.protocol = 0;
64  state->xforward.helo_name = 0;
65  state->xforward.ident = 0;
66  state->xforward.domain = 0;
67 }
68 
69 /* smtpd_xforward_preset - set xforward attributes to "unknown" */
70 
72 {
73 
74  /*
75  * Sanity checks.
76  */
77  if (state->xforward.flags)
78  msg_panic("smtpd_xforward_preset: bad flags: 0x%x",
79  state->xforward.flags);
80 
81  /*
82  * This is a temporary solution. Unknown forwarded attributes get the
83  * same values as unknown normal attributes, so that we don't break
84  * assumptions in pre-existing code.
85  */
92  /* Leave helo at zero. */
94  /* Leave ident at zero. */
95  /* Leave domain context at zero. */
96 }
97 
98 /* smtpd_xforward_reset - reset xforward attributes */
99 
101 {
102 #define FREE_AND_WIPE(s) { if (s) myfree(s); s = 0; }
103 
104  state->xforward.flags = 0;
105  FREE_AND_WIPE(state->xforward.name);
106  FREE_AND_WIPE(state->xforward.addr);
107  FREE_AND_WIPE(state->xforward.port);
112  FREE_AND_WIPE(state->xforward.ident);
113  FREE_AND_WIPE(state->xforward.domain);
114 }
SMTPD_XFORWARD_ATTR xforward
Definition: smtpd.h:167
char * rfc_addr
Definition: smtpd.h:60
char * mystrdup(const char *str)
Definition: mymalloc.c:225
NORETURN msg_panic(const char *fmt,...)
Definition: msg.c:295
void smtpd_xforward_preset(SMTPD_STATE *state)
char * protocol
Definition: smtpd.h:61
char * domain
Definition: smtpd.h:64
#define CLIENT_PROTO_UNKNOWN
Definition: smtpd.h:281
void smtpd_xforward_reset(SMTPD_STATE *state)
char * namaddr
Definition: smtpd.h:59
#define FREE_AND_WIPE(s)
char * ident
Definition: smtpd.h:63
#define CLIENT_NAME_UNKNOWN
Definition: qmqpd.h:62
char * helo_name
Definition: smtpd.h:62
#define CLIENT_ADDR_UNKNOWN
Definition: qmqpd.h:63
void smtpd_xforward_init(SMTPD_STATE *state)
#define CLIENT_PORT_UNKNOWN
Definition: qmqpd.h:64
#define CLIENT_NAMADDR_UNKNOWN
Definition: qmqpd.h:65
#define SMTPD_STATE_XFORWARD_INIT
Definition: smtpd.h:203