Gnus development mailing list
 help / color / mirror / Atom feed
* messsage-user-fqdn
@ 2003-02-20 21:50 Reiner Steib
  2003-02-21 15:40 ` messsage-user-fqdn Kai Großjohann
  2003-02-22 22:17 ` messsage-user-fqdn Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: Reiner Steib @ 2003-02-20 21:50 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]

Hi,

nowadays, many people don't a have properly configured system, so that
`system-name' often isn't useful for the generation of the domain name
of Message-Ids.  Additionally, many people have the own FQDN
(e.g. from their provider, like CIS-DFN) or the have their own domain.

People often ask how to set the FQDN[1].  They are often advised to
redefine `message-make-fqdn' or `message-make-message-id' (ugly hacks,
IMHO) or to set `mail-host-address':

,----
| (defun message-make-fqdn ()
|   "copy docstring from orig def"
|   "hotmail.com")
| (defun message-make-message-id ()
|   (concat
|    "<" (message-unique-id)"@some domain name You like>"))
`----

But there only very rough checks in `message.el' concerning the
validity of this string (does it contain a dot?
localhost.*?). Ref. [1] also is a nice example about invalid domain
parts: "@a.z«". :-(

I propose to add a variable `messsage-user-fqdn' *and* add a better
validity check for the domain part as well.

,----
| 2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
| 
| 	* message.el (message-user-fqdn, message-valid-fqdn-regexp): New
| 	variables.
| 	(message-make-fqdn): Use it.  Improved validity check.
| 
| 2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
| 
| 	* message.texi (News Headers): Update description of Message-ID.
`----

The new variable `message-valid-fqdn-regexp' is a duplication of
`gnus-button-valid-fqdn-regexp'.  But AFAIK, it's not allowed to
require `gnus-art' from `message.el', is it?  What about the other way
round?  Other possibilities?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: message.messsage-user-fqdn.patch --]
[-- Type: text/x-patch, Size: 5433 bytes --]

Index: lisp/ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/ChangeLog,v
retrieving revision 6.2020
diff -u -r6.2020 ChangeLog
--- lisp/ChangeLog	20 Feb 2003 02:39:08 -0000	6.2020
+++ lisp/ChangeLog	20 Feb 2003 21:52:47 -0000
@@ -1,3 +1,9 @@
+2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* message.el (message-user-fqdn, message-valid-fqdn-regexp): New
+	variables.
+	(message-make-fqdn): Use it.  Improved validity check.
+
 2003-02-20  Jesper Harder  <harder@ifa.au.dk>
 
 	* gnus-sum.el (gnus-simplify-subject-fully, gnus-subject-equal)
Index: lisp/message.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/message.el,v
retrieving revision 6.301
diff -u -r6.301 message.el
--- lisp/message.el	20 Feb 2003 00:39:05 -0000	6.301
+++ lisp/message.el	20 Feb 2003 21:52:47 -0000
@@ -1273,6 +1273,12 @@
   :group 'message-headers
   :type 'boolean)
 
