From patchwork Fri Aug 26 09:27:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?No=C3=A9=20Rubinstein?= X-Patchwork-Id: 663037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sLG0z2rPYz9s9c for ; Fri, 26 Aug 2016 19:27:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=ecm7VamG; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id AF0E9A54D0; Fri, 26 Aug 2016 09:27:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gaDl-Hn72L3f; Fri, 26 Aug 2016 09:27:45 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id C9E8AA53E1; Fri, 26 Aug 2016 09:27:44 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 2C9911C22CF for ; Fri, 26 Aug 2016 09:27:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 276A9A53E1 for ; Fri, 26 Aug 2016 09:27:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yfkweStGKAfQ for ; Fri, 26 Aug 2016 09:27:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 26D93A2C88 for ; Fri, 26 Aug 2016 09:27:43 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id q128so10579870wma.1 for ; Fri, 26 Aug 2016 02:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iXp3T4oWpiLrlymp8USEnf6tpkCXldMjpRtG6VhDMak=; b=ecm7VamGtz09ma3BBrB4gzWcVTsl+pqSvrMybuEJFUu9tRErtVaWfRbNrE1CvxLzng Qu2gcMEfXYrOqh8Oiuvv6mNHvByDrk2pADAsGETiPGdarpd7dYKIgC3s2by9phEsqyqn FuknWjK3W4mrAlF0bvsLC12MfwivDuWDpDGA0vwR1fjOyD7JTzfdPQgIS+xLBkDrGxK0 jLnRgVIyMVpZGk3iWMajJEUPtr3hKhdvu0sgu4j4nF+BEgbO4Uc/yzbH41VnJTU890SX yxXRhg1xfpjqAtMK+nOtTrktdNpIRPGJ2RKsFitdGJw+e5q+V8h4rhhxDkWe4y6pnwlX bh6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iXp3T4oWpiLrlymp8USEnf6tpkCXldMjpRtG6VhDMak=; b=SfWmPkx0xAjjMeQhRmwXT7M7QqHUieH/jN/dEIANVtbBu52SR3iu6CwlApp++JRSKJ snJ/DtPId0UUM8nWmbQetLnQ6eg+gO3/39DkaTr2WzHNBh9k1LhVwb7ixWWnCOgrDbyN 9/ymoH9KQjfLFE4Omj7Ez6NgvuedcdokqcLhmnRSvuhtcrFbXidKHKo03KHkv4Ii6BND o5oueze7diEAHlsMMc1rS5gUf2r0d2tf3JZ72ZCTZ1cwIhmhEFk/+T9Qm1pUWOaGEogg zj94Ltw0B1MuHw0d3fCNOuV/RP5wEiTzJdKhS+vDEmVRbgoClOGJnlGQf13XlIgjm7bQ 7eDQ== X-Gm-Message-State: AE9vXwNZ2GqeMJYHf6fmSNyniHsc/HGbDMTnlUggOhN74Z4quJv6beaJAhOH/sMLBLpknA== X-Received: by 10.28.226.67 with SMTP id z64mr2798110wmg.85.1472203661206; Fri, 26 Aug 2016 02:27:41 -0700 (PDT) Received: from nrubinstein-de.aldebaran.lan ([37.166.73.138]) by smtp.gmail.com with ESMTPSA id c139sm42799855wme.4.2016.08.26.02.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Aug 2016 02:27:39 -0700 (PDT) From: noe.rubinstein@gmail.com X-Google-Original-From: nrubinstein@aldebaran.com To: buildroot@buildroot.org Date: Fri, 26 Aug 2016 11:27:36 +0200 Message-Id: <1472203656-5901-1-git-send-email-nrubinstein@aldebaran.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Thomas Petazzoni , Rahul Bedarkar , Romain Naour , Al West , =?UTF-8?q?No=C3=A9=20Rubinstein?= Subject: [Buildroot] [PATCH] Trousers: fix build with musl X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Noé Rubinstein The trousers code uses getpwent_r, which is not available in musl. Detect the availability of getpwent_r in the TrouSerS build system, and use it conditionally. This broke the build of tpm-tools because linking with libtspi.so failed. Fixes this build failure: http://autobuild.buildroot.net/results/830fc20c68a0653afa5567edffc2ededc4e45cc6 --- Runtime-tested by running tpm_version in a chroot and verifying that it creates a "user.data" file with both the Buildroot-provided CodeSourcery and Musl toolchains on x86_64. Build tested with http://autobuild.buildroot.org/toolchains/tarballs/br-arm-cortex-a9-musl-2016.08-rc1-4-g07e8d1c.tar.bz2 Signed-off-by: Noé Rubinstein --- ...t-getpwent_r-is-available-before-using-it.patch | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 package/trousers/0004-Check-that-getpwent_r-is-available-before-using-it.patch diff --git a/package/trousers/0004-Check-that-getpwent_r-is-available-before-using-it.patch b/package/trousers/0004-Check-that-getpwent_r-is-available-before-using-it.patch new file mode 100644 index 0000000..6ed440e --- /dev/null +++ b/package/trousers/0004-Check-that-getpwent_r-is-available-before-using-it.patch @@ -0,0 +1,78 @@ +From 9e42c405f30d2b52d019598436ea346ef8586f43 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?No=C3=A9=20Rubinstein?= +Date: Wed, 24 Aug 2016 18:55:25 +0200 +Subject: [PATCH] Check that getpwent_r is available before using it + +This fixes building trousers with musl +--- + configure.in | 4 ++++ + src/tspi/ps/tspps.c | 10 +++++----- + 2 files changed, 9 insertions(+), 5 deletions(-) + +diff --git a/configure.in b/configure.in +index fd3f5f1..e3d7acf 100644 +--- a/configure.in ++++ b/configure.in +@@ -145,6 +145,10 @@ else + AC_MSG_ERROR(["gtk", "openssl" and "none" are the only supported gui options for trousers]) + fi + ++# Look for getpwent_r. If it is not found, getpwent will be used instead, with ++# an additional mutex. ++AC_CHECK_FUNC(getpwent_r, [AC_DEFINE(HAVE_GETPWENT_R)]) ++ + # + # The default port that the TCS daemon listens on + # +diff --git a/src/tspi/ps/tspps.c b/src/tspi/ps/tspps.c +index c6f9c3d..9d00d2a 100644 +--- a/src/tspi/ps/tspps.c ++++ b/src/tspi/ps/tspps.c +@@ -45,7 +45,7 @@ + + static int user_ps_fd = -1; + static MUTEX_DECLARE_INIT(user_ps_lock); +-#if (defined (__FreeBSD__) || defined (__OpenBSD__)) ++#ifndef HAVE_GETPWENT_R + static MUTEX_DECLARE_INIT(user_ps_path); + #endif + static struct flock fl; +@@ -60,7 +60,7 @@ get_user_ps_path(char **file) + TSS_RESULT result; + char *file_name = NULL, *home_dir = NULL; + struct passwd *pwp; +-#if (defined (__linux) || defined (linux) || defined(__GLIBC__)) ++#ifdef HAVE_GETPWENT_R + struct passwd pw; + #endif + struct stat stat_buf; +@@ -72,7 +72,7 @@ get_user_ps_path(char **file) + *file = strdup(file_name); + return (*file) ? TSS_SUCCESS : TSPERR(TSS_E_OUTOFMEMORY); + } +-#if (defined (__FreeBSD__) || defined (__OpenBSD__)) ++#ifndef HAVE_GETPWENT_R + MUTEX_LOCK(user_ps_path); + #endif + +@@ -90,7 +90,7 @@ get_user_ps_path(char **file) + #else + setpwent(); + while (1) { +-#if (defined (__linux) || defined (linux) || defined(__GLIBC__)) ++#ifdef HAVE_GETPWENT_R + rc = getpwent_r(&pw, buf, PASSWD_BUFSIZE, &pwp); + if (rc) { + LogDebugFn("USER PS: Error getting path to home directory: getpwent_r: %s", +@@ -99,7 +99,7 @@ get_user_ps_path(char **file) + return TSPERR(TSS_E_INTERNAL_ERROR); + } + +-#elif (defined (__FreeBSD__) || defined (__OpenBSD__)) ++#else + if ((pwp = getpwent()) == NULL) { + LogDebugFn("USER PS: Error getting path to home directory: getpwent: %s", + strerror(rc)); +-- +2.1.4 +