Previously, the pki-pkcs12-extract.sh script relied on the existence of the /dev/fd directory. In Linux, this is normally symbolically linked to the /proc/self/fd directory, allowing processes to access its STDIN, STDOUT, etc as named files. If the /dev/fd directory did not exist, the script failed. This includes, for example, trying to run engine-setup during installation from a kickstart file. With this update, the script was updated to use the /proc/self/fd directly. Now the script only requires that the /proc direcory is mounted, and does not fail if the /dev/fd directory does not exist.
Description of problem:
When kickstarting a RHEV system the following error occurs in the ovirt logs:
Traceback in ovirt-engine-setup-20150302232315-a4ccw1.log
~~~
2015-03-02 23:23:59 DEBUG otopi.context context._executeMethod:138 Stage misc METHOD otopi.plugins.ovirt_engine_setup.ovirt_engine.pki.ssh.Plugin._misc
2015-03-02 23:23:59 DEBUG otopi.plugins.ovirt_engine_setup.ovirt_engine.pki.ssh plugin.executeRaw:785 execute: ('/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh', '--name=engine', '--passin=**FILTERED**', '--key=-'), executable='None', cwd='None', env=None
2015-03-02 23:23:59 DEBUG otopi.plugins.ovirt_engine_setup.ovirt_engine.pki.ssh plugin.executeRaw:803 execute-result: ('/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh', '--name=engine', '--passin=**FILTERED**', '--key=-'), rc=1
2015-03-02 23:23:59 DEBUG otopi.context context._executeMethod:152 method exception
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/otopi/context.py", line 142, in _executeMethod
method['method']()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine/pki/ssh.py", line 115, in _misc
logStreams=False,
File "/usr/lib/python2.6/site-packages/otopi/plugin.py", line 871, in execute
command=args[0],
RuntimeError: Command '/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh' failed to execute
2015-03-02 23:23:59 ERROR otopi.context context._executeMethod:161 Failed to execute stage 'Misc configuration': Command '/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh' failed to execute
2015-03-02 23:23:59 DEBUG otopi.transaction transaction.abort:131 aborting 'Yum Transaction'
~~~
Version-Release number of selected component (if applicable): RHEV 5.6
How reproducible: Very reproducible, Roman Hodain reproduced the issue with extra logging adding:
#/bin/sh -x
exec &>/root/pki.out
to /usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh and reproducing the issue. The openssl complains about /dev/fd/1 which is not available during the installation:
/root/pki.out:
openssl pkcs12 -in /etc/pki/ovirt-engine/keys/engine.p12 -passin pass:mypass -passout pass: -nocerts -out /dev/fd/1 -nodes
Error opening output file /dev/fd/1
/dev/fd/1: No such file or directory
To fix the issue:
As it turns out the device is missing during the installation. A workaround can be achieve by adding the following in the post script of the kickstart:
mkdir /dev/fd
ln -s /proc/self/fd/0 /dev/fd/0
ln -s /proc/self/fd/1 /dev/fd/1
Related code:
=========================================================================
/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh:
if [ "${key}" = - ]; then
key=/dev/fd/1
else
touch "${key}"
chmod go-rwx "${key}" || die "Cannot set key permissions"
fi
openssl \
pkcs12 \
-in "${pkcs12}" \
-passin "pass:${passin}" \
-passout "pass:${passout}" \
-nocerts \
-out "${key}" \
${extra_args} \
|| die "Cannot create key"
return 0
=========================================================================
All credit for reproducing and solving the issue goes to: Roman.Hodain++
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://rhn.redhat.com/errata/RHEA-2016-0376.html
Description of problem: When kickstarting a RHEV system the following error occurs in the ovirt logs: Traceback in ovirt-engine-setup-20150302232315-a4ccw1.log ~~~ 2015-03-02 23:23:59 DEBUG otopi.context context._executeMethod:138 Stage misc METHOD otopi.plugins.ovirt_engine_setup.ovirt_engine.pki.ssh.Plugin._misc 2015-03-02 23:23:59 DEBUG otopi.plugins.ovirt_engine_setup.ovirt_engine.pki.ssh plugin.executeRaw:785 execute: ('/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh', '--name=engine', '--passin=**FILTERED**', '--key=-'), executable='None', cwd='None', env=None 2015-03-02 23:23:59 DEBUG otopi.plugins.ovirt_engine_setup.ovirt_engine.pki.ssh plugin.executeRaw:803 execute-result: ('/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh', '--name=engine', '--passin=**FILTERED**', '--key=-'), rc=1 2015-03-02 23:23:59 DEBUG otopi.context context._executeMethod:152 method exception Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/otopi/context.py", line 142, in _executeMethod method['method']() File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine/pki/ssh.py", line 115, in _misc logStreams=False, File "/usr/lib/python2.6/site-packages/otopi/plugin.py", line 871, in execute command=args[0], RuntimeError: Command '/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh' failed to execute 2015-03-02 23:23:59 ERROR otopi.context context._executeMethod:161 Failed to execute stage 'Misc configuration': Command '/usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh' failed to execute 2015-03-02 23:23:59 DEBUG otopi.transaction transaction.abort:131 aborting 'Yum Transaction' ~~~ Version-Release number of selected component (if applicable): RHEV 5.6 How reproducible: Very reproducible, Roman Hodain reproduced the issue with extra logging adding: #/bin/sh -x exec &>/root/pki.out to /usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh and reproducing the issue. The openssl complains about /dev/fd/1 which is not available during the installation: /root/pki.out: openssl pkcs12 -in /etc/pki/ovirt-engine/keys/engine.p12 -passin pass:mypass -passout pass: -nocerts -out /dev/fd/1 -nodes Error opening output file /dev/fd/1 /dev/fd/1: No such file or directory To fix the issue: As it turns out the device is missing during the installation. A workaround can be achieve by adding the following in the post script of the kickstart: mkdir /dev/fd ln -s /proc/self/fd/0 /dev/fd/0 ln -s /proc/self/fd/1 /dev/fd/1 Related code: ========================================================================= /usr/share/ovirt-engine/bin/pki-pkcs12-extract.sh: if [ "${key}" = - ]; then key=/dev/fd/1 else touch "${key}" chmod go-rwx "${key}" || die "Cannot set key permissions" fi openssl \ pkcs12 \ -in "${pkcs12}" \ -passin "pass:${passin}" \ -passout "pass:${passout}" \ -nocerts \ -out "${key}" \ ${extra_args} \ || die "Cannot create key" return 0 ========================================================================= All credit for reproducing and solving the issue goes to: Roman.Hodain++