From nobody Sun May 12 02:07:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653642425; cv=none; d=zohomail.com; s=zohoarc; b=GgNJ6SP+h8T2P1Z4taBxtEv0SO4jEh/Mc38AQVqFW+gESF7IwT/WFb6fTsr1YPs5eYBQXZ6mK86wrxOQADp20D277FmQtmAcLqtVkxgIhx4Qtfx12naET6nPqnNKZOk/U+cIzFUlVUPzbKiWdpf61M3AlRYupb/6h9fhsL/X/gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653642425; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=m0sfV+yAVx3eTxhsCZiXUJYV/3iGep7pBmTjy8O8XJk=; b=WD1Bhx6ArKNI2CoJ+4jd7IHC26rFMI60Ii6XF11ID0rcKVAXwLtkpyeYTxQqwqqiLLBHYDggr6YgaAb3lAz9QFevpAtKPcoBRnhjkok9cuYbZuvBRZwREoifFMlGoHTT+4f8apDt0VpmIp13im7DIgKCmYyRAKxnrZ+ePyJR/CE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1653642425241405.77965010722903; Fri, 27 May 2022 02:07:05 -0700 (PDT) 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-359-TtXBDkVMNxiXgCI6UUFHYQ-1; Fri, 27 May 2022 05:06:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF27C3802B90; Fri, 27 May 2022 09:06:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C11E72026D64; Fri, 27 May 2022 09:06:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 837A2193212A; Fri, 27 May 2022 09:06:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D11AA194704C for ; Fri, 27 May 2022 09:06:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AE3061400C2C; Fri, 27 May 2022 09:06:53 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 562221410DD5 for ; Fri, 27 May 2022 09:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653642424; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=m0sfV+yAVx3eTxhsCZiXUJYV/3iGep7pBmTjy8O8XJk=; b=K1malSyFsQ3DP0FEmxtgHmk4gzd6mJqVsOhu904nVtM6uV7Hd5U+uq8nWBOyH3JxeBhuHF ATeS7ug14AzOpvoSjfHO/k04PNkVS57NR7ue1vaMbQvWZZJll5rujzRi2lafdRgNdWDMT5 AYwazrnHbhN0RqjOi9EEnP/WlEfg6hs= X-MC-Unique: TtXBDkVMNxiXgCI6UUFHYQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] nss: Compare hostname case insensitive Date: Fri, 27 May 2022 11:06:46 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653642425707100001 Content-Type: text/plain; charset="utf-8"; x-default="true" There are some tools that convert hostname to lowercase before resolving it (e.g. ssh). In a way it makes sense because DNS is case insensitive and in case of ssh the lowercase version is then used to find matching record in its config file. However, our NSS module performs case sensitive comparison, which makes it useless with ssh. Just consider a machine named FooBar. Therefore, switch to case insensitive string comparison. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1777873 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- build-aux/syntax-check.mk | 2 +- tests/nsstest.c | 1 + tools/nss/libvirt_nss_leases.c | 2 +- tools/nss/libvirt_nss_macs.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 73f8a21c1b..f9f60c934c 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1337,7 +1337,7 @@ sc_prohibit_enum_impl_with_vir_prefix_in_virsh: ## Exceptions ## ## ---------- ## =20 -exclude_file_name_regexp--sc_avoid_strcase =3D ^tools/vsh\.h$$ +exclude_file_name_regexp--sc_avoid_strcase =3D ^tools/(vsh\.h|nss/libvirt_= nss_(leases|macs)\.c)$$ =20 exclude_file_name_regexp--sc_avoid_write =3D ^src/libvirt-stream\.c$$ =20 diff --git a/tests/nsstest.c b/tests/nsstest.c index 2c2e57769b..a03f230452 100644 --- a/tests/nsstest.c +++ b/tests/nsstest.c @@ -173,6 +173,7 @@ mymain(void) # if !defined(LIBVIRT_NSS_GUEST) DO_TEST("fedora", AF_INET, "192.168.122.197", "192.168.122.198", "192.= 168.122.199", "192.168.122.3"); DO_TEST("gentoo", AF_INET, "192.168.122.254"); + DO_TEST("Gentoo", AF_INET, "192.168.122.254"); DO_TEST("gentoo", AF_INET6, "2001:1234:dead:beef::2"); DO_TEST("gentoo", AF_UNSPEC, "192.168.122.254"); DO_TEST("non-existent", AF_UNSPEC, NULL); diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c index 536fcf8608..770dae8625 100644 --- a/tools/nss/libvirt_nss_leases.c +++ b/tools/nss/libvirt_nss_leases.c @@ -272,7 +272,7 @@ findLeasesParserEndMap(void *ctx) } } else { DEBUG("Check name '%s' vs '%s'", parser->name, NULLSTR(parser->ent= ry.hostname)); - if (parser->entry.hostname && !strcmp(parser->name, parser->entry.= hostname)) + if (parser->entry.hostname && !strcasecmp(parser->name, parser->en= try.hostname)) found =3D true; } DEBUG("Found %d", found); diff --git a/tools/nss/libvirt_nss_macs.c b/tools/nss/libvirt_nss_macs.c index d4b165eef6..f45d149793 100644 --- a/tools/nss/libvirt_nss_macs.c +++ b/tools/nss/libvirt_nss_macs.c @@ -142,7 +142,7 @@ findMACsParserEndMap(void *ctx) if (parser->state !=3D FIND_MACS_STATE_ENTRY) return 0; =20 - if (!strcmp(parser->entry.name, parser->name)) { + if (!strcasecmp(parser->entry.name, parser->name)) { char **macs =3D realloc(*parser->macs, sizeof(char *) * ((*parser->nmacs) + parser-= >entry.nmacs)); if (!macs) --=20 2.35.1