init_system_name fqdn?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

init_system_name fqdn?

Ken Olum
A while back, init_system_name tried to find the system's fully
qualified domain name.  Then this code was taken out, and now it just
uses whatever gethostname returns.  I think this is a poor choice.  Many
systems are configured without a fully qualified hostname.  Then when
you send mail you get "i-did-not-set--mail-host-address--so-tickle-me"
in your from address. Of course this is easily fixed by setting
mail-host-address, e.g., in site-start.el, but then when you go to
report a bug and say "emacs -Q" ... "M-x report-emacs-bug" you are back
to "so tickle me".

                                        Ken

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Yuri Khan-2
On Fri, Jun 16, 2017 at 9:17 PM, Ken Olum <[hidden email]> wrote:

> A while back, init_system_name tried to find the system's fully
> qualified domain name.  Then this code was taken out, and now it just
> uses whatever gethostname returns.  I think this is a poor choice.  Many
> systems are configured without a fully qualified hostname.

Even if they are, they are not likely to be able to receive email at
their configured FQDN.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Ken Olum
   From: Yuri Khan <[hidden email]>
   Date: Fri, 16 Jun 2017 21:33:05 +0700

   > Many systems are configured without a fully qualified hostname.

   Even if they are, they are not likely to be able to receive email at
   their configured FQDN.

I think the Unix hostname setting has nothing to do with how the system
is configured on the Internet.  So the fact that hostname is set to
something with no domain is not relevant to whether users can receive
mail.

                                        Ken

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Tim Cross-5
I'm not sure what your expected result is? If the system does not have a fqdn, which is very common, especially with many SOHO users, then what should it be set to if not hostname? 

I do remember years ago when lots of systems assumed/expected a fqdn. To make things work correctly, you had to define localhost.localdomain as many systems use a test along the lines of "has at least 2 components in the domain name". 

My current home machine, with a pretty much default Ubuntu setup has a hostname of tim-desktop. If I use hostname -f it is still tim-desktop because this machine does not have a fqdn - I don't have a real domain name, so cannot have a real fqdn. If I did, the system would be configured accordingly and hostname -f wold return the fqdn. 

Is your concern that even when you have a system setup with a fqdn that emacs is still only using the hostname part i.e. not hostname -f? If so, yes, this is probably incorrect. 

On the other hand, if you are concerned about the fact that if the system does not have a fqdn, you don't get a 'real' email address (or at least one which looks real, but may have no MX)? If so, I don't think this is something emacs can really do much about and at least an obvious 'bad address' is better as it may alert the user to the problem. 

Yes, this does mean that when you do emacs -Q on a system without a fqdn, and then try to send a bug report, the address is incorrect, but that is probably the least of your problems. The email is unlikely to be sent  as the system is unlikely to have a correctly configure MTA. If it does, it probably should be configured to re-write the from address to be whatever mailhob/smarthost the system uses anyway. 

I recall a number of threads in the past about this issue and suggestions to do things like change bug reporting to use a web service instead of relying on email. However, most of these alternative solutions either added additional complexity or required additional infrastructure which someone would have to maintain. From memory, managing the additional infrastructure to provide a web service for bug reports and ensuring it was secure and not susceptible to spam/abuse was the real issue. 

At the end of the day, I don't think being able to send email correctly from emacs -Q is anything Emacs can reliably solve. However, it isn't a big issue - I've found it pretty easy to just select the message, copy it into my mail client and send it that way. From memory, I think there is even some text in the bug report template warning about this and what to do. 




On 17 June 2017 at 04:10, Ken Olum <[hidden email]> wrote:
   From: Yuri Khan <[hidden email]>
   Date: Fri, 16 Jun 2017 21:33:05 +0700

   > Many systems are configured without a fully qualified hostname.

   Even if they are, they are not likely to be able to receive email at
   their configured FQDN.

I think the Unix hostname setting has nothing to do with how the system
is configured on the Internet.  So the fact that hostname is set to
something with no domain is not relevant to whether users can receive
mail.

                                        Ken




--
regards,

Tim

--
Tim Cross

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Ken Olum
If your system has no fully qualified domain name, i.e., there is no DNS
entry that points to this host, then of course you cannot receive and
probably cannot send email, and I don't think it's very important
exactly how it fails.  But if your system is properly set up as an
Internet host but gethostname does not return the FQDN (e.g., because
you put the short name first in /etc/hosts), then I think
init_system_name should use the FQDN.  In the cases in which I have
observed this, "hostname -f" does return the FQDN.

In emacs-24, the procedure of init_system_name was to first do
gethostname, but if that didn't return a qualified name, it would try
getaddrinfo with ai_canonname, and if that failed look in the list of
aliases given by gethostbyname.  Later all this code was removed and now
it just calls gethostname.

                                        Ken

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Stefan Monnier
In reply to this post by Ken Olum
> A while back, init_system_name tried to find the system's fully
> qualified domain name.  Then this code was taken out, and now it just
> uses whatever gethostname returns.  I think this is a poor choice.

