From nobody Fri Apr 26 19:52:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565262056; cv=none; d=zoho.com; s=zohoarc; b=Pk9XsvuS5NVJmOzkekKMipaHoFW/6c2SkpvHhgE9MvjujCb7LrsBw26HcBLU2EcNifkD6qV7h+9ofnvZsRALUf8l6H269N6eDboYfWdB8y8NtF09tCJYDB26YfiE9ta0DhLypN5CdEaJqD7qxdqg/cm514G/nfi1DYBaxiY9EUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565262056; 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:ARC-Authentication-Results; bh=td4xsH2CRxqQWD8/AMfBLvU/1MpTWytUVXDYPaGxmcU=; b=FptWU22Bq4zKFP9wzEJcEuhOJ2UUlra2LK8vPQbjuoakzdFdNYCTxD9thm3J6l8pFBkwMORXyFaOgGbMG0E/ZeysAnthuIWuX1WgoeSBT702UoOJGSXtscQHTrtZ9QqnQlySAe/3Ha5oy4c/BGAI+a/yCf0xYcZQtGe99JXV668= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156526205607750.49401171056047; Thu, 8 Aug 2019 04:00:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2D2030A76A9; Thu, 8 Aug 2019 11:00:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89F3760BE2; Thu, 8 Aug 2019 11:00:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4AC341806B00; Thu, 8 Aug 2019 11:00:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78B0qfR011007 for ; Thu, 8 Aug 2019 07:00:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30EA45D784; Thu, 8 Aug 2019 11:00:52 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (dhcp-94.gsslab.fab.redhat.com [10.33.9.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 961315D721; Thu, 8 Aug 2019 11:00:49 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 12:00:47 +0100 Message-Id: <20190808110047.1357-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tools: avoid accidentally using files from gnulib X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 08 Aug 2019 11:00:55 +0000 (UTC) The AM_CPPFLAGS setting includes the gnulib headers, which means we can get some replacement functions defined. Since virt-login-shell and the NSS module intentionally don't link to gnulib, these replacement functions causes link failures. This was seen cross-compiling on Debian for example: virt-login-shell.o: In function `main': /builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:81: unde= fined reference to `rpl_strerror' /builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:66: unde= fined reference to `rpl_strerror' /builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:75: unde= fined reference to `rpl_strerror' The only way to avoid these replacement gnulib headers is to drop the -Ignulib/lib flags. We do still want to use gnulib for configmake.h and intprops.h, but those can be included via their full path. We must also stop using internal.h, since that expects -Ignulib/lib to be on the include path in order to resolve the verify.h header. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- Technically a CI build fix, but waiting for review before pushing since it is larger than most build fixes. cfg.mk | 3 +++ tools/Makefile.am | 10 ++++++++++ tools/nss/libvirt_nss.c | 13 ++++++++++--- tools/nss/libvirt_nss_leases.c | 15 ++++++++------- tools/nss/libvirt_nss_leases.h | 2 +- tools/nss/libvirt_nss_macs.c | 6 +++--- tools/nss/libvirt_nss_macs.h | 2 +- tools/virt-login-shell.c | 8 ++++++-- 8 files changed, 42 insertions(+), 17 deletions(-) diff --git a/cfg.mk b/cfg.mk index cc1f79a051..f082448293 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1345,3 +1345,6 @@ exclude_file_name_regexp--sc_prohibit_cross_inclusion= =3D \ =20 exclude_file_name_regexp--sc_prohibit_dirent_d_type =3D \ ^(src/util/vircgroup.c)$ + +exclude_file_name_regexp--sc_prohibit_strcmp =3D \ + ^(tools/nss/libvirt_nss.*\.c) diff --git a/tools/Makefile.am b/tools/Makefile.am index 09cada949b..df3d628bab 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -23,6 +23,12 @@ AM_CPPFLAGS =3D \ -I$(top_srcdir) \ $(NULL) =20 +# We do not want to accidentally include stuff from gnulib +# or the main src/ dir or public API dir. Specific files can +# still be included via their path relative to the root if +# needed +STANDALONE_CPPFLAGS =3D -I$(top_srcdir) + WARN_CFLAGS +=3D $(STRICT_FRAME_LIMIT_CFLAGS) =20 AM_CFLAGS =3D \ @@ -199,6 +205,8 @@ virt_host_validate_CFLAGS =3D \ virt_login_shell_SOURCES =3D \ virt-login-shell.c =20 +virt_login_shell_CPPFLAGS =3D $(STANDALONE_CPPFLAGS) + virt_login_shell_helper_SOURCES =3D \ virt-login-shell-helper.c =20 @@ -486,6 +494,7 @@ noinst_LTLIBRARIES +=3D nss/libnss_libvirt_impl.la nss_libnss_libvirt_impl_la_SOURCES =3D \ $(LIBVIRT_NSS_SOURCES) =20 +nss_libnss_libvirt_impl_la_CPPFLAGS =3D $(STANDALONE_CPPFLAGS) nss_libnss_libvirt_impl_la_CFLAGS =3D \ -DLIBVIRT_NSS \ $(YAJL_CFLAGS) \ @@ -516,6 +525,7 @@ nss_libnss_libvirt_guest_impl_la_SOURCES =3D \ nss/libvirt_nss_macs.c \ $(NULL) =20 +nss_libnss_libvirt_guest_impl_la_CPPFLAGS =3D $(STANDALONE_CPPFLAGS) nss_libnss_libvirt_guest_impl_la_CFLAGS =3D \ -DLIBVIRT_NSS \ -DLIBVIRT_NSS_GUEST \ diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index 7122065b28..b75f51c560 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include =20 @@ -40,7 +42,12 @@ # include #endif =20 -#include "configmake.h" +/* + * This gnulib files is used for its macros only, + * so doesn't introduce a link time dep, which we + * must avoid + */ +#include "gnulib/lib/configmake.h" =20 #include "libvirt_nss_leases.h" =20 @@ -131,7 +138,7 @@ findLease(const char *name, char *path; size_t dlen =3D strlen(entry->d_name); =20 - if (dlen >=3D 7 && STREQ(entry->d_name + dlen - 7, ".status")) { + if (dlen >=3D 7 && !strcmp(entry->d_name + dlen - 7, ".status")) { char **tmpLease; if (asprintf(&path, "%s/%s", leaseDir, entry->d_name) < 0) goto cleanup; @@ -142,7 +149,7 @@ findLease(const char *name, leaseFiles =3D tmpLease; leaseFiles[nleaseFiles++] =3D path; #if defined(LIBVIRT_NSS_GUEST) - } else if (dlen >=3D 5 && STREQ(entry->d_name + dlen - 5, ".macs")= ) { + } else if (dlen >=3D 5 && !strcmp(entry->d_name + dlen - 5, ".macs= ")) { if (asprintf(&path, "%s/%s", leaseDir, entry->d_name) < 0) goto cleanup; =20 diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c index 48a54d5841..86881641a9 100644 --- a/tools/nss/libvirt_nss_leases.c +++ b/tools/nss/libvirt_nss_leases.c @@ -23,6 +23,7 @@ #include #include #include +#include #include =20 #include @@ -60,7 +61,7 @@ typedef struct { =20 =20 static int -appendAddr(const char *name ATTRIBUTE_UNUSED, +appendAddr(const char *name __attribute__((unused)), leaseAddress **tmpAddress, size_t *ntmpAddress, const char *ipAddr, @@ -165,7 +166,7 @@ findLeasesParserInteger(void *ctx, return 0; =20 if (parser->state =3D=3D FIND_LEASES_STATE_ENTRY) { - if (STRNEQ(parser->key, "expiry-time")) + if (strcmp(parser->key, "expiry-time")) return 0; =20 parser->entry.expiry =3D val; @@ -190,13 +191,13 @@ findLeasesParserString(void *ctx, return 0; =20 if (parser->state =3D=3D FIND_LEASES_STATE_ENTRY) { - if (STREQ(parser->key, "ip-address")) { + if (!strcmp(parser->key, "ip-address")) { if (!(parser->entry.ipaddr =3D strndup((char *)stringVal, stri= ngLen))) return 0; - } else if (STREQ(parser->key, "mac-address")) { + } else if (!strcmp(parser->key, "mac-address")) { if (!(parser->entry.macaddr =3D strndup((char *)stringVal, str= ingLen))) return 0; - } else if (STREQ(parser->key, "hostname")) { + } else if (!strcmp(parser->key, "hostname")) { if (!(parser->entry.hostname =3D strndup((char *)stringVal, st= ringLen))) return 0; } else { @@ -264,12 +265,12 @@ findLeasesParserEndMap(void *ctx) DEBUG("Check %zu macs", parser->nmacs); for (i =3D 0; i < parser->nmacs && !found; i++) { DEBUG("Check mac '%s' vs '%s'", parser->macs[i], NULLSTR(parse= r->entry.macaddr)); - if (STREQ_NULLABLE(parser->macs[i], parser->entry.macaddr)) + if (parser->entry.macaddr && !strcmp(parser->macs[i], parser->= entry.macaddr)) found =3D true; } } else { DEBUG("Check name '%s' vs '%s'", parser->name, NULLSTR(parser->ent= ry.hostname)); - if (STREQ_NULLABLE(parser->name, parser->entry.hostname)) + if (parser->entry.hostname && !strcmp(parser->name, parser->entry.= hostname)) found =3D true; } DEBUG("Found %d", found); diff --git a/tools/nss/libvirt_nss_leases.h b/tools/nss/libvirt_nss_leases.h index e213681e46..c451742152 100644 --- a/tools/nss/libvirt_nss_leases.h +++ b/tools/nss/libvirt_nss_leases.h @@ -20,7 +20,7 @@ =20 #pragma once =20 -#include "internal.h" +#include =20 typedef struct { unsigned char addr[16]; diff --git a/tools/nss/libvirt_nss_macs.c b/tools/nss/libvirt_nss_macs.c index fb5526bd7b..26ba4bf515 100644 --- a/tools/nss/libvirt_nss_macs.c +++ b/tools/nss/libvirt_nss_macs.c @@ -67,7 +67,7 @@ findMACsParserString(void *ctx, return 0; =20 if (parser->state =3D=3D FIND_MACS_STATE_ENTRY) { - if (STRNEQ(parser->key, "domain")) + if (strcmp(parser->key, "domain")) return 0; =20 free(parser->entry.name); @@ -75,7 +75,7 @@ findMACsParserString(void *ctx, return 0; } else if (parser->state =3D=3D FIND_MACS_STATE_ENTRY_MACS) { char **macs; - if (STRNEQ(parser->key, "macs")) + if (strcmp(parser->key, "macs")) return 0; =20 if (!(macs =3D realloc(parser->entry.macs, @@ -142,7 +142,7 @@ findMACsParserEndMap(void *ctx) if (parser->state !=3D FIND_MACS_STATE_ENTRY) return 0; =20 - if (STREQ(parser->entry.name, parser->name)) { + if (!strcmp(parser->entry.name, parser->name)) { char **macs =3D realloc(*parser->macs, sizeof(char *) * ((*parser->nmacs) + parser-= >entry.nmacs)); if (!macs) diff --git a/tools/nss/libvirt_nss_macs.h b/tools/nss/libvirt_nss_macs.h index 64e291f549..2774f3a9f2 100644 --- a/tools/nss/libvirt_nss_macs.h +++ b/tools/nss/libvirt_nss_macs.h @@ -20,7 +20,7 @@ =20 #pragma once =20 -#include "internal.h" +#include =20 int findMACs(const char *file, diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index 41d0b349aa..f92cc0a749 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -28,8 +28,12 @@ #include #include =20 -#include "configmake.h" -#include "intprops.h" +/* + * These gnulib files are used for their macros only, + * so don't introduce a link time dep, which we must avoid + */ +#include "gnulib/lib/configmake.h" +#include "gnulib/lib/intprops.h" =20 int main(int argc, char **argv) { char uidstr[INT_BUFSIZE_BOUND(uid_t)]; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list