preserving file permissions for samba shares when file is edited
Could finally figure out why permission was changing. The confusion arose from the map archive = yes
setting being the default value in Samba. After setting map archive = no
, the owner execute bit started behaving like I expected it to behave.
Found the answer by reading the documentation over here: http://www.samba.org/samba/docs/using_samba/ch08.html in the File Permissions and Attributes on MS-DOS and Unix section. It clearly mentions this side effect:
Consequently, there is no use for any of the three Unix executable bits that are present on a file in a Samba disk share. DOS files, however, have their own attributes that need to be preserved when they are stored in a Unix environment: the archive, system, and hidden bits. Samba can preserve these bits by reusing the executable permission bits of the file on the Unix side--if it is instructed to do so. Mapping these bits, however, has an unfortunate side effect: if a Windows user stores a file in a Samba share, and you view it on Unix with the
ls -al
command, some of the executable bits won't mean what you'd expect them to.
However, it also mentions this:
We should warn you that the default value of the
map archive
option isyes
, while the other two options have a default value ofno
. This is because many programs do not work properly if the archive bit is not stored correctly for DOS and Windows files. The system and hidden attributes, however, are not critical for a program's operation and are left to the discretion of the administrator.
You can also read more about the archive bit over here: http://en.wikipedia.org/wiki/Archive_bit
How does one make Samba change the owner of a file when it is edited?
Samba can't automatically change the ownership of the file for you if it's edited. It would be possible to write a Samba VFS plugin that can do this for you, but at that point you're probably better off setting up the audit module.
Retaining file permissions with SVN
Subversion does not manage file permissions.
Do not share a working copy between two users, two OSes, or two different SVN client versions. It's heavily discouraged in part because of what you've discovered here.
How can I set up Samba preserve file ownership on writes to a single Samba share?
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.
Strange file permissions for cifs mounted folder
My be windows machine was rebooted or hibernated and mount.cifs fails to re-read or re-mount it properly.
If you still the same problem - try to remount it and check logs in your windows machine and make sure you set correct power options in windows PC.
Related Topics
How to Copy All PDF Files from a Directory and Its Subdirectories to One Location
Count the Number of Executable Files in Bash
Any Way to Exit Bash Script, But Not Quitting the Terminal
List Files Over a Specific Size in Current Directory and All Subdirectories
How to Print Only the Hex Values from Hexdump Without the Line Numbers or the Ascii Table
How I Should Run My Golang Process in Background
How to Skip Saturday and Sunday in a Cron Expression
Check If Environment Variable Is Already Set
Search and Replace Text in All Files of a Linux Directory
When Should I Write a Linux Kernel Module
Escape Single Quotes in Shell Script
Issue While Validating Bash Script
Looking for Files Not Owned by a Specific User
I Want to Contribute to the Linux Kernel
Managing User Configuration Files Across Multiple Computers
Compress Files While Reading Data from Stdin