From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by sourceware.org (Postfix) with ESMTPS id BF6713858D32 for ; Sat, 4 Nov 2023 13:24:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF6713858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=zplane.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zplane.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BF6713858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=66.111.4.26 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699104242; cv=none; b=CmTCzHawJkPMB1AlRRXxWSr2a9Y1sdCvOclcPH+R6x3dRgqO8Yjfr1dr3DjMJ8X8wYOOFychVN58NaIfWcAvDlslLo0w4g5ceiICGLMaEbNOEjhEfcS1BshVCODkDhJlqB6RLlv9eM0T/B9/rwTO1dIj5EP5MnPpsnVu0e9mER8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699104242; c=relaxed/simple; bh=z+7/KHQlZ1Ho5AqNbntHqzRYwD4aFbdome5ylY8Ijy0=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=xy3u5A3DOcMvfJdA1CE9hvNHDueySK8ro36t4nrepbt3nwtg3FsVETKC99OgVyTXJziFy8t8KHRmbvOSU14jdF1lc+prw/lTsXGUQlGkRZ56WzMC2Dx0BLBII5/eK2Hbuc2MQCHg+rt9vk1ttdn8/aQl5j0M7RYfbXTGnmxYJCg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1CC1A5C00CB for ; Sat, 4 Nov 2023 09:23:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 04 Nov 2023 09:23:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zplane.com; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:reply-to:sender:subject :subject:to:to; s=fm2; t=1699104238; x=1699190638; bh=Dz7/5CpDUC t8nauycoF6Sf0ymEkguBN7UjfBeykKw3s=; b=aLXW0NC37YwuomxW+dAxHNuvGh JDRAJXj4w7r0m6Md4sMgNeF2RI/BZHOfaztQhmulymzeuXb31EM6Infg0WgURx6s r8ou7TXcEhHpU9c/DxZl4PUOWrZQMy1mL/0rUS3+SA6GMJJRgEGQjiJHTIeIxmL3 43W7boxPVrGmhWof0jMrGcWhqSoOm4xbTMTbCYdWVI0uo6Nu4jGV74dZLGGI+Ga1 xHODZmch0fn6C0uPAfFy6tljNwu/gn8VkK1F6Hou3qHrZDoz7H7XufiiyELTot2a 01lAgvUmq7j1pQ5eisUC0z5e7ud1YKN8jMucRTPIG8PVeg20kJ5GzHZ/KeMQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1699104238; x=1699190638; bh=Dz7/5CpDUCt8nauycoF6Sf0ymEkg uBN7UjfBeykKw3s=; b=pBpkbKQ/kfu8j22yTMLLyNVfiSaV2aNuNMkEvvEJsAqi H53+nN1qvetbXjDDHMHQJDJSAEXtKTc5KPYhHXnPumjbPTWzKha2XfLXMo5u3GbA QtqnJaCmU21LnWn+VP92iu1jPjYT+Hx8ICvILU4tKzRg56BTXSp1NcOSJ7J0Dvx9 kLvYl87g1wUerdFaHg7+77pZb1mO5z14iYKmYYinDdIwkLb6DlGexu+UUPGmPMTS fNoLTT2xJgWHy8/rI839JGoSsgbVcdC6tsC/Z7gjYBn87UILwNKq6kX8KCDstsXb Dt8iNxSm5twj9lEzJEDEUyfh+Pc0ar1VCykf+rFjZA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddutddgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkrhggtggusehttdertd dttddvnecuhfhrohhmpefilhgvnhhnucfiohhluggvnhcuoehgughgseiiphhlrghnvgdr tghomheqnecuggftrfgrthhtvghrnhepgfdutdejudekiefguedthfefkeeggefggefhle evvdevvddvhedthefhhfduffegnecuffhomhgrihhnpeiiphhlrghnvgdrtghomhdpshho uhhrtggvfigrrhgvrdhorhhgpdhlrghunhgthhhprggurdhnvghtpdhsthgrtghkvgigtg hhrghnghgvrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepghgughesiihplhgrnhgvrdgtohhm X-ME-Proxy: Feedback-ID: i002c41f6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 4 Nov 2023 09:23:57 -0400 (EDT) Received: by gc.zplane.com (Postfix, from userid 501) id ECA3440129; Sat, 4 Nov 2023 07:23:56 -0600 (MDT) Date: Sat, 4 Nov 2023 07:23:56 -0600 From: Glenn Golden To: libc-help@sourceware.org Subject: getent ahostsv4 seems to interact with network interface addressing Message-ID: Reply-To: gdg@zplane.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,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: System: Arch linux, glibc 2.38-7, kernel 6.1.59-1, commodity i686 laptop. Description of issue: Not sure if this is a bug or just a misunderstanding on my part as to how getent ought to be behaving when attempting lookups using the ahostsv4 database, expecting it to query and return results from /etc/hosts. The behavior of "getent ahostsv4 HOSTNAME" seems to strangely depend on whether there are any network interfaces presently having an assigned v4 address, as demonstrated in detail in "Steps to reproduce" below. In the typical case, when at least one network interface has a v4 address assigned to it, then "getent ahostsv4 HOSTNAME" behaves as expected, i.e. it returns the addresses of HOSTNAME obtained from /etc/hosts. But if there are no network interfaces having an assigned v4 address, then that same command fails with a null return and exits with code 2, which is documented (in getent.1) as "One or more supplied keys could not be found in the database." I am baffled by this. If this is expected behavior, can someone explain why? Steps to reproduce (as root): # # Step 0: Display all interfaces having v4 addresses. NOTE: In this example, # interface wlu2 happens to be a WiFi dongle. # $ ip -4 -br addr lo UNKNOWN 127.0.0.1/8 wlu2 UP 192.168.1.16/32 # # Step 1: Demonstrate that getent behaves as expected to resolve the v4 # address of host 'sam.zplane.com' (which appears in /etc/hosts): # $ getent ahostsv4 sam.zplane.com 192.168.1.15 STREAM sam.zplane.com 192.168.1.15 DGRAM 192.168.1.15 RAW # # Step 2: Now remove the v4 addr from interface wlu2: # $ ip addr del 192.168.1.16/32 dev wlu2 # # Step 3: Confirm that wlu2 (or any other external interface) no longer # has a v4 address: # $ ip -4 -br addr lo UNKNOWN 127.0.0.1/8 # # Step 4: Now getent fails to resolve the same local host as before, # displaying nothing and exiting with code 2: # $ getent ahostsv4 sam.zplane.com $ echo $? 2 # # Step 5: Re-assign an address to wlu2. (NOTE: Any address will do here, # it does not have to be on the 192.168.1 local subnet.) # $ ip addr add 192.168.1.16/32 dev wlu2 # # Step 6: Now getent once again behaves as expected: # $ getent ahostsv4 sam.zplane.com 192.168.1.15 STREAM sam.zplane.com 192.168.1.15 DGRAM 192.168.1.15 RAW Possibly related to: https://sourceware.org/bugzilla/show_bug.cgi?id=24816 https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1945097 https://unix.stackexchange.com/questions/98693/ https://unix.stackexchange.com/questions/71379/ TIA for any insight into this behavior. Thanks, Glenn Golden