From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6A09F3858401 for ; Tue, 13 Sep 2022 14:35:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A09F3858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663079753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+cVV8qidJnTA37RdQCLaouPt03iL0CFAVy+ec7LfYqE=; b=O1yyn137VkVj94WoHB+VNpCZT4BiLFKMHrSn4yLdaSLIthCtQF4bpYtKd5pKMvXVnDYrXf cRd+rpR2xcZymbttcx1gjhOarOZu5OnEMnT7XwEjqfkWJ/XEAy4nMhrFUGM3/xtDc6MNuo RZdehYMAVJH/ZlWo4RZa9JeDjcvpJis= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-JL10iNhrMZycdXQonetX7g-1; Tue, 13 Sep 2022 10:35:47 -0400 X-MC-Unique: JL10iNhrMZycdXQonetX7g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 427A53817A77 for ; Tue, 13 Sep 2022 14:35:47 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.210]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A83A349BB61 for ; Tue, 13 Sep 2022 14:35:46 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 1/2] nss: Implement --no-addrconfig option for getent In-Reply-To: References: X-From-Line: 462265b0ce37bd57b9304d873e9bccdb1cc4a199 Mon Sep 17 00:00:00 2001 Message-Id: <462265b0ce37bd57b9304d873e9bccdb1cc4a199.1663079342.git.fweimer@redhat.com> Date: Tue, 13 Sep 2022 16:35:44 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The ahosts, ahostsv4, ahostsv6 commands unconditionally pass AI_ADDRCONFIG to getaddrinfo, which is not always desired. --- NEWS | 5 ++++- nss/getent.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index ef274d1a42..d4739d93c6 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,10 @@ Version 2.37 Major new features: - [Add new features here] +* The getent tool now supports the --no-addrconfig option. When + present, getent no longer passes AI_ADDRCONFIG to the getaddrinfo + function, and the output may contain addresses of families not + configured on the current host. Deprecated and removed features, and other changes affecting compatibility: diff --git a/nss/getent.c b/nss/getent.c index 8178b4b470..39a42e707d 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -58,6 +58,8 @@ static const struct argp_option args_options[] = { { "service", 's', N_("CONFIG"), 0, N_("Service configuration to be used") }, { "no-idn", 'i', NULL, 0, N_("disable IDN encoding") }, + { "no-addrconfig", 'A', NULL, 0, + N_("disable AI_ADDRCONFIG (for ahosts*)") }, { NULL, 0, NULL, 0, NULL }, }; @@ -79,6 +81,9 @@ static struct argp argp = /* Additional getaddrinfo flags for IDN encoding. */ static int idn_flags = AI_IDN | AI_CANONIDN; +/* Set to 0 by --no-addrconfig. */ +static int addrconfig_flags = AI_ADDRCONFIG; + /* Print the version information. */ static void print_version (FILE *stream, struct argp_state *state) @@ -346,7 +351,7 @@ ahosts_keys_int (int af, int xflags, int number, char *key[]) struct addrinfo hint; memset (&hint, '\0', sizeof (hint)); - hint.ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME + hint.ai_flags = (AI_V4MAPPED | addrconfig_flags | AI_CANONNAME | idn_flags | xflags); hint.ai_family = af; @@ -905,6 +910,10 @@ parse_option (int key, char *arg, struct argp_state *state) idn_flags = 0; break; + case 'A': + addrconfig_flags = 0; + break; + default: return ARGP_ERR_UNKNOWN; } -- 2.37.2