gcc-6: use $(GNU_ARCH) in manifest
[unleashed-userland.git] / components / trousers / patches / tspi_ps_tspps.c.patch
blob506fec77109fd8d1936242dad512bd17e398bd20
1 --- a/src/tspi/ps/tspps.c.orig 2011-03-24 13:06:14.607907754 -0700
2 +++ b/src/tspi/ps/tspps.c 2011-03-24 13:07:30.668528209 -0700
3 @@ -42,6 +42,7 @@
4 #include "spi_utils.h"
5 #include "tspps.h"
6 #include "tsplog.h"
7 +#include <libgen.h>
9 static int user_ps_fd = -1;
10 static MUTEX_DECLARE_INIT(user_ps_lock);
11 @@ -70,9 +70,12 @@
12 TSS_RESULT result;
13 char *file_name = NULL, *home_dir = NULL;
14 struct passwd *pwp;
15 -#if (defined (__linux) || defined (linux) || defined(__GLIBC__))
16 +#if (defined (__linux) || defined (linux) || defined(__GLIBC__) || defined(SOLARIS))
17 struct passwd pw;
18 #endif
19 +#ifdef SOLARIS
20 + char pwbuf[PASSWD_BUFSIZE];
21 +#endif
22 struct stat stat_buf;
23 char buf[PASSWD_BUFSIZE];
24 uid_t euid;
25 @@ -94,9 +97,16 @@
26 * in the user's home directory, which may be shared
27 * by multiple systems.
29 - * The directory path on Solaris is /var/tpm/userps/[EUID]/
30 + * The directory path on Solaris is /var/user[USERNAME]/tpm/userps
32 - rc = snprintf(buf, sizeof (buf), "%s/%d", TSS_USER_PS_DIR, euid);
34 + pwp = getpwuid_r(euid, &pw, pwbuf, sizeof (pwbuf));
35 + if (pwp != NULL) {
36 + rc = snprintf(buf, sizeof (buf), "/var/user/%s/tpm/userps",
37 + pwp->pw_name);
38 + } else {
39 + return TSPERR(TSS_E_INTERNAL_ERROR);
40 + }
41 #else
42 setpwent();
43 while (1) {
44 @@ -142,7 +152,7 @@
45 if (errno == ENOENT) {
46 errno = 0;
47 /* Create the user's ps directory if it is not there. */
48 - if ((rc = mkdir(buf, 0700)) == -1) {
49 + if ((rc = mkdirp(buf, 0700)) == -1) {
50 LogDebugFn("USER PS: Error creating dir: %s: %s", buf,
51 strerror(errno));
52 result = TSPERR(TSS_E_INTERNAL_ERROR);
53 @@ -157,8 +167,8 @@
55 /* Directory exists or has been created, return the path to the file */
56 #if defined (SOLARIS)
57 - rc = snprintf(buf, sizeof (buf), "%s/%d/%s", TSS_USER_PS_DIR, euid,
58 - TSS_USER_PS_FILE);
59 + rc = snprintf(buf, sizeof (buf), "/var/user/%s/tpm/userps/%s",
60 + pwp->pw_name, TSS_USER_PS_FILE);
61 #else
62 rc = snprintf(buf, sizeof (buf), "%s/%s/%s", home_dir, TSS_USER_PS_DIR,
63 TSS_USER_PS_FILE);