Question

I have mapped to a Windows share using cifs/samba on CentOS. Using this command:

sudo mount -t cifs -o username=Username //path/to/share /var/share

My PHP application now needs the ability to create directories and upload files to /var/share (which is now the mapped cifs share). All of the files there all belong to root:root. When I attempt to do a chown to change the files to apache:apache, there are no errors thrown by Linux, but when I do an ls -l, it still shows the owners to be root:root.

Is there a way to get around this so my app can write to the share?

Was it helpful?

Solution

The username in your mount command is the "Windows" username, with the authentication being managed by Samba. By default, the exported volume has everything owned by root. What you need to do is to specify the *NIX user and group names in your mount command. Here's what I do to mount my Mac on my Ubuntu box, using Apple's CIFS implementation:

sudo mount -t cifs //192.168.1.3/Shared /media/Shared -o username=mike,password=XXXX,uid=1000,gid=1000,nounix,sec=ntlmssp

You can use textual names instead of numbers for the uid and gid. the "nounix,sec=ntlmssp" is needed for compatibility with recent versions of the Mac OS X CIFS server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top