From: David Bremner <david@tethera.net>
To: Tomi Ollila <tomi.ollila@iki.fi>,
David Bremner <david@tethera.net>,
notmuch@notmuchmail.org
Subject: [PATCH] lib: use 'localhost' rather than fqdn for default mail address.
Date: Thu, 9 Sep 2021 09:51:03 -0300 [thread overview]
Message-ID: <20210909125103.215302-1-david@tethera.net> (raw)
In-Reply-To: <m2v93cstql.fsf@guru.guru-group.fi>
As discussed in the thread starting at [1], the fully qualified domain
name is a bit tricky to get reproducibly, might reveal information
people prefer to keep private, and somewhat unlikely to provide
reliable mail routing.
The new approach of $current_username@localhost is better for the
first two considerations, and probably at least as good as a test mail
address.
[1]: id:87sfyibqhj.fsf@tethera.net
---
lib/config.cc | 17 ++---------------
test/T590-libconfig.sh | 10 ++++------
2 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/lib/config.cc b/lib/config.cc
index 7ecc3c7b..408570bc 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -543,25 +543,12 @@ _get_username_from_passwd_file (void *ctx)
static const char *
_get_email_from_passwd_file (void *ctx)
{
-
- char hostname[256];
- struct hostent *hostent;
- const char *domainname;
char *email;
char *username = _get_username_from_passwd_file (ctx);
- gethostname (hostname, 256);
- hostname[255] = '\0';
-
- hostent = gethostbyname (hostname);
- if (hostent && (domainname = strchr (hostent->h_name, '.')))
- domainname += 1;
- else
- domainname = "(none)";
-
- email = talloc_asprintf (ctx, "%s@%s.%s",
- username, hostname, domainname);
+ email = talloc_asprintf (ctx, "%s@localhost",
+ username);
talloc_free (username);
return email;
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 41f67bae..59b82a6f 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -12,12 +12,10 @@ import os, sys, pwd, socket
pw = pwd.getpwuid(os.getuid())
user = pw.pw_name
name = pw.pw_gecos.partition(",")[0]
-fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
- socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
+
for l in sys.stdin:
if l[:4] == "08: ":
- l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1)
- l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1)
+ l = l.replace(user, "USERNAME", 1)
elif l[:4] == "10: ":
l = l.replace("'" + name, "'USER_FULL_NAME", 1)
sys.stdout.write(l)
@@ -416,7 +414,7 @@ cat <<'EOF' >EXPECTED
05: 'unread;inbox'
06: ''
07: 'true'
-08: 'USERNAME@FQDN'
+08: 'USERNAME@localhost'
09: 'NULL'
10: 'USER_FULL_NAME'
11: '8000'
@@ -761,7 +759,7 @@ cat <<'EOF' >EXPECTED
05: 'unread;inbox'
06: ''
07: 'true'
-08: 'USERNAME@FQDN'
+08: 'USERNAME@localhost'
09: 'NULL'
10: 'USER_FULL_NAME'
11: '8000'
--
2.30.2
next prev parent reply other threads:[~2021-09-09 12:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-05 22:35 Is default email address in notmuch setup / lib useful? David Bremner
2021-09-06 17:14 ` Alexander Adolf
2021-09-06 20:39 ` Tomi Ollila
2021-09-07 1:26 ` David Bremner
2021-09-07 7:57 ` Tomi Ollila
2021-09-09 12:51 ` David Bremner [this message]
2021-09-09 20:09 ` [PATCH] lib: use 'localhost' rather than fqdn for default mail address Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210909125103.215302-1-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
--cc=tomi.ollila@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).