Skip to contentSkip to conversation

echo command string break-up fix

PATCH RESEND Applied Stefan Berger 2 participants 2 messages Sep 12, 2006 – Sep 14, 2006

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 echo command string break-up fix

When redirecting the output of the echo command using '>' on bash, the output seems to be broken up into multiple write()s (depending on the version of busybox?). Unfortunately /dev/tpm0 needs to have the complete command written to in one chunk. The work-around 'echo <string> > file ; cat file > /dev/tpm0' seems to get around this problem.
The patch also removes a redundant test and error output.

xen-unstable.hg/tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py +1 -1
Index: root/xen-unstable.hg/tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py
===================================================================
@@ -42,7 +42,7 @@ except ConsoleError, e:
     FAIL("Error while creating /dev/tpm0")
 
 try:
-    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > /dev/tpm0")
+    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > seq; cat seq > /dev/tpm0")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
xen-unstable.hg/tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py +1 -1
Index: root/xen-unstable.hg/tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py
===================================================================
@@ -43,7 +43,7 @@ except ConsoleError, e:
     FAIL("Error while creating /dev/tpm0")
 
 try:
-    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > /dev/tpm0")
+    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > seq; cat seq > /dev/tpm0")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
xen-unstable.hg/tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py +1 -1
Index: root/xen-unstable.hg/tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py
===================================================================
@@ -43,7 +43,7 @@ except ConsoleError, e:
     FAIL("Error while creating /dev/tpm0")
 
 try:
-    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > /dev/tpm0")
+    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > seq; cat seq > /dev/tpm0")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
xen-unstable.hg/tools/xm-test/tests/vtpm/vtpm_utils.py +0 -3
Index: root/xen-unstable.hg/tools/xm-test/tests/vtpm/vtpm_utils.py
===================================================================
@@ -8,9 +8,6 @@ from XmTestLib import *
 if ENABLE_HVM_SUPPORT:
     SKIP("vtpm tests not supported for HVM domains")
 
-if not os.path.exists("/dev/tpm0"):
-    SKIP("This machine has no hardware TPM; cannot run this test")
-
 status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
 if output == "":
     FAIL("virtual TPM manager must be started to run this test")

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Applied
#1 lore raw
Quoted 8 lines · Stefan Berger

When redirecting the output of the echo command using '>' on bash, the output seems to be broken up into multiple write()s (depending on the version of busybox?). Unfortunately /dev/tpm0 needs to have the complete command written to in one chunk. The work-around 'echo <string> > file ; cat file > /dev/tpm0' seems to get around this problem.
The patch also removes a redundant test and error output.

Applied, thank you.

Ewan.