mirror of
https://github.com/stefanberger/swtpm.git
synced 2025-08-22 19:04:35 +00:00
swtpm_setup: log errors from tcsd in logfile
Redirect stdout and stderr from tcsd into a file and if tcsd reported an error copy the error into the logfile. This makes debugging tcsd related issues, such as ownership or access mode issues, easier. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
3b33116d97
commit
9d8d6d0378
@ -502,7 +502,7 @@ start_tcsd()
|
|||||||
{
|
{
|
||||||
local TCSD=$1
|
local TCSD=$1
|
||||||
|
|
||||||
local user group ctr=0 ctr2
|
local user group ctr=0 ctr2 tmp tcsd_error_file
|
||||||
|
|
||||||
user=$(id -u -n)
|
user=$(id -u -n)
|
||||||
group=$(id -g -n)
|
group=$(id -g -n)
|
||||||
@ -516,9 +516,10 @@ start_tcsd()
|
|||||||
TCSD_CONFIG="$(mktemp)"
|
TCSD_CONFIG="$(mktemp)"
|
||||||
TCSD_DATA_DIR="$(mktemp -d)"
|
TCSD_DATA_DIR="$(mktemp -d)"
|
||||||
TCSD_DATA_FILE="$(TMPDIR=${TCSD_DATA_DIR} mktemp)"
|
TCSD_DATA_FILE="$(TMPDIR=${TCSD_DATA_DIR} mktemp)"
|
||||||
|
tcsd_error_file="$(TMPDIR=${TCSD_DATA_DIR} mktemp)"
|
||||||
|
|
||||||
if [ -z "$TCSD_CONFIG" ] || [ -z "$TCSD_DATA_DIR" ] || \
|
if [ -z "$TCSD_CONFIG" ] || [ -z "$TCSD_DATA_DIR" ] || \
|
||||||
[ -z "$TCSD_DATA_FILE" ]; then
|
[ -z "$TCSD_DATA_FILE" ] || [ -z "$tcsd_error_file" ]; then
|
||||||
logerr "Could not create temporary file; TMPDIR=$TMPDIR"
|
logerr "Could not create temporary file; TMPDIR=$TMPDIR"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -547,7 +548,7 @@ EOF
|
|||||||
# make sure tcsd is gone
|
# make sure tcsd is gone
|
||||||
stop_tcsd 1
|
stop_tcsd 1
|
||||||
|
|
||||||
TCSD_TCP_DEVICE_HOSTNAME=127.0.0.1 $TCSD -c "$TCSD_CONFIG" -e -f &>/dev/null &
|
TCSD_TCP_DEVICE_HOSTNAME=127.0.0.1 $TCSD -c "$TCSD_CONFIG" -e -f &>"$tcsd_error_file" &
|
||||||
TCSD_PID=$!
|
TCSD_PID=$!
|
||||||
|
|
||||||
# poll for open port (good) or the process to have
|
# poll for open port (good) or the process to have
|
||||||
@ -576,6 +577,11 @@ EOF
|
|||||||
return 0
|
return 0
|
||||||
done
|
done
|
||||||
|
|
||||||
|
tmp="$(cat "$tcsd_error_file")"
|
||||||
|
if [ -n "$tmp" ]; then
|
||||||
|
logerr "tcsd error: $tmp"
|
||||||
|
fi
|
||||||
|
|
||||||
ctr=$((ctr + 1))
|
ctr=$((ctr + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user