2

Getting an unexpected behavior when mounting more than a single share.

NFS Server

$ -> cd /mnt/raid/nas && ls -lZa
drwxrwxr-x. nas        filer      unconfined_u:object_r:file_t:s0  file
drwxrwxr-x. nas        filer      unconfined_u:object_r:file_t:s0  repo

$ -> cat /etc/exports
/mnt/raid/nas                   10.1.0.0/18(rw,fsid=0,sync)
/mnt/raid/nas/repo              10.1.0.0/18(rw,all_squash,sync,no_subtree_check,anonuid=501,anongid=503)
/mnt/raid/nas/file/perm         10.1.0.0/18(rw,all_squash,sync,no_subtree_check,anonuid=501,anongid=503)

$ -> id nas && id filer
uid=501(nas) gid=501(nas) groups=501(nas)
uid=502(filer) gid=503(filer) groups=503(filer)

NFS Client

$ -> id nas && id filer
uid=501(nas) gid=501(nas) groups=501(nas)
uid=502(filer) gid=503(filer) groups=503(filer)

$ -> cd /mnt/nas && ls -lZa
drwxrwxr-x. nas        filer      unconfined_u:object_r:mnt_t:s0   repo
drwxrwxr-x. nas        filer      unconfined_u:object_r:mnt_t:s0   store

$ -> sudo mount -t nfs4 nas-1:/repo /mnt/nas/repo
$ -> sudo mount -t nfs4 nas-1:/file/perm /mnt/nas/store/file/perm/

$ -> df -h
nas-1:/repo
                  550G  240G  283G  46% /mnt/nas/repo
nas-1:/file/perm
                  550G  240G  283G  46% /mnt/nas/store/file/perm

But when I write a test file to each, only the perm/ correctly squashes the user.

$ -> touch /mnt/nas/repo/imagemagick/test_$$.txt
$ -> ls /mnt/nas/repo/imagemagick
-rw-rw-r--.  1 mpurcell mpurcell    0 Apr  5 20:31 test_24571.txt

$ -> touch /mnt/nas/store/file/perm/test_$$.txt
$ -> ls /mnt/nas/store/file/perm/
-rw-rw-r--. 1 nas filer    0 Apr  5 20:32 test_24571.txt

I tried disabling selinux on both boxes, but that did not work either.

Why is one mount correctly squashing the user/group and the other is not?

---Update---

Do I have to bind the NFS mounts on the NFS server? I had a weird entry in my /etc/fstab file where one of the shared directories was being mounted (with bind) and that was the one that was working. I removed the entry from /etc/fstab on the NFS server, remounted everything, and now the once working mount on NFS client is no longer working.

Mike Purcell
  • 1,708
  • 7
  • 32
  • 54

1 Answers1

0

Ugh finally got it working, had to do the following to hack the all_squash feature. I did it awhile ago and don't remember why it had to be done, but without it I couldn't get the perms to squash properly.

$ -> ls /mnt/raid/nas
drwxrwxr-x. 2  nas  filer  repo
drwxrwxr-x. 3  nas  filer  repo_all_squash_hack

$ -> ls /mnt/raid/nas/file
drwxrwxr-x. 2  nas  filer  perm
drwxrwxr-x. 3  nas  filer  perm_all_squash_hack

Then in /etc/fstab:

/mnt/raid/nas/file/perm_all_squash_hack /mnt/raid/nas/file/perm none    bind    0 0
/mnt/raid/nas/repo_all_squash_hack    /mnt/raid/nas/repo none    bind    0 0

Now everything mounts up as expected. Also confirmed via:

$ -> cat /proc/fs/nfs/exports
/mnt/raid/nas   10.1.0.0/18(rw,root_squash,sync,wdelay,no_subtree_check,fsid=0,uuid=d962b590:d8986203:00000000:00000000,sec=1)
/mnt/raid/nas/repo  10.1.0.0/18(rw,root_squash,all_squash,sync,wdelay,no_subtree_check,anonuid=501,anongid=503,uuid=d962b590:d8986203:00000000:00000000,sec=1)
/mnt/raid/nas/file/perm 10.1.0.0/18(rw,root_squash,all_squash,sync,wdelay,no_subtree_check,anonuid=501,anongid=503,uuid=d962b590:d8986203:00000000:00000000,sec=1)
Mike Purcell
  • 1,708
  • 7
  • 32
  • 54