Skip to content

Commit 69bac71

Browse files
committed
codebase: silence dd output while capturing output in variables when needed
Signed-off-by: Thierry Laurion <[email protected]>
1 parent a450dba commit 69bac71

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

initrd/bin/inject_firmware.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ chmod a+x "$INITRD_ROOT/init"
9696
# Linux ignores zeros between archive segments, so any extra padding is not
9797
# harmful.
9898
FW_INITRD="/tmp/inject_firmware_initrd.cpio.gz"
99-
dd if="$ORIG_INITRD" of="$FW_INITRD" bs=512 conv=sync status=none
99+
dd if="$ORIG_INITRD" of="$FW_INITRD" bs=512 conv=sync status=none > /dev/null 2>&1
100100
# Pack up the new contents and append to the initrd. Don't spend time
101101
# compressing this.
102102
(cd "$INITRD_ROOT"; find . | cpio -o -H newc) >>"$FW_INITRD"

initrd/bin/tpmr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ tpm2_counter_create() {
332332
esac
333333
done
334334
prompt_tpm_owner_password
335-
rand_index="1$(dd if=/dev/urandom bs=1 count=3 | xxd -pc3)"
335+
rand_index="1$(dd if=/dev/urandom bs=1 count=3 2>/dev/null | xxd -pc3)"
336336
tpm2 nvdefine -C o -s 8 -a "ownerread|authread|authwrite|nt=1" \
337337
-P "$(tpm2_password_hex "$(cat "/tmp/secret/tpm_owner_password")")" "0x$rand_index" >/dev/console ||
338338
{
@@ -412,7 +412,7 @@ tpm1_destroy() {
412412
index="$1" # Index of the sealed file
413413
size="$2" # Size of zeroes to overwrite for TPM1
414414

415-
dd if=/dev/zero bs="$size" count=1 of=/tmp/wipe-totp-zero
415+
dd if=/dev/zero bs="$size" count=1 of=/tmp/wipe-totp-zero > /dev/null 2>&1
416416
tpm nv_writevalue -in "$index" -if /tmp/wipe-totp-zero ||
417417
die "Unable to wipe sealed secret from TPM NVRAM"
418418
}
@@ -690,7 +690,7 @@ tpm2_reset() {
690690
# The default lockout password is empty, so we must set this, and we
691691
# don't need to provide any auth (use the default empty password).
692692
tpm2 changeauth -Q -c lockout \
693-
"hex:$(dd if=/dev/urandom bs=32 count=1 status=none | xxd -p | tr -d ' \n')"
693+
"hex:$(dd if=/dev/urandom bs=32 count=1 status=none 2>/dev/null | xxd -p | tr -d ' \n')"
694694
}
695695
tpm1_reset() {
696696
TRACE_FUNC
@@ -729,7 +729,7 @@ tpm2_kexec_finalize() {
729729
# being cleared in the OS.
730730
# This passphrase is only effective before the next boot.
731731
echo "Locking TPM2 platform hierarchy..."
732-
randpass=$(dd if=/dev/urandom bs=4 count=1 status=none | xxd -p)
732+
randpass=$(dd if=/dev/urandom bs=4 count=1 status=none 2>/dev/null | xxd -p)
733733
tpm2 changeauth -c platform "$randpass" ||
734734
warn "Failed to lock platform hierarchy of TPM2"
735735
}

initrd/bin/unpack_initramfs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ unpack_first_segment() {
6161
mkdir -p "$dest_dir"
6262

6363
# peek the beginning of the file to determine what type of content is next
64-
magic="$(dd if="$unpack_archive" bs=6 count=1 status=none | xxd -p)"
64+
magic="$(dd if="$unpack_archive" bs=6 count=1 status=none 2>/dev/null | xxd -p)"
6565

6666
# read this segment of the archive, then write the rest to the next file
6767
(

initrd/mount-boot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dev_blocks=`cat "$dev_size_file"`
3636
#
3737
# Extract the signed file from the hard disk image
3838
#
39-
if ! dd if="$dev" of="$cmd_sig" bs=512 skip="`expr $dev_blocks - 1`"; then
39+
if ! dd if="$dev" of="$cmd_sig" bs=512 skip="`expr $dev_blocks - 1`" > /dev/null 2>&1; then
4040
echo >&2 '!!!!!'
4141
echo >&2 '!!!!! Boot block extraction failed'
4242
echo >&2 '!!!!! Dropping to recovery shell'

targets/qemu.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $(MEMORY_SIZE_FILE):
4545
@echo "$(QEMU_MEMORY_SIZE)" >"$(MEMORY_SIZE_FILE)"
4646
USB_FD_IMG=$(build)/$(BOARD)/usb_fd.raw
4747
$(USB_FD_IMG):
48-
dd if=/dev/zero bs=1M of="$(USB_FD_IMG)" bs=1M count=256
48+
dd if=/dev/zero bs=1M of="$(USB_FD_IMG)" bs=1M count=256 >/dev/null 2>&1
4949
# Debian obnoxiously does not include /usr/sbin in PATH for non-root, even
5050
# though it is meaningful to use mkfs.vfat (etc.) as non-root
5151
MKFS_VFAT=mkfs.vfat; \

0 commit comments

Comments
 (0)