Give Apache write permissions on mounted share.

mickey79

True Defiance
Ave,

I’ve run into a permissions snag.
I have Apache Web Server running on Mac OS X with PHP. I have a folder on a windows machine mounted on my Mac OS X as a share using the “mount –t smbfs //user@192.168.1.2/ShareName Share”. The “user” has full read-write permission and physically I’m able to do anything I want sitting on my Mac OS X in this share, like create, delete or modify files.

The problem is, I don’t think Apache Web Server (or PHP) has write access on this share. In PHP, I’m able to read data from files on this share, but I’m not able to write data to any file on that share. I get access is denied.

Is there anyway while mounting to give Apache write access to the files on this share? I don’t see how I can provide Apache Web Server (installed on my Mac) Write Access through the Windows System that has the original folder. Windows is only able to provide the Mac User with Permissions, not Apache.

Any help would be appreciated.

Thanks
 
Mickey,

Did you have any difficulties getting Apache to read files off of the SMB mounted volume? I'm having problems with just that much. Despite the volume having R-X for world in all recursively I get the following error in the Apache logs: Permission defined: access to /alias failed because search permissions are missing on a component of the path. By the way, I couldn't use OSX's SMB/CIFS mount GUI tool to get those permissions. I had to use mount_smb at the terminal. How did you get past this Apache/SMB read permissions glitch? It was suggested to me that I should be using CIFS (ie mount -t cifs) instead of SMB but it looks like 10.4 doesn't support CIFS. And that's another question I have: why not? I see references on the web to Mac mount_cifs in earlier versions of OSX. Was it removed? If so, why and how can I install it?

Thanks,
jlpp
 
Ave,

I was able to find the solution for it. Logically it's simple, at the time of mounting your Windows Share on your Mac OS X as an SMB share, simply specify Apache Web Server as the User & Group owner of the entire share. Thereafter Apache Web Server will have Full Rights to Anything residing on that share.

Technically how to do this took me a while, but I finally found the commands.

The command (in my case) is:

mount_smbfs -u 70 -g 70 //user@ServerName/ShareName SharePoint

The "70" that you see is both the UID and GID of Apache Web Server in my Mac OS X. It may be different in yours but you can find that out in the NetInfo Manager. By giving the "-u 70 -g 70" parameters, we're basically instructing that the mounted share should be owned by Apache Web Server and not the root or any other user.

If you did "ls -la" on the share in Terminal, you will see "www" in both Owner & Group columns.

This solved it for me. Any php script on my Apache Web Server was able to read/write any file on the Share!

Mickey
 
Hmm... I tried your fix and it didn't work for me. Apache still can't read the volume. It gives the same error. I think my problem might be something very unusual; either a bug or a bad configuration problem somewhere. Anyway, if anyone can suggest how I might troubleshoot this problem, let me know. Here's the error again for the record: Permission denied: access to /aliastosmbvolume failed because search permissions are missing on a component of the path.

Thanks,
jlpp
 
I found that the problem was somehow caused by the path in which the mount was defined not being owned by www:www. I don't know why that had the effect it did as this directory was originally owned by a different user but set up to be r+x to world. Anyway, a quick sudo chown www:www dirname fixed the problem.
 
Back
Top