danieltalsky
danieltalsky

Reputation: 7920

How can I set up Samba preserve file ownership on writes to a single Samba share?

I'd like to edit Solr configuration files on my linux box via a samba share. The files need to be tomcat6:mygroup, but when I edit the files via windows, it writes them as myuser:mygroup. Is it possible to change the write settings for a single samba share so it preserves the existing user, group and permissions?

Is this something that can be done via Samba configuration, or is something trickier needed?

Upvotes: 1

Views: 3292

Answers (1)

Kurt Pfeifle
Kurt Pfeifle

Reputation: 90213

You should include an appropriate force user statement into your smb.conf. I'm assuming your Samba share's name is smbshare:

[smbshare]
  ....
  force user = tomcat6
  ....

You can find out more details via man smb.conf. The important points are: tomcat6 needs to be a user on the system. Your connection to the [smbshare] needs to take place with valid user credentials. Once connected all file operations will be performed under the credentials of tomcat6 though. (You don't seem to want an additional setting of force user = ..., which is also possible....)

Update: You said you wanted to "preserve the existing user, group and permissions". Note, that my suggestion doesn't do that. It forces all edited files to be owned by tomcat6:mygroup instead of preserving the original settings. Maybe this is good enough for your purpose.

Upvotes: 5

Related Questions