Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rng-tools: Fix for rngd daemon failing to start #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions linux-tools/rng_tools/rng-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
source $LTPBIN/tc_utils.source
load_rng_mod=0
rng_service=rngd
rngd_cleanup=0

################################################################################
# Utility functions
Expand All @@ -43,14 +44,10 @@ rng_service=rngd
#
function tc_local_setup()
{
tc_register "Setting up machine to run the tests"
tc_root_or_break || return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tc_register will register "Setting up machine to run the tests" as one test and increment TST_TOTAL , but I dont see corresponding tc_pass*/tc_fail* associated to this. If intention is put info in logs, you can use tc_info "Setting up machine to run the tests"

tc_exec_or_break rngd rngtest || return

rngd_cleanup=0
# Check if RNG device, RANDOM NUMBER GENERATOR
tc_exists /dev/random /dev/urandom
tc_break_if_bad $? "RNG device doesnot exist" || return

cat >> $TCTMP/entropy.py <<-EOF
#!/usr/bin/python
import sys, time
Expand All @@ -59,15 +56,6 @@ function tc_local_setup()

chmod +x $TCTMP/entropy.py

# rngd init script is missing
# Bug in redhat bugzilla - Bug 215371
systemctl is-active rngd 2>&1 >/dev/null
[ $? -eq 0 ] && \
rngd_cleanup=1

systemctl stop $rng_service 2>&1 >/dev/null
tc_service_start_and_wait $rng_service

}

#
Expand All @@ -93,6 +81,37 @@ function tc_local_cleanup()
# Testcase functions
################################################################################

#
#Check TPM device.
#
function check_rng()
{

tc_register "checking TPM device"
tc_exists /dev/random /dev/urandom /dev/tpm*
if [ $? -ne 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few doubts here:

Evenif /dev/tpm is not present , random number generator works with /dev/urandom or with /dev/hwrng.
I could verify in system which doesnt have /dev/tpm and successfully start rngd using "rngd -f"

Can you please verify again if /dev/tpm is must here.

tc_conf "TPM devices were not found, Skipping tests"
exit 0
else
lsmod |grep -qw tpm-rng
if [ $? -ne 0 ]; then
modprobe tpm-rng >/dev/null
if [ $? -eq 0 ]; then
load_rng_mod=1
else
tc_conf "Failed to load tpm-rng module"
exit 0
fi
fi
fi
systemctl is-active rngd 2>&1 >/dev/null
[ $? -eq 0 ] && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tc_service* can be used here

rngd_cleanup=1


tc_service_restart_and_wait $rng_service
}

#
# test01 rngd test
#
Expand Down Expand Up @@ -175,9 +194,10 @@ function test03()
# main
################################################################################

TST_TOTAL=3

tc_setup
check_rng
TST_TOTAL=4
test01
test02
test03