chef / knife-windows

Plugin for Chef's knife tool for working with Windows nodes
Apache License 2.0
152 stars 110 forks source link

Using a password with a caret (^) doesn't work. #387

Closed joekiller closed 8 years ago

joekiller commented 8 years ago

I'm trying to do stuff like knife winrm HOST chef-client -m -x 'user' -P 'pass^word' -VV.

I end up seeing:

DEBUG: WinRM::WinRMWebService options: {:user=>"user", :pass=>"password",

If I leave the password toggle out and rely on

So it seems like https://github.com/chef/knife-windows/blob/9e0494f35d284eee5d3725e0c237b88ecddaecdc/lib/chef/knife/winrm_base.rb#L52 is stripping the ^

because https://github.com/chef/knife-windows/blob/14c6b9bda654dc4fda2fa9f03a7e26bc9b926297/lib/chef/knife/winrm_knife_base.rb#L274 works.

joekiller commented 8 years ago

Oh and this only affects windows. I'm running in powershell.

mwrock commented 8 years ago

Try using 2 carets. The knife commands are .bat files that spawn ruby. The bat file is run in CMD.exe where the caret is special. 2 carets should escape the second.

joekiller commented 8 years ago

Thanks for the tip. I ended up having to use 4 caret's per caret I wanted. Details here: http://stackoverflow.com/questions/5254460/how-can-i-get-a-password-containing-a-caret-passed-unchanged-as-a-parameter

Solution: Unquoted, use 4 consecutive carets (ex: use pass^^^^word to produce pass^word) Solution: Quoted, use 2 consecutive carets (ex: use "pass^^word" to produce pass^word)

my oh my!