+(defcustom message-user-fqdn nil
+  "*Domain part of Messsage-Ids."
+  :group 'message-headers
+  :link '(custom-manual "(message)News Headers")
+  :type 'string)
+
 ;;; Internal variables.
 
 (defvar message-sending-message "Sending...")
@@ -1381,6 +1387,19 @@
 (defvar message-bogus-system-names "^localhost\\."
   "The regexp of bogus system names.")
 
+(defcustom message-valid-fqdn-regexp
+  (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
+	  ;; valid TLDs:
+	  "\\([a-z][a-z]" ;; two letter country TDLs
+	  "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
+	  "\\|aero\\|coop\\|info\\|name\\|museum"
+	  "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
+	  "\\)")
+  "Regular expression that matches a valid FQDN."
+  ;; see also: gnus-button-valid-fqdn-regexp
+  :group 'message-headers
+  :type 'regexp)
+
 (eval-and-compile
   (autoload 'message-setup-toolbar "messagexmas")
   (autoload 'mh-new-draft-name "mh-comp")
@@ -4483,23 +4502,34 @@
 
 (defun message-make-fqdn ()
   "Return user's fully qualified domain name."
-  (let ((system-name (system-name))
-	(user-mail (message-user-mail-address)))
+  (let* ((system-name (system-name))
+	 (user-mail (message-user-mail-address))
+	 (user-domain
+	  (if (string-match "@\\(.*\\)\\'" user-mail)
+	      (match-string 1 user-mail))))
     (cond
-     ((and (string-match "[^.]\\.[^.]" system-name)
+     ((and message-user-fqdn
+	   (stringp message-user-fqdn)
+	   (string-match message-valid-fqdn-regexp message-user-fqdn)
+	   (not (string-match message-bogus-system-names message-user-fqdn)))
+      message-user-fqdn)
+     ;; `message-user-fqdn' seems to be valid
+     ((and (string-match message-valid-fqdn-regexp system-name)
 	   (not (string-match message-bogus-system-names system-name)))
       ;; `system-name' returned the right result.
       system-name)
      ;; Try `mail-host-address'.
      ((and (boundp 'mail-host-address)
 	   (stringp mail-host-address)
-	   (string-match "\\." mail-host-address))
+	   (string-match message-valid-fqdn-regexp mail-host-address)
+	   (not (string-match message-bogus-system-names mail-host-address)))
       mail-host-address)
      ;; We try `user-mail-address' as a backup.
-     ((and user-mail
-	   (string-match "\\." user-mail)
-	   (string-match "@\\(.*\\)\\'" user-mail))
-      (match-string 1 user-mail))
+     ((and user-domain
+	   (stringp user-domain)
+	   (string-match message-valid-fqdn-regexp user-domain)
+	   (not (string-match message-bogus-system-names user-domain)))
+      user-domain)
      ;; Default to this bogus thing.
      (t
       (concat system-name ".i-did-not-set--mail-host-address--so-tickle-me")))))
Index: texi/ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/gnus/texi/ChangeLog,v
retrieving revision 6.457
diff -u -r6.457 ChangeLog
--- texi/ChangeLog	18 Feb 2003 20:32:24 -0000	6.457
+++ texi/ChangeLog	20 Feb 2003 21:52:47 -0000
@@ -1,3 +1,7 @@
+2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* message.texi (News Headers): Update description of Message-ID.
+
 2003-02-18  Reiner Steib  <Reiner.Steib@gmx.de>
 
 	* gnus.texi (Article Washing): Mention `g'.
Index: texi/message.texi
===================================================================
RCS file: /usr/local/cvsroot/gnus/texi/message.texi,v
retrieving revision 6.66
diff -u -r6.66 message.texi
--- texi/message.texi	5 Feb 2003 10:10:19 -0000	6.66
+++ texi/message.texi	20 Feb 2003 21:52:47 -0000
@@ -1466,14 +1466,18 @@
 
 @item Message-ID
 @cindex Message-ID
+@vindex message-user-fqdn
 @vindex mail-host-address
+@vindex user-mail-address
 @findex system-name
 @cindex Sun
+@cindex i-did-not-set--mail-host-address--so-tickle-me
 This required header will be generated by Message.  A unique ID will be
-created based on the date, time, user name and system name.  Message
-will use @code{system-name} to determine the name of the system.  If
-this isn't a fully qualified domain name (FQDN), Message will use
-@code{mail-host-address} as the FQDN of the machine.
+created based on the date, time, user name and system name.  For the
+domain part, message will look (in this order) at
+@code{message-user-fqdn}, @code{system-name}, @code{mail-host-address}
+and @code{message-user-mail-address} (i.e. @code{user-mail-address})
+until a probably valid fully qualified domain name (FQDN) was found.
 
 @item User-Agent
 @cindex User-Agent

[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


Bye, Reiner.

[1] E.g. <news:86wujvvxpu.fsf@a.z>
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: messsage-user-fqdn
  2003-02-20 21:50 messsage-user-fqdn Reiner Steib
@ 2003-02-21 15:40 ` Kai Großjohann
  2003-02-22 22:17 ` messsage-user-fqdn Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 7+ messages in thread
From: Kai Großjohann @ 2003-02-21 15:40 UTC (permalink / raw)


Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:

> The new variable `message-valid-fqdn-regexp' is a duplication of
> `gnus-button-valid-fqdn-regexp'.  But AFAIK, it's not allowed to
> require `gnus-art' from `message.el', is it?  What about the other way
> round?  Other possibilities?

The other way round sounds like a very good idea.  So just move the
value and have gnus-button-valid-fqdn-regexp get it from message.

-- 
A preposition is not a good thing to end a sentence with.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: messsage-user-fqdn
  2003-02-20 21:50 messsage-user-fqdn Reiner Steib
  2003-02-21 15:40 ` messsage-user-fqdn Kai Großjohann
@ 2003-02-22 22:17 ` Lars Magne Ingebrigtsen
  2003-02-23  6:32   ` messsage-user-fqdn Peter Wu
  1 sibling, 1 reply; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2003-02-22 22:17 UTC (permalink / raw)


Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:

> People often ask how to set the FQDN[1].  They are often advised to
> redefine `message-make-fqdn' or `message-make-message-id' (ugly hacks,
> IMHO) or to set `mail-host-address':

The latter is the right answer.  :-)

> I propose to add a variable `messsage-user-fqdn' *and* add a better
> validity check for the domain part as well.

In what way does that help above setting `mail-host-address' to
something correct?

> The new variable `message-valid-fqdn-regexp' is a duplication of
> `gnus-button-valid-fqdn-regexp'.  But AFAIK, it's not allowed to
> require `gnus-art' from `message.el', is it?  What about the other way
> round?  Other possibilities?

The other way around would be OK.

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: messsage-user-fqdn
  2003-02-22 22:17 ` messsage-user-fqdn Lars Magne Ingebrigtsen
@ 2003-02-23  6:32   ` Peter Wu
  2003-02-23 10:29     ` messsage-user-fqdn Kai Großjohann
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Wu @ 2003-02-23  6:32 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:
>
>> People often ask how to set the FQDN[1].  They are often advised to
>> redefine `message-make-fqdn' or `message-make-message-id' (ugly hacks,
>> IMHO) or to set `mail-host-address':
>
> The latter is the right answer.  :-)

Well, it seems that the latter approach does not work for my 0.15. Also,
message-make-fqdn does not work well here. It just still reads my fake
domain on my box.

-- 
Peter Wu
Powered by FreeBSD 4.7-STABLE



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: messsage-user-fqdn
  2003-02-23  6:32   ` messsage-user-fqdn Peter Wu
@ 2003-02-23 10:29     ` Kai Großjohann
  2003-02-23 11:31       ` messsage-user-fqdn Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Kai Großjohann @ 2003-02-23 10:29 UTC (permalink / raw)


Peter Wu <peterwu@canada.com> writes:

> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> Reiner Steib <4.uce.03.r.s@nurfuerspam.de> writes:
>>
>>> People often ask how to set the FQDN[1].  They are often advised to
>>> redefine `message-make-fqdn' or `message-make-message-id' (ugly hacks,
>>> IMHO) or to set `mail-host-address':
>>
>> The latter is the right answer.  :-)
>
> Well, it seems that the latter approach does not work for my 0.15.

If system-name has a dot, then system-name is used.

Maybe message-make-fqdn should be changed to always prefer
mail-host-address, if set?
-- 
A preposition is not a good thing to end a sentence with.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: messsage-user-fqdn
  2003-02-23 10:29     ` messsage-user-fqdn Kai Großjohann
@ 2003-02-23 11:31       ` Lars Magne Ingebrigtsen
  2003-02-23 13:25         ` messsage-user-fqdn Kai Großjohann
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2003-02-23 11:31 UTC (permalink / raw)


kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:

> If system-name has a dot, then system-name is used.
>
> Maybe message-make-fqdn should be changed to always prefer
> mail-host-address, if set?

`mail-host-address' is fine as a back-up address, but `system-name'
is better (if it is set).  For instance, I could set
`mail-host-address' to "gnus.org", but I'd still want the Message-IDs
to say "quimbies.gnus.org", since that's the machine I'm sending
from... 

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: messsage-user-fqdn
  2003-02-23 11:31       ` messsage-user-fqdn Lars Magne Ingebrigtsen
@ 2003-02-23 13:25         ` Kai Großjohann
  0 siblings, 0 replies; 7+ messages in thread
From: Kai Großjohann @ 2003-02-23 13:25 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> `mail-host-address' is fine as a back-up address, but `system-name'
> is better (if it is set).  For instance, I could set
> `mail-host-address' to "gnus.org", but I'd still want the Message-IDs
> to say "quimbies.gnus.org", since that's the machine I'm sending
> from... 

After we have been discussing so long, I had a look at the original
patch and I think that Reiner has chosen the right solution: add a
new variable.

So I've now committed Reiner's change.

Sorry for the delay, Reiner.
I hope it's okay with you, Lars.
-- 
A preposition is not a good thing to end a sentence with.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-02-23 13:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-20 21:50 messsage-user-fqdn Reiner Steib
2003-02-21 15:40 ` messsage-user-fqdn Kai Großjohann
2003-02-22 22:17 ` messsage-user-fqdn Lars Magne Ingebrigtsen
2003-02-23  6:32   ` messsage-user-fqdn Peter Wu
2003-02-23 10:29     ` messsage-user-fqdn Kai Großjohann
2003-02-23 11:31       ` messsage-user-fqdn Lars Magne Ingebrigtsen
2003-02-23 13:25         ` messsage-user-fqdn Kai Großjohann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).