Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1666317

Summary: Inconsistency between tpm documentation and headers
Product: Red Hat Enterprise Linux 7 Reporter: Piyush Bhoot <pbhoot>
Component: tpm-toolsAssignee: Jerry Snitselaar <jsnitsel>
Status: CLOSED ERRATA QA Contact: Vilém Maršík <vmarsik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.7CC: jsnitsel, jwright, rvr, smeisner
Target Milestone: rc   
Target Release: 7.8   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 20:11:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1713151    
Attachments:
Description Flags
reproducer none

Description Piyush Bhoot 2019-01-15 13:46:22 UTC
Created attachment 1520776 [details]
reproducer

Description of problem:

Inconsistency between tpm documentation and headers

The `man 3 tpmUnsealFile` documentation says to "#include <tpm_unseal/tpm_unseal.h>" and that the signature for tpmUnsealFile is "int tpmUnsealFile(char* file, char** data, int* size);"

If you look at the header file, which is actually at /usr/include/tpm_tools/tpm_unseal.h, the signature for that function is "int tpmUnsealFile(char*, unsigned char**, int*, BOOL)". One of these must be incorrect.

Version-Release number of selected component (if applicable):
tpm-tools-devel-1.3.9-2.el7.x86_64
tpm-tools-1.3.9-2.el7.x86_64

How reproducible:
Always

Steps to Reproduce:

Reproducer code attached

Actual results:

tmptest.cpp:13:40: error: too few arguments to function ‘int tpmUnsealFile(char*, unsigned char**, int*, int)’
  r = tpmUnsealFile(path, data, datasize);
                                        ^
In file included from tmptest.cpp:1:0:
/usr/include/tpm_tools/tpm_unseal.h:40:5: note: declared here
 int tpmUnsealFile(char*, unsigned char**, int*, BOOL);

Expected results:

No error or warning

Comment 2 Jerry Snitselaar 2019-01-28 06:20:25 UTC
Patch submitted upstream to fix outdated manpage.

Comment 4 Vilém Maršík 2019-06-21 17:59:37 UTC
Hi,
the manpage added the BOOL argument, but still says:
#include <tpm_unseal/tpm_unseal.h>
If you try this, you get:
# gcc test.c
test.c:1:35: fatal error: tpm_unseal/tpm_unseal.h: No such file or directory
 #include <tpm_unseal/tpm_unseal.h>

On the other hand, if you try
#include <tpm_tools/tpm_unseal.h>
you get:
# gcc test.c
In file included from test.c:1:0:
/usr/include/tpm_tools/tpm_unseal.h:40:49: error: unknown type name ‘BOOL’
 int tpmUnsealFile(char*, unsigned char**, int*, BOOL);

I guess this should work, and if another header defines the type BOOL, it should be included from tpm_unseal.h _and_ required by tpm-tools-devel, right? Did I miss something?

Version: tpm-tools-devel-1.3.9-5.el7.x86_64

Comment 5 Jerry Snitselaar 2019-06-21 18:14:09 UTC
Yeah, kick this back to me. I'm not sure if I just swept this bz up with the other manpage cleanup bz and I guess completely missed what this was asking. We should drop this from the errata and I can clean it up for 7.8. tpm_utils.h includes a define of BOOL, but it doesn't ship in either package I think it is just used for building everything.

Comment 7 Vilém Maršík 2019-06-21 18:55:19 UTC
Okay, removed from erratum.

Comment 9 Jerry Snitselaar 2019-08-01 16:37:07 UTC
Pushed with patch to correct header include in example to <tpm_tools/tpm_unseal.h>.

Comment 11 Jerry Snitselaar 2019-11-08 01:07:29 UTC
I've come across another issue here, but I don't think it is exception or blocker worthy since it has existed since 2009 according to git blame.

The tpmUnsealFile declaration in tpm_unseal.h uses BOOL, but nothing defines BOOL for 3rd party programs that make use of libtpm_unseal and tpm_unseal.h.

The tpm-tools code itself has the following in tpm_utils.h:

#ifndef BOOL
#define BOOL int
#endif

and I think the solution would be to add that to tpm_unseal.h as well.

I've opened bug #1770048 to track it.

Comment 12 Vilém Maršík 2020-02-05 18:56:38 UTC
Jerry, is this really fixed?
[root@amd-pike-02 ~]# g++ tpmtest.cpp
In file included from tpmtest.cpp:1:0:
/usr/include/tpm_tools/tpm_unseal.h:40:49: error: ‘BOOL’ has not been declared
 int tpmUnsealFile(char*, unsigned char**, int*, BOOL);
                                                 ^
tpmtest.cpp: In function ‘int main()’:
tpmtest.cpp:7:15: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
  char* path = "/home/testuser/.ssh/.ldappasswd";
               ^
tpmtest.cpp:13:40: error: too few arguments to function ‘int tpmUnsealFile(char*, unsigned char**, int*, int)’
  r = tpmUnsealFile(path, data, datasize);
                                        ^
In file included from tpmtest.cpp:1:0:
/usr/include/tpm_tools/tpm_unseal.h:40:5: note: declared here
 int tpmUnsealFile(char*, unsigned char**, int*, BOOL);
     ^
[root@amd-pike-02 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 Beta (Maipo)

Comment 13 Jerry Snitselaar 2020-02-05 19:12:57 UTC
It looks like your test program is still using the old signature, and doesn't have the 4th argument. The header file and manpage match each other now, which this bug was reporting, but there is an issue with the header file mentioned in comment #11.

BOOL isn't defined, and causes the problem unless someone adds the bit I put in that comment. This apparently has existed in the header file upstream since 2009:

f581b0f6b85bf (Rajiv Andrade    2009-08-20 17:22:59 -0300 44) int tpmUnsealFile(char*, unsigned char**, int*, BOOL);
7b7019074dbc5 (kylene           2005-08-12 18:52:46 +0000 45) void tpmUnsealShred(unsigned char*, int);

Comment 14 Jerry Snitselaar 2020-02-05 19:22:33 UTC
I meant to say that the manpage now points to tpm_tools/tpm_unseal.h. The function signature in the manpage was fixed in 1.3.9-5.

Comment 15 Vilém Maršík 2020-02-06 16:24:50 UTC
Okay, if I change the function call according to the manpage, it will not fail on this, but on the missing BOOL. You reported that as another bug, but then closed it as WONTFIX. From my point of view, things are still broken. We can close this, but why not at least fix the BOOL problem for 7.9 ? Do you think that none will compile TPM code on RHEL7 in the future?

Comment 16 Jerry Snitselaar 2020-02-06 16:35:23 UTC
No one has complained about the problem which has existed for over 10 years. So either no one is compiling against it, or they are solving the BOOL undefined then they see it. If you want, open that bz back up and I'll fix that.

Comment 17 Vilém Maršík 2020-02-06 16:42:41 UTC
Okay, TPM1.2 is obsolete anyway, closing.

Comment 19 errata-xmlrpc 2020-03-31 20:11:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1184