summaryrefslogtreecommitdiffstats
path: root/recipes-tpm/trousers/files/0001-Check-that-getpwent_r-is-available-before-using-it.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-tpm/trousers/files/0001-Check-that-getpwent_r-is-available-before-using-it.patch')
-rw-r--r--recipes-tpm/trousers/files/0001-Check-that-getpwent_r-is-available-before-using-it.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/recipes-tpm/trousers/files/0001-Check-that-getpwent_r-is-available-before-using-it.patch b/recipes-tpm/trousers/files/0001-Check-that-getpwent_r-is-available-before-using-it.patch
new file mode 100644
index 0000000..e7ba2eb
--- /dev/null
+++ b/recipes-tpm/trousers/files/0001-Check-that-getpwent_r-is-available-before-using-it.patch
@@ -0,0 +1,85 @@
1From bb721b0ae5882992037153e7257791101172556e Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?No=C3=A9=20Rubinstein?= <nrubinstein@aldebaran.com>
3Date: Wed, 24 Aug 2016 18:55:25 +0200
4Subject: [PATCH] Check that getpwent_r is available before using it
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This fixes building trousers with musl
10
11Signed-off-by: Noé Rubinstein <nrubinstein@aldebaran.com>
12---
13Upstream-Status: Inappropriate [not author https://git.busybox.net/buildroot/plain/package/trousers/0004-Check-that-getpwent_r-is-available-before-using-it.patch]
14Signed-off-by: André Draszik <adraszik@tycoint.com>
15 configure.in | 4 ++++
16 src/tspi/ps/tspps.c | 10 +++++-----
17 2 files changed, 9 insertions(+), 5 deletions(-)
18
19diff --git a/configure.in b/configure.in
20index add23dc..cfdfcaa 100644
21--- a/configure.in
22+++ b/configure.in
23@@ -144,6 +144,10 @@ else
24 AC_MSG_ERROR(["gtk", "openssl" and "none" are the only supported gui options for trousers])
25 fi
26
27+# Look for getpwent_r. If it is not found, getpwent will be used instead, with
28+# an additional mutex.
29+AC_CHECK_FUNC(getpwent_r, [AC_DEFINE(HAVE_GETPWENT_R)])
30+
31 #
32 # The default port that the TCS daemon listens on
33 #
34diff --git a/src/tspi/ps/tspps.c b/src/tspi/ps/tspps.c
35index c6f9c3d..9d00d2a 100644
36--- a/src/tspi/ps/tspps.c
37+++ b/src/tspi/ps/tspps.c
38@@ -45,7 +45,7 @@
39
40 static int user_ps_fd = -1;
41 static MUTEX_DECLARE_INIT(user_ps_lock);
42-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
43+#ifndef HAVE_GETPWENT_R
44 static MUTEX_DECLARE_INIT(user_ps_path);
45 #endif
46 static struct flock fl;
47@@ -60,7 +60,7 @@ get_user_ps_path(char **file)
48 TSS_RESULT result;
49 char *file_name = NULL, *home_dir = NULL;
50 struct passwd *pwp;
51-#if (defined (__linux) || defined (linux) || defined(__GLIBC__))
52+#ifdef HAVE_GETPWENT_R
53 struct passwd pw;
54 #endif
55 struct stat stat_buf;
56@@ -72,7 +72,7 @@ get_user_ps_path(char **file)
57 *file = strdup(file_name);
58 return (*file) ? TSS_SUCCESS : TSPERR(TSS_E_OUTOFMEMORY);
59 }
60-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
61+#ifndef HAVE_GETPWENT_R
62 MUTEX_LOCK(user_ps_path);
63 #endif
64
65@@ -90,7 +90,7 @@ get_user_ps_path(char **file)
66 #else
67 setpwent();
68 while (1) {
69-#if (defined (__linux) || defined (linux) || defined(__GLIBC__))
70+#ifdef HAVE_GETPWENT_R
71 rc = getpwent_r(&pw, buf, PASSWD_BUFSIZE, &pwp);
72 if (rc) {
73 LogDebugFn("USER PS: Error getting path to home directory: getpwent_r: %s",
74@@ -99,7 +99,7 @@ get_user_ps_path(char **file)
75 return TSPERR(TSS_E_INTERNAL_ERROR);
76 }
77
78-#elif (defined (__FreeBSD__) || defined (__OpenBSD__))
79+#else
80 if ((pwp = getpwent()) == NULL) {
81 LogDebugFn("USER PS: Error getting path to home directory: getpwent: %s",
82 strerror(rc));
83--
842.10.2
85