Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a directory shared in my Ubuntu VM. This is my smb.conf:

...
[share]
comment = Ubuntu File Server Share
path = /home/foo/share
browsable = yes
guest ok = yes
read only = no
create mask = 0644

Almost everything works fine, i.e. when a new file is created, it is masked 0644. But also whenever I open (in Windows) and save an existing file, that file's permissions are also set to 0644. That's pretty annoying when editing scripts, which had previously been masked 0755 or 777.

Is there a way to make Samba keep existing permission masks when files are overwritten?
[edit] ... while creating new files with permissions 0644

share|improve this question
    
I have the same problem and it's very annoying. Did you happen to find a solution? –  Daniel Standage Sep 25 '12 at 19:50
    
@DanielStandage No, I haven't. As a workaround, I have a script that keeps fixing the executable flags :/ –  Pumbaa80 Sep 25 '12 at 21:00

4 Answers 4

add:

map archive = no

to the [Share]. The default (yes) will set the execute bit on pretty much everything you save. When set to no, you can leave your create mask set to 755 or whatever.

I find this essential if you edit a lot of system files like /etc/mail/aliases, which will fail to compile with the execute bit set.

;o) Cor

share|improve this answer
    
Thanks, good idea! Unfortunately it doesn't wort as intended on my machine (Win7 with Ubuntu 12.04). All bits are reset when I overwrite a file. –  Pumbaa80 Jun 10 '13 at 7:48

I use samba to share between Windows and Kubuntu, except on my system Linux is the host, not the VM. For my setup, I made the user names in both systems the same, then set valid users in smb.conf to my user name. I don't have a create mask setting, and permissions work fine.

[shared]
comment = My Shared Partition
path = /mnt/shared/
browseable = yes
available = yes
read only = no
guest ok = no
valid users = my_user_name
share|improve this answer
    
But what does that mean for newly created files? –  Pumbaa80 May 23 '12 at 13:09
    
Because the user profile names match, all new files get created with the user and primary group of the host account name, with the following permissions: -rwx------ –  Tom May 23 '12 at 13:56

I think if you set your samba guest account to be an account that would normally write files with 775 permissions you should be good to go.

[global]
guest account = [unix user]

Or you could create a samba user the same your user on Ubuntu who has 755 permissions (each samba user needs to match an UNIX user) and then access the samba share by logging in as that user.

user@ubuntu$ ~ sudo smbpasswd -a [username]
share|improve this answer
    
I don't see how that solves my problem. I was asking how to make sure that existing permissions are not modified. –  Pumbaa80 May 22 '13 at 7:04
    
If your Unix/Linux user is writing files as 755, and you logon to the Samba server as your Unix/Linux user, than files you create/edit should theoretically be written with the 755 permissions. Have you tried this? –  not__p May 22 '13 at 18:15
    
@Pumbaa80 I see you are trying to hack the way Linux and Samba handles permissions. You probably will want to look into ACL's. With them you should be able to define permission masks per user. Thus, you log into samba with user A and read/write with permissions 755, and as user B read/write with 644. –  not__p May 22 '13 at 19:33
    
I don't see how that solves my problem. I was asking how to make sure that existing permissions are not modified. –  Pumbaa80 May 23 '13 at 8:42

To stop Samba from resetting a file's permissions when a file is saved through Samba, set the following parameter in smb.conf:

nt acl support = no

This stops Samba from attempting to map UNIX permissions to Windows access control list.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.