vrijdag 13 februari 2009

Konqueror: nfs, "The file or folder ... does not exist"

I really like konqueror because I can browse alot of sources with one application: mobile phone, ftp, files, nfs, ...

I use a FreeBSD host as nfs-server. And a gentoo box as a client.

After starting konqueror and typing the address of my nfs server in the location bar:
nfs://location

I see the different shares (as defined in /etc/exports).
However, when I click on one of the shared directories, I get an error:
The file or folder ... does not exist
.

This is strange as I am sure the permissions are correct. I mounted the share as root earlier, so an "Access Denied" message would be more appropriate then if faulty permissions where the cause.

When I tried it running Konqueror as the root user everything worked as expected. So I went digging in the Konqueror settings and stuff. I couldn't find anything.

So I decided to look on the nfs server. In /var/log/messages I found messages like this:
Feb xx 16:10:15 nfs-server mountd[53679]: mount request from 172.16.1.5 from unprivileged port


I did some research on the internet and found out why this message is displayed (however it is at first sight unclear if it is a warning, info or error message; if you have no access then you get "permission denied").
nfs sees connections from unprivileged ports (ports higher then 1024) as insecure. As konqueror is running as a normal user, it can't use privileged ports.

Now we know the cause, we still need to know what the solution for this is.
On a linux nfs server it is the "insecure" option in /etc/exports which also allows requests from unprivileged ports.
So I thought I put it in on my FreeBSD /etc/exports file.
However, when I restarted the nfs server I got this in /var/log/messages on the server (I also tried some other options that work in linux):
Feb xx 14:02:25 nfs-server mountd[52665]: bad exports list line /myvolume/filestorage 172.16.1.5(ro,insecure,all_squash,anon_uid=65534,anon_gid=65534)


It took me a while to find out that FreeBSD NFS and Linux NFS configs are not compatible:
Linux: http://linux.die.net/man/5/exports
FreeBSD: http://www.freebsd.org/cgi/man.cgi?query=exports&sektion=5
As you can see, FreeBSD has no such option in /etc/exports.

I looked again at the message in /var/log/messages and noted a very important detail: mountd.
Mountd is the process which is complaining. So I should be looking into the mountd manual.
So I did and found the -n option.
-n Allow non-root mount requests to be served. This should only be

specified if there are clients such as PC's, that require it. It
will automatically clear the vfs.nfsrv.nfs_privport sysctl flag,
which controls if the kernel will accept NFS requests from
reserved ports only.


This seems exactly what I want to accomplish. So I killed mountd and restarted it with the -n option:
killall mountd
mountd -r -n


It works!

To make this change permanent put one of the following two in /etc/rc.conf:
mountd_flags="-r -n"

or
weak_mountd_authentication="YES"

The last one I found in /etc/defaults/rc.conf (which is a very important file to see what defaults are used(and it is the proper way of doing this).

It took me a long time to solve this so I hope this helps somebody!