Skip to content

Commit 430f3b5

Browse files
usrflocorecode
authored andcommitted
Added system hostname to received header comment
1 parent 08150f3 commit 430f3b5

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

dma.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ int readmail(struct queue *, int, int);
239239

240240
/* util.c */
241241
const char *hostname(void);
242+
const char *systemhostname(void);
242243
void setlogident(const char *, ...) __attribute__((__format__ (__printf__, 1, 2)));
243244
void errlog(int, const char *, ...) __attribute__((__format__ (__printf__, 2, 3)));
244245
void errlogx(int, const char *, ...) __attribute__((__format__ (__printf__, 2, 3)));

mail.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bounce(struct qitem *it, const char *reason)
7272
error = fprintf(bounceq.mailf,
7373
"Received: from MAILER-DAEMON\n"
7474
"\tid %s\n"
75-
"\tby %s (%s);\n"
75+
"\tby %s (%s on %s);\n"
7676
"\t%s\n"
7777
"X-Original-To: <%s>\n"
7878
"From: MAILER-DAEMON <>\n"
@@ -90,7 +90,7 @@ bounce(struct qitem *it, const char *reason)
9090
"%s\n"
9191
"\n",
9292
bounceq.id,
93-
hostname(), VERSION,
93+
hostname(), VERSION, systemhostname(),
9494
rfc822date(),
9595
it->addr,
9696
it->sender,
@@ -364,12 +364,12 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
364364
"Received: from %s (uid %d)\n"
365365
"\t(envelope-from %s)\n"
366366
"\tid %s\n"
367-
"\tby %s (%s);\n"
367+
"\tby %s (%s on %s);\n"
368368
"\t%s\n",
369369
username, useruid,
370370
queue->sender,
371371
queue->id,
372-
hostname(), VERSION,
372+
hostname(), VERSION, systemhostname(),
373373
rfc822date());
374374
if ((ssize_t)error < 0)
375375
return (-1);

util.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,25 @@ hostname(void)
9999
}
100100

101101
local:
102+
snprintf(name, sizeof(name), "%s", systemhostname());
103+
104+
initialized = 1;
105+
return (name);
106+
}
107+
108+
const char *
109+
systemhostname(void)
110+
{
111+
#ifndef HOST_NAME_MAX
112+
#define HOST_NAME_MAX 255
113+
#endif
114+
static char name[HOST_NAME_MAX+1];
115+
static int initialized = 0;
116+
char *s;
117+
118+
if (initialized)
119+
return (name);
120+
102121
if (gethostname(name, sizeof(name)) != 0)
103122
*name = 0;
104123
/*

0 commit comments

Comments
 (0)