components/trousers/patches/tspi_ps_tspps.c.patch
changeset 1825 6864cd9b9a00
parent 777 e2e604cdbd6a
child 5941 db8aa9865e9f
equal deleted inserted replaced
1824:fb933e605dec 1825:6864cd9b9a00
       
     1 #
       
     2 # tspi_ps_tspps.c.patch
       
     3 # This change implements Solaris-specific locations for the
       
     4 # TSS PS (persistent storage), aka TPM keystore.
       
     5 # It is not suitable for upstream use.  This change was implemented in-house.
       
     6 #
     1 --- src/tspi/ps/tspps.c.orig	2011-03-24 13:06:14.607907754 -0700
     7 --- src/tspi/ps/tspps.c.orig	2011-03-24 13:06:14.607907754 -0700
     2 +++ src/tspi/ps/tspps.c	2011-03-24 13:07:30.668528209 -0700
     8 +++ src/tspi/ps/tspps.c	2011-03-24 13:07:30.668528209 -0700
     3 @@ -70,9 +70,12 @@
     9 @@ -70,9 +70,12 @@
     4  	TSS_RESULT result;
    10  	TSS_RESULT result;
     5  	char *file_name = NULL, *home_dir = NULL;
    11  	char *file_name = NULL, *home_dir = NULL;
    12 +	char pwbuf[PASSWD_BUFSIZE];
    18 +	char pwbuf[PASSWD_BUFSIZE];
    13 +#endif
    19 +#endif
    14  	struct stat stat_buf;
    20  	struct stat stat_buf;
    15  	char buf[PASSWD_BUFSIZE];
    21  	char buf[PASSWD_BUFSIZE];
    16  	uid_t euid;
    22  	uid_t euid;
    17 @@ -94,9 +97,16 @@
    23 @@ -94,9 +97,15 @@
    18           * in the user's home directory, which may be shared
    24           * in the user's home directory, which may be shared
    19           * by multiple systems.
    25           * by multiple systems.
    20           *
    26           *
    21 -         * The directory path on Solaris is /var/tpm/userps/[EUID]/
    27 -         * The directory path on Solaris is /var/tpm/userps/[EUID]/
    22 +         * The directory path on Solaris is /var/user[USERNAME]/tpm/userps
    28 +         * The directory path on Solaris is /var/user/[USERNAME]/tpm/userps
    23           */
    29           */
    24 -        rc = snprintf(buf, sizeof (buf), "%s/%d", TSS_USER_PS_DIR, euid);
    30 -        rc = snprintf(buf, sizeof (buf), "%s/%d", TSS_USER_PS_DIR, euid);
    25 +
    31 +	rc = getpwuid_r(euid, &pw, pwbuf, sizeof (pwbuf), &pwp);
    26 +	pwp = getpwuid_r(euid, &pw, pwbuf, sizeof (pwbuf));
    32 +	if ((rc != 0) || (pwp == NULL)) {
    27 +	if (pwp != NULL) {
       
    28 +		rc = snprintf(buf, sizeof (buf), "/var/user/%s/tpm/userps",
       
    29 +		    pwp->pw_name);
       
    30 +	} else {
       
    31 +		return TSPERR(TSS_E_INTERNAL_ERROR);
    33 +		return TSPERR(TSS_E_INTERNAL_ERROR);
    32 +	}
    34 +	}
       
    35 +	rc = snprintf(buf, sizeof (buf), "/var/user/%s/tpm/userps",
       
    36 +	    pwp->pw_name);
       
    37 +
    33  #else
    38  #else
    34  	setpwent();
    39  	setpwent();
    35  	while (1) {
    40  	while (1) {
    36 @@ -142,7 +152,7 @@
    41 @@ -142,7 +152,7 @@
    37  		if (errno == ENOENT) {
    42  		if (errno == ENOENT) {