On Wed, Feb 06, 2019 at 02:42:58AM +0000, Patton, Matthew [Contractor] wrote:
> > Returning to the OP's question, Postfix does append $mydomain to the > > automatically derived value of $myhostname when the latter is not > > explicitly set > > > > ------------------------------------- > > in main.cf and is not fully qualified. > > Except that it doesn't. (or I misunderstood what you wrote) > I set $myhostname = 'smtp'. > $mydomain was also set. Actually, it does, under the stated condition. You have an explicit setting, which is honoured. Postfix does not second-guess explicit settings, the administrator knows best. > I had to set both since gethostbyname() would have returned a value of > 'ip-XXXXXX.aws.internal'. Which is discussed in the second part of my post. > If Postfix had instead used $myhostname.$mydomain IFF $myhostname is not > FQDN (has no dots at all) then 'smtp'.$mydomain would have been perfectly > fine since there was an A record for it for quite some time. If that's what you want, and you're setting myhostname explicitly, then it is your responsibility to do that. This allows users who do want dotless hostnames to have those if that's right for them. > > The above assumes that the system hostname is stable, and not derived via > > DHCP. In the latter case do set an explicit stable FQDN for $myhostname. Which is apparently not your case. :-( > Fair enough. But I still think that at the very least the docs should be > a little more explicit, and furthermore a warning is merited during > valid_hostname() and with SLOPPY_VALID_HOSTNAME we can continue without > error. The documentation explains how the default value is constructed. As with all the other parameters, if you choose a non-default value, then that's what you get: http://www.postfix.org/postconf.5.html#myhostname > If nothing else HELO should really scream if there are no dots or should > be revised to always default to doing the reasonable thing. There are legitimate use-cases on private networks where a short HELO is perfectly fine, and may be preferred. Postfix defaults to an FQDN for myhostname, but will bend to your will if you override that default. > even if it allows you to still shoot oneself in the foot? It's also a good > idea not to surprise software users with unexpected outcomes. I had every > expectation that setting both $myhostname and $mydomain was sufficient for > proper behavior. You misunderstood the documentation, the domain is only appended when computing the *default* value, when the name returned by gethostname() is dotless. Read with a bit of care, the documentation promises exactly that. The internet hostname of this mail system. The default is to ----------- use the fully-qualified domain name (FQDN) from gethostname(), or to use the non-FQDN result from gethostname() and append ----------------------------------------------------- ".$mydomain". $myhostname is used as a default value for many ------------- other configuration parameters. That is mydomain is only appended to the result of gethostname() when constructing the default value, it plays no role in explicit settings by the administrator, and this is correct behaviour. Warnings about unqualified hostnames don't belong in the running Postfix system, they could be part of some option postconf(1) "lint-mode", if someone had cycles to contribute the requisite code. -- Viktor.