1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
From: Antonio Radici <antonio@debian.org>
Date: Thu, 27 Feb 2014 15:58:54 +0100
Subject: Md.etc_mailname_gethostbyname
If /etc/mailname is present, the hostname inside the file will be
used, rather than calling gethostbyname() on the actual hostname.
Gbp-Pq: Topic debian-specific
---
init.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/init.c b/init.c
index d95c9bc..767d43c 100644
--- a/init.c
+++ b/init.c
@@ -48,6 +48,7 @@
#include <unistd.h>
#include <string.h>
#include <sys/utsname.h>
+#include <netdb.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/time.h>
@@ -2943,6 +2944,31 @@ static void mutt_srandom (void)
srandom(seed);
}
+int getmailname(char *s, size_t l)
+{
+ FILE *f;
+ char tmp[512];
+ char *p = tmp;
+
+ if ((f = fopen ("/etc/mailname", "r")) == NULL)
+ return (-1);
+
+ if (fgets (tmp, 510, f) != NULL) {
+ while (*p && !ISSPACE(*p) && l > 0) {
+ *s++ = *p++;
+ l--;
+ }
+ if (*(s-1) == '.')
+ s--;
+ *s = 0;
+
+ fclose (f);
+ return 0;
+ }
+ fclose (f);
+ return (-1);
+}
+
void mutt_init (int skip_sys_rc, LIST *commands)
{
struct passwd *pw;
@@ -3019,10 +3045,25 @@ void mutt_init (int skip_sys_rc, LIST *commands)
Hostname = mutt_substrdup (utsname.nodename, p);
p++;
strfcpy (buffer, p, sizeof (buffer)); /* save the domain for below */
+ Fqdn = safe_strdup (utsname.nodename);
}
else
Hostname = safe_strdup (utsname.nodename);
+ /* if /etc/mailname exists use it and ignore everything else */
+ if (getmailname(buffer, sizeof (buffer)) != -1)
+ Fqdn = safe_strdup(buffer);
+
+ /* try gethostbyname(3) if /etc/mailname does not exists */
+ if (!Fqdn) {
+ struct hostent *hp;
+
+ if ((hp = gethostbyname(Hostname)))
+ Fqdn = safe_strdup(hp->h_name);
+ }
+
+ if (Fqdn) {
+ } else
#ifndef DOMAIN
#define DOMAIN buffer
if (!p && getdnsdomainname (buffer, sizeof (buffer)) == -1)
|