Richard Marian Thomaiyar | 14fddef | 2018-07-13 23:55:56 +0530 | [diff] [blame] | 1 | trousers: fix compiling with musl |
| 2 | |
| 3 | use POSIX getpwent instead of getpwent_r |
| 4 | |
| 5 | Upstream-Status: Submitted |
| 6 | |
| 7 | Signed-off-by: Armin Kuster <akuster@mvista.com> |
| 8 | |
| 9 | Index: git/src/tspi/ps/tspps.c |
| 10 | =================================================================== |
| 11 | --- git.orig/src/tspi/ps/tspps.c |
| 12 | +++ git/src/tspi/ps/tspps.c |
| 13 | @@ -66,9 +66,6 @@ get_user_ps_path(char **file) |
| 14 | TSS_RESULT result; |
| 15 | char *file_name = NULL, *home_dir = NULL; |
| 16 | struct passwd *pwp; |
| 17 | -#if (defined (__linux) || defined (linux) || defined(__GLIBC__)) |
| 18 | - struct passwd pw; |
| 19 | -#endif |
| 20 | struct stat stat_buf; |
| 21 | char buf[PASSWD_BUFSIZE]; |
| 22 | uid_t euid; |
| 23 | @@ -96,24 +93,15 @@ get_user_ps_path(char **file) |
| 24 | #else |
| 25 | setpwent(); |
| 26 | while (1) { |
| 27 | -#if (defined (__linux) || defined (linux) || defined(__GLIBC__)) |
| 28 | - rc = getpwent_r(&pw, buf, PASSWD_BUFSIZE, &pwp); |
| 29 | - if (rc) { |
| 30 | - LogDebugFn("USER PS: Error getting path to home directory: getpwent_r: %s", |
| 31 | - strerror(rc)); |
| 32 | - endpwent(); |
| 33 | - return TSPERR(TSS_E_INTERNAL_ERROR); |
| 34 | - } |
| 35 | - |
| 36 | -#elif (defined (__FreeBSD__) || defined (__OpenBSD__)) |
| 37 | if ((pwp = getpwent()) == NULL) { |
| 38 | LogDebugFn("USER PS: Error getting path to home directory: getpwent: %s", |
| 39 | strerror(rc)); |
| 40 | endpwent(); |
| 41 | +#if (defined (__FreeBSD__) || defined (__OpenBSD__)) |
| 42 | MUTEX_UNLOCK(user_ps_path); |
| 43 | +#endif |
| 44 | return TSPERR(TSS_E_INTERNAL_ERROR); |
| 45 | } |
| 46 | -#endif |
| 47 | if (euid == pwp->pw_uid) { |
| 48 | home_dir = strdup(pwp->pw_dir); |
| 49 | break; |