unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Is default email address in notmuch setup / lib useful?
@ 2021-09-05 22:35 David Bremner
  2021-09-06 17:14 ` Alexander Adolf
  0 siblings, 1 reply; 7+ messages in thread
From: David Bremner @ 2021-09-05 22:35 UTC (permalink / raw)
  To: notmuch


Currently notmuch tries to make a guess for a default email address
based on the "fully qualified hostname" of the host it is running
on. This is roughly equivalent to running "hostname -f". I have observed
two things

1) It's a bit flaky. There are various functions (gethostbyname,
getaddrinfo) that work in subtly different ways.  We've tried
three different setups in the test suite to test this, and none of them
work everywhere.

2) It doesn't seem that useful. The number of people running notmuch on
hosts that can (and want to) receive email seems pretty
small. Furthermore, it's not obvious we're going to get the right
name. For example on my laptop it returns "zancas.local", which is only
routable on my home LAN.

I could be wrong about 2, though.  If you actually find this to be a
useful feature, please reply to this thread.

If people agree it's generally not useful, I'd propose to replace it
with some simpler default like "localhost" [1], equally useful to for
testing, but simpler to implement and test.

[1]: required by at least RFC6761

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is default email address in notmuch setup / lib useful?
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Adolf @ 2021-09-06 17:14 UTC (permalink / raw)
  To: David Bremner, notmuch

David Bremner <david@tethera.net> writes:

> Currently notmuch tries to make a guess for a default email address
> based on the "fully qualified hostname" of the host it is running
> on. This is roughly equivalent to running "hostname -f". I have observed
> two things
> [...]
> If people agree it's generally not useful, I'd propose to replace it
> with some simpler default like "localhost" [1], equally useful to for
> testing, but simpler to implement and test.
> [...]

I'd support David's suggestion to just default it to "localhost".

If an unsuspecting user tries to send their first email with notmuch,
the current behaviour could reveal information about the user's local
infrastructure in the message. "localhost" is a much safer default, IMO.

  --alex

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is default email address in notmuch setup / lib useful?
  2021-09-06 17:14 ` Alexander Adolf
@ 2021-09-06 20:39   ` Tomi Ollila
  2021-09-07  1:26     ` David Bremner
  0 siblings, 1 reply; 7+ messages in thread
From: Tomi Ollila @ 2021-09-06 20:39 UTC (permalink / raw)
  To: Alexander Adolf, David Bremner, notmuch

On Mon, Sep 06 2021, Alexander Adolf wrote:

> David Bremner <david@tethera.net> writes:
>
>> Currently notmuch tries to make a guess for a default email address
>> based on the "fully qualified hostname" of the host it is running
>> on. This is roughly equivalent to running "hostname -f". I have observed
>> two things
>> [...]
>> If people agree it's generally not useful, I'd propose to replace it
>> with some simpler default like "localhost" [1], equally useful to for
>> testing, but simpler to implement and test.
>> [...]
>
> I'd support David's suggestion to just default it to "localhost".
>
> If an unsuspecting user tries to send their first email with notmuch,
> the current behaviour could reveal information about the user's local
> infrastructure in the message. "localhost" is a much safer default, IMO.

Agreed. I tried to look whether we could get rid of user.name and
user.primary_email config values (and then emacs/other email clients
would need to resolve that information elsewhere). I don't know if
that can ever be done (or should), but the the current beaviour
is flaky (and I agree potentially insecure).


>
>   --alex

Tomi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is default email address in notmuch setup / lib useful?
  2021-09-06 20:39   ` Tomi Ollila
@ 2021-09-07  1:26     ` David Bremner
  2021-09-07  7:57       ` Tomi Ollila
  0 siblings, 1 reply; 7+ messages in thread
From: David Bremner @ 2021-09-07  1:26 UTC (permalink / raw)
  To: Tomi Ollila, Alexander Adolf, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

>
> Agreed. I tried to look whether we could get rid of user.name and
> user.primary_email config values (and then emacs/other email clients
> would need to resolve that information elsewhere). I don't know if
> that can ever be done (or should), but the the current beaviour
> is flaky (and I agree potentially insecure).

Would that involve getting rid of notmuch-reply, or something else?

d

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is default email address in notmuch setup / lib useful?
  2021-09-07  1:26     ` David Bremner
@ 2021-09-07  7:57       ` Tomi Ollila
  2021-09-09 12:51         ` [PATCH] lib: use 'localhost' rather than fqdn for default mail address David Bremner
  0 siblings, 1 reply; 7+ messages in thread
From: Tomi Ollila @ 2021-09-07  7:57 UTC (permalink / raw)
  To: David Bremner, Alexander Adolf, notmuch

On Mon, Sep 06 2021, David Bremner wrote:

> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>>
>> Agreed. I tried to look whether we could get rid of user.name and
>> user.primary_email config values (and then emacs/other email clients
>> would need to resolve that information elsewhere). I don't know if
>> that can ever be done (or should), but the the current beaviour
>> is flaky (and I agree potentially insecure).
>
> Would that involve getting rid of notmuch-reply, or something else?

I did not think/remember that. Are there any users (am I a user >;D) ?

Anyway, localhost ftw (for now)

>
> d

Tomi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] lib: use 'localhost' rather than fqdn for default mail address.
  2021-09-07  7:57       ` Tomi Ollila
@ 2021-09-09 12:51         ` David Bremner
  2021-09-09 20:09           ` Tomi Ollila
  0 siblings, 1 reply; 7+ messages in thread
From: David Bremner @ 2021-09-09 12:51 UTC (permalink / raw)
  To: Tomi Ollila, David Bremner, notmuch

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] lib: use 'localhost' rather than fqdn for default mail address.
  2021-09-09 12:51         ` [PATCH] lib: use 'localhost' rather than fqdn for default mail address David Bremner
@ 2021-09-09 20:09           ` Tomi Ollila
  0 siblings, 0 replies; 7+ messages in thread
From: Tomi Ollila @ 2021-09-09 20:09 UTC (permalink / raw)
  To: David Bremner, notmuch

On Thu, Sep 09 2021, David Bremner wrote:

> 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);

perhaps the above 2 lines as one:

> +    email = talloc_asprintf (ctx, "%s@localhost", username);

LGTM in any way.

Tomi

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-09 20:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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         ` [PATCH] lib: use 'localhost' rather than fqdn for default mail address David Bremner
2021-09-09 20:09           ` Tomi Ollila

Code repositories for project(s) associated with this inbox:

	notmuch.git.git (no URL configured)

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 NNTP newsgroup(s).