aboutsummaryrefslogtreecommitdiffstats
path: root/meta-tpm/recipes-tpm1/trousers/files/get-user-ps-path-use-POSIX-getpwent-instead-of-getpwe.patch
blob: 3f5a144d9a9ffd323743b9aeca7bdfb62aed67d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
trousers: fix compiling with musl

use POSIX getpwent instead of getpwent_r

Upstream-Status: Submitted

Signed-off-by: Armin Kuster <akuster@mvista.com>

Index: git/src/tspi/ps/tspps.c
===================================================================
--- git.orig/src/tspi/ps/tspps.c
+++ git/src/tspi/ps/tspps.c
@@ -66,9 +66,6 @@ get_user_ps_path(char **file)
 	TSS_RESULT result;
 	char *file_name = NULL, *home_dir = NULL;
 	struct passwd *pwp;
-#if (defined (__linux) || defined (linux) || defined(__GLIBC__))
-	struct passwd pw;
-#endif
 	struct stat stat_buf;
 	char buf[PASSWD_BUFSIZE];
 	uid_t euid;
@@ -96,24 +93,15 @@ get_user_ps_path(char **file)
 #else
 	setpwent();
 	while (1) {
-#if (defined (__linux) || defined (linux) || defined(__GLIBC__))
-		rc = getpwent_r(&pw, buf, PASSWD_BUFSIZE, &pwp);
-		if (rc) {
-			LogDebugFn("USER PS: Error getting path to home directory: getpwent_r: %s",
-				   strerror(rc));
-			endpwent();
-			return TSPERR(TSS_E_INTERNAL_ERROR);
-		}
-
-#elif (defined (__FreeBSD__) || defined (__OpenBSD__))
 		if ((pwp = getpwent()) == NULL) {
 			LogDebugFn("USER PS: Error getting path to home directory: getpwent: %s",
                                    strerror(rc));
 			endpwent();
+#if (defined (__FreeBSD__) || defined (__OpenBSD__))
 			MUTEX_UNLOCK(user_ps_path);
+#endif
 			return TSPERR(TSS_E_INTERNAL_ERROR);
 		}
-#endif
 		if (euid == pwp->pw_uid) {
                         home_dir = strdup(pwp->pw_dir);
                         break;