On Saturday, November 10, 2012 04:35:33 PM Philip Guenther wrote:
> Hmm, it works for me, using an exports of
> 
> /usr/src -mapall=guenther 127.0.0.1
> /usr/obj -mapall=guenther 127.0.0.1
> 
> and switching the -mapall on /usr/src from "guenther" to "otheruser",
> pkill -HUP mountd, then testing by creating a file in a mode 777
> directory on the NFS mount from 127.0.0.1.  Various other switches and
> tests show that it doesn't seem to be related to the sorting of the
> directory names.
> 
> So: need more data.  Run mountd yourself with the -d option and snag
> the *complete* output from start, making changes to /etc/exports and
> HUP'ing it, etc.
I've been working with Tim on this. 

I set up a new  exports file like yours  above:
# cat /etc/exports                                                              
                                                                                
                                 
#       $OpenBSD: exports,v 1.2 2002/05/31 08:15:44 pjanzen Exp $
#
# NFS exports Database
# See exports(5) for more information.  Be very careful:  misconfiguration
# of this file can result in your filesystems being readable by the world.
/usr/src -mapall=common 127.0.0.1

Then I setup the nfs servers by manually running the daemons:
nas1#portmap & mountd -d & nfsd -tun4
[1] 13159
[2] 7037
[1] - Done                 portmap 
nas1#Getting export list.
Got line #      $OpenBSD: exports,v 1.2 2002/05/31 08:15:44 pjanzen Exp $
Got line #
Got line # NFS exports Database
Got line # See exports(5) for more information.  Be very careful:  
misconfiguration
Got line # of this file can result in your filesystems being readable by the 
world.
Got line /usr/src -mapall=common 127.0.0.1
Making new ep fs=0x406,0x22b1c3bb
doing opt -mapall=common 127.0.0.1
got host 127.0.0.1
exporting /usr/src
unexporting / /
unexporting /home /home
unexporting /root /root
unexporting /storage /storage
unexporting /tmp /tmp
unexporting /usr /usr
unexporting /var /var
Getting mount list.
Here we go.

I then chmod /usr/src to 777 so that my user "common" has write permissions 
there:
#chmod 777 /usr/src

I then mount the export to a local directory:
#mount -t nfs 127.0.0.1:/usr/src /mnt/test

And mountd then provides the following output:

Got mount request from 127.0.0.1
rpcpath: /usr/src
# Mount successful for /usr/src by 127.0.0.1.
Got line #      $OpenBSD: exports,v 1.2 2002/05/31 08:15:44 pjanzen Exp $
Got line #
Got line # NFS exports Database
Got line # See exports(5) for more information.  Be very careful:  
misconfiguration
Got line # of this file can result in your filesystems being readable by the 
world.
Got line /usr/src -mapall=joe 127.0.0.1
Making new ep fs=0x3,0xd111762b
doing opt -mapall=joe 127.0.0.1
got host 127.0.0.1
exporting /usr/src
unexporting / /
unexporting /home /home
unexporting /usr /usr

>From there I can create a test file on the mount point while logged in as 
root:
nas1#whoami                                                                     
                                                                                
                                    
root
nas1#touch /mnt/test/test.123                                                   
                                                                                
                                    
nas1#ls -l /mnt/test/test.123                                                   
                                                                                
                                    
-rw-r--r--  1 common  wsrc  0 Nov 14 12:16 /mnt/test/test.123

The test file is correctly created with owner "common" as the mapall option 
directs.

Now the problem kicks in if I edit /etc/exports, change mapall to another 
user, unmount the export, and HUP mountd:

#       $OpenBSD: exports,v 1.2 2002/05/31 08:15:44 pjanzen Exp $
#
# NFS exports Database
# See exports(5) for more information.  Be very careful:  misconfiguration
# of this file can result in your filesystems being readable by the world.
/usr/src -mapall=maptest 127.0.0.1

nas1#umount /mnt/test
nas1#pkill -HUP mountd
Got line #      $OpenBSD: exports,v 1.2 2002/05/31 08:15:44 pjanzen Exp $
Got line #
Got line # NFS exports Database
Got line # See exports(5) for more information.  Be very careful:  
misconfiguration
Got line # of this file can result in your filesystems being readable by the 
world.
Got line /usr/src -mapall=maptest 127.0.0.1
Making new ep fs=0x406,0x22b1c3bb
doing opt -mapall=maptest 127.0.0.1
got host 127.0.0.1
exporting /usr/src
unexporting / /
unexporting /home /home
unexporting /root /root
unexporting /storage /storage
unexporting /tmp /tmp
unexporting /usr /usr
unexporting /var /var

Then remount the export:
nas1#mount -t nfs 127.0.0.1:/usr/src /mnt/test/                                 
                                                                                
                                
Got mount request from 127.0.0.1
rpcpath: /usr/src
Mount successful for /usr/src by 127.0.0.1.
Got line #      $OpenBSD: exports,v 1.2 2002/05/31 08:15:44 pjanzen Exp $
Got line #
Got line # NFS exports Database
Got line # See exports(5) for more information.  Be very careful:  
misconfiguration
Got line # of this file can result in your filesystems being readable by the 
world.
Got line /usr/src -mapall=maptest 127.0.0.1
Making new ep fs=0x406,0x22b1c3bb
doing opt -mapall=maptest 127.0.0.1
got host 127.0.0.1
exporting /usr/src
unexporting / /
unexporting /home /home
unexporting /root /root
unexporting /storage /storage
unexporting /tmp /tmp
unexporting /usr /usr
unexporting /var /var

Delete the old test file:
#rm /mnt/test/test.123

And recreate the test file after the mapall change:
nas1#touch /mnt/test/test.123
nas1#ls -l /mnt/test/test.123                                                   
                                                                                
                                
-rw-r--r--  1 common  wsrc  0 Nov 14 12:22 /mnt/test/test.123

As you can see, mapall does not correctly map the new test file to the 
"maptest" user as indicated in the exports file and still uses the "common" 
user that was previously configured. For some reason, the user specified in 
mapall sticks, even with a reload of mountd, and mountd sees the change.

Any ideas on further debugging would be appreciated.

Joe Kowalski

Reply via email to