]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/nfsmount.c
nfs-utils patch for mount-reserved-port
[nfs-utils.git] / utils / mount / nfsmount.c
index 1266660c7f090c50e6c60bbc970aeb8560528134..f21c81c4a583c077facab4c4b105b0ed84f00c65 100644 (file)
@@ -59,7 +59,7 @@
 
 #include "conn.h"
 #include "xcommon.h"
-#include "nfsmount.h"
+#include "mount.h"
 #include "nfsumount.h"
 #include "nfs_mount.h"
 #include "mount_constants.h"
@@ -306,7 +306,7 @@ getport(
        enum clnt_stat stat;
 
        saddr->sin_port = htons (PMAPPORT);
-       socket = get_socket(saddr, prot, FALSE);
+       socket = get_socket(saddr, prot, FALSE, FALSE);
 
        switch (prot) {
        case IPPROTO_UDP:
@@ -376,7 +376,7 @@ probe_port(clnt_addr_t *server,
                                                inet_ntoa(saddr->sin_addr), prog, *p_vers,
                                                *p_prot == IPPROTO_UDP ? "udp" : "tcp", p_port);
                                }
-                               if (clnt_ping(saddr, prog, *p_vers, *p_prot))
+                               if (clnt_ping(saddr, prog, *p_vers, *p_prot, NULL))
                                        goto out_ok;
                                if (rpc_createerr.cf_stat == RPC_TIMEDOUT)
                                        goto out_bad;
@@ -638,7 +638,9 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
                                if (nfs_mount_version < 5) {
                                        printf(_("Warning: ignoring sec=%s option\n"), secflavor);
                                        continue;
-                               } else if (!strcmp(secflavor, "sys"))
+                               } else if (!strcmp(secflavor, "none"))
+                                       data->pseudoflavor = AUTH_NONE;
+                               else if (!strcmp(secflavor, "sys"))
                                        data->pseudoflavor = AUTH_SYS;
                                else if (!strcmp(secflavor, "krb5"))
                                        data->pseudoflavor = AUTH_GSS_KRB5;
@@ -833,14 +835,14 @@ nfsmount(const char *spec, const char *node, int *flags,
                     *nfs_pmap = &nfs_server.pmap;
        struct pmap  save_mnt, save_nfs;
 
-       int fsock;
+       int fsock = -1;
 
        mntres_t mntres;
 
        struct stat statbuf;
        char *s;
        int bg, retry;
-       int retval;
+       int retval = EX_FAIL;
        time_t t;
        time_t prevt;
        time_t timeout;
@@ -851,8 +853,6 @@ nfsmount(const char *spec, const char *node, int *flags,
                *nfs_mount_vers = find_kernel_nfs_mount_version();
        nfs_mount_version = *nfs_mount_vers;
 
-       retval = EX_FAIL;
-       fsock = -1;
        if (strlen(spec) >= sizeof(hostdir)) {
                fprintf(stderr, _("mount: "
                                  "excessively long host:dir argument\n"));
@@ -1084,11 +1084,11 @@ nfsmount(const char *spec, const char *node, int *flags,
                }
 #if NFS_MOUNT_VERSION >= 5
                mountres = &mntres.nfsv3.mountres3_u.mountinfo;
-               i = mountres->auth_flavours.auth_flavours_len;
+               i = mountres->auth_flavors.auth_flavors_len;
                if (i <= 0) 
-                       goto noauth_flavours;
+                       goto noauth_flavors;
 
-               flavor = mountres->auth_flavours.auth_flavours_val;
+               flavor = mountres->auth_flavors.auth_flavors_val;
                while (--i >= 0) {
                        if (flavor[i] == data.pseudoflavor)
                                yum = 1;
@@ -1106,7 +1106,7 @@ nfsmount(const char *spec, const char *node, int *flags,
                        nfs_call_umount(&mnt_server, &dirname);
                        goto fail;
                }
-noauth_flavours:
+noauth_flavors:
 #endif
                fhandle = &mntres.nfsv3.mountres3_u.mountinfo.fhandle;
                memset(data.old_root.data, 0, NFS_FHSIZE);
@@ -1120,20 +1120,22 @@ noauth_flavours:
 #endif
        }
 
-       /* create nfs socket for kernel */
-
-       if (nfs_pmap->pm_prot == IPPROTO_TCP)
-               fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-       else
-               fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-       if (fsock < 0) {
-               perror(_("nfs socket"));
-               goto fail;
-       }
-       if (bindresvport(fsock, 0) < 0) {
-               perror(_("nfs bindresvport"));
-               goto fail;
+       if (nfs_mount_version == 1) {
+               /* create nfs socket for kernel */
+               if (nfs_pmap->pm_prot == IPPROTO_TCP)
+                       fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+               else
+                       fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+               if (fsock < 0) {
+                       perror(_("nfs socket"));
+                       goto fail;
+               }
+               if (bindresvport(fsock, 0) < 0) {
+                       perror(_("nfs bindresvport"));
+                       goto fail;
+               }
        }
+
 #ifdef NFS_MOUNT_DEBUG
        printf(_("using port %d for nfs deamon\n"), nfs_pmap->pm_port);
 #endif
@@ -1143,7 +1145,7 @@ noauth_flavours:
         * to avoid problems with multihomed hosts.
         * --Swen
         */
-       if (linux_version_code() <= 66314
+       if (linux_version_code() <= 0x01030a && fsock != -1
            && connect(fsock, (struct sockaddr *) nfs_saddr,
                       sizeof (*nfs_saddr)) < 0) {
                perror(_("nfs connect"));