sergio/takana
> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…
⎇ 3171dd59f9faebfd7ddd35d3994e41964ac47973
tandas/staged-fallidos-go-20260705/gross-grey_tuple.patch
History
raw
1Index: include/conf.h
2===================================================================
3--- a/include/conf.h (revision 519)
4+++ b/include/conf.h (working copy)
5@@ -41,6 +41,7 @@
6 "stat_type", "status", \
7 "grey_mask", "24", \
8 "grey_delay", "10", \
9+ "grey_tuple", "user", \
10 "syslog_facility", "mail", \
11 "blocker_port", "4466", \
12 "blocker_weight", "1", \
13@@ -80,6 +81,7 @@
14 "log_level", \
15 "grey_mask", \
16 "grey_delay", \
17+ "grey_tuple", \
18 "check", \
19 "protocol", \
20 "syslog_facility", \
21Index: include/common.h
22===================================================================
23--- a/include/common.h (revision 519)
24+++ b/include/common.h (working copy)
25@@ -151,6 +151,12 @@
26 # endif /* bool */
27 #endif /* HAVE_BOOL */
28
29+typedef enum
30+{
31+ GREY_TUPLE_USER = 0,
32+ GREY_TUPLE_SERVER,
33+} greytupletype_t;
34+
35 typedef struct peer_s
36 {
37 struct sockaddr_in peer_addr;
38@@ -207,6 +213,7 @@
39 int grey_mask;
40 int protocols;
41 int greylist_delay;
42+ greytupletype_t grey_tuple;
43 postfix_config_t postfix;
44 sjsms_config_t sjsms;
45 blocker_config_t blocker;
46Index: src/gross.c
47===================================================================
48--- a/src/gross.c (revision 519)
49+++ b/src/gross.c (working copy)
50@@ -112,7 +112,7 @@
51 {
52 int ret;
53 configlist_t *cp;
54- const char *updatestr;
55+ const char *updatestr, *greytuplestr;
56 struct hostent *host = NULL;
57 char buffer[MAXLINELEN] = { '\0' };
58 params_t *pp;
59@@ -214,6 +214,17 @@
60 daemon_shutdown(EXIT_CONFIG, "Invalid updatestyle: %s", updatestr);
61 }
62
63+ greytuplestr = CONF("grey_tuple");
64+ if ((greytuplestr == NULL) || (strcmp(greytuplestr, "user") == 0)) {
65+ logstr(GLOG_DEBUG, "grey_tuple: USER");
66+ ctx->config.grey_tuple = GREY_TUPLE_USER;
67+ } else if (strcmp(greytuplestr, "server") == 0) {
68+ logstr(GLOG_DEBUG, "grey_tuple: SERVER");
69+ ctx->config.grey_tuple = GREY_TUPLE_SERVER;
70+ } else {
71+ daemon_shutdown(EXIT_CONFIG, "Invalid grey_tuple: %s", greytuplestr);
72+ }
73+
74 /* we must reset errno because strtol returns 0 if it fails */
75 errno = 0;
76 ctx->config.grey_mask = strtol(CONF("grey_mask"), (char **)NULL, 10);
77Index: src/worker.c
78===================================================================
79--- a/src/worker.c (revision 519)
80+++ b/src/worker.c (working copy)
81@@ -186,6 +186,14 @@
82 }
83 }
84
85+static const char *domain_part(const char *email)
86+{
87+ char *p = strchr(email, '@');
88+ if (p == NULL)
89+ return email;
90+ return p + 1;
91+}
92+
93 int
94 test_tuple(final_status_t *final, grey_tuple_t *request, tmout_action_t *ta)
95 {
96@@ -233,7 +241,14 @@
97 }
98
99 /* greylist */
100- snprintf(maskedtuple, MSGSZ, "%s %s %s", chkipstr, request->sender, request->recipient);
101+ switch (ctx->config.grey_tuple) {
102+ case GREY_TUPLE_USER:
103+ snprintf(maskedtuple, MSGSZ, "%s %s %s", chkipstr, request->sender, request->recipient);
104+ break;
105+ case GREY_TUPLE_SERVER:
106+ snprintf(maskedtuple, MSGSZ, "%s %s %s", chkipstr, domain_part(request->sender), request->helo_name);
107+ break;
108+ }
109 digest = sha256_string(maskedtuple);
110
111 querylog_entry = &final->querylog_entry;
112Index: doc/examples/grossd.conf
113===================================================================
114--- a/doc/examples/grossd.conf (revision 519)
115+++ b/doc/examples/grossd.conf (working copy)
116@@ -93,6 +93,13 @@
117 # only if response is STATUS_GREY
118 # DEFAULT: update = grey
119
120+# 'grey_tuple' is the way greylisting tuples are created. Valid options are
121+# 'normal' and 'loose'. If 'grey_tuple = user' the tuple for grey listing
122+# will be: masked client-ip, sender email, recipient email. If 'grey_tuple =
123+# server' the tuple for greylisting will be client-ip, domain of sender email
124+# and helo.
125+# DEFAULT: grey_tuple = normal
126+
127 # 'grey_mask' is the mask for grossd to use when matching client_ip
128 # against the database. Default is 24, so grossd treats addresses
129 # like a.b.c.d as a.b.c.0. Setting this to 32 makes grossd to
130Index: man/grossd.conf.5.in
131===================================================================
132--- a/man/grossd.conf.5.in (revision 519)
133+++ b/man/grossd.conf.5.in (working copy)
134@@ -66,6 +66,12 @@
135 \fIgrossd\fP\|(8) will update the database only if the response is
136 `\s-1STATUS_GREY\s+1'. Setting it to `always' may reduce the impact on
137 \s-1DNS\s+1 servers.
138+.IP "\fBgrey_tuple\fP" 4
139+is the greylisting tuple. Valid options are `user' and `server'. If set to
140+`user', which is the default, \fIgrossd\fP\|(8) will create the tuple from
141+the masked `smtp\-client\-ip', sender email and recipient email. If set to
142+`server' it will create the tuple from the masked `smtp\-client\-ip', the sender
143+email domain and helo message.
144 .IP "\fBgrey_mask\fP" 4
145 is the mask for \fIgrossd\fP\|(8) to use when matching the
146 `smtp\-client\-ip' against the database. Default is 24, which makes \fIgrossd\fP\|(8)