Tuesday, May 12, 2015

pyWebDav <-> Windows 8.1: one-line file sharing, after a couple of registry tweaks

How often do you want to share a directory of files on one (*nix) system, and mount it as a network drive on a Windows host, with minimum hassle? For me, this is a common occurrence. After a couple of adjustments to my Windows 8 machine, I can do this after installing the pywebdav module, making for a one-liner that creates a temporary high-throughput network share that can be mounted as a drive in Windows.

The annoying part of this trick is that it takes a couple of registry tweaks, and this may affect other resources shared through WebClient, notably, SharePoint.

The easy part of this is installing the pyWebDav Python package, and running a one-line command to start a WebDAV server. Install this (in BSD we type pkg install py27-PyWebDAV). The -D option specifies the directory to share, and I like to know what the program is thinking (verbose with -v option):
davserver -D directory_to_share -n -H server_ip_address_here -v
davserver needs the IP address of the network resource that it will use to listen for connection requests. You can test the server using the loopback address and a webdav client installed on the same machine.

Now for the more annoying part: registry changes, with some commentary. On a Windows machine, navigate to the following subkey in regedit:

HKLM/System/CurrentControlSet/Services/WebClient/Parameters

Modify these values:

SupportLocking=0x0 (default=0x1) 
REQUIRED for interoperability with pyWebDav. 
  • davserver's -J parameter appears buggy / nonfunctional with Windows 8, so we have to modify the registry.

FileSizeLimitInBytes=0xffffffff (or whatever, default is 50 000 000d)
Optional, but you should change this.
  • The default value of this is only 50 megabytes, which is really useless for ISOs or whatnot. I recommend 4.2 gigabytes, which is what this value represents. A bigger value would be preferable. Fix this, Microsoft! We've moved on to use terabyte devices.

BasicAuthLevel=0x2

Optional change, useful if you add basic authentication (which pyWebDav supports)
  • 0 - Basic authentication disabled
  • 1 - Basic authentication enabled for Secure Sockets Layer (SSL) shares only (default)
  • 2 or greater - Basic authentication enabled for SSL shares and for non-SSL shares
Now that you've made these changes, you can restart the WebClient service. Launch cmd with administrator privileges and type:
net stop  WebClient
net start WebClient
 Mount the share (note that you'll need to do this in a cmd shell WITHOUT administrator privileges for your user to see the drive):
net use * http://server_ip_address:8008/
You can also map network drives using a more GUI method.

Sweet!

No comments: