]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mountd/mountd.c
Mountd listens on 2 different versions for NFSv2 (MOUNTv1 and MOUNTv2)
[nfs-utils.git] / utils / mountd / mountd.c
index a0a1f2d03a7c61c5b339bd72498abbe8fac9bde3..5373d81ff3c207c3c5719df902f58af1e264bc6f 100644 (file)
@@ -80,10 +80,10 @@ static int nfs_version = -1;
 static void
 unregister_services (void)
 {
-       if (nfs_version & 0x1)
+       if (nfs_version & (0x1 << 1)) {
                pmap_unset (MOUNTPROG, MOUNTVERS);
-       if (nfs_version & (0x1 << 1))
                pmap_unset (MOUNTPROG, MOUNTVERS_POSIX);
+       }
        if (nfs_version & (0x1 << 2))
                pmap_unset (MOUNTPROG, MOUNTVERS_NFSV3);
 }
@@ -712,8 +712,10 @@ main(int argc, char **argv)
                        usage(argv [0], 1);
                }
 
-       /* No more arguments allowed. */
-       if (optind != argc || !(nfs_version & 0x7))
+       /* No more arguments allowed.
+        * Require at least one valid version (2, 3, or 4)
+        */
+       if (optind != argc || !(nfs_version & 0xE))
                usage(argv [0], 1);
 
        if (chdir(state_dir)) {
@@ -761,12 +763,12 @@ main(int argc, char **argv)
        if (new_cache)
                cache_open();
 
-       if (nfs_version & 0x1)
+       if (nfs_version & (0x1 << 1)) {
                rpc_init("mountd", MOUNTPROG, MOUNTVERS,
                         mount_dispatch, port);
-       if (nfs_version & (0x1 << 1))
                rpc_init("mountd", MOUNTPROG, MOUNTVERS_POSIX,
                         mount_dispatch, port);
+       }
        if (nfs_version & (0x1 << 2))
                rpc_init("mountd", MOUNTPROG, MOUNTVERS_NFSV3,
                         mount_dispatch, port);