Bug? Group name is not correct when I touch a new file on zfs!

I use TrueNAS-SCALE-24.04.2

First, I create a user user1:group1

root@truenas[~]# groupadd -g 3001 group1
root@truenas[~]# useradd -u 3001 -g 3001 user1

create a zpool names mypool

root@truenas[~]# dd if=/dev/zero of=/root/zfs.raw count=204800
root@truenas[~]# zpool create mypool /root/zfs.raw -m /mnt/mypool

Through the mount -v command, you can see that the nfsv4 protocol is adopted by default.

root@truenas[~]# mount -v
...
mypool on /mnt/mypool type zfs (rw,relatime,xattr,nfs4acl,casesensitive)
...

I use “user1” to write a “test.txt” file into zfs. You can see that the user of this file is “user1”, but the group is “root”. This is very strange because the main group of “user1” is “group1”, not “root”.

root@truenas[~]# chmod 777 /mnt/mypool
root@truenas[~]# sudo -u user1 touch /mnt/mypool/test.txt
root@truenas[~]# ls -l /mnt/mypool
total 1
-rw-r--r-- 1 user1 root 0 Sep  8 22:49 test.txt

I changed the “acltype” of mypool to “posixacl” and touch a new fiile names “test2.txt”, and it was normal.

root@truenas[~]# zfs set acltype=posixacl mypool
root@truenas[~]# mount -v
...
mypool on /mnt/mypool type zfs (rw,relatime,xattr,posixacl,casesensitive)
...
root@truenas[~]# sudo -u user1 touch /mnt/mypool/test2.txt  
root@truenas[~]# ls -l /mnt/mypool
total 1
-rw-r--r-- 1 user1 root   0 Sep  8 22:49 test.txt
-rw-r--r-- 1 user1 group1 0 Sep  8 22:58 test2.txt

I am not sure if this is a problem with this version of TrueNas or a problem with the linux kernel, but at least I did not find this problem on ubuntu22. what’s going on?

This seems to be expected behavior. Using the original NFSv4 acl, the file inherits the group from the dataset, which is owned by the group root (ls -ld /mnt/mypool to confirm). Posix acls inherit the group from the user performing the task.

That’s correct. This is a feature of our NFSv4 ACL implementation in SCALE to make it compatible with FreeBSD behavior in core.

How can I configure this behavior by myself?
I have a ZFS formated HDD used on both system(ubuntu and truenas). I found that on ubuntu NFSv4 acl filesystem ,a new file inherit the group from the user performing the task just like Posix acls

Use POSIX ACL type if you need to use on non-truenas systems. Do note that you would face the same issue if you exported pool from Core / FreeBSD and started manipulating data in ubuntu.

1 Like