return 0;
if (!ascii_strcasecmp(addr->mailbox, MCore.username)
- || string_is_address(addr->mailbox, MCore.username, Hostname)
+ || string_is_address(addr->mailbox, MCore.username, MCore.shorthost)
|| string_is_address(addr->mailbox, MCore.username, mutt_fqdn(0))
|| string_is_address(addr->mailbox, MCore.username, mutt_fqdn(1))
|| (From && !ascii_strcasecmp(From->mailbox, addr->mailbox)))
case 'h': /* hostname */
snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
- snprintf (buf, buflen, fmt, NONULL (Hostname));
+ snprintf (buf, buflen, fmt, NONULL(MCore.shorthost));
break;
case 'l': /* approx length of current message in bytes */
WHERE char *ForwFmt;
WHERE char *Fqdn;
WHERE char *HdrFmt;
-WHERE char *Hostname;
WHERE char *ImapAuthenticators INITVAL (NULL);
WHERE char *ImapDelimChars INITVAL (NULL);
*/
#include <lib-lib/lib-lib.h>
-#include <sys/utsname.h>
#include <lib-lua/lib-lua.h>
#include <lib-sys/unix.h>
void mutt_init (int skip_sys_rc, string_list_t * commands)
{
struct passwd *pw;
- struct utsname utsname;
const char *p;
char buffer[STRING], error[STRING];
int default_rc = 0, need_pause = 0;
Realname = m_strdup(rnbuf);
}
- /* And about the host... */
- uname (&utsname);
- /* some systems report the FQDN instead of just the hostname */
- if ((p = strchr (utsname.nodename, '.'))) {
- Hostname = p_dupstr(utsname.nodename, p - utsname.nodename);
- p++;
- m_strcpy(buffer, sizeof(buffer), p); /* save the domain for below */
- }
- else
- Hostname = m_strdup(utsname.nodename);
-
- if (!p && getdnsdomainname(buffer, sizeof(buffer)) == -1)
- Fqdn = m_strdup("@");
- else
- if (*buffer != '@') {
- Fqdn = p_new(char, m_strlen(buffer) + m_strlen(Hostname) + 2);
- sprintf (Fqdn, "%s.%s", NONULL(Hostname), buffer);
- }
- else
- Fqdn = m_strdup(NONULL (Hostname));
-
#ifdef USE_NNTP
{
FILE *f;
NewsServer = m_strdup(p);
#endif
- if ((p = getenv ("MAIL")))
- Spoolfile = m_strdup(p);
- else if ((p = getenv ("MAILDIR")))
+ if ((p = getenv("MAIL") ?: getenv("MAILDIR"))) {
Spoolfile = m_strdup(p);
- else {
+ } else {
#ifdef HOMESPOOL
mutt_concat_path(buffer, sizeof(buffer), NONULL(MCore.homedir), MAILPATH);
#else
** top of threads in the thread tree. Note that when $$hide_limited is
** \fIset\fP, this option will have no effect.
*/
- {"history", DT_NUM, R_NONE, UL &HistSize, "10" },
/*
** .pp
** This variable controls the size (in number of strings remembered) of
** This variable controls whether or not a \fTMail-Followup-To:\fP header field is
** honored when group-replying to a message.
*/
- {"hostname", DT_STR, R_NONE, UL &Fqdn, "" },
- /*
- ** .pp
- ** Specifies the hostname to use after the ``\fT@\fP'' in local e-mail
- ** addresses and during generation of \fTMessage-ID:\fP headers.
- ** .pp
- ** Please be sure to really know what you are doing when changing this variable
- ** to configure a custom domain part of Message-IDs.
- */
{"ignore_list_reply_to", DT_BOOL, R_NONE, OPTIGNORELISTREPLYTO, "no" },
/*
** .pp
## gecos_mask
## hcache_backend
## homedir
+## hostname
## no
## quit
## send_charset
## sendmail
## sendmail_wait
## shell
+## shorthost
## sysconfdir
## tmpdir
## use_8bitmime
*/
#include <lib-lib/lib-lib.h>
-#include <lib-lua/lib-lua.h>
+#include <sys/utsname.h>
#include <sys/types.h>
#include <pwd.h>
+#include <lib-lua/lib-lua.h>
+#include <lib-sys/unix.h>
+
#include "../mutt.h"
@import "base.cpkg"
return m_strdup(pw ? pw->pw_dir : (getenv("HOME") ?: "/"));
}
+static char *madmutt_init_shorthost(void)
+{
+ struct utsname utsname;
+ const char *p;
+
+ /* some systems report the FQDN instead of just the hostname */
+ uname(&utsname);
+ p = strchrnul(utsname.nodename, '.');
+ return p_dupstr(utsname.nodename, p - utsname.nodename);
+}
+
+static char *madmutt_init_hostname(void)
+{
+ char buffer[STRING];
+
+ if (getdnsdomainname(buffer, sizeof(buffer)) < 0)
+ return m_strdup("@");
+
+ if (*buffer != '@') {
+ int len = m_strlen(buffer) + m_strlen(MCore.shorthost) + 2;
+ char *res = p_new(char, len);
+ snprintf(res, len, "%s.%s", NONULL(MCore.shorthost), buffer);
+ return res;
+ }
+
+ return m_strdup(NONULL(MCore.shorthost));
+}
+
#if defined(HAVE_QDBM)
# define HCACHE_BACKEND "qdbm"
#elif defined(HAVE_GDBM)
*/
path_t shell = madmutt_init_shell();
- /* TODO: document */
path_t username = madmutt_init_username();
-
- /* TODO: document */
path_t homedir = madmutt_init_homedir();
+ /*
+ ** .pp
+ ** Specifies the hostname to use after the ``\fT@\fP'' in local e-mail
+ ** addresses and during generation of \fTMessage-ID:\fP headers.
+ ** .pp
+ ** Please be sure to really know what you are doing when changing this variable
+ ** to configure a custom domain part of Message-IDs.
+ */
+ string_t hostname = madmutt_init_hostname();
+ string_t shorthost = madmutt_init_shorthost();
+
/*
** .pp
** This variable allows you to specify where Madmutt will place its
for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d",
- dest->path, NONULL (Hostname), (int) getpid (), Counter++);
+ dest->path, NONULL(MCore.shorthost), (int) getpid (), Counter++);
umask (Umask);
if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
if (errno != EEXIST) {
for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s",
dest->path, subdir, (long) time (NULL),
- (unsigned int) getpid (), Counter++, NONULL (Hostname), suffix);
+ (unsigned int) getpid (), Counter++, NONULL (MCore.shorthost), suffix);
umask (Umask);
if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%u_%d.%s%s", subdir,
(long) time (NULL), (unsigned int) getpid (), Counter++,
- NONULL (Hostname), suffix);
+ NONULL (MCore.shorthost), suffix);
snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
if (safe_rename (msg->path, full) == 0) {
case 'h':
snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
- snprintf (buf, buflen, fmt, NONULL (Hostname));
+ snprintf (buf, buflen, fmt, NONULL (MCore.shorthost));
break;
case 'f':
}
}
-const char *mutt_fqdn (short may_hide_host)
+const char *mutt_fqdn(short may_hide_host)
{
char *p = NULL, *q;
- if (Fqdn && Fqdn[0] != '@') {
- p = Fqdn;
+ if (MCore.hostname && MCore.hostname[0] != '@') {
+ p = MCore.hostname;
if (may_hide_host && option (OPTHIDDENHOST)) {
- if ((p = strchr (Fqdn, '.')))
+ if ((p = strchr(MCore.hostname, '.')))
p++;
/* sanity check: don't hide the host if
the fqdn is something like detebe.org. */
- if (!p || !(q = strchr (p, '.')))
- p = Fqdn;
+ if (!p || !(q = strchr(p, '.')))
+ p = MCore.hostname;
}
}
const char *fqdn;
if (!(fqdn = mutt_fqdn(0)))
- fqdn = NONULL(Hostname);
+ fqdn = NONULL(MCore.shorthost);
mutt_gen_localpart(localpart, sizeof(localpart), MsgIdFormat);
snprintf(buf, sizeof(buf), "<%s@%s>", localpart, fqdn);