[mutt] 02/04: changing the etc_mailname_gethostbyname.patch to use mutt libraries

Antonio Radici antonio at moszumanska.debian.org
Sun Nov 26 12:08:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

antonio pushed a commit to branch master
in repository mutt.

commit e851557099757132b23b23392c173498cf27f863
Author: Antonio Radici <antonio at debian.org>
Date:   Sun Nov 26 11:09:19 2017 +0000

    changing the etc_mailname_gethostbyname.patch to use mutt libraries
---
 debian/changelog                                   |  3 +
 ...tch => 882690-use_fqdn_from_etc_mailname.patch} | 82 +++++++++++-----------
 debian/patches/series                              |  2 +-
 3 files changed, 46 insertions(+), 41 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4f40c5f..ad58e57 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,9 @@ mutt (1.9.1-5) UNRELEASED; urgency=medium
     for text/html content.
   * debian/{rules,control}: removed any reference to notmuch.
   * Bumped Standards-Version to 4.1.1; no changes required.
+  * debian/patches:
+    + rewrote Md.etc_mailname_gethostbyname.patch and renamed it to
+      882690-use_fqdn_from_etc_mailname.patch (Closes: 882690)
 
  -- Antonio Radici <antonio at debian.org>  Sat, 25 Nov 2017 18:23:05 +0000
 
diff --git a/debian/patches/debian-specific/Md.etc_mailname_gethostbyname.patch b/debian/patches/debian-specific/882690-use_fqdn_from_etc_mailname.patch
similarity index 61%
rename from debian/patches/debian-specific/Md.etc_mailname_gethostbyname.patch
rename to debian/patches/debian-specific/882690-use_fqdn_from_etc_mailname.patch
index cb25449..17c1c51 100644
--- a/debian/patches/debian-specific/Md.etc_mailname_gethostbyname.patch
+++ b/debian/patches/debian-specific/882690-use_fqdn_from_etc_mailname.patch
@@ -1,67 +1,61 @@
-From: Antonio Radici <antonio at 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.
----
- init.c | 32 ++++++++++++++++++++++++++++++--
- 1 file changed, 30 insertions(+), 2 deletions(-)
+
+This patch is based on Md.etc_mailname_gethostbyname.patch which did not apply
+cleanly to mutt 1.9.1 so I decided to rewrite to use the mutt libraries.
 
 --- a/init.c
 +++ b/init.c
-@@ -134,6 +134,33 @@
+@@ -134,6 +134,30 @@
    return (-1);
  }
  
-+static int getmailname(char *s, size_t l)
++/* getmailname returns the content of /etc/mailname if present, so that the caller can use that instead of calling
++ * gethostbyname() on the hostname; the function returns NULL in case of failure or a dynamically allocated buffer in
++ * case of success. The buffer needs to be freed after use.
++ */
++static char *getmailname(void)
 +{
-+    FILE *f;
-+    char tmp[512];
-+    char *p = tmp;
-+
-+    if ((f = fopen ("/etc/mailname", "r")) == NULL)
-+       return (-1);
++  FILE *f;
++  int lineno = 0;
++  size_t slen = 0;
++  char *s;
 +
-+    if (fgets (tmp, 510, f) != NULL) {
-+      while (*p && !ISSPACE(*p) && l > 0) {
-+	*s++ = *p++;
-+	l--;
-+      }
-+      if (*(s-1) == '.')
-+	s--;
-+      *s = 0;
++  if (!(f = safe_fopen("/etc/mailname", "r")))
++  {
++    return NULL;
++  }
 +
-+      fclose (f);
-+      return 0;
-+    }
-+    fclose (f);
-+    return (-1);
++  s = mutt_read_line(NULL, &slen, f, &lineno, 0);
++  safe_fclose(&f);
++  if (!s || slen == 0) {
++    return NULL;
++  }
++  return s;
 +}
 +
-+
-+
  int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
  {
    char		ch;
-@@ -3399,22 +3426,43 @@
+@@ -3398,23 +3422,42 @@
+     exit (1);
    }
  
-   /* some systems report the FQDN instead of just the hostname */
-+  /* If /etc/mailname is available, use that as domain name, otherwise the
-+   * configured domain, DNS or uname (in order) */
-+  if (getmailname(buffer, sizeof(buffer)) != -1)
-+  {
-+    Fqdn = safe_strdup(buffer);
-+  }
+-  /* some systems report the FQDN instead of just the hostname */
    if ((p = strchr (utsname.nodename, '.')))
      Hostname = mutt_substrdup (utsname.nodename, p);
    else
      Hostname = safe_strdup (utsname.nodename);
 -
-   /* now get FQDN.  Use configured domain first, DNS next, then uname */
+-  /* now get FQDN.  Use configured domain first, DNS next, then uname */
 -  if (domain)
-+  if (domain && !Fqdn)
++  /* If /etc/mailname is available, use that as domain name, otherwise the
++   * configured domain, DNS or uname (in order) */
++  if ((p = getmailname()))
++  {
++    Fqdn = safe_strdup(p);
++  }
++  else if (domain)
    {
      /* we have a compile-time domain name, use that for Fqdn */
      Fqdn = safe_malloc (mutt_strlen (domain) + mutt_strlen (Hostname) + 2);
@@ -93,3 +87,11 @@ used, rather than calling gethostbyname() on the actual hostname.
    }
    else
      /*
+@@ -3428,7 +3471,6 @@
+      */
+     Fqdn = safe_strdup(utsname.nodename);
+ 
+-
+   if ((p = getenv ("MAIL")))
+     Spoolfile = safe_strdup (p);
+   else if ((p = getenv ("MAILDIR")))
diff --git a/debian/patches/series b/debian/patches/series
index ef78fe4..d89b8d6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,5 +1,5 @@
 debian-specific/Muttrc.patch
-debian-specific/Md.etc_mailname_gethostbyname.patch
+debian-specific/882690-use_fqdn_from_etc_mailname.patch
 debian-specific/use_usr_bin_editor.patch
 debian-specific/correct_docdir_in_man_page.patch
 debian-specific/document_debian_defaults.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mutt/mutt.git



More information about the pkg-mutt-commits mailing list