Merge pull request #1259 in YUNIONIO/onecloud from ~QUXUAN/onecloud:hotfix/qx-qcloud-instance-password to release/2.4.0

* commit 'c40dc1edcd799cc9ebcf6091b9ab246bb46594bd':
  避免腾讯云使用以/开头的密码
This commit is contained in:
邱剑
2019-03-15 14:52:10 +08:00
+9 -2
View File
@@ -36,8 +36,15 @@ func RandomPassword2(width int) string {
ps := PasswordStrength{}
var buf bytes.Buffer
for i := 0; i < width; i += 1 {
index := rand.Intn(len(CHARS))
ch := CHARS[index]
var ch byte
for {
index := rand.Intn(len(CHARS))
ch = CHARS[index]
if i == 0 && ch == '/' {
continue
}
break
}
if strings.IndexByte(DIGITS, ch) >= 0 {
ps.Digits += 1
} else if strings.IndexByte(LETTERS, ch) >= 0 {