Date: Wed, 19 Jul 2017 20:29:08 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r321244 - stable/10/usr.sbin/cron/cron Message-ID: <201707192029.v6JKT85g021869@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Wed Jul 19 20:29:07 2017 New Revision: 321244 URL: https://svnweb.freebsd.org/changeset/base/321244 Log: MFC r269550: r269550 (by peter): Check gethostname(2) return code - but even if it succeeds it may not null terminate. Temporarily use "From: $user@$hostname" rather than "From: $user". The latter exposes incompatible behavior if using dma(8). sendmail(8) (and other alternatives) canonify either form on submission (even if masquerading), but dma will leak a non-compliant address to the internet. Modified: stable/10/usr.sbin/cron/cron/do_command.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/cron/cron/do_command.c ============================================================================== --- stable/10/usr.sbin/cron/cron/do_command.c Wed Jul 19 20:26:35 2017 (r321243) +++ stable/10/usr.sbin/cron/cron/do_command.c Wed Jul 19 20:29:07 2017 (r321244) @@ -484,14 +484,17 @@ child_process(e, u) auto char mailcmd[MAX_COMMAND]; auto char hostname[MAXHOSTNAMELEN]; - (void) gethostname(hostname, MAXHOSTNAMELEN); + if (gethostname(hostname, MAXHOSTNAMELEN) == -1) + hostname[0] = '\0'; + hostname[sizeof(hostname) - 1] = '\0'; (void) snprintf(mailcmd, sizeof(mailcmd), MAILARGS, MAILCMD); if (!(mail = cron_popen(mailcmd, "w", e))) { warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); + fprintf(mail, "From: Cron Daemon <%s@%s>\n", + usernm, hostname); fprintf(mail, "To: %s\n", mailto); fprintf(mail, "Subject: Cron <%s@%s> %s\n", usernm, first_word(hostname, "."),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707192029.v6JKT85g021869>