mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-12-03 23:57:06 +00:00
fix(xcat-core): the encrypted-password cases read a directory as a file on Ubuntu
The four encrypted_passwd_*_diskfull cases fail on every Ubuntu cell with "grep: /install/autoinst/<node>: Is a directory". On Ubuntu that path is a cloud-init directory holding user-data, meta-data and vendor-data; on the other families it is a single file. The crypted password is in user-data, so the product writes what the cases look for and the cases read the wrong path. Take user-data when the path is a directory. Each case now also checks that the crypt marker is in the output, not only that grep returned 0. A marker the file does not carry still returns non-zero, and the "Is a directory" message carries no marker, so neither check is satisfied by an error. The openssl case extracted the hash by field position, which gives an empty string for a quoted YAML value that may carry a "root:" prefix, and an empty file compared equal to nothing. Take the hash itself. crypt_system_password passes an already hashed password through unchanged, so the value in user-data is the value the passwd table holds. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> (cherry picked from commit 357c634dae73a5f1120def9f5d8d0e2107d53060)
This commit is contained in:
@@ -8,8 +8,12 @@ check:rc==0
|
||||
cmd:if grep Ubuntu /etc/*release;then if [ ! -e /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz ]; then copycds $$ISO;mkdir -p /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/;touch /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz;fi;fi
|
||||
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
|
||||
check:rc==0
|
||||
cmd:grep '\$1\$' /install/autoinst/$$CN
|
||||
#On Ubuntu the artefact is a cloud-init directory, so the crypted password is in its
|
||||
#user-data; on the other families it is a single file. Reading the directory as a file
|
||||
#answers "Is a directory" and measures nothing.
|
||||
cmd:f=/install/autoinst/$$CN; [ -d "$f" ] && f="$f/user-data"; grep '\$1\$' "$f"
|
||||
check:rc==0
|
||||
check:output=~\$1\$
|
||||
cmd:oldcryptmethod=`cat /tmp/tmpcryptmethod |sed 's/\"//g'`;chtab key=system passwd.cryptmethod=$oldcryptmethod
|
||||
check:rc==0
|
||||
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
|
||||
@@ -82,8 +86,12 @@ check:rc==0
|
||||
cmd:if grep Ubuntu /etc/*release;then if [ ! -e /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz ]; then copycds $$ISO;mkdir -p /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/;touch /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz;fi;fi
|
||||
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
|
||||
check:rc==0
|
||||
cmd:grep '\$5\$' /install/autoinst/$$CN
|
||||
#On Ubuntu the artefact is a cloud-init directory, so the crypted password is in its
|
||||
#user-data; on the other families it is a single file. Reading the directory as a file
|
||||
#answers "Is a directory" and measures nothing.
|
||||
cmd:f=/install/autoinst/$$CN; [ -d "$f" ] && f="$f/user-data"; grep '\$5\$' "$f"
|
||||
check:rc==0
|
||||
check:output=~\$5\$
|
||||
cmd:oldcryptmethod=`cat /tmp/tmpcryptmethod |sed 's/\"//g'`;chtab key=system passwd.cryptmethod=$oldcryptmethod
|
||||
check:rc==0
|
||||
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
|
||||
@@ -156,8 +164,12 @@ check:rc==0
|
||||
cmd:if grep Ubuntu /etc/*release;then if [ ! -e /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz ]; then copycds $$ISO;mkdir -p /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/;touch /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz;fi;fi
|
||||
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
|
||||
check:rc==0
|
||||
cmd:grep '\$6\$' /install/autoinst/$$CN
|
||||
#On Ubuntu the artefact is a cloud-init directory, so the crypted password is in its
|
||||
#user-data; on the other families it is a single file. Reading the directory as a file
|
||||
#answers "Is a directory" and measures nothing.
|
||||
cmd:f=/install/autoinst/$$CN; [ -d "$f" ] && f="$f/user-data"; grep '\$6\$' "$f"
|
||||
check:rc==0
|
||||
check:output=~\$6\$
|
||||
cmd:oldcryptmethod=`cat /tmp/tmpcryptmethod |sed 's/\"//g'`;chtab key=system passwd.cryptmethod=$oldcryptmethod
|
||||
check:rc==0
|
||||
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
|
||||
@@ -235,7 +247,9 @@ check:rc==0
|
||||
cmd:if grep Ubuntu /etc/*release;then if [ ! -e /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz ]; then copycds $$ISO;mkdir -p /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/;touch /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot/initrd.gz;fi;fi
|
||||
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
|
||||
check:rc==0
|
||||
cmd:if grep SUSE /etc/*release;then grep '\$6\$' /install/autoinst/$$CN | awk 'gsub(/^ *| *$/,"")'| awk -v head="<user_password>" -v tail="</user_password>" '{print substr($0, index($0,head)+length(head),index($0,tail)-index($0,head)-length(head))}' > /tmp/instcryptedpasswd; elif grep -E "Red Hat|CentOS|Rocky|Alma|openEuler" /etc/*release;then grep '\$6\$' /install/autoinst/$$CN |awk -F " " '{print $3}' > /tmp/instcryptedpasswd; elif grep Ubuntu /etc/*release;then grep '\$6\$' /install/autoinst/$$CN |awk -F " " '{print $4}' > /tmp/instcryptedpasswd;else echo "Sorry,this is not supported os"; fi
|
||||
#The Ubuntu branch reads the cloud-init user-data, where the hash is quoted and may carry a
|
||||
#"root:" prefix, so take the hash itself rather than a field position.
|
||||
cmd:if grep SUSE /etc/*release;then grep '\$6\$' /install/autoinst/$$CN | awk 'gsub(/^ *| *$/,"")'| awk -v head="<user_password>" -v tail="</user_password>" '{print substr($0, index($0,head)+length(head),index($0,tail)-index($0,head)-length(head))}' > /tmp/instcryptedpasswd; elif grep -E "Red Hat|CentOS|Rocky|Alma|openEuler" /etc/*release;then grep '\$6\$' /install/autoinst/$$CN |awk -F " " '{print $3}' > /tmp/instcryptedpasswd; elif grep Ubuntu /etc/*release;then grep -ho '\$6\$[^"]*' /install/autoinst/$$CN/user-data | head -1 > /tmp/instcryptedpasswd;else echo "Sorry,this is not supported os"; fi
|
||||
check:rc==0
|
||||
cmd:diff /tmp/tmpcryptedpasswd /tmp/instcryptedpasswd
|
||||
check:rc==0
|
||||
|
||||
Reference in New Issue
Block a user