]> git.notmuchmail.org Git - notmuch/commitdiff
lib: use 'localhost' rather than fqdn for default mail address.
authorDavid Bremner <david@tethera.net>
Thu, 9 Sep 2021 12:51:03 +0000 (09:51 -0300)
committerDavid Bremner <david@tethera.net>
Fri, 10 Sep 2021 11:17:06 +0000 (08:17 -0300)
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
test/T590-libconfig.sh

index 7ecc3c7b4ba25f9a65202b4bedc11056b954b600..8775b00af8396280792e4af7049973b873f35586 100644 (file)
@@ -543,25 +543,11 @@ _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;
index 41f67baeceb02719802439cc9e0936e2f264f6dd..59b82a6f6a81069b9578c83cafd24a546f98a58b 100755 (executable)
@@ -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'