1 If /etc/mailname is present, the hostname inside the file will be
2 used, rather than calling gethostbyname() on the actual hostname
9 #include <sys/utsname.h>
14 @@ -2952,6 +2953,31 @@
18 +int getmailname(char *s, size_t l)
24 + if ((f = fopen ("/etc/mailname", "r")) == NULL)
27 + if (fgets (tmp, 510, f) != NULL) {
28 + while (*p && !ISSPACE(*p) && l > 0) {
43 void mutt_init (int skip_sys_rc, LIST *commands)
46 @@ -3026,10 +3052,25 @@
47 Hostname = mutt_substrdup (utsname.nodename, p);
49 strfcpy (buffer, p, sizeof (buffer)); /* save the domain for below */
50 + Fqdn = safe_strdup (utsname.nodename);
53 Hostname = safe_strdup (utsname.nodename);
55 + /* if /etc/mailname exists use it and ignore everything else */
56 + if (getmailname(buffer, sizeof (buffer)) != -1)
57 + Fqdn = safe_strdup(buffer);
59 + /* try gethostbyname(3) if /etc/mailname does not exists */
63 + if ((hp = gethostbyname(Hostname)))
64 + Fqdn = safe_strdup(hp->h_name);
71 if (!p && getdnsdomainname (buffer, sizeof (buffer)) == -1)