[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NFS-050 bug fix
I've been trying to NFS mount from my Linux PC to my MiNT STe. I've
exported / from the PC, and tried to mount it on the ST with
# net.mount merry:/ /nfs/merry
(net.mount is the NFS mount program, as distinct from the MinixFS
mount program.) Whenever I try to access /nfs/merry, even just to do
an "ls -l /nfs", I get permission denied errors, and the PC's logs get
a message like:
Jun 16 01:08:03 merry mount[8655]: NFS request from 10.0.0.1 originated
on insecure port, psychoanalysis suggested
Using Linux's packet logging, I have discovered that, while MiNTnet's
NFS-050 is correctly using a secure port to send its access requests,
the mount program is not doing the same for its mount requests. Here's
a patch to nfs-050 to solve this.
There was also a bug in the bindresvport() implementation in the nfs
filesystem, but the bug was never exercised since the filesystem could
always allocate port 1023. The problem was an r instead of a
(-errno). I found this one out when I copied the code into nfsmnt.c;
this could not allocate port 1023 because the nfs fs had. I'll
generate a patch to fix the version of bindresvport() in the nfs
filesystem soon.
Bye,
--Charles
--- nfs-050/mount/nfsmnt.c.orig Sat Jul 9 18:36:52 1994
+++ nfs-050/mount/nfsmnt.c Mon Jun 17 02:26:18 1996
@@ -104,12 +104,41 @@
+/* bindresvport() copied from nfs-050/xfs/sock_ipc.c --cpbs */
+
+long
+bindresvport(int s)
+{
+#define EADDRINUSE (-310)
+ struct sockaddr_in sin;
+ short port;
+ long r;
+
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ for (port = IPPORT_RESERVED-1; port > IPPORT_RESERVED/2; --port)
+ {
+ sin.sin_port = htons(port);
+ r = bind(s, (struct sockaddr *)&sin, sizeof(sin));
+ if (r == 0)
+ return 0;
+
+ if (r < 0 && (-errno) != EADDRINUSE)
+ return r;
+ }
+ return EADDRINUSE;
+}
+
+
+
static int
make_socket(long maxmsgsize)
{
long res;
int fd;
+#if 0
struct sockaddr_in sin;
+#endif
fd = socket(PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
@@ -127,11 +156,15 @@
}
#endif
+#if 0
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = htons(0);
res = bind(fd, (struct sockaddr*)&sin, sizeof(sin));
+#else
+ res = bindresvport(fd);
+#endif
if (res < 0)
{
fprintf(stderr, "open_connection: bind() failed with %d\n", -errno);