How to set up group write permissions on new created files on cifs mount point (samba/fstab)

12,376

Can you try to add mount option file_mode=0770,dir_mode=0770.

  1. Try to modify /etc/fstab file:

    //smbserver/nas /media/nas      cifs    uid=bertrand,gid=nas,credentials=/root/.smbcredentials,file_mode=0770,dir_mode=0770     0     0
    
  2. Or, mount command

    sudo mount -t cifs //smbserver/nas /media/nas -o uid=bertrand,gid=nas,rw,credentials=/root/.smbcredentials,file_mode=0770,dir_mode=0770
    

My test environment:

OS version: Ubuntu 10.04.4 LTS
kernel version: 2.6.35-25
mount.cifs version: 1.12-3.4.7
samba version: Version 3.4.7
Share:
12,376

Related videos on Youtube

web.learner
Author by

web.learner

Updated on September 18, 2022

Comments

  • web.learner
    web.learner over 1 year

    I try to mount a samba share with cifs and set write permission to the group on the default file/directory creation mask.
    After hours spent searching the web and trying, I can't get this to work, all my files are created with "rw-r--r--" and I want "rw-rw----"

    My serveur is a Debian on Cubieboard (Cubian r4)
    All umasks of all users are set to 002 using /etc/pam.d/common-session file with "session optional pam_umask.so umask=002"
    This works great.

    My client is Ubuntu Desktop 64bit 13.10.
    All umasks of all users are set to 002 using /etc/bash.bashrc file with umask 002 (because the pam_umask.so doesn't work on the client).
    This works great too.

    User "bertrand" and group "nas" exist on both the client and the server.
    On the server, user "bertrand" has only one group "nas".
    On the client, user "bertrand" has "nas" as secondary group.
    User bertrand has same password on client, server and samba server.

    => /etc/samba/smb.conf on the server :

    [global]
    server string = %h
    map to guest = Bad User
    obey pam restrictions = Yes
    pam password change = Yes
    passwd program = /usr/bin/passwd %u
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    unix password sync = Yes
    syslog = 0
    log file = /var/log/samba/log.%m
    max log size = 1000
    name resolve order = lmhosts host wins bcast
    dns proxy = No
    wins support = Yes
    panic action = /usr/share/samba/panic-action %d
    idmap config * : backend = tdb
    
    [NAS]
    comment = NAS drive
    path = /media/usbnas
    valid users = @nas
    force group = nas
    read only = No
    create mask = 0660
    directory mask = 0771
    

    => /etc/fstab on the client:

    //smbserver/nas /media/nas      cifs    uid=bertrand,gid=nas,credentials=/root/.smbcredentials     0     0
    

    The .smbcredentials contains:

    username=bertrand
    password=********
    

    The mounting point works on my client, I can browse my nas, create, delete, modify files and directories but all new files and all new directories always has read only permission for group.

    How to give group write permissions by default ?

    Thanks.

  • user221594
    user221594 over 10 years
  • Ben Johnson
    Ben Johnson over 5 years
    Very helpful! While file_mode and dir_mode are explained clearly on the cifs manpage, the arguments that they accept are not. In particular, the full octal representation is required! That is, 755 will yield "garbled" permissions such as d????????? ? ? ? ?, whereas 0755 will work as expected.