From 11896e65d379898091db3d6b07d90c4215c09a4d Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Fri, 29 Jan 2021 11:52:42 +0800 Subject: [PATCH] fix(host-deployer): remove escape character on windows passwd --- pkg/hostman/guestfs/fsdriver/windows.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/hostman/guestfs/fsdriver/windows.go b/pkg/hostman/guestfs/fsdriver/windows.go index 5f6d0deebe..57856b1912 100644 --- a/pkg/hostman/guestfs/fsdriver/windows.go +++ b/pkg/hostman/guestfs/fsdriver/windows.go @@ -356,6 +356,8 @@ func (w *SWindowsRootFs) ChangeUserPasswd(part IDiskPartition, account, gid, pub tool.CheckPath() success := false + // symbol ^ is escape character is batch file. + password = strings.ReplaceAll(password, "^", "") if rinfo != nil && version.GE(rinfo.Version, "6.1") { success = w.deployPublicKeyByGuest(account, password) } else { @@ -408,8 +410,6 @@ func (w *SWindowsRootFs) deployPublicKeyByGuest(uname, passwd string) bool { logPath := w.guestDebugLogPath chksum := stringutils2.GetMD5Hash(passwd + logPath[(len(logPath)-10):]) - // symbol ^ is escape character is batch file. - passwd = strings.ReplaceAll(passwd, "^", "^^") chgpwdScript := strings.Join([]string{ w.MakeGuestDebugCmd("change password step 1"), strings.Join([]string{