2

I've set up a CIFS mount on my CentOS 6.4 server with autofs :

File /etc/auto.mnt :

Photos -fstype=cifs,perm,rw,uid=505,forceuid,gid=505,forcegid,file_mode=0770,dir_mode=0770,credentials=/root/credentials.txt ://adsrv01/Photos

What a ls command shows :

[root@websrv01 mnt]# ls -l
total 4
drwxr-xr-x 1 root root 4096 Apr 26 12:01 Photos

What I expect from the ls command :

[root@websrv01 mnt]# ls -l
total 4
drwxrwx--- 1 photos photos 4096 Apr 26 12:01 Photos

Do you see anything wrong ? How can I set owner and chmod right ?

Edit : I forgot to say that chown and chmod commands are denied for root user on the /mnt/Photos directory. I can't get it right, and I also tried using fstab.

This is what happens with fstab :

mkdir /mnt/Photos
chmod 770 /mnt/Photos
chown photos:photos /mnt/Photos
mount /mnt/Photos

The permissions are automatically changed and set to 755 when the directory is mounted. I can't set the mode back to 770 : permission denied.

7

I found the answer : you have to use the option nounix together with file_mode and dir_mode

Here is my fstab :

//adsrv01/Photos      /mnt/Photos           cifs    credentials=/root/credentials.txt,file_mode=0770,dir_mode=0770,nounix,uid=505,gid=505 0 0
|improve this answer|||||
  • 2
    fstab is not autofs... – RandomInsano Jun 16 '16 at 18:39
0

I've been just able to get a sane working setup, partly thanks to your answer @mimipc, but I'm sharing here a more complete description.

My rPI is called malinovka.daonet.home in my /etc/fstab. On both server and client, I have netvor user, and I want to use a single share from the client to both read and write to a single share.

To export the share from the malinovka rpi, I've added this section to the smb.conf:

[netvorovo]
   comment = netvorovo
   public = no
   writeable = yes
   browsable = yes
   path = /path/to/netvorovo
   create mask = 0644
   directory mask = 0755

and "created user" (that is, even if the netvor user is already created, I need to "create" it again for samba):

smbpasswd -a netvor

(I've just generated strong password that is only used for samba).

On the client, I have three files under /etc/auto.master.d:

  • malinovka.autofs:

    /-  /etc/auto.master.d/malinovka.map --timeout=300
    
  • malinovka.map:

    /mnt/netvorovo    -fstype=cifs,credentials=/etc/auto.master.d/malinovka.credentials,uid=9860,gid=9860,file_mode=0640,dir_mode=0750,nounix ://malinovka.daonet.home/netvorovo
    
  • and malinovka.credentials:

    username=netvor
    password=(redacted)
    

At this point, logged in as netvor, I can just create files/dirs on /mnt/netvorovo and the default modes are as usual.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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