Skip to content

Commit 3263ea3

Browse files
committed
core: 改成使用 /dev/urandom 以修复生成随机密码时阻塞
fixes #469 fixes #471
1 parent 7c19559 commit 3263ea3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

reinstall.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,10 +2343,6 @@ prompt_password() {
23432343
warn false "Leave blank to use a random password."
23442344
warn false "不填写则使用随机密码"
23452345
while true; do
2346-
# 特殊字符列表
2347-
# https://learn.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994562(v=ws.11)
2348-
chars=\''A-Za-z0-9~!@#$%^&*_=+`|(){}[]:;"<>,.?/-'
2349-
random_password=$(tr -dc "$chars" </dev/random | head -c16)
23502346
IFS= read -r -p "Password: " password
23512347
if [ -n "$password" ]; then
23522348
IFS= read -r -p "Retype password: " password_confirm
@@ -2356,7 +2352,11 @@ prompt_password() {
23562352
error "Passwords don't match. Try again."
23572353
fi
23582354
else
2359-
password=$random_password
2355+
# 特殊字符列表
2356+
# https://learn.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994562(v=ws.11)
2357+
# 有的机器运行 centos 7 ,用 /dev/random 产生 16 位密码,开启了 rngd 也要 5 秒,关闭了 rngd 则长期阻塞
2358+
chars=\''A-Za-z0-9~!@#$%^&*_=+`|(){}[]:;"<>,.?/-'
2359+
password=$(tr -dc "$chars" </dev/urandom | head -c16)
23602360
break
23612361
fi
23622362
done

0 commit comments

Comments
 (0)