1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | /* $NetBSD: smtpd_xforward.c,v 1.1.1.2 2010/06/17 18:07:08 tron Exp $ */ /*++ /* NAME /* smtpd_xforward 3 /* SUMMARY /* maintain XCLIENT information /* SYNOPSIS /* #include "smtpd.h" /* /* void smtpd_xforward_init(state) /* SMTPD_STATE *state; /* /* void smtpd_xforward_preset(state) /* SMTPD_STATE *state; /* /* void smtpd_xforward_reset(state) /* SMTPD_STATE *state; /* DESCRIPTION /* smtpd_xforward_init() zeroes the attributes for storage of /* XFORWARD command parameters. /* /* smtpd_xforward_preset() takes the result from smtpd_xforward_init() /* and sets all fields to the same "unknown" value that regular /* client attributes would have. /* /* smtpd_xforward_reset() restores the state from smtpd_xforward_init(). /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /*--*/ /* System library. */ #include <sys_defs.h> /* Utility library. */ #include <mymalloc.h> #include <msg.h> /* Global library. */ #include <mail_proto.h> /* Application-specific. */ #include <smtpd.h> /* smtpd_xforward_init - initialize xforward attributes */ void smtpd_xforward_init(SMTPD_STATE *state) { state->xforward.flags = 0; state->xforward.name = 0; state->xforward.addr = 0; state->xforward.port = 0; state->xforward.namaddr = 0; state->xforward.protocol = 0; state->xforward.helo_name = 0; state->xforward.ident = 0; state->xforward.domain = 0; } /* smtpd_xforward_preset - set xforward attributes to "unknown" */ void smtpd_xforward_preset(SMTPD_STATE *state) { /* * Sanity checks. */ if (state->xforward.flags) msg_panic("smtpd_xforward_preset: bad flags: 0x%x", state->xforward.flags); /* * This is a temporary solution. Unknown forwarded attributes get the * same values as unknown normal attributes, so that we don't break * assumptions in pre-existing code. */ state->xforward.flags = SMTPD_STATE_XFORWARD_INIT; state->xforward.name = mystrdup(CLIENT_NAME_UNKNOWN); state->xforward.addr = mystrdup(CLIENT_ADDR_UNKNOWN); state->xforward.port = mystrdup(CLIENT_PORT_UNKNOWN); state->xforward.namaddr = mystrdup(CLIENT_NAMADDR_UNKNOWN); state->xforward.rfc_addr = mystrdup(CLIENT_ADDR_UNKNOWN); /* Leave helo at zero. */ state->xforward.protocol = mystrdup(CLIENT_PROTO_UNKNOWN); /* Leave ident at zero. */ /* Leave domain context at zero. */ } /* smtpd_xforward_reset - reset xforward attributes */ void smtpd_xforward_reset(SMTPD_STATE *state) { #define FREE_AND_WIPE(s) { if (s) myfree(s); s = 0; } state->xforward.flags = 0; FREE_AND_WIPE(state->xforward.name); FREE_AND_WIPE(state->xforward.addr); FREE_AND_WIPE(state->xforward.port); FREE_AND_WIPE(state->xforward.namaddr); FREE_AND_WIPE(state->xforward.rfc_addr); FREE_AND_WIPE(state->xforward.protocol); FREE_AND_WIPE(state->xforward.helo_name); FREE_AND_WIPE(state->xforward.ident); FREE_AND_WIPE(state->xforward.domain); } |