Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Hyper-V: SMB share failed to be created #12639

Open
rgl opened this issue Jan 3, 2022 · 3 comments · May be fixed by #12933
Open

Windows Hyper-V: SMB share failed to be created #12639

rgl opened this issue Jan 3, 2022 · 3 comments · May be fixed by #12933

Comments

@rgl
Copy link
Contributor

rgl commented Jan 3, 2022

Vagrant version

2.2.19

Host operating system

Windows 10 10.0.19044.1415

Guest operating system

Ubuntu 20.04. But I think it does not matter, as this code is host specific.

Vagrantfile

  config.vm.provider 'hyperv' do |hv, config|
    ...
    config.vm.synced_folder '.', '/vagrant',
      type: 'smb',
      smb_username: ENV['VAGRANT_SMB_USERNAME'] || ENV['USER'],
      smb_password: ENV['VAGRANT_SMB_PASSWORD']
...

The full Vagrantfile is at https://github.com/rgl/ubuntu-vagrant/blob/master/example/Vagrantfile.

Debug output

The relevant part is:

INFO subprocess: Starting process: ["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "$p = Start-Process -FilePath powershell -ArgumentList @('-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', 'JABwACAAPQAgAFMAdABhAHIAdAAtAFAAcgBvAGMAZQBzAHMAIAAtAEYAaQBsAGUAUABhAHQAaAAgAHAAbwB3AGUAcgBzAGgAZQBsAGwAIAAtAEEAcgBnAHUAbQBlAG4AdABMAGkAcwB0ACAAQAAoACcALQBOAG8ATABvAGcAbwAnACwAIAAnAC0ATgBvAFAAcgBvAGYAaQBsAGUAJwAsACAAJwAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAnACwAIAAnAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAJwAsACA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DAFEAQQBUAEEAQgBCAEEARgBNAEEAVgBBAEIARgBBAEYAZwBBAFMAUQBCAFUAQQBFAE0AQQBUAHcAQgBFAEEARQBVAEEATwB3AEEAPQAnACkAIAAtAFAAYQBzAHMAVABoAHIAdQAgAC0AVwBpAG4AZABvAHcAUwB0AHkAbABlACAASABpAGQAZABlAG4AIAAtAFcAYQBpAHQAIAAtAFIAZQBkAGkAcgBlAGMAdABTAHQAYQBuAGQAYQByAGQATwB1AHQAcAB1AHQAIAAnAEMAOgAvAFUAcwBlAHIAcwAvAFIAVQBJAEcAfgAxAC4ATABPAFAALwBBAHAAcABEAGEAdABhAC8ATABvAGMAYQBsAC8AVABlAG0AcAAvAHYAYQBnAHIAYQBuAHQAMgAwADIAMgAwADEAMAAzAC0ANAA0ADQANAAtADEAZABhAGoAaAAyAGQALwBzAHQAZABvAHUAdAAuAHQAeAB0ACcAIAAtAFIAZQBkAGkAcgBlAGMAdABTAHQAYQBuAGQAYQByAGQARQByAHIAbwByACAAJwBDADoALwBVAHMAZQByAHMALwBSAFUASQBHAH4AMQAuAEwATwBQAC8AQQBwAHAARABhAHQAYQAvAEwAbwBjAGEAbAAvAFQAZQBtAHAALwB2AGEAZwByAGEAbgB0ADIAMAAyADIAMAAxADAAMwAtADQANAA0ADQALQAxAGQAYQBqAGgAMgBkAC8AcwB0AGQAZQByAHIALgB0AHgAdAAnADsAIABpAGYAKAAkAHAAKQB7ACAAZQB4AGkAdAAgACQAcAAuAEUAeABpAHQAQwBvAGQAZQA7ACAAfQBlAGwAcwBlAHsAIABlAHgAaQB0ACAAMQAgAH0A') -PassThru -WindowStyle Hidden -Wait -Verb RunAs; if($p){ exit $p.ExitCode; }else{ exit 1 }"]
 INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 31998
DEBUG subprocess: Exit status: 1
ERROR warden: Error occurred: Exporting an SMB share failed! Details about the failure are shown
below. Please inspect the error message and correct any problems.

Host path: 

Stderr: 

Stdout: 
 INFO warden: Beginning recovery process...

Expected behavior

The SMB share should have been created without any error.

Actual behavior

It failed to create the SMB with an unknown error.

After decoding the logged script from above, this comes down to:

& "C:/HashiCorp/Vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/hosts/windows/scripts/set_share.ps1" "C:\rgl\ubuntu-vagrant\example" "vgt-e6ce178ba0986c42029ec13e4cd4b201-6ad5fdbcbf2eaa93bd62f92333a2e6e5" "vgt-e6ce178ba0986c42029ec13e4cd4b201-6ad5fdbcbf2eaa93bd62f92333a2e6e5" ; exit $LASTEXITCODE;

Which , when manually executed, returns this:

The syntax of this command is:

NET SHARE
sharename
          sharename=drive:path [/GRANT:user,[READ | CHANGE | FULL]]
                               [/USERS:number | /UNLIMITED]
                               [/REMARK:"text"]
                               [/CACHE:Manual | Documents| Programs | BranchCache | None]
          sharename [/USERS:number | /UNLIMITED]
                    [/REMARK:"text"]
                    [/CACHE:Manual | Documents | Programs | BranchCache | None]
          {sharename | devicename | drive:path} /DELETE
          sharename \\computername /DELETE

share path: C:\rgl\ubuntu-vagrant\example
error

Looking at that set_share.ps1 script, I have a couple of questions:

  1. Why is it using net share instead of the New-SmbShare cmdlet (which is supported from Windows 2012R2+)?
    • NB Replacing net share with New-SmbShare worked for me.
  2. Why is it granting permissions to Everyone instead of the smb_username given in the Vagrantfile?
  3. There's a logical error in the for loop. It should use the -lt (less than) operator instead of -le (less than or equal).
    • NB Without this, that script will always print the odd WARNING: empty path argument encountered - complete message.

Would a PR be acceptable for fixing this (at least 1 and 3)?

@rgl
Copy link
Contributor Author

rgl commented Jan 3, 2022

To add, the UAC stuff also seems to have an influence in this... so this is related to #10628 too.

@rgl
Copy link
Contributor Author

rgl commented Sep 23, 2022

Anyone?

@unickq
Copy link

unickq commented Nov 21, 2023

anyone v2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants