Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp651663rwd; Mon, 12 Jun 2023 20:49:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6f944ZxM0mNnzYa/QIdQqNcrL4k9sPzZgsfuRrPZkCSvvLATVa0FgJcOQMQcVs8K5tgxae X-Received: by 2002:a17:907:3182:b0:974:1eb9:f74f with SMTP id xe2-20020a170907318200b009741eb9f74fmr9725650ejb.15.1686628157270; Mon, 12 Jun 2023 20:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686628157; cv=none; d=google.com; s=arc-20160816; b=hlu2WJj4uLzi+j2UGF3xiIiD+yYNZrUTCy3M19O7xpHcUaB/GnfUJLc40Z2BvmLY2i W42FPo0ZeZpRA6+60s/aqflAICNoukPQi1Ogb9LiB6a3/wVkdjvgs4vkvu3npAiVVqLW miLCK0L+F6NFzxuBuZWrCQT/lBjG9tM1pnnUw2QgqHPtvL9QLy82EKbYh8Q99UosmGj8 BP3ZmMoRd7eSAuuPEuN5f6fMzNlHeS/x7gccWm6KUvYuYuEpQP0Xo9B1mJC6jkpZ3Dev v0MrMPI11gINN2Sten8S31VUbOScPFWQnrWCdipTkGEsJIYmhHcbcgM9zf+55A7/qpNw kgwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=iH1h2NrrphK3sn1s4pS2s9yjaVdW93PrKjQsi+VjOYM=; b=ZQ4zsmue11PYdpYKQH9c7caLOCKXVogZM8K3kOOgdQgxAWAUtpRKEg52A60YESI2Ee narcXpHZfpgxQOXY8X7cIcnh4X/y4p5+6x6224CB52injmHojbkKGKs8airQeTuizX0Z IJq/CTg9Mgvxbj230aJQkO9l9+JA0Kr37tE1E3E6bbeogVvmuIwb+qRnBOjZHYW6q5z+ ZxAfJwIpnkQ4LLc/QVkL0QyRTw5HgHsLYMTo1YHxXZdziML3NIoBEoScTYstezGL/mv6 a0xk2OvFPvilxuZanUAIfh6XuqLehMk25MGuwWMuQ9/LJ/odCK/meB5vWMVrO23D9EQU jo6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nubmail.ca header.s=fm2 header.b=xJJoDSkx; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=GXnxzC7I; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qu10-20020a170907110a00b0096f935a9482si5583075ejb.188.2023.06.12.20.48.35; Mon, 12 Jun 2023 20:49:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nubmail.ca header.s=fm2 header.b=xJJoDSkx; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=GXnxzC7I; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233225AbjFMDqf (ORCPT + 99 others); Mon, 12 Jun 2023 23:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbjFMDqd (ORCPT ); Mon, 12 Jun 2023 23:46:33 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0EBB4 for ; Mon, 12 Jun 2023 20:46:32 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id CC5933200913; Mon, 12 Jun 2023 23:46:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 12 Jun 2023 23:46:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nubmail.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1686627991; x= 1686714391; bh=iH1h2NrrphK3sn1s4pS2s9yjaVdW93PrKjQsi+VjOYM=; b=x JJoDSkxCBYcGDYnLMO+pJG4ifkFQQJ4bGZ5Z5PhlnaBc0HtEvKbYjzulhNABE+UB O2ICbGsdtTXVRnYxQad0TX6vBjCHFe4Ow4SOeLXOlO7Ly2rEzMDFGfGoFweH0UVC rQQ9HajtoaJZqaWO2yQY+px3h2uOSa1Q4mzo18nqP498JhDu2FJ08VJvvltd8vnb w1zhiFi6TGSCemOGzv4k+6APJuifI7QR70vcV2TJhmP9nV6bVM6VdLKRfJusi7V/ 99ZbuJVT0s/Dxa2Blsn1MXYY+C188byvMqGF8uWVt2kKzsL6AV5DP+5j0a32GA4S Bung4cZkavQXa28uN1qdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1686627991; x= 1686714391; bh=iH1h2NrrphK3sn1s4pS2s9yjaVdW93PrKjQsi+VjOYM=; b=G XnxzC7I4uUVqOKZe2hg+o1Y4/KmkAy5BvAUC1WvB0or/UnBKRgs0kIKpO+A8vxcq X0Yb7gWh5S1VoLuGGFunkgrRb6/zBvbqHerdreSAgxB8WC6TtI1fKQ8UEo3XZ9az 6KyYE9a9wyOcubNVX6Vo6WYFnI03UsXDs4J8yQ45oDxOfWjlGUDJRbz2loKRr2Mz RlQarrPF9ByCJvm9QlpJoAOrFWndj11g1gcj1Ope6VORHk2YgdvJuF99VKimugbp vvFluJK6WnWoem+ZPty4JqcCmg23qj8dTsv4zowKfEq7HuSqeFgPkOgfBVAWV/0O h+WcIMNn/fyTpu/dVKf1w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeduiedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeetrhgrmhcutehkhhgrvhgrnhcuoehgihhthhhusgesrghr rghmrdhnuhgsmhgrihhlrdgtrgeqnecuggftrfgrthhtvghrnhepheejudefhffftdfgud ejffffiedufedtleehffegteeiveejgfeffefhkeduvddtnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhithhhuhgssegrrhgrmhdrnhhusg hmrghilhdrtggr X-ME-Proxy: Feedback-ID: i8ce9446d:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Jun 2023 23:46:30 -0400 (EDT) From: Aram Akhavan To: linux-nfs@vger.kernel.org Cc: Aram Akhavan Subject: [PATCH 2/2] libnfsidmap: try to get the domain directly from hostname if the DNS lookup fails and always show the log message if the domain can't be determined Date: Mon, 12 Jun 2023 20:46:25 -0700 Message-Id: <20230613034625.498132-3-github@aram.nubmail.ca> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613034625.498132-1-github@aram.nubmail.ca> References: <20230613034625.498132-1-github@aram.nubmail.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org In nfs4_init_name_mapping(), if no domain is specified in the config file, the hostname will be looked up in DNS, and the domain extracted from that. If DNS resolution isn't up at this time (i.e. on idmapd startup), the hardcoded domain in IDMAPD_DEFAULT_DOMAIN is used. This will break id mapping for anyone who doesn't happen to use "localdomain". Previously, the log message indicating this has happened requires -v to be passed, so the "failure" was silent by default. Signed-off-by: Aram Akhavan --- support/nfsidmap/libnfsidmap.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c index 0a912e52..f8c36480 100644 --- a/support/nfsidmap/libnfsidmap.c +++ b/support/nfsidmap/libnfsidmap.c @@ -219,10 +219,15 @@ static int domain_from_dns(char **domain) if (gethostname(hname, sizeof(hname)) == -1) return -1; - if ((he = gethostbyname(hname)) == NULL) - return -1; - if ((c = strchr(he->h_name, '.')) == NULL || *++c == '\0') - return -1; + if ((he = gethostbyname(hname)) == NULL) { + IDMAP_LOG(1, ("libnfsidmap: DNS lookup of hostname failed. Attempting to use domain from hostname as is.")); + if ((c = strchr(hname, '.')) == NULL || *++c == '\0') + return -1; + } + else { + if ((c = strchr(he->h_name, '.')) == NULL || *++c == '\0') + return -1; + } /* * Query DNS to see if the _nfsv4idmapdomain TXT record exists * If so use it... @@ -387,7 +392,7 @@ int nfs4_init_name_mapping(char *conffile) dflt = 1; ret = domain_from_dns(&default_domain); if (ret) { - IDMAP_LOG(1, ("libnfsidmap: Unable to determine " + IDMAP_LOG(0, ("libnfsidmap: Unable to determine " "the NFSv4 domain; Using '%s' as the NFSv4 domain " "which means UIDs will be mapped to the 'Nobody-User' " "user defined in %s", -- 2.39.2