python-whoosh: bump to version 2.7.4
[buildroot-gz.git] / package / trousers / 0004-Check-that-getpwent_r-is-available-before-using-it.patch
blob7014ad7afb5e92a4305d7cbb70ca878cf7ba66e4
1 From 9e42c405f30d2b52d019598436ea346ef8586f43 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?No=C3=A9=20Rubinstein?= <nrubinstein@aldebaran.com>
3 Date: Wed, 24 Aug 2016 18:55:25 +0200
4 Subject: [PATCH] Check that getpwent_r is available before using it
6 This fixes building trousers with musl
8 Signed-off-by: NoƩ Rubinstein <nrubinstein@aldebaran.com>
9 ---
10 configure.in | 4 ++++
11 src/tspi/ps/tspps.c | 10 +++++-----
12 2 files changed, 9 insertions(+), 5 deletions(-)
14 diff --git a/configure.in b/configure.in
15 index fd3f5f1..e3d7acf 100644
16 --- a/configure.in
17 +++ b/configure.in
18 @@ -145,6 +145,10 @@ else
19 AC_MSG_ERROR(["gtk", "openssl" and "none" are the only supported gui options for trousers])
22 +# Look for getpwent_r. If it is not found, getpwent will be used instead, with
23 +# an additional mutex.
24 +AC_CHECK_FUNC(getpwent_r, [AC_DEFINE(HAVE_GETPWENT_R)])
27 # The default port that the TCS daemon listens on
29 diff --git a/src/tspi/ps/tspps.c b/src/tspi/ps/tspps.c
30 index c6f9c3d..9d00d2a 100644
31 --- a/src/tspi/ps/tspps.c
32 +++ b/src/tspi/ps/tspps.c
33 @@ -45,7 +45,7 @@
35 static int user_ps_fd = -1;
36 static MUTEX_DECLARE_INIT(user_ps_lock);
37 -#if (defined (__FreeBSD__) || defined (__OpenBSD__))
38 +#ifndef HAVE_GETPWENT_R
39 static MUTEX_DECLARE_INIT(user_ps_path);
40 #endif
41 static struct flock fl;
42 @@ -60,7 +60,7 @@ get_user_ps_path(char **file)
43 TSS_RESULT result;
44 char *file_name = NULL, *home_dir = NULL;
45 struct passwd *pwp;
46 -#if (defined (__linux) || defined (linux) || defined(__GLIBC__))
47 +#ifdef HAVE_GETPWENT_R
48 struct passwd pw;
49 #endif
50 struct stat stat_buf;
51 @@ -72,7 +72,7 @@ get_user_ps_path(char **file)
52 *file = strdup(file_name);
53 return (*file) ? TSS_SUCCESS : TSPERR(TSS_E_OUTOFMEMORY);
55 -#if (defined (__FreeBSD__) || defined (__OpenBSD__))
56 +#ifndef HAVE_GETPWENT_R
57 MUTEX_LOCK(user_ps_path);
58 #endif
60 @@ -90,7 +90,7 @@ get_user_ps_path(char **file)
61 #else
62 setpwent();
63 while (1) {
64 -#if (defined (__linux) || defined (linux) || defined(__GLIBC__))
65 +#ifdef HAVE_GETPWENT_R
66 rc = getpwent_r(&pw, buf, PASSWD_BUFSIZE, &pwp);
67 if (rc) {
68 LogDebugFn("USER PS: Error getting path to home directory: getpwent_r: %s",
69 @@ -99,7 +99,7 @@ get_user_ps_path(char **file)
70 return TSPERR(TSS_E_INTERNAL_ERROR);
73 -#elif (defined (__FreeBSD__) || defined (__OpenBSD__))
74 +#else
75 if ((pwp = getpwent()) == NULL) {
76 LogDebugFn("USER PS: Error getting path to home directory: getpwent: %s",
77 strerror(rc));
78 --
79 2.1.4