[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: where is /etc/hosts supposed to come from?

On 2009-12-29 14:18:47 -0800, Russ Allbery wrote:
> Vincent Lefevre <vincent@vinc17.org> writes:
> > When I compile Mutt or any other portable software (e.g. conforming to
> > POSIX), I don't mind if such software isn't integrated with the Debian
> > system. I just want it work according to the POSIX spec. If it doesn't
> > because the system configuration doesn't comply to POSIX, then the
> > system (configuration) is broken.
> I don't think POSIX says what you think it says, but I could be wrong.
> Could you cite the exact section that says that systems are required by
> POSIX to be configured in the manner that you describe?

I haven't say anything about the configuration, just that POSIX says
that a system (locally identified by nodename) has a canonical name.

> getaddrinfo does not place such a restriction; AI_CANONNAME is
> allowed to fail.  Note the use of the word "attempt"

Yes, but a failure is something one can expect to happen under some
occasions, at least for remote hosts. This doesn't mean that hosts
don't have a canonical name, just that this canonical name couldn't
be determined.

For the local host, I would say that a failure is mostly due to a
configuration problem (unless a remote DNS is used, in which case
it may be down, and BTW, that's why I think it is a bad idea to use
one for something purely local). I'd say that making the request
fail on purpose is contrary to POSIX, and I find it not surprising
that software could fail to behave correctly because of that.

> and the note:
>     Since different implementations use different conceptual models, the
>     terms ``canonical name'' and ``alias'' cannot be precisely defined for
>     the general case. However, Domain Name System implementations are
>     expected to interpret them as they are used in RFC 1034.
> I don't believe there's any requirement anywhere in POSIX that the
> return value of uname -n be registered in DNS.

I haven't said that. And this is often not the case under Debian,
i.e. the FQDN is often obtained from /etc/hosts, which has the
precedence over DNS (see /etc/nsswitch.conf).

> In fact, the POSIX definition of the uname utility specifically
> says "the name of this node within an implementation-defined
> communications network." Implementation-defined means you cannot
> depend on it to be anything in particular without additional
> information about the implementation you're using.

This is implementation-defined, but still, the host has a canonical
name, that should be obtainable with getaddrinfo, as described.

BTW, Debian defines /etc/mailname as containing the FQDN. So,
this notion is explicitly defined on Debian, and one should
expect "hostname -f" to return the same name (according to its

Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

Reply to: