]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/network.c
mount: silently fails when bad option values are given
[nfs-utils.git] / utils / mount / network.c
index f020933dfe87d6ed1d55e6e04b401943d5d768a2..d9903ed44c492cc3fccedfa04ea2b38ab5a3b83f 100644 (file)
@@ -857,7 +857,14 @@ int nfs_advise_umount(const struct sockaddr *sap, const socklen_t salen,
                return 0;
        }
 
-       client->cl_auth = authunix_create_default();
+       client->cl_auth = nfs_authsys_create();
+       if (client->cl_auth == NULL) {
+               if (verbose)
+                       nfs_error(_("%s: Failed to create RPC auth handle"),
+                               progname);
+               CLNT_DESTROY(client);
+               return 0;
+       }
 
        res = CLNT_CALL(client, MOUNTPROC_UMNT,
                        (xdrproc_t)xdr_dirpath, (caddr_t)argp,
@@ -957,8 +964,10 @@ CLIENT *mnt_openclnt(clnt_addr_t *mnt_server, int *msock)
        }
        if (clnt) {
                /* try to mount hostname:dirname */
-               clnt->cl_auth = authunix_create_default();
-               return clnt;
+               clnt->cl_auth = nfs_authsys_create();
+               if (clnt->cl_auth)
+                       return clnt;
+               CLNT_DESTROY(clnt);
        }
        return NULL;
 }
@@ -1203,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)
                        return 1;
                }
        case PO_BAD_VALUE:
+               nfs_error(_("%s: invalid value for 'nfsprog=' option"),
+                               progname);
                return 0;
        }
 
@@ -1242,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version)
                        }
                        return 0;
                case PO_NOT_FOUND:
-                       nfs_error(_("%s: option parsing error\n"),
+                       nfs_error(_("%s: parsing error on 'vers=' option\n"),
                                        progname);
+                       return 0;
                case PO_BAD_VALUE:
+                       nfs_error(_("%s: invalid value for 'vers=' option"),
+                                       progname);
                        return 0;
                }
        case 4: /* nfsvers */
@@ -1256,9 +1270,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version)
                        }
                        return 0;
                case PO_NOT_FOUND:
-                       nfs_error(_("%s: option parsing error\n"),
+                       nfs_error(_("%s: parsing error on 'nfsvers=' option\n"),
                                        progname);
+                       return 0;
                case PO_BAD_VALUE:
+                       nfs_error(_("%s: invalid value for 'nfsvers=' option"),
+                                       progname);
                        return 0;
                }
        }
@@ -1327,6 +1344,8 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)
                        return 1;
                }
        case PO_BAD_VALUE:
+               nfs_error(_("%s: invalid value for 'port=' option"),
+                               progname);
                return 0;
        }
 
@@ -1373,8 +1392,9 @@ int nfs_nfs_proto_family(struct mount_options *options,
 
        switch (po_rightmost(options, nfs_transport_opttbl)) {
        case 0: /* udp */
-               return 1;
        case 1: /* tcp */
+               /* for compatibility; these are always AF_INET */
+               *family = AF_INET;
                return 1;
        case 2: /* proto */
                option = po_get(options, "proto");
@@ -1413,6 +1433,8 @@ nfs_mount_program(struct mount_options *options, unsigned long *program)
                        return 1;
                }
        case PO_BAD_VALUE:
+               nfs_error(_("%s: invalid value for 'mountprog=' option"),
+                               progname);
                return 0;
        }
 
@@ -1442,6 +1464,8 @@ nfs_mount_version(struct mount_options *options, unsigned long *version)
                        return 1;
                }
        case PO_BAD_VALUE:
+               nfs_error(_("%s: invalid value for 'mountvers=' option"),
+                               progname);
                return 0;
        }
 
@@ -1500,6 +1524,8 @@ nfs_mount_port(struct mount_options *options, unsigned long *port)
                        return 1;
                }
        case PO_BAD_VALUE:
+               nfs_error(_("%s: invalid value for 'mountport=' option"),
+                               progname);
                return 0;
        }