Win32APIError when creating a directory on vboxsf shared folder inside Windows guest

Hi,

I’m desperately trying to create a directory on a vboxsf shared folder inside a windows guest.

Host: MacOS sierra
Guest: Windows 10
Hypervisor: VirtualBox 5.1.14
Chef versions: 12 & 13

Example recipe:

directory "\\\\vboxsrv\\vagrant\\foo" do
  action :create
end

When I run this via chef-apply my_recipe.rb I get the following error:

C:\repos\system\tools\chef>C:\opscode\chefdk\bin\chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * directory[\\vboxsrv\vagrant\foo] action create

    ================================================================================
    Error executing action `create` on resource 'directory[\\vboxsrv\vagrant\foo]'
    ================================================================================

    Chef::Exceptions::Win32APIError
    -------------------------------
    Incorrect function.
    ---- Begin Win32 API output ----
    System Error Code: 1
    System Error Message: Incorrect function.
    ---- End Win32 API output ----

    Resource Declaration:
    ---------------------
    # In test.rb

      2: directory "\\\\vboxsrv\\vagrant\\foo" do
      3:   action :create
      4: end

    Compiled Resource:
    ------------------
    # Declared in test.rb:2:in `run_chef_recipe'

    directory("\\vboxsrv\vagrant\foo") do
      action [:create]
      default_guard_interpreter :default
      path "\\\\vboxsrv\\vagrant\\foo"
      declared_type :directory
      cookbook_name "(chef-apply cookbook)"
      recipe_name "(chef-apply recipe)"
      group nil
      mode nil
      owner nil
    end

    System Info:
    ------------
    chef_version=13.2.20
    platform=windows
    platform_version=10.0.14393
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
    program_name=C:/opscode/chefdk/bin/chef-apply
    executable=C:/opscode/chefdk/bin/chef-apply

[2017-07-13T15:36:25+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T15:36:25+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T15:36:25+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T15:36:25+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T15:36:25+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[\\vboxsrv\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

[2017-07-13T15:36:25+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[\\vboxsrv\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

Creating that directory via cmd works perfectly fine.

Any ideas what’s going wrong here?

Cheers,
Torben

Btw I originally tried to create the directory on the mapped network drive C:\vagrant, i.e.:

directory "C:\\vagrant\\foo" do
  action :create
end

In that case I additional got this error message: "get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)"

Full output:

C:\repos\system\tools\chef>C:\opscode\chefdk\bin\chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * directory[C:\vagrant\foo] action create

    ================================================================================
    Error executing action `create` on resource 'directory[C:\vagrant\foo]'
    ================================================================================

    Chef::Exceptions::Win32APIError
    -------------------------------
    Incorrect function.
    get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)---- Begin Win32 API output ----
    System Error Code: 1
    System Error Message: Incorrect function.
    ---- End Win32 API output ----

    Resource Declaration:
    ---------------------
    # In test.rb

      2: directory "C:\\vagrant\\foo" do
      3:   action :create
      4: end

    Compiled Resource:
    ------------------
    # Declared in test.rb:2:in `run_chef_recipe'

    directory("C:\vagrant\foo") do
      action [:create]
      default_guard_interpreter :default
      path "C:\\vagrant\\foo"
      declared_type :directory
      cookbook_name "(chef-apply cookbook)"
      recipe_name "(chef-apply recipe)"
      mode nil
      group nil
      owner nil
    end

    System Info:
    ------------
    chef_version=13.2.20
    platform=windows
    platform_version=10.0.14393
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
    program_name=C:/opscode/chefdk/bin/chef-apply
    executable=C:/opscode/chefdk/bin/chef-apply

[2017-07-13T16:05:26+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T16:05:26+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T16:05:26+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T16:05:26+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T16:05:26+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[C:\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

[2017-07-13T16:05:26+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[C:\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

Does that help?

The code in question is probably around here:

Still I have no idea…

I might be out of date on the docs, but I thought that the directory resource was for folders on the local system.

Maybe you could write a resource to check if the network dir exists, and if not, create it?

Regards,
Dan-Joe Lopez

Please put the stacktrace from C:/Users/vagrant/.chef/cache/chef-stacktrace.out in a gist and post it to this thread.