From 508661d676c552582d238847a194b414bccd3b0d Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 18 Oct 2024 10:35:05 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E9=9D=9E?= =?UTF-8?q?=E7=BA=A2=E5=B8=BD=E7=B3=BB=E7=BB=9F=E8=A3=85=E4=BA=86=20python?= =?UTF-8?q?2=20=E6=97=B6=EF=BC=8C=E7=94=9F=E6=88=90=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #178 --- reinstall.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 01d8c17..12d0924 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1870,15 +1870,18 @@ save_password() { # alpine if is_have_cmd busybox && busybox mkpasswd --help 2>&1 | grep -wq sha512; then crypted=$(printf '%s' "$password" | busybox mkpasswd -m sha512) - # centos 7 - elif is_have_cmd python2; then - crypted=$(python2 -c "import crypt; print(crypt.crypt('$password', crypt.mksalt(crypt.METHOD_SHA512)))") # others elif install_pkg openssl && openssl passwd --help 2>&1 | grep -wq '\-6'; then crypted=$(printf '%s' "$password" | openssl passwd -6 -stdin) # debian 9 / ubuntu 16 elif is_have_cmd apt-get && install_pkg whois && mkpasswd -m help | grep -wq sha-512; then crypted=$(printf '%s' "$password" | mkpasswd -m sha-512 --stdin) + # centos 7 + # crypt.mksalt 是 python3 的 + # 红帽把它 backport 到了 centos7 的 python2 上 + # 在其它发行版的 python2 上运行会出错 + elif is_have_cmd yum && is_have_cmd python2; then + crypted=$(python2 -c "import crypt, sys; print(crypt.crypt(sys.argv[1], crypt.mksalt(crypt.METHOD_SHA512)))" "$password") else error_and_exit "Could not generate sha512 password." fi