ze-filter  (ze-filter-0.8.0-develop-180218)
mlfi_helo.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : janvier 2002
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 /* ****************************************************************************
26  * *
27  * *
28  ******************************************************************************/
29 sfsistat
30 mlfi_helo(ctx, helohost)
31  SMFICTX *ctx;
32  char *helohost;
33 {
34  CTXPRIV_T *priv = MLFIPRIV(ctx);
35  int result = SMFIS_CONTINUE;
36 
38 
39  if (priv == NULL) {
40  result = SMFIS_TEMPFAIL;
41  goto fin;
42  }
43 
45 
46  sm_macro_update(ctx, priv->sm);
47 
48  if (helohost == NULL || strlen(helohost) == 0) {
49  helohost = "empty.empty";
50  log_msg_context(ctx, "Empty helo parameter");
51  }
52 
53  FREE(priv->helohost);
54  priv->helohost = NULL;
55 
56  if ((priv->helohost = strdup(helohost)) == NULL) {
57  ZE_LogSysError("strdup(helohost) error");
58  result = SMFIS_TEMPFAIL;
59 
60  goto fin;
61  }
62 #if _FFR_DELAYED_REJECT
63  if (priv->delayed_result.result != SMFIS_CONTINUE) {
64  if (priv->callback >= priv->delayed_result.callback) {
65  (void) jsmfi_setreply(ctx, "550", "5.7.1", priv->delayed_result.reply);
67  goto fin;
68  }
69  }
70 #endif
71 
72  result = check_cpu_load(ctx, CONNID_STR(priv->id), priv->peer_addr,
73  priv->netclass.class);
74  if (result != SMFIS_CONTINUE) {
75  log_msg_context(ctx, "Global load control reject");
76 
77  goto fin;
78  }
79 
80  result = check_filter_open_connections(ctx, CONNID_STR(priv->id),
81  priv->peer_addr, priv->netclass.class);
82  if (result != SMFIS_CONTINUE) {
83  log_msg_context(ctx, "Global open connections limit");
84 
85  goto fin;
86  }
87 
88  priv->ehlo_flags = check_ehlo_value(ctx);
89 
90  result = validate_connection(ctx);
91  if (result != SMFIS_CONTINUE)
92  goto fin;
93 
94 #if _FFR_MODULES
95  /*
96  ** ze-filter modules
97  **
98  */
99  if (do_module_callback(ctx, 0, &result))
100  goto fin;
101  if (result != SMFIS_CONTINUE)
102  goto fin;
103 #endif /* _FFR_MODULES */
104 
105 
106 fin:
108 
109  /*
110  * continue processing
111  */
112  return result;
113 }
uint32_t check_ehlo_value(SMFICTX *)
#define SMFIS_TEMPFAIL
int jsmfi_setreply(SMFICTX *, char *, char *, char *)
Definition: ze-libmilter.c:99
#define FREE(x)
Definition: macros.h:37
char * peer_addr
#define CALLBACK_EHLO
Definition: ze-callback.h:29
#define SMFIS_CONTINUE
#define MLFIPRIV(ctx)
#define INIT_CALLBACK(p, which)
Definition: ze-filter.c:125
void sm_macro_update(SMFICTX *, sm_mac_T *)
Definition: ze-smmacros.c:150
CONNID_T id
char * why
#define INIT_CALLBACK_DELAY()
Definition: ze-filter.c:135
sfsistat mlfi_helo(SMFICTX *ctx, char *helohost)
Definition: mlfi_helo.c:30
dresult_T delayed_result
#define ZE_LogSysError(...)
Definition: zeSyslog.h:129
sfsistat validate_connection(SMFICTX *)
char * reply
bool do_module_callback(SMFICTX *ctx, int step, int *result)
Definition: ze-mod-tools.c:84
char * helohost
uint32_t ehlo_flags
sm_mac_T * sm
#define CONNID_STR(connid)
Definition: ze-filter.h:113
#define CHECK_CALLBACK_DELAY()
Definition: ze-filter.c:146
netclass_T netclass
void log_msg_context(SMFICTX *ctx, char *why)
sfsistat result