Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp368588rdh; Thu, 26 Oct 2023 04:46:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF4fk4zwatp+ucyM7IeZU1B9+04yUhv7T3KGWNxTNyEj/hFrvcp3swwSVlUBKg4XvdyfL1 X-Received: by 2002:a05:6870:e87:b0:1ea:2d32:d8cd with SMTP id mm7-20020a0568700e8700b001ea2d32d8cdmr22877246oab.42.1698320800395; Thu, 26 Oct 2023 04:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698320800; cv=none; d=google.com; s=arc-20160816; b=Kv1yti8QMeu6X5Akefai/EnxM0L/5yTZ6k7Ac5ktV50y+lM1CXXreARsA96u3z9pBl 6/sQosOt5EDZLMjK8gd3gYb3ZrVTWzEEjVdBhoGJAJiBqurnN17RPjOQ+tltFaitRK6H ylEtoe1kkN0UQl0sHucHBPxj4eKY81oX8ZwKXmb2S8JiHRib6BP4NWXbX0akBNxKSHZo /UXRoDw7mIwTqZ9R7itp1bxtMCobWiu6OOcy0m+40UMVrU2GWoASG7gwWymYGHYjM0WF sRufc0cJKO2ENgr+l3GjYIQn4y6upMpcjJG0br2NZkOPBjHqb3P0GA7/TrDh4FMMYqUf 78BQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=2HyR5USNsI5fYvBXrP0pyDXzpLblruu9FbswJvKYzQI=; fh=EzCKI2rDoDjdDSPxwRheMMjdlmz/a1HUyvXW5gCu388=; b=AyhmdpxMmDAauh6q/OZTn2HaDTn6evDj75ZGIYwGIG3DjOMHs+Ag9iAC+scDmYupiQ RCoZV1D1aKeejAdAgG7GDXmRS7HS1jiPCj1dbITDCcwaPh5yWVF4InDhZIOF45KoNnA+ XndnQ1kDjmb2liGnYUdRjrXanlgNAkoLx9YQP883qol9Q4V/UvgVpVve2XJo44aW7SiI dwkjFL/phefZnV/JmSMcIg7kVgp4TdxmGmnoarZaAk2+YBIcFM7uTC75vzp9litvmM8T 0tYgKWMWokwa0sRi1NDBfrvVJHhWrvOxlik0oX6zMJTpCOlUd6HyeuJIWD5BsuCCo8E6 mjew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=fDePx19c; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u77-20020a25ab53000000b00d865b810d03si14635420ybi.642.2023.10.26.04.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 04:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=fDePx19c; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 12FB28108BFE; Thu, 26 Oct 2023 04:46:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbjJZLqe (ORCPT + 99 others); Thu, 26 Oct 2023 07:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjJZLqd (ORCPT ); Thu, 26 Oct 2023 07:46:33 -0400 X-Greylist: delayed 61 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 26 Oct 2023 04:46:29 PDT Received: from smtpdh19-2.aruba.it (smtpdh19-2.aruba.it [62.149.155.149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F46B1A7 for ; Thu, 26 Oct 2023 04:46:29 -0700 (PDT) Received: from localhost.localdomain ([146.241.115.208]) by Aruba Outgoing Smtp with ESMTPSA id vynjq3v5QpgXYvynkqNRmH; Thu, 26 Oct 2023 13:45:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1698320724; bh=QFuL8Wqq9npNMw07i07+jC6u8BSIhQzvy3c+e3sLfD4=; h=From:To:Subject:Date:MIME-Version; b=fDePx19cM4eDIC0PkDoH2NZDmuCiTVcBARsm2HCFgqzFnrxAtg/o2TmOonQZ9KyXg HCYCeSxSQKNNYYEp7PGxaqtfcB16PC2nQ87yxABksp6A/KP+lgUkJGEA5Y7M9liz6x 2xyUI+VGAHIZnk/0/nYmvLY6vztZVPK9bQSVg6kFDIcxw1Jib0+khoNEMgxr0Jw4Lo T2k+XatE0FJNXWXW9AzxDP/V4w49f2cjtw3Vc56T7a0v3Y4fQRoqS50mkhZMllCRdm z8OGmmBBvI2ama7v4BLHsAKLO1mdXnx/YJpbFv1rqcwO/4nD4UKkGCPztMS7paMwhG /3mrKbmrfDOZw== From: Giulio Benetti To: linux-nfs@vger.kernel.org Cc: Giulio Benetti Subject: [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Date: Thu, 26 Oct 2023 13:45:21 +0200 Message-Id: <20231026114522.567140-1-giulio.benetti@benettiengineering.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfBnFJPwrl4qZ93xF+YbgNxlS5bjEzWrXp9fcU/XlXFmw6h7cFTHQeWaXsNoRl+ViXeqkENgUpjqWkM84hBvYGLxqYCfdfgEhDH5x/EQf6yLV0hIfz6/T 7iFHGNxb4RD3LGx2HMpMdOpIjnkhmUwaknCJ6TW0kUs/U1FV/kVmmUw2OJnFcqBbFdiJx9QzhCCrbKUIKC9/25KTrVxD0de7jh5UM+rI49HFHcx7NDiOPHg8 lgllnoKP2qfbbYgurwN114AKWzudGxde7upU6BrfKyCbhKXgmodKare8/m6yiLQL X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 26 Oct 2023 04:46:34 -0700 (PDT) Function getrandom() is present only with glibc 2.24+ so add a direct syscall otherwise. This is only possible with Linux 3.17+ so let's also check for it and in case emit error on autotools configure. Signed-off-by: Giulio Benetti --- configure.ac | 32 +++++++++++++++++++++++++++++++ support/reexport/backend_sqlite.c | 17 +++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6fbcb974..7efca90c 100644 --- a/configure.ac +++ b/configure.ac @@ -328,6 +328,38 @@ AC_CHECK_HEADERS([sched.h], [], []) AC_CHECK_FUNCS([unshare fstatat statx], [] , []) AC_LIBPTHREAD([]) +AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)]) +AC_LINK_IFELSE([AC_LANG_SOURCE([ + #include /* for NULL */ + #include + int main() { + return getrandom(NULL, 0U, 0U); + } +])], [ + AC_DEFINE([HAVE_GETRANDOM], [1], + [Define to 1 if you have the `getrandom' function.]) + AC_MSG_RESULT([yes]) +], [ + AC_MSG_RESULT([no]) + + AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)]) + AC_LINK_IFELSE([AC_LANG_SOURCE([ + #include /* for NULL */ + #include /* for syscall */ + #include /* for SYS_getrandom */ + int main() { + syscall(SYS_getrandom, NULL, 0, 0); + return 0; + } + ])], [ + AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1], + [Define to 1 if you have `syscall' and `SYS_getrandom'.]) + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_ERROR(['syscall' and 'SYS_getrandom' not found.]) + ]) +]) + # rpc/rpc.h can come from the glibc or from libtirpc nfsutils_save_CPPFLAGS="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} ${TIRPC_CFLAGS}" diff --git a/support/reexport/backend_sqlite.c b/support/reexport/backend_sqlite.c index 132f30c4..f1e390bc 100644 --- a/support/reexport/backend_sqlite.c +++ b/support/reexport/backend_sqlite.c @@ -7,13 +7,28 @@ #include #include #include -#include #include #include "conffile.h" #include "reexport_backend.h" #include "xlog.h" +/* Fix up glibc <= 2.24 not having getrandom() */ +#if defined HAVE_GETRANDOM +#include +#else +#include +static ssize_t getrandom(void *buffer, size_t length, unsigned flags) +{ +# if defined(__NR_getrandom) + return syscall(__NR_getrandom, buffer, length, flags); +# else + errno = ENOSYS; + return -1; +# endif +} +#endif + #define REEXPDB_DBFILE NFS_STATEDIR "/reexpdb.sqlite3" #define REEXPDB_DBFILE_WAIT_USEC (5000) -- 2.34.1