Bug 1093148 - chown does not respect NFSv4 no_root_squash
Summary: chown does not respect NFSv4 no_root_squash
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: libnfsidmap
Version: 19
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Steve Dickson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1043558 1093093 1129790
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-30 17:54 UTC by Steve Dickson
Modified: 2014-09-17 19:35 UTC (History)
5 users (show)

Fixed In Version: libnfsidmap-0.25-8.fc19
Clone Of: 1093093
Environment:
Last Closed: 2014-05-29 23:24:51 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Steve Dickson 2014-04-30 17:54:41 UTC
+++ This bug was initially created as a clone of Bug #1093093 +++

+++ This bug was initially created as a clone of Bug #1043558 +++

Description of problem:

when chown a file on nfsv4 mount it seems to not respect NFSv4 no_root_squash option:

NFS server export:
[root@nfs ~]# cat /etc/exports
/scratch *(rw,fsid=0,async,insecure,no_root_squash)

[root@nfs ~]# exportfs -rv
exporting *:/scratch

NFS Client:
[root@client ~]# mount -t nfs  -o vers=4 nfs.example.org:/ /mnt/rhel6/

[root@client ~]# cat /proc/mounts
rootfs / rootfs rw 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
devtmpfs /dev devtmpfs rw,relatime,size=500204k,nr_inodes=125051,mode=755 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /dev/shm tmpfs rw,relatime 0 0
/dev/mapper/myvg-rootvol / ext4 rw,relatime,barrier=1,data=ordered 0 0
/proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0
/dev/vda1 /boot ext3 rw,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
nfs.example.org:/ /mnt/rhel6 nfs4 rw,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.33.20.36,minorversion=0,local_lock=none,addr=10.33.20.128 0 0


Create a file:
[root@client ~]# touch /mnt/rhel6/testfile_root
[root@client ~]# ll /mnt/rhel6/testfile_root
-rw-r--r-- 1 root root 0 Dec 16  2013 /mnt/rhel6/testfile_root

Chown the file:
[root@client ~]# chown root:root /mnt/rhel6/testfile_root
[root@client ~]# ll /mnt/rhel6/testfile_root
-rw-r--r-- 1 nobody nobody 0 Dec 16  2013 /mnt/rhel6/testfile_root

Doing the same for a "normal" user works as expected:
[root@client ~]# su - test

Create a file:
[test@client ~]$ touch /mnt/rhel6/testfile_test
[test@client ~]$ ll /mnt/rhel6/testfile_test
-rw-rw-r-- 1 test test 0 Dec 16  2013 /mnt/rhel6/testfile_test

Chown the file:
[test@client ~]$ chown test:test /mnt/rhel6/testfile_test
[test@client ~]$ ll /mnt/rhel6/testfile_test
-rw-rw-r-- 1 test test 0 Dec 16  2013 /mnt/rhel6/testfile_test


How reproducible:
always

Steps to Reproduce:
1. cat /etc/exports 
/scratch *(rw,fsid=0,async,insecure,no_root_squash)

2. # mount -t nfs  -o vers=4 nfs.example.org:/ /mnt/rhel6/

3. # touch /mnt/rhel6/testfile_root
=> check file perms:
-rw-r--r-- 1 root root 0 Dec 16  2013 /mnt/rhel6/testfile_root

4. # chown root:root /mnt/rhel6/testfile_root
=> check file perms:
-rw-r--r-- 1 nobody nobody 0 Dec 16  2013 /mnt/rhel6/testfile_root

Actual results:
chown to root:root results in nobody:nobody

Expected results:
chown to root:root results in root:root



--- Additional comment from Martin Schuppert on 2013-12-16 11:29:55 EST ---

It works when setting nfs4_disable_idmapping=n

[root@client ~]# cat /etc/modprobe.d/nfs.conf 
options nfs nfs4_disable_idmapping=n


[root@client ~]# mount -t nfs  -o vers=4 nfs.example.org:/ /mnt/rhel6/
[root@client ~]# touch /mnt/rhel6/testfile_rootttt
[root@client ~]# ll /mnt/rhel6/testfile_rootttt
-rw-r--r-- 1 root root 0 Dec 16  2013 /mnt/rhel6/testfile_rootttt

[root@client ~]# chown root:root /mnt/rhel6/testfile_rootttt
[root@client ~]# ll /mnt/rhel6/testfile_rootttt
-rw-r--r-- 1 root root 0 Dec 16  2013 /mnt/rhel6/testfile_rootttt
..

--- Additional comment from Steve Dickson on 2014-04-30 10:55:30 EDT ---

This is the needed fix  for libnfsidmap 

diff -up ./libnfsidmap.c.orig ./libnfsidmap.c
--- ./libnfsidmap.c.orig	2014-04-30 10:19:28.000000000 -0400
+++ ./libnfsidmap.c	2014-04-30 10:49:05.000000000 -0400
@@ -99,8 +99,12 @@ static char * toupper_str(char *s)
 static int id_as_chars(char *name, int *id)
 {
 	long int value = strtol(name, NULL, 10);
-	if (value == 0)
-		return 0;
+
+	if (value == 0) {
+		/* check for zero id values */
+		if (strcmp(name, "0") != 0)
+			return 0;
+	}
 	*id = (int)value;
 	return 1;
 }

--- Additional comment from Steve Dickson on 2014-04-30 10:56:31 EDT ---

Looking for a QE ack...

Comment 1 Steve Dickson 2014-04-30 21:12:42 UTC
This problem does not happen with new kernels since they don't use libnfsidmap

Comment 2 Steve Dickson 2014-05-01 13:53:46 UTC
Reopening... I'm going to make the fix ways....

Comment 3 Fedora Update System 2014-05-01 14:29:09 UTC
libnfsidmap-0.25-8.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/libnfsidmap-0.25-8.fc19

Comment 4 Fedora Update System 2014-05-01 14:30:00 UTC
libnfsidmap-0.25-8.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/libnfsidmap-0.25-8.fc20

Comment 5 Fedora Update System 2014-05-01 22:20:02 UTC
Package libnfsidmap-0.25-8.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing libnfsidmap-0.25-8.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-5873/libnfsidmap-0.25-8.fc20
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2014-05-29 23:24:51 UTC
libnfsidmap-0.25-8.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2014-05-29 23:26:16 UTC
libnfsidmap-0.25-8.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.