From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qKgaElEDOmHtSQAAgWs5BA (envelope-from ) for ; Thu, 09 Sep 2021 14:51:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id OEYADlEDOmGUeAAA1q6Kng (envelope-from ) for ; Thu, 09 Sep 2021 12:51:29 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F30AF11E95 for ; Thu, 9 Sep 2021 14:51:27 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 2529E20588; Thu, 9 Sep 2021 08:51:23 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 4D55E2057C for ; Thu, 9 Sep 2021 08:51:20 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 04CE45FD5C; Thu, 9 Sep 2021 08:51:19 -0400 (EDT) Received: (nullmailer pid 215350 invoked by uid 1000); Thu, 09 Sep 2021 12:51:18 -0000 From: David Bremner To: Tomi Ollila , David Bremner , notmuch@notmuchmail.org Subject: [PATCH] lib: use 'localhost' rather than fqdn for default mail address. Date: Thu, 9 Sep 2021 09:51:03 -0300 Message-Id: <20210909125103.215302-1-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Message-ID-Hash: AQGUXOICFTZJQGRH7THFMNMMHGUOLTVR X-Message-ID-Hash: AQGUXOICFTZJQGRH7THFMNMMHGUOLTVR X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631191889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=88QzRUDMPNyLZsXICd1wSXLNo1OUsKuc9vzu6No0Ud4=; b=K1UFL6Ntt5yfslWZ9EDVoe4GWMBmS3Kni/4ruQVIvPIg3/8VkEieGXgqCz1OKy99R+k4Az 3q2RhX4xE707bcCI14WHHcgr405lQl5wCQLn/rkrhpC2NIIsa6BnWNds6J7Cp2Ve3Btg9S xV33Racu+CfMVAT3JXuN0743Bpv823MO0BkN29pyEBZitBoBPJ0Ll0yfSRo/iMfzVdwT7o C20EuyH/CO4ozGfK8t2xjZuGmpeOxPNU0yOqOjeCWgsfSN3Y9OIAmP1aVOW7eSSqv+2CF5 zUf3lUm3zIdgasgN1P3n9SjxPskIyW1yP2urB303Sokk1BJcsdb8mJxvxVHs8w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631191889; a=rsa-sha256; cv=none; b=sLVTW5nNgMNvRAyaK0bYxB2jFJZ5fEb/cJPQD3mupju11o/JKeLof85Ur5RUaX/Z7t/e9j KexvszfD02MJ/0pie3to+9Lopn+LDjhHR6YwCWHQsHQ5V7XrWSQQyWY6s5ozTR33Hhgpl4 A8NwtI+Gl6MesbpwNJ2W7gP7NvfRXSkfCDlbBl0CPpR9yDGJ/h7Ux2t717GJEFvbQ+WAqf BsW4+Zn9saoDStD48S4rct3BEjA6CuC3r5BUk/nxUZSNlLV5rG3b580v4QVbn6q5YNXQrn tkjUlxgSC6QlpROKiuihGwAsCfZKzcxzyDLTJl90e+WEQl17YUG6qFFmJf7gGA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.12 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: F30AF11E95 X-Spam-Score: -1.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: DKhMXGuMEOKP 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