As a small weekend project, I've been working on a simple Python HTTP "file server" of sorts. The basic idea is that authorized users can log in to a web interface and browse files in specific locations on my home network. The Python script is accessed through Apache on my Mac Mini, but some of the files I need access to are on Windows boxes. Unfortunately this presented something of a problem, as the Apache user on OS X (_www
as of Snow Leopard) doesn't have permission to access Windows shares mounted by users.
Sounds simple enough, right? Just chmod
or chown
the Windows share and go to town. Unfortunately, this doesn't seem to work; neither chown
or chmod
have any effect on mounted Windows shares. Oddly, they don't output any errors; they just don't do anything. The only way around this seems to be to mount the shares as the Apache user (or whichever user you need to have access). Here's how to do so in Snow Leopard, with instructions modified slightly from a Stack Overflow question on the subject:
- Create the mountpoint
mkdir /Volumes/Mount_Name
- Set the permissions on the mount point
sudo chown _www:_www /Volumes/Mount_Name sudo chmod 755 /Volumes/Mount_Name
- If necessary, make a symlink from your Apache documents folder to the mount point
ln -s /Volumes/Mount_Name /Library/WebServer/Documents/Mount_Name
- Mount the share as the Apache user
sudo -u _www mount_smbfs //DOMAIN;User:Password@Host/Share /Volumes/Mount_Name
I doubt a great number of people will need this information as it's a strange sort of setup, but it's my hope that these instructions will save someone some time.