Wietse Venema:
> Wietse Venema:
> > Anton Yuzhaninov:
> > > In postfix-2.5.4 environment variable CLIENT_HOSTNAME is not set at all,
> > > if hostname is unknown.
> > >
> > > Older version work in different way - env variable CLIENT_HOSTNAME set to
> > > string unknown.
> > >
> > > Why this change was change not listed in Changelog?
> >
> > Because it was not supposed to change in this way.
>
> Before 20080411, this bug was hidden by a different bug, where an
> unknown remote client would show up as CLIENT_HOSTNAME=localhost
> after mail was processed by a local content filter.
>
> 20080411
>
> Bugfix (introduced Postfix 2.3): the queue manager would
> initialize missing client logging attributes (from xforward)
> with real client attributes. Fix: enable this backwards
> compatibility feature only with queue files that don't
> contain logging attributes. Problem reported by Liviu Daia.
> Files *qmgr/qmgr_message.c.
>
> One possible fix is to have the Postfix SMTP server write all client
> attributes to the queue file, including the attributes that are
> known to have the value "unknown".
It is not that simple, so below is a workaround for Postfix 2.5
and 2.6 that avoids the trouble with empty client attribute values.
The final solution may need some restructuring of the way the client
attributes are handled; that is too much change for Postfix 2.5.
Wietse
diff -cr /var/tmp/postfix-2.6-20080903/src/local/command.c ./src/local/command.c
*** /var/tmp/postfix-2.6-20080903/src/local/command.c Sat Nov 10 20:16:32 2007
--- ./src/local/command.c Wed Sep 24 20:33:55 2008
***************
*** 171,181 ****
#define EXPORT_REQUEST(name, value) \
if ((value)[0]) argv_add(env, (name), (value), ARGV_END);
! EXPORT_REQUEST("CLIENT_HOSTNAME", state.msg_attr.request->client_name);
! EXPORT_REQUEST("CLIENT_ADDRESS", state.msg_attr.request->client_addr);
EXPORT_REQUEST("CLIENT_HELO", state.msg_attr.request->client_helo);
! EXPORT_REQUEST("CLIENT_PROTOCOL", state.msg_attr.request->client_proto);
EXPORT_REQUEST("SASL_METHOD", state.msg_attr.request->sasl_method);
EXPORT_REQUEST("SASL_SENDER", state.msg_attr.request->sasl_sender);
EXPORT_REQUEST("SASL_USERNAME", state.msg_attr.request->sasl_username);
--- 171,185 ----
#define EXPORT_REQUEST(name, value) \
if ((value)[0]) argv_add(env, (name), (value), ARGV_END);
+ #define LOCAL_LOG_ATTR(x) (DEL_REQ_ATTR_AVAIL(x) ? (x) : "unknown")
! EXPORT_REQUEST("CLIENT_HOSTNAME",
! LOCAL_LOG_ATTR(state.msg_attr.request->client_name));
! EXPORT_REQUEST("CLIENT_ADDRESS",
! LOCAL_LOG_ATTR(state.msg_attr.request->client_addr));
EXPORT_REQUEST("CLIENT_HELO", state.msg_attr.request->client_helo);
! EXPORT_REQUEST("CLIENT_PROTOCOL",
! LOCAL_LOG_ATTR(state.msg_attr.request->client_proto));
EXPORT_REQUEST("SASL_METHOD", state.msg_attr.request->sasl_method);
EXPORT_REQUEST("SASL_SENDER", state.msg_attr.request->sasl_sender);
EXPORT_REQUEST("SASL_USERNAME", state.msg_attr.request->sasl_username);
diff -cr /var/tmp/postfix-2.6-20080903/src/pipe/pipe.c ./src/pipe/pipe.c
*** /var/tmp/postfix-2.6-20080903/src/pipe/pipe.c Sun Jun 29 14:41:59 2008
--- ./src/pipe/pipe.c Wed Sep 24 20:34:19 2008
***************
*** 1201,1218 ****
dict_update(PIPE_DICT_TABLE, PIPE_DICT_NEXTHOP, STR(buf));
} else
dict_update(PIPE_DICT_TABLE, PIPE_DICT_NEXTHOP, request->nexthop);
vstring_sprintf(buf, "%ld", (long) request->data_size);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_SIZE, STR(buf));
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_ADDR,
! request->client_addr);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_HELO,
request->client_helo);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_NAME,
! request->client_name);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_PORT,
! request->client_port);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_PROTO,
! request->client_proto);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_SASL_METHOD,
request->sasl_method);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_SASL_USERNAME,
--- 1201,1221 ----
dict_update(PIPE_DICT_TABLE, PIPE_DICT_NEXTHOP, STR(buf));
} else
dict_update(PIPE_DICT_TABLE, PIPE_DICT_NEXTHOP, request->nexthop);
+
+ #define PIPE_LOG_ATTR(x) (DEL_REQ_ATTR_AVAIL(x) ? (x) : "unknown")
+
vstring_sprintf(buf, "%ld", (long) request->data_size);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_SIZE, STR(buf));
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_ADDR,
! PIPE_LOG_ATTR(request->client_addr));
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_HELO,
request->client_helo);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_NAME,
! PIPE_LOG_ATTR(request->client_name));
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_PORT,
! PIPE_LOG_ATTR(request->client_port));
dict_update(PIPE_DICT_TABLE, PIPE_DICT_CLIENT_PROTO,
! PIPE_LOG_ATTR(request->client_proto));
dict_update(PIPE_DICT_TABLE, PIPE_DICT_SASL_METHOD,
request->sasl_method);
dict_update(PIPE_DICT_TABLE, PIPE_DICT_SASL_USERNAME,