[GLLUG] Automating Windows SMB drive mapping (Was: Samba + Linux, FreeBSD, and (sigh) Windows)

C. Ulrich dincht at securenym.net
Thu Nov 6 03:00:07 EST 2003

On Wed, 2003-11-05 at 15:23, Brian Hoort wrote:
> We have similar wishes.  When you get a solution worked out, post a quickie 
> overview so we can implement our own solutions.
> Thank!

[Posting this reply to the list also in case others would like to flame
me. :P]

Thus far, the general plan is to essentially copy the FreeBSD method of
mounting SMB shares onto the local filesystems. 

First we'll create a folder titled "SMB" somewhere on the Windows file
system to hold a small program (SMBMOUNT.EXE) to read the share
configuration from a file (SMB.CONF) in the user's Local Settings folder
and mount (or, "map") the share as a local drive letter.  I'm not too
familiar with the Windows Way of doing things, but a quick examination
of the filesystem leads me to believe that C:\WINDOWS\SYSTEM32 would be
the best place for the SMB folder.

So, if all goes according to plan, the following events occur:

1. A user logs in, and SMBMOUNT.EXE is run automatically on login, via
the Startup folder for example.

2. SMBMOUNT mount looks for SMB.CONF in "%USERNAME%/Local Settings" and
processes the information contained therein such as the drive letter,
smb host, smb share, smb username, and password. The password will be
obfusicated within the configuration file via a weak XOR encryption
algorithm shamelessly ripped from the FreeBSD smbutil command.

(This is not ideal but it protects the password from being discovered
via casual observation. Storing the password locally, even if it's
obfusicated is obviously not a particularly great solution if you don't
or can't trust your users completely. In this case, you might use a
server-side domain login script or something to map your smb drives
instead. SMBMOUNT will also be capable of performing the obfusication of
a plaintext password on the command line just in case you don't feel
like working out the algorithm on pencil and paper.)

3. SMBMOUNT uses the information gleaned from SMB.CONF to construct and
execute a NET USE command to map the share to a drive letter.

Hope this helps. Right now, I'm in the process of writing SMBMOUNT in C.
It won't be a particularly large undertaking, but my C knowledge is more
than a little rusty, plus I've got schoolwork to attend to so I can't
say for certain when it'll be done. A rough estimate may be between a
couple weeks from now and mid-December. I'd be more than happy to share
the source and binary when it's up and running on my machines. Apologies
if any of this is unclear. It's getting rather late as I type this...

--Charles Ulrich

More information about the linux-user mailing list