use POSIX getpwent instead of getpwent_r
This was causing the libtspi to have the getpwent_r with when loaded via 
tpm-tools, it would fail.

[ Yocto #11095]

Signed-off-by: Armin Kuster <[email protected]>
---
 ...path-use-POSIX-getpwent-instead-of-getpwe.patch | 49 ++++++++++++++++++++++
 recipes-tpm/trousers/trousers_git.bb               |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 
recipes-tpm/trousers/files/get-user-ps-path-use-POSIX-getpwent-instead-of-getpwe.patch

diff --git 
a/recipes-tpm/trousers/files/get-user-ps-path-use-POSIX-getpwent-instead-of-getpwe.patch
 
b/recipes-tpm/trousers/files/get-user-ps-path-use-POSIX-getpwent-instead-of-getpwe.patch
new file mode 100644
index 0000000..3f5a144
--- /dev/null
+++ 
b/recipes-tpm/trousers/files/get-user-ps-path-use-POSIX-getpwent-instead-of-getpwe.patch
@@ -0,0 +1,49 @@
+trousers: fix compiling with musl
+
+use POSIX getpwent instead of getpwent_r
+
+Upstream-Status: Submitted
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+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;
diff --git a/recipes-tpm/trousers/trousers_git.bb 
b/recipes-tpm/trousers/trousers_git.bb
index 6671808..352374c 100644
--- a/recipes-tpm/trousers/trousers_git.bb
+++ b/recipes-tpm/trousers/trousers_git.bb
@@ -14,6 +14,7 @@ SRC_URI = " \
        file://trousers.init.sh \
        file://trousers-udev.rules \
        file://tcsd.service \
+        file://get-user-ps-path-use-POSIX-getpwent-instead-of-getpwe.patch \
        "
 
 S = "${WORKDIR}/git"
-- 
2.7.4

-- 
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to