It depends on what it's used for.  What is your use for it where it's
a poor choice?

> Many systems are configured without a fully qualified hostname.
> Then when you send mail you get
> "i-did-not-set--mail-host-address--so-tickle-me" in your from address.

Indeed, gethostname doesn't return a good choice for mail-host-address.
But of all the machines I have had access to in the last 10 years, not
a single one had an FQDN that was a good choice for
mail-host-address either.  So the only "advantage" of the old code was
that it was more complex and could delay startup by 2min in some cases.

> Of course this is easily fixed by setting mail-host-address,
> e.g., in site-start.el, but then when you go to report a bug and say
> "emacs -Q" ... "M-x report-emacs-bug" you are back to "so tickle me".

How do you suggest Emacs discovers that it should use
"iro.umontreal.ca" (hint: no machine has such an FQDN)?

[ Actually, even that is dicey: nowadays "username @ mail-host-address"
  is likely to be generally wrong.  Instead, every user has her own
  choice of mail service, so user `foo` would want to use
  `[hidden email]`, user `bar` will want to use
  `[hidden email]`.  ]


        Stefan


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Stefan Monnier
In reply to this post by Ken Olum
> exactly how it fails.  But if your system is properly set up as an
> Internet host but gethostname does not return the FQDN (e.g., because
> you put the short name first in /etc/hosts), then I think
> init_system_name should use the FQDN.

How do you suggest Emacs decide whether the "system is properly set up as an
Internet host"?

Why don't you just set up /etc/hostname (I don't think /etc/hosts is
consulted to compute `system-name`) with the FQDN instead of
a short name on those hosts that are properly setup as an Internet host?


        Stefan


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Ken Olum
In reply to this post by Stefan Monnier
   From: Stefan Monnier <[hidden email]>
   Date: Sat, 17 Jun 2017 11:29:22 -0400

   > A while back, init_system_name tried to find the system's fully
   > qualified domain name.  Then this code was taken out, and now it just
   > uses whatever gethostname returns.  I think this is a poor choice.

   It depends on what it's used for.  What is your use for it where it's
   a poor choice?

The hostname of the machine I'm using is "cosmos", because that's what I
put in /etc/hostname.  Its FQDN is cosmos.phy.tufts.edu, and that's
where my email address is.  This is what "hostname -f" prints and what
the old code used to guess.  I connected to a server maintained by the
Tufts IT department and it was set up the same way.

   Indeed, gethostname doesn't return a good choice for mail-host-address.
   But of all the machines I have had access to in the last 10 years, not
   a single one had an FQDN that was a good choice for
   mail-host-address either.  So the only "advantage" of the old code was
   that it was more complex and could delay startup by 2min in some cases.

I don't know what was causing this delay, but certainly we don't want
it.  Can "hostname -f" cause a similar delay?

Would you suggest not guessing at all and requiring the installer to set
mail-host-address or the user to set user-mail-address before mail can
be sent?  I think if we're going to guess at all, "hostname -f" or some
equivalent code might be a better guess than gethostname().

   From: Stefan Monnier <[hidden email]>
   Date: Sat, 17 Jun 2017 12:30:52 -0400

   How do you suggest Emacs decide whether the "system is properly set up as an
   Internet host"?

It cannot.  The question is whether to guess at all, and if so what to guess.

   Why don't you just set up /etc/hostname (I don't think /etc/hosts is
   consulted to compute `system-name`) with the FQDN instead of
   a short name on those hosts that are properly setup as an Internet host?

Of course I could do that.  I was thinking that maybe there were other
people who have similarly configured systems and would find it easier
for emacs to work "of the box" instead of having to change their
hostnames.  But as you say maybe it's unlikely that guessing would work
at all.  If that's so, rather than possibly making wrong guesses which
would lead replies to be discarded, maybe emacs by default should ask
for your email address instead of making any guess.  (Then it could set
user-mail-address in your init file in the usual way, so it wouldn't
have to ask again, except in the case of -Q.)

                                        Ken

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Stefan Monnier
> The hostname of the machine I'm using is "cosmos", because that's what I
> put in /etc/hostname.  Its FQDN is cosmos.phy.tufts.edu, and that's
> where my email address is.

My understanding of the current state of email in the world is that such
a situation is extremely rare nowadays (even though it was pretty
standard 20 years ago, indeed).

> I don't know what was causing this delay,

Misconfigurations.

> but certainly we don't want it.  Can "hostname -f" cause
> a similar delay?

I think so, yes (IIRC this happened  when /etc/nsswitch.conf would say
to consult a DNS server, while the server mentioned in /etc/resolv.conf
was currently unreachable).

> Would you suggest not guessing at all and requiring the installer to set
> mail-host-address or the user to set user-mail-address before mail can
> be sent?

Yes.  I think nowadays, guessing the user-mail-address based on
"username" and "system-name" is just hopeless.  A better basis for the
guess could be ~/.gitconfig.

If we want "emacs -Q" to get a valid email without prompting you every
time, then we need to store the email somewhere else than ~/.emacs.


        Stefan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Paul Eggert
Stefan Monnier wrote:
> Yes.  I think nowadays, guessing the user-mail-address based on
> "username" and "system-name" is just hopeless.  A better basis for the
> guess could be ~/.gitconfig.

Yes, perhaps we could default the email address to the output of the command
'git config --get user.email' if the command is successful.  This would be a win
for my setup, where /etc/hostname contains 'Penguin.CS.UCLA.EDU' (because that's
what our local DNS says my machine's name is, and Fedora's setup procedure fills
in /etc/hostname from that), but [hidden email] does not work as an
email address.
> If we want "emacs -Q" to get a valid email without prompting you every
> time, then we need to store the email somewhere else than ~/.emacs.

Yes, defaulting to .gitconfig would have fixed some of the misconfigured emails
I've sent from Emacs over the years, when I mistakenly sent email from emacs -Q.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Lars Ingebrigtsen
Paul Eggert <[hidden email]> writes:

> Yes, perhaps we could default the email address to the output of the
> command 'git config --get user.email' if the command is successful.

Or we could do what every other program that exists now does, and accept
that there now is no way of programmatically guessing what the email
address is and just ask the user (if the user wants to send an email).

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Ken Olum
   From: Lars Ingebrigtsen <[hidden email]>
   Date: Sat, 17 Jun 2017 21:51:11 +0200

   Or we could do what every other program that exists now does, and accept
   that there now is no way of programmatically guessing what the email
   address is and just ask the user (if the user wants to send an email).

Not quite every program.  Mailx and its successor s-nail work without my
needing to specify any from address.  In my case they guess right, but I
don't know what procedure they use.  Perhaps it is not such a good idea.

Emacs could get your address from git, but what if you don't use git?
Presumably there are many other programs that might have some knowledge
of your email address also.  Which set should we use?

Emacs currently accepts the environment variable EMAIL.  It's not very
standard but a few other programs (e.g., Mutt) use it also.  It would be
good to keep that at least (and it will be convenient if you report lots
of bugs with emacs -Q).

                                        Ken

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: init_system_name fqdn?

Tim Cross-5
In reply to this post by Ken Olum
If you have a fqdn for a host and hostname -f does not return the fqdn, then your system is not configured correctly. This would likely cause errors or problems with other software as well. 

Having a FQDN and a DNS entry are not the same thing. You can have a fqdn without a DNS entry, though it isn't very useful of course as nobody else can resolve the fqdn to an IP address (unless you put a manual entry in /etc/hosts of course). 

There are only incidental relationships between FQDN and the ability to send/receive email. You definitely do not need a fqdn to send email and there are a number of ways to have email delivered to a machine without a fqdn or DNS entry e.g. fetchmail. mailhobs with local /etc/hosts entries with 192.168.x.x or 10.x.x.x addresses etc. 

There are many different ways for a system to support sending/receiving email and it is extremely unlikely that Emacs will be able to determine this correctly automatically. Any attempt to do so will almost certainly be complex and error prone and a pain to maintain. Add to this that far fewer hosts actually do email anymore. 20 years ago, I always setup a local mail server on my system. Now I rarely do. ISPs now frequently block port 25 and most medium to large organisations have very strict policies in place to prevent users from setting up mail servers due to the frequency of misconfiguration that either caused errors or created an open mail relay which could be used for spam and potentially adversely impact on an organisations reputation or result i their mail being blackholed etc. 

I think I'm with Stefan on this one. The only sane and maintainable solution is to have emacs check for an explicit mail address configuration set by the user and if none exists, prompt the user for one when sending email. In reality, you will probably have to prompt for the name of the mail server as well and possibly a password as many mail servers now use authenticated smtp and you cannot assume the local host has a configured MTA.

Or you just display a message saying to cut and paste your message into your preferred mail client and send it that way.

Tim

On 18 June 2017 at 00:17, Ken Olum <[hidden email]> wrote:
If your system has no fully qualified domain name, i.e., there is no DNS
entry that points to this host, then of course you cannot receive and
probably cannot send email, and I don't think it's very important
exactly how it fails.  But if your system is properly set up as an
Internet host but gethostname does not return the FQDN (e.g., because
you put the short name first in /etc/hosts), then I think
init_system_name should use the FQDN.  In the cases in which I have
observed this, "hostname -f" does return the FQDN.

In emacs-24, the procedure of init_system_name was to first do
gethostname, but if that didn't return a qualified name, it would try
getaddrinfo with ai_canonname, and if that failed look in the list of
aliases given by gethostbyname.  Later all this code was removed and now
it just calls gethostname.

                                        Ken




--
regards,

Tim

--
Tim Cross

Loading...