LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Configure Samba to create files of given permission (https://www.linuxquestions.org/questions/linux-newbie-8/configure-samba-to-create-files-of-given-permission-4175501838/)

NotionCommotion 04-15-2014 01:28 PM

Configure Samba to create files of given permission
 
If I create a directory or file from a Windows PC on a Samba shared linux folder, they have the following permissions.

Code:

drwxrwxr-x.  2 phped phped 4096 Apr 15 05:28 test
-rwxrw-r--.  1 phped phped    0 Apr 15 05:24 test.php

I am okay with the owner/group as well as the directory permissions, however, I wish the file to be -rwxrwxr-x.

How can I do this? My /etc/samba/smb.conf file is:
Code:

[global]
workgroup=WORKGROUP
server string = Samba Server Version %v

# interfaces = lo wlan0 192.168.0.1/24
hosts allow = 127. 192.168.0.

log file = /var/log/samba/log.%m
max log size = 50

security = user
passdb backend = tdbsam

[www]
        comment = Apache WWW Directory
        path = /var/www
        public = no
        # valid users = phped
        read only = no
        writable = yes
        browseable = yes
        create mask = 0775
        create mode = 0775
        directory mode = 0775
        share modes = yes

Thank you

bigrigdriver 04-15-2014 02:30 PM

If I'm not mistaken, you need to make an addition to the [global] section of samba.conf. Something like this:
Code:

# If you want to create files with owner=rwx, group=rwx, other=rx permissions, set
# create mask to 0775.
  create mask = 0775


dolphin_oracle 04-15-2014 02:43 PM

I suspect those are the linux permissions set on the folder on the server side. Try "force create mode = 775"

NotionCommotion 04-16-2014 05:36 AM

Since I already have "create mask = 0775" in the specific shared folder, I don't think it is necessary in the global section. I guess it is a good idea to put it there so all individual folders inherit it.

"force create mode = 775" did the trick.

I still don't understand why both "force create mode" and "create mask" (synonym for "create mode") for used for files, and "force directory mode" and "directory mask" (synonym for "directory mode") are used for directories.

According to http://www.samba.org/samba/docs/man/...tml#CREATEMASK,
Quote:

When a file (or directory) is created, the necessary permissions are calculated according to the mapping from DOS modes to UNIX permissions, and the resulting UNIX mode is then bit-wise 'AND'ed with this parameter. This parameter may be thought of as a bit-wise MASK for the UNIX modes of a file. Any bit not set here will be removed from the modes set on a file when it is created.
Where are these DOS modes coming from? What is the point to force a value only to mask it?


All times are GMT -5. The time now is 11:56 AM.