From 163144aab02a47427340d0ecc75e2abde675f4c9 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 11 Jan 2020 18:07:10 +0000 Subject: $local_part_verified --- src/src/acl.c | 28 ++++++++++++---------------- src/src/configure.default | 2 +- src/src/expand.c | 1 + src/src/globals.c | 1 + src/src/globals.h | 1 + src/src/route.c | 4 +++- src/src/routers/rf_get_errors_address.c | 8 ++++---- 7 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/src/acl.c b/src/src/acl.c index 799af39c3..7284831a6 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -866,11 +866,10 @@ while ((s = (*func)()) != NULL) { uschar *endptr; - if (Ustrncmp(s, "acl_c", 5) != 0 && - Ustrncmp(s, "acl_m", 5) != 0) + if (Ustrncmp(s, "acl_c", 5) != 0 && Ustrncmp(s, "acl_m", 5) != 0) { *error = string_sprintf("invalid variable name after \"set\" in ACL " - "modifier \"set %s\" (must start \"acl_c\" or \"acl_m\")", s); + "modifier \"set %s\" (must start \"acl_c\" or \"acl_m\")", s); return NULL; } @@ -878,19 +877,19 @@ while ((s = (*func)()) != NULL) if (!isdigit(*endptr) && *endptr != '_') { *error = string_sprintf("invalid variable name after \"set\" in ACL " - "modifier \"set %s\" (digit or underscore must follow acl_c or acl_m)", - s); + "modifier \"set %s\" (digit or underscore must follow acl_c or acl_m)", + s); return NULL; } - while (*endptr != 0 && *endptr != '=' && !isspace(*endptr)) + while (*endptr && *endptr != '=' && !isspace(*endptr)) { if (!isalnum(*endptr) && *endptr != '_') - { - *error = string_sprintf("invalid character \"%c\" in variable name " - "in ACL modifier \"set %s\"", *endptr, s); - return NULL; - } + { + *error = string_sprintf("invalid character \"%c\" in variable name " + "in ACL modifier \"set %s\"", *endptr, s); + return NULL; + } endptr++; } @@ -3634,15 +3633,12 @@ for (; cb; cb = cb->next) sender_address_cache, -1, 0, CUSS &sender_data); break; - /* Connection variables must persist forever */ + /* Connection variables must persist forever; message variables not */ case ACLC_SET: { int old_pool = store_pool; - if ( cb->u.varname[0] == 'c' -#ifndef DISABLE_DKIM - || cb->u.varname[0] == 'd' -#endif + if ( cb->u.varname[0] != 'm' #ifndef DISABLE_EVENT || event_name /* An event is being delivered */ #endif diff --git a/src/src/configure.default b/src/src/configure.default index 08f5a9d10..93aa1678d 100644 --- a/src/src/configure.default +++ b/src/src/configure.default @@ -863,7 +863,7 @@ smarthost_smtp: local_delivery: driver = appendfile - file = /var/mail/$home + file = /var/mail/$local_part_verified delivery_date_add envelope_to_add return_path_add diff --git a/src/src/expand.c b/src/src/expand.c index 366cd737a..be6cd6162 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -587,6 +587,7 @@ static var_entry var_table[] = { { "local_part_data", vtype_stringptr, &deliver_localpart_data }, { "local_part_prefix", vtype_stringptr, &deliver_localpart_prefix }, { "local_part_suffix", vtype_stringptr, &deliver_localpart_suffix }, + { "local_part_verified", vtype_stringptr, &deliver_localpart_verified }, #ifdef HAVE_LOCAL_SCAN { "local_scan_data", vtype_stringptr, &local_scan_data }, #endif diff --git a/src/src/globals.c b/src/src/globals.c index 15ad4e932..edd1edbbc 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -817,6 +817,7 @@ uschar *deliver_localpart_orig = NULL; uschar *deliver_localpart_parent = NULL; uschar *deliver_localpart_prefix = NULL; uschar *deliver_localpart_suffix = NULL; +uschar *deliver_localpart_verified = NULL; uschar *deliver_out_buffer = NULL; int deliver_queue_load_max = -1; address_item *deliver_recipients = NULL; diff --git a/src/src/globals.h b/src/src/globals.h index bb66cb239..9dfa4a768 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -488,6 +488,7 @@ extern uschar *deliver_localpart_orig; /* The original local part for delivery * extern uschar *deliver_localpart_parent; /* The parent local part for delivery */ extern uschar *deliver_localpart_prefix; /* The stripped prefix, if any */ extern uschar *deliver_localpart_suffix; /* The stripped suffix, if any */ +extern uschar *deliver_localpart_verified; /* de-tainted by check_local_part */ extern uschar *deliver_out_buffer; /* Buffer for copying file */ extern int deliver_queue_load_max; /* Different value for queue running */ extern address_item *deliver_recipients; /* Current set of addresses */ diff --git a/src/src/route.c b/src/src/route.c index c6119eed0..16ce72c2b 100644 --- a/src/src/route.c +++ b/src/src/route.c @@ -927,7 +927,7 @@ if ((rc = route_check_dls(r->name, US"local_parts", r->local_parts, login of a local user. Note: the third argument to route_finduser() must be NULL here, to prevent a numeric string being taken as a numeric uid. If the user is found, set deliver_home to the home directory, and also set -local_user_{uid,gid}. */ +local_user_{uid,gid} and local_part_verified. */ if (r->check_local_user) { @@ -938,6 +938,7 @@ if (r->check_local_user) r->name, addr->local_part); return SKIP; } + deliver_localpart_verified = string_copy(US (*pw)->pw_name); deliver_home = string_copy(US (*pw)->pw_dir); local_user_gid = (*pw)->pw_gid; local_user_uid = (*pw)->pw_uid; @@ -1670,6 +1671,7 @@ for (r = addr->start_router ? addr->start_router : routers; r; r = nextr) the local part sorted. */ router_name = r->name; + deliver_localpart_verified = NULL; deliver_set_expansions(addr); /* For convenience, the pre-router checks are in a separate function, which diff --git a/src/src/routers/rf_get_errors_address.c b/src/src/routers/rf_get_errors_address.c index 858c806f1..9ef46801e 100644 --- a/src/src/routers/rf_get_errors_address.c +++ b/src/src/routers/rf_get_errors_address.c @@ -88,13 +88,13 @@ else const uschar *address_expansions_save[ADDRESS_EXPANSIONS_COUNT]; address_item *snew = deliver_make_addr(s, FALSE); - if (sender_address != NULL) + if (sender_address) { save1 = sender_address[0]; sender_address[0] = 0; } - for (i = 0, p = address_expansions; *p != NULL;) + for (i = 0, p = address_expansions; *p;) address_expansions_save[i++] = **p++; f.address_test_mode = FALSE; @@ -119,10 +119,10 @@ else debug_printf("------ End verifying errors address %s ------\n", s); f.address_test_mode = save_address_test_mode; - for (i = 0, p = address_expansions; *p != NULL;) + for (i = 0, p = address_expansions; *p; ) **p++ = address_expansions_save[i++]; - if (sender_address != NULL) sender_address[0] = save1; + if (sender_address) sender_address[0] = save1; } return OK; -- cgit v1.2.3