diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-20 19:45:18 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-20 19:45:18 +0000 |
commit | deae95b3e1d638ccaacb1d93f4b19ff63938f65d (patch) | |
tree | 1b7caeb51f89a223a6ca1311ac93ad4149a96830 /usr.sbin | |
parent | 3d4918291785756eae7009031bb5ed4b2d49f63f (diff) |
use the machine hostname, not localhost, in mail.maildir.c
spotted and ok tedu@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/mail.maildir.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/mail.maildir.c b/usr.sbin/smtpd/mail.maildir.c index 7612a7343f2..6352aa745ef 100644 --- a/usr.sbin/smtpd/mail.maildir.c +++ b/usr.sbin/smtpd/mail.maildir.c @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/param.h> #include <ctype.h> #include <err.h> @@ -114,6 +115,7 @@ maildir_engine(const char *dirname, int junk) char extpath[PATH_MAX]; char subdir[PATH_MAX]; char filename[PATH_MAX]; + char hostname[MAXHOSTNAMELEN]; char tmp[PATH_MAX]; char new[PATH_MAX]; @@ -165,10 +167,13 @@ maildir_engine(const char *dirname, int junk) } } + if (gethostname(hostname, sizeof hostname) != 0) + (void)strlcpy(hostname, "localhost", sizeof hostname); + (void)snprintf(filename, sizeof filename, "%lld.%08x.%s", (long long int) time(NULL), arc4random(), - "localhost"); + hostname); (void)snprintf(tmp, sizeof tmp, "%s/tmp/%s", dirname, filename); |