summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init.c')
-rw-r--r--init.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/init.c b/init.c
index 9fcd53f2..0cc362b7 100644
--- a/init.c
+++ b/init.c
@@ -2887,6 +2887,7 @@ static void mutt_srandom (void)
void mutt_init (int skip_sys_rc, LIST *commands)
{
struct passwd *pw;
+ struct utsname utsname;
char *p, buffer[STRING];
int i, default_rc = 0, need_pause = 0;
BUFFER err;
@@ -2952,21 +2953,30 @@ void mutt_init (int skip_sys_rc, LIST *commands)
#endif
/* And about the host... */
+ uname (&utsname);
+ /* some systems report the FQDN instead of just the hostname */
+ if ((p = strchr (utsname.nodename, '.')))
{
- size_t namelen = sysconf(_SC_HOST_NAME_MAX);
- char *name = safe_malloc(namelen + 1);
- if (gethostname(name, namelen) == -1)
- {
- fputs (_("unable to determine hostname"), stderr);
- exit (1);
- }
- Hostname = safe_strdup(name);
- FREE (&name);
+ Hostname = mutt_substrdup (utsname.nodename, p);
+ p++;
+ strfcpy (buffer, p, sizeof (buffer)); /* save the domain for below */
}
+ else
+ Hostname = safe_strdup (utsname.nodename);
- /* determine the DNS domain name */
- getdnsdomainname (buffer, sizeof (buffer));
- Fqdn = safe_strdup(buffer);
+#ifndef DOMAIN
+#define DOMAIN buffer
+ if (!p && getdnsdomainname (buffer, sizeof (buffer)) == -1)
+ Fqdn = safe_strdup ("@");
+ else
+#endif /* DOMAIN */
+ if (*DOMAIN != '@')
+ {
+ Fqdn = safe_malloc (mutt_strlen (DOMAIN) + mutt_strlen (Hostname) + 2);
+ sprintf (Fqdn, "%s.%s", NONULL(Hostname), DOMAIN); /* __SPRINTF_CHECKED__ */
+ }
+ else
+ Fqdn = safe_strdup(NONULL(Hostname));
if ((p = getenv ("MAIL")))
Spoolfile = safe_strdup (p);