Open fsackur opened 5 years ago
I believe that the debug output INFO subprocess: Starting process: ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive" # ... etc ...
can be recreated manually with:
Start-Process "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\/powershell.EXE" -ArgumentList "-NoLogo", "-NoProfile", "-NonInteractive" # ... etc ...
N.B. the debug output includes the string
$p
. When I run Start-Process, I also try escaping that as `$p.
When I do that, I get a powershell window visible and, if not running already as admin, I get a UAC prompt. So that weird slash/backslash combo isn't breaking anything. However... why wrap a base64-encoded command in another one so many times? It appears to be the final wrapping that breaks this.
I can't reproduce the issue on Windows 10 update 1607, but I can on 1803.
I'm also experiencing this with Windows 10.0.19044.1415 (aka 21H2).
Running vagrant from an elevated shell and commenting the UAC stuff and setting sudo: false
seems to help:
As a diff:
--- "C:\\HashiCorp\\Vagrant\\embedded\\gems\\2.2.19\\gems\\vagrant-2.2.19\\plugins\\hosts\\windows\\cap\\smb.rb.orig.txt" 2022-01-03 17:37:02.265982000 +0000
+++ "C:\\HashiCorp\\Vagrant\\embedded\\gems\\2.2.19\\gems\\vagrant-2.2.19\\plugins\\hosts\\windows\\cap\\smb.rb" 2022-01-03 17:21:12.930813600 +0000
@@ -51,10 +51,10 @@
@@logger.debug("shares to be removed: #{prune_shares}")
if prune_shares.size > 0
- machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.prune_warning") + "\n")
- sleep UAC_PROMPT_WAIT
+ # machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.prune_warning") + "\n")
+ # sleep UAC_PROMPT_WAIT
@@logger.info("remove shares: #{prune_shares}")
- result = Vagrant::Util::PowerShell.execute(script_path, *prune_shares, sudo: true)
+ result = Vagrant::Util::PowerShell.execute(script_path, *prune_shares, sudo: false)
if result.exit_code != 0
failed_name = result.stdout.to_s.sub("share name: ", "")
raise SyncedFolderSMB::Errors::PruneShareFailed,
@@ -100,14 +100,14 @@
]
end
if !shares.empty?
- uac_notified = false
+ # uac_notified = false
shares.each_slice(10) do |s_shares|
- if !uac_notified
- machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.create_warning") + "\n")
- uac_notified = true
- sleep(UAC_PROMPT_WAIT)
- end
- result = Vagrant::Util::PowerShell.execute(script_path, *s_shares, sudo: true)
+ # if !uac_notified
+ # machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.create_warning") + "\n")
+ # uac_notified = true
+ # sleep(UAC_PROMPT_WAIT)
+ # end
+ result = Vagrant::Util::PowerShell.execute(script_path, *s_shares, sudo: false)
if result.exit_code != 0
share_path = result.stdout.to_s.sub("share path: ", "")
raise SyncedFolderSMB::Errors::DefineShareFailed,
FYI, I've created https://github.com/hashicorp/vagrant/pull/12933 that fixes this for me.
Vagrant version
2.2.3
Host operating system
Windows 10.0.17763.0, clean build, no Docker. Enterprise managed, we do have security agents, but they don't pop up any notifications.
Guest operating system
Ubuntu 16.04
Vagrantfile
Debug output
Expected behavior
SMB share created, visible with
net share
. No UAC popup expected, as running console as admin. OR, if command fails, we get diagnostic output.Actual behavior
Share not created. HOWEVER, if I decode the Base64 string and run THAT, command completes as expected and share is created. No diagnostic output if not running with
--
debug`, I find this unhelpful:Steps to reproduce
vagrant up
in a console that's running as administrator