citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

opensmtpd.diff (628B)


      1 diff --git a/smtpd/smtp.c b/smtpd/smtp.c
      2 index 5f817be..a318b16 100644
      3 --- a/smtpd/smtp.c
      4 +++ b/smtpd/smtp.c
      5 @@ -161,6 +161,15 @@ smtp_setup_listeners(void)
      6  			sizeof(opt)) < 0)
      7  			fatal("smtpd: setsockopt");
      8  #endif
      9 +#ifdef IPV6_V6ONLY
     10 +		/* If using IPv6, bind only to IPv6 if possible. This avoids
     11 +		   ambiguities with IPv4-mapped IPv6 addresses. */
     12 +		if (l->ss.ss_family == AF_INET6) {
     13 +				if (setsockopt(l->fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt,
     14 +						sizeof(opt)) < 0)
     15 +						fatal("smtpd: setsockopt");
     16 +		}
     17 +#endif
     18  		if (bind(l->fd, (struct sockaddr *)&l->ss, SS_LEN(&l->ss)) == -1)
     19  			fatal("smtpd: bind");
     20  	}
     21