0

I have enabled TPM 2.0 using bios.

$ [ -c /dev/tpmrm0 ] && echo "TPM 2.0"
TPM 2.0

When I am trying to install tpm-tools, it is giving the following error:

% sudo apt install tpm-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
tpm-tools is already the newest version (1.3.9.1-0.2ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up trousers (0.3.14+fixed1-1build1) ...
Job for trousers.service failed because the control process exited with error code.
See "systemctl status trousers.service" and "journalctl -xe" for details.
invoke-rc.d: initscript trousers, action "start" failed.
● trousers.service - LSB: starts tcsd
     Loaded: loaded (/etc/init.d/trousers; generated)
     Active: failed (Result: exit-code) since Wed 2021-02-10 03:59:26 AEST; 3ms ago
       Docs: man:systemd-sysv-generator(8)
    Process: 7414 ExecStart=/etc/init.d/trousers start (code=exited, status=30)

Feb 10 03:59:26 blueray-i5 systemd[1]: Starting LSB: starts tcsd...
Feb 10 03:59:26 blueray-i5 trousers[7414]:  * Starting Trusted Computing daemon tcsd
Feb 10 03:59:26 blueray-i5 trousers[7414]: /etc/init.d/trousers: 32: [: /dev/tpm0: unexpected operator
Feb 10 03:59:26 blueray-i5 tcsd[7420]: TCSD TDDL[7420]: TrouSerS ioctl: (25) Inappropriate ioctl for device
Feb 10 03:59:26 blueray-i5 tcsd[7420]: TCSD TDDL[7420]: TrouSerS Falling back to Read/Write device support.
Feb 10 03:59:26 blueray-i5 tcsd[7420]: TCSD TCS[7420]: TrouSerS ERROR: TCS GetCapability failed with result = 0x1e
Feb 10 03:59:26 blueray-i5 trousers[7414]:    ...fail!
Feb 10 03:59:26 blueray-i5 systemd[1]: trousers.service: Control process exited, code=exited, status=30/n/a
Feb 10 03:59:26 blueray-i5 systemd[1]: trousers.service: Failed with result 'exit-code'.
Feb 10 03:59:26 blueray-i5 systemd[1]: Failed to start LSB: starts tcsd.
dpkg: error processing package trousers (--configure):
 installed trousers package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of tpm-tools:
 tpm-tools depends on trousers; however:
  Package trousers is not configured yet.

dpkg: error processing package tpm-tools (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 trousers
 tpm-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

So, I tried to start trousers service. It is giving the following message:

    % systemctl start trousers.service
    Job for trousers.service failed because the control process exited with error code.
    See "systemctl status trousers.service" and "journalctl -xe" for details.
    % systemctl status trousers.service
    ● trousers.service - LSB: starts tcsd
         Loaded: loaded (/etc/init.d/trousers; generated)
         Active: failed (Result: exit-code) since Wed 2021-02-10 04:04:56 AEST; 23s ago
           Docs: man:systemd-sysv-generator(8)
        Process: 9114 ExecStart=/etc/init.d/trousers start (code=exited, status=30)
    
    Feb 10 04:04:56 blueray-i5 systemd[1]: Starting LSB: starts tcsd...
    Feb 10 04:04:56 blueray-i5 trousers[9114]:  * Starting Trusted Computing daemon tcsd
    Feb 10 04:04:56 blueray-i5 trousers[9114]: /etc/init.d/trousers: 32: [: /dev/tpm0: unexpected operator
    Feb 10 04:04:56 blueray-i5 tcsd[9120]: TCSD TDDL[9120]: TrouSerS ioctl: (25) Inappropriate ioctl for device
    Feb 10 04:04:56 blueray-i5 tcsd[9120]: TCSD TDDL[9120]: TrouSerS Falling back to Read/Write device support.
    Feb 10 04:04:56 blueray-i5 tcsd[9120]: TCSD TCS[9120]: TrouSerS ERROR: TCS GetCapability failed with result = 0x1e
    Feb 10 04:04:56 blueray-i5 trousers[9114]:    ...fail!
    Feb 10 04:04:56 blueray-i5 systemd[1]: trousers.service: Control process exited, code=exited, status=30/n/a
    Feb 10 04:04:56 blueray-i5 systemd[1]: trousers.service: Failed with result 'exit-code'.
    Feb 10 04:04:56 blueray-i5 systemd[1]: Failed to start LSB: starts tcsd.

What can I do?

0

3 Answers 3

1

Addressing the comment made by the OP here, in which they want to take the code here and rewrite it into a neater form.

I'm repeating the code here just in case it would disappear from the external site:

    if [ ! -e /dev/tpmrm ]
        then
            log_warning_msg "device driver not loaded, skipping."
            exit 0
        fi

        for tpm_dev in /dev/tpmrm; do
            TPM_OWNER=$(stat -c %U $tpm_dev)
            if [ "x$TPM_OWNER" != "xtss" ]
            then
                log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
            fi
        done

        if [ ! -e /dev/tpm0 ]
        then
            log_warning_msg "device driver not loaded, skipping."
            exit 0
        fi

        for tpm_dev in /dev/tpm0; do
            TPM_OWNER=$(stat -c %U $tpm_dev)
            if [ "x$TPM_OWNER" != "xtss" ]
            then
                log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
            fi
        done

Sorting out the formatting and rewriting it into a single loop:

for tpm_dev in /dev/tpmrm /dev/tpm0; do
    if [ ! -e "$tpm_dev" ]; then
        log_warning_msg "device driver not loaded, skipping."
        continue
    fi

    TPM_OWNER=$(stat -c %U "$tpm_dev")
    if [ "$TPM_OWNER" != "tss" ]; then
        log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
    fi
done

It's unclear whether the exit 0 that the original script contained should still be executed if a device file doesn't exist. I opted for using continue instead to skip ahead to the next device path (since the message said "skipping").

The only other things I changed was to remove the antiquated safe-guard with x in the second test, and I added a set of missing double quotes.

Alternatively, without continue:

for tpm_dev in /dev/tpmrm /dev/tpm0; do
    if [ -e "$tpm_dev" ]; then
        TPM_OWNER=$(stat -c %U "$tpm_dev")
        if [ "$TPM_OWNER" != "tss" ]; then
            log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
        fi
    else
        log_warning_msg "device driver not loaded, skipping."
    fi
done
0

This was answered by user Minix on Stack Overflow:

The answer to that particular error message is a broken line in the given script /etc/init.d/trousers.

The offending line 32:

31:
32: if [ ! -e /dev/tpm* ]
33: then

gets expanded to:

if [ ! -e /dev/tpm /dev/tpm0 ]

Which provokes an error. Changing that line to something like:

31:
32: if [ ! -e /dev/tpm ] && [ ! -e /dev/tpm0 ]
33: then

should at least make the script work.

1
  • This exact code actually did not solve my problem. I modified the code in a medieval way. The code that worked is pastebin.com/Wza5URRj . I did not know what the loops are doing so kept them as it is. If someone can bring them in one loop then I will be glad to change it in my system. Feb 11, 2021 at 14:06
0
if [ ! -e /dev/tpmrm ]
then
    log_warning_msg "device driver not loaded, skipping."
    exit 0
fi

for tpm_dev in /dev/tpmrm; do
    TPM_OWNER=$(stat -c %U $tpm_dev)
    if [ "x$TPM_OWNER" != "xtss" ]
    then
        log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
    fi
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.