--- trousers-0.3.11.2/src/tspi/ps/tspps.c.orig +++ trousers-0.3.11.2/src/tspi/ps/tspps.c @@ -42,6 +42,7 @@ #include "spi_utils.h" #include "tspps.h" #include "tsplog.h" +#include static int user_ps_fd = -1; static MUTEX_DECLARE_INIT(user_ps_lock); @@ -60,9 +61,12 @@ TSS_RESULT result; char *file_name = NULL, *home_dir = NULL; struct passwd *pwp; -#if (defined (__linux) || defined (linux) || defined(__GLIBC__)) +#if (defined (__linux) || defined (linux) || defined(__GLIBC__) || defined(SOLARIS)) struct passwd pw; #endif +#ifdef SOLARIS + char pwbuf[PASSWD_BUFSIZE]; +#endif struct stat stat_buf; char buf[PASSWD_BUFSIZE]; uid_t euid; @@ -84,9 +88,16 @@ * in the user's home directory, which may be shared * by multiple systems. * - * The directory path on Solaris is /var/tpm/userps/[EUID]/ + * The directory path on Solaris is /var/user[USERNAME]/tpm/userps */ - rc = snprintf(buf, sizeof (buf), "%s/%d", TSS_USER_PS_DIR, euid); + + pwp = getpwuid_r(euid, &pw, pwbuf, sizeof (pwbuf)); + if (pwp != NULL) { + rc = snprintf(buf, sizeof (buf), "/var/user/%s/tpm/userps", + pwp->pw_name); + } else { + return TSPERR(TSS_E_INTERNAL_ERROR); + } #else setpwent(); while (1) { @@ -132,7 +143,7 @@ if (errno == ENOENT) { errno = 0; /* Create the user's ps directory if it is not there. */ - if ((rc = mkdir(buf, 0700)) == -1) { + if ((rc = mkdirp(buf, 0700)) == -1) { LogDebugFn("USER PS: Error creating dir: %s: %s", buf, strerror(errno)); result = TSPERR(TSS_E_INTERNAL_ERROR); @@ -147,8 +158,8 @@ /* Directory exists or has been created, return the path to the file */ #if defined (SOLARIS) - rc = snprintf(buf, sizeof (buf), "%s/%d/%s", TSS_USER_PS_DIR, euid, - TSS_USER_PS_FILE); + rc = snprintf(buf, sizeof (buf), "/var/user/%s/tpm/userps/%s", + pwp->pw_name, TSS_USER_PS_FILE); #else rc = snprintf(buf, sizeof (buf), "%s/%s/%s", home_dir, TSS_USER_PS_DIR, TSS_USER_PS_FILE);