You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Md.etc_mailname_gethostbyname.patch 1.9KB

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