mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-12-04 16:17:06 +00:00
fix(xcat-core): Genesis node stops at "Getting initial certificate"
openssl req reads the config file at OPENSSLDIR/openssl.cnf and exits 1 when it is
absent. install() in xCAT-genesis-base/dracut_105/{ubuntu,el}/module-setup.sh runs
dracut_install openssl, which copies the program and its shared libraries and nothing
else. OPENSSLDIR is /usr/lib/ssl on Ubuntu and /etc/pki/tls on EL, so the one file
doxcat writes serves EL alone, and getcert loops on openssl req until it gives up.
Measured on an Ubuntu compute node: /usr/lib/ssl did not exist, the image carried
/etc/pki/tls/openssl.cnf, and the key verified "RSA key ok". Supplying a config turned
the same command into a 1602 byte certificate request.
Each module now installs the config file that its own openssl names, and the image
build stops when that file is absent. getcert reports what openssl printed beside the
key it used, and reads the file with bash builtins so it needs no external command.
Two mutations, each failing only the cases that name it: dropping the install call
fails both module cases and keeps the other four; restoring the old message fails the
message case alone.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -40,10 +40,25 @@ _dracut_install_opt() {
|
||||
fi
|
||||
}
|
||||
|
||||
# openssl req reads the config file at OPENSSLDIR/openssl.cnf and exits 1 without it, so the
|
||||
# node makes no certificate request. dracut_install copies the program and its libraries only.
|
||||
# OPENSSLDIR is /usr/lib/ssl on Ubuntu and /etc/pki/tls on EL, so ask openssl where it looks.
|
||||
_dracut_install_openssl_config() {
|
||||
local dir cnf
|
||||
dir=$(openssl version -d 2>/dev/null | sed -e 's/^OPENSSLDIR: *"*//' -e 's/"*$//')
|
||||
cnf="${dir:-/etc/ssl}/openssl.cnf"
|
||||
if [ ! -e "$cnf" ]; then
|
||||
dfatal "xcat: no openssl config at $cnf; Genesis cannot request a certificate"
|
||||
exit 1
|
||||
fi
|
||||
dracut_install "$cnf"
|
||||
}
|
||||
|
||||
install() {
|
||||
local genesis_openeuler=0 timezone timezone_files locale_file locale_files
|
||||
[[ -f /etc/openEuler-release ]] && genesis_openeuler=1
|
||||
dracut_install wget openssl tar mstflint ipmitool cpio gzip lsmod ethtool modprobe touch echo cut wc bash
|
||||
_dracut_install_openssl_config
|
||||
dracut_install netstat # broadcom update requires
|
||||
dracut_install uniq # mellanox update requires
|
||||
dracut_install grep ip hostname /usr/bin/awk egrep grep dirname expr
|
||||
|
||||
@@ -40,12 +40,27 @@ _dracut_install_opt() {
|
||||
fi
|
||||
}
|
||||
|
||||
# openssl req reads the config file at OPENSSLDIR/openssl.cnf and exits 1 without it, so the
|
||||
# node makes no certificate request. dracut_install copies the program and its libraries only.
|
||||
# OPENSSLDIR is /usr/lib/ssl on Ubuntu and /etc/pki/tls on EL, so ask openssl where it looks.
|
||||
_dracut_install_openssl_config() {
|
||||
local dir cnf
|
||||
dir=$(openssl version -d 2>/dev/null | sed -e 's/^OPENSSLDIR: *"*//' -e 's/"*$//')
|
||||
cnf="${dir:-/etc/ssl}/openssl.cnf"
|
||||
if [ ! -e "$cnf" ]; then
|
||||
dfatal "xcat: no openssl config at $cnf; Genesis cannot request a certificate"
|
||||
exit 1
|
||||
fi
|
||||
dracut_install "$cnf"
|
||||
}
|
||||
|
||||
install() {
|
||||
# Ubuntu multiarch triplet for architecture-specific library paths
|
||||
local TRIPLET
|
||||
TRIPLET=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null || echo x86_64-linux-gnu)
|
||||
|
||||
dracut_install wget openssl tar ipmitool cpio gzip lsmod ethtool modprobe touch echo cut wc bash
|
||||
_dracut_install_openssl_config
|
||||
_dracut_install_opt mstflint
|
||||
dracut_install netstat # broadcom update requires
|
||||
dracut_install uniq # mellanox update requires
|
||||
|
||||
@@ -21,9 +21,15 @@ fi
|
||||
# requests fail. An emulated node needs minutes for that key.
|
||||
CSR_TIMEOUT=${GETCERT_CSR_TIMEOUT:-600}
|
||||
CSR_DEADLINE=$((SECONDS + CSR_TIMEOUT))
|
||||
while ! openssl req -new -key /etc/xcat/certkey.pem -out /tmp/tls.csr -subj "/CN=$(hostname)" >& /dev/null; do
|
||||
CSR_ERROR=/tmp/getcert.csr.err
|
||||
while ! openssl req -new -key /etc/xcat/certkey.pem -out /tmp/tls.csr -subj "/CN=$(hostname)" > /dev/null 2> $CSR_ERROR; do
|
||||
if [ "$SECONDS" -ge "$CSR_DEADLINE" ]; then
|
||||
give_up "no certificate request after ${CSR_TIMEOUT}s; /etc/xcat/certkey.pem is not usable"
|
||||
# Name the key that was used AND what openssl printed: the key is usually intact and
|
||||
# the absent file is OPENSSLDIR/openssl.cnf.
|
||||
# Read and flatten with bash builtins. The Genesis payload is a minimal initramfs
|
||||
# and need not carry tr or cat.
|
||||
csr_error=$(< $CSR_ERROR)
|
||||
give_up "no certificate request after ${CSR_TIMEOUT}s using /etc/xcat/certkey.pem: ${csr_error//$'\n'/ }"
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user