Re: [PATCH 04/13] test: use correct fqdn in passwd_sanitize()

Subject: Re: [PATCH 04/13] test: use correct fqdn in passwd_sanitize()

Date: Sat, 01 May 2021 23:14:31 +0300

To: Felipe Contreras, notmuch@notmuchmail.org

Cc: Daniel Kahn Gillmor

From: Tomi Ollila


On Sat, May 01 2021, Felipe Contreras wrote:

> My fqdn is 'natae.localdomain', however, socket.getfqdn() returns
> 'localhost'.
>
> To fetch the true fqdn we need socket.getaddrinfo().
>
> For more information see: https://stackoverflow.com/a/11580042/10474
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  test/test-lib.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index ae653363..21dda265 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -709,7 +709,7 @@ import os, sys, pwd, socket
>  pw = pwd.getpwuid(os.getuid())
>  user = pw.pw_name
>  name = pw.pw_gecos.partition(",")[0]
> -fqdn = socket.getfqdn()
> +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0, socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]

I trust you this works better. 

LGTM.

Tomi
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: