Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 02e0b14d8fa025a5db410d60a7c0dfebd536aaeb Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sun, 6 Nov 2016 23:40:54 -0800 |
| 4 | Subject: [PATCH] Musl does not have _r versions of getent() and getpwent() |
| 5 | APIs |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 6 | |
| 7 | Taken from gentoo |
| 8 | http://data.gpo.zugaina.org/musl/net-fs/samba/files/samba-4.3.9-remove-getpwent_r.patch |
| 9 | |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12 | --- |
| 13 | source4/torture/local/nss_tests.c | 13 ++++++++----- |
| 14 | 1 file changed, 8 insertions(+), 5 deletions(-) |
| 15 | |
| 16 | diff --git a/source4/torture/local/nss_tests.c b/source4/torture/local/nss_tests.c |
| 17 | index 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, |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 21 | return true; |
| 22 | } |
| 23 | |
| 24 | - |
| 25 | static bool test_getgrgid(struct torture_context *tctx, |
| 26 | gid_t gid, |
| 27 | struct group *grp_p) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | @@ -333,6 +332,7 @@ static bool test_enum_passwd(struct torture_context *tctx, |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 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) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 36 | @@ -381,6 +381,7 @@ static bool test_enum_r_passwd(struct torture_context *tctx, |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 37 | |
| 38 | return true; |
| 39 | } |
| 40 | +#endif |
| 41 | |
| 42 | static bool torture_assert_passwd_equal(struct torture_context *tctx, |
| 43 | const struct passwd *p1, |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 44 | @@ -432,7 +433,7 @@ static bool test_passwd_r(struct torture_context *tctx) |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 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++) { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 53 | @@ -460,7 +461,7 @@ static bool test_passwd_r_cross(struct torture_context *tctx) |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 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++) { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 62 | @@ -531,6 +532,7 @@ static bool test_enum_group(struct torture_context *tctx, |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 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) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 70 | @@ -579,6 +581,7 @@ static bool test_enum_r_group(struct torture_context *tctx, |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 71 | |
| 72 | return true; |
| 73 | } |
| 74 | +#endif |
| 75 | |
| 76 | static bool torture_assert_group_equal(struct torture_context *tctx, |
| 77 | const struct group *g1, |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 78 | @@ -635,7 +638,7 @@ static bool test_group_r(struct torture_context *tctx) |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 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++) { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 87 | @@ -663,7 +666,7 @@ static bool test_group_r_cross(struct torture_context *tctx) |
Brad Bishop | 7f28bc5 | 2017-12-03 23:42:40 -0500 | [diff] [blame] | 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++) { |