1From 02e0b14d8fa025a5db410d60a7c0dfebd536aaeb Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 6 Nov 2016 23:40:54 -0800
4Subject: [PATCH] Musl does not have _r versions of getent() and getpwent()
5 APIs
6
7Taken from gentoo
8http://data.gpo.zugaina.org/musl/net-fs/samba/files/samba-4.3.9-remove-getpwent_r.patch
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11
12---
13 source4/torture/local/nss_tests.c | 13 ++++++++-----
14 1 file changed, 8 insertions(+), 5 deletions(-)
15
16diff --git a/source4/torture/local/nss_tests.c b/source4/torture/local/nss_tests.c
17index 2cd6122..04f13c6 100644
18--- a/source4/torture/local/nss_tests.c
19+++ b/source4/torture/local/nss_tests.c
20@@ -247,7 +247,6 @@ static bool test_getgrnam_r(struct torture_context *tctx,
21 	return true;
22 }
23
24-
25 static bool test_getgrgid(struct torture_context *tctx,
26 			  gid_t gid,
27 			  struct group *grp_p)
28@@ -333,6 +332,7 @@ static bool test_enum_passwd(struct torture_context *tctx,
29 	return true;
30 }
31
32+#if HAVE_GETPWENT_R
33 static bool test_enum_r_passwd(struct torture_context *tctx,
34 			       struct passwd **pwd_array_p,
35 			       size_t *num_pwd_p)
36@@ -381,6 +381,7 @@ static bool test_enum_r_passwd(struct torture_context *tctx,
37
38 	return true;
39 }
40+#endif
41
42 static bool torture_assert_passwd_equal(struct torture_context *tctx,
43 					const struct passwd *p1,
44@@ -432,7 +433,7 @@ static bool test_passwd_r(struct torture_context *tctx)
45 	struct passwd *pwd, pwd1, pwd2;
46 	size_t num_pwd;
47
48-	torture_assert(tctx, test_enum_r_passwd(tctx, &pwd, &num_pwd),
49+	torture_assert(tctx, test_enum_passwd(tctx, &pwd, &num_pwd),
50 						"failed to enumerate passwd");
51
52 	for (i=0; i < num_pwd; i++) {
53@@ -460,7 +461,7 @@ static bool test_passwd_r_cross(struct torture_context *tctx)
54 	struct passwd *pwd, pwd1, pwd2, pwd3, pwd4;
55 	size_t num_pwd;
56
57-	torture_assert(tctx, test_enum_r_passwd(tctx, &pwd, &num_pwd),
58+	torture_assert(tctx, test_enum_passwd(tctx, &pwd, &num_pwd),
59 						"failed to enumerate passwd");
60
61 	for (i=0; i < num_pwd; i++) {
62@@ -531,6 +532,7 @@ static bool test_enum_group(struct torture_context *tctx,
63 	return true;
64 }
65
66+#if HAVE_GETGRENT_R
67 static bool test_enum_r_group(struct torture_context *tctx,
68 			      struct group **grp_array_p,
69 			      size_t *num_grp_p)
70@@ -579,6 +581,7 @@ static bool test_enum_r_group(struct torture_context *tctx,
71
72 	return true;
73 }
74+#endif
75
76 static bool torture_assert_group_equal(struct torture_context *tctx,
77 				       const struct group *g1,
78@@ -635,7 +638,7 @@ static bool test_group_r(struct torture_context *tctx)
79 	struct group *grp, grp1, grp2;
80 	size_t num_grp;
81
82-	torture_assert(tctx, test_enum_r_group(tctx, &grp, &num_grp),
83+	torture_assert(tctx, test_enum_group(tctx, &grp, &num_grp),
84 					       "failed to enumerate group");
85
86 	for (i=0; i < num_grp; i++) {
87@@ -663,7 +666,7 @@ static bool test_group_r_cross(struct torture_context *tctx)
88 	struct group *grp, grp1, grp2, grp3, grp4;
89 	size_t num_grp;
90
91-	torture_assert(tctx, test_enum_r_group(tctx, &grp, &num_grp),
92+	torture_assert(tctx, test_enum_group(tctx, &grp, &num_grp),
93 					       "failed to enumerate group");
94
95 	for (i=0; i < num_grp; i++) {
96