Preserve original collect password to be used for subcloud collect

Collecting from a subcloud using a user account with a password
containing special characters such as $, [, ], /, or " will fail
due to an "Invalid Password" error.

When the collect command is initially invoked by the user, the first
escape character(s) are added to prefix the special character(s)
in the password. Subcloud collects initiate a second call to collect
which leads to a double special character escape which corrupts the
password.

This update resolves this issue by preserving the original unescaped
password so it can be passed to the subcloud collect. Doing so avoids
the double password escape.

Test Plan:

PASS: Verify subcloud collect without special sudo password characters
PASS: Verify subcloud collect with special sudo password characters
PASS: Verify host collect without special sudo password characters
PASS: Verify host collect with special sudo password characters

Closes-Bug: 2072394
Change-Id: If7cf684b6412687c89e5af36b5b2e9b6e2a832f9
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2024-07-11 01:13:19 +00:00
parent 2fed22e72d
commit 0b6055487e

View File

@ -1120,6 +1120,11 @@ if [ -z "${pw}" ] ; then
echo ""
fi
# Save the original unmodified password so it can be used in a subcloud
# collect which calls collect directly again.
# In that case we don't want to do a double special character replacement.
PW=${pw}
# When the pw is used locally for expect requests ...
#
# Although bash 'read' will handle sanitizing the password
@ -1963,7 +1968,9 @@ function collect_subcloud_run()
# copy the pw file to the subcloud and then cleanup
TEMPFILE=$(mktemp)
echo "${pw}" > ${TEMPFILE}
# Use the original password that was not already
# special character string replaced.
echo "${PW}" > ${TEMPFILE}
copy_file_to_host "${TEMPFILE}" "${subcloud}" "/tmp"
rc=${?}
remove_file_local ${TEMPFILE}