tags:

views:

394

answers:

1

I'd like to read some data from an NFS share from my Java program. I'd need the program to authenticate to the NFS server first, then do the I/O. (Requiring the NFS share to be previously mounted is not acceptable.)

So, I'd like the functionality that's provided by this library: http://jcifs.samba.org/ , except for NFS instead of CIFS. Is such a thing built into Java already, or do I need a third-party library?

I'm also interested in whether this can be done in Perl, Python, or Ruby. But mostly Java.

A: 

NFS is almost always implemented in-kernel, but it looks like you may be in luck. I googled for "nfs client library", and found a few, one even in Java.

http://www.jars.com/utilities/libraries/resource.php/12291

edit: that one's old and abandoned. sorry.

If you can make sysadmin style changes during install of your app, you can set up automount. e.g. on my linux systems at home, /net/llama/home/peter is my home directory on llama, but the trick is that it's only mounted when I access the path. This looks like a decent intro to automounting:

http://wiki.archlinux.org/index.php/Autofs It mostly applies to any Linux distro, except for the bits about installing specific packages.

If you want to enable this only for the user of your app, the automount directory could be inside a directory with limited permissions, unlike the usual /net.

Peter Cordes
That jars.com link points to a Java library listing that looks promising at first, but it was posted in 1998 and no longer links to anything.I definitely wanted this to work from Windows machines, which makes automount seem like not the right choice.
Ben
sorry, didn't check the link carefully after I found it with google. Any luck with any of the other client libraries? Maybe you could wrap them with a java interface?
Peter Cordes
Hmm, before, I was looking for a library that supported user/pass authentication, but now I see that all the NFS shares at my workplace don't require a user/pass to mount. Maybe NFS doesn't do that. I'm looking at JFtp, an open-source program whose GUI does what I need my program to. It's nice, since it works on Windows and Linux. At the very least, I could strip some code out of that.
Ben
From looking at the JFtp source, I've found the Sun WebNFS Developer's Guide, which appears to be compatible with standard NFS servers.
Ben
Glad you found something useful. Authenticated NFS is a recent invention, in NFS terms. It was designed (by Sun) back when root on every machine on the network was trusted, so IP:port, where port < 1024, is sufficient authentication. (unpriviledged users can't open ports < 1024 on Unix).
Peter Cordes