X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmountd%2Fmountd.c;h=dc84404aa1e81ad18d03cf811bacaa439a5dd840;hb=26fd34002585e6a5aa09204b0b01d836fa83dcf3;hp=a0a1f2d03a7c61c5b339bd72498abbe8fac9bde3;hpb=55257d644359aec6fba463968bd503d5ae231eb7;p=nfs-utils.git diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index a0a1f2d..dc84404 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -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); } @@ -192,7 +192,8 @@ sig_hup (int sig) } bool_t -mount_null_1_svc(struct svc_req *rqstp, void *argp, void *resp) +mount_null_1_svc(struct svc_req *UNUSED(rqstp), void *UNUSED(argp), + void *UNUSED(resp)) { return 1; } @@ -210,7 +211,7 @@ mount_mnt_1_svc(struct svc_req *rqstp, dirpath *path, fhstatus *res) } bool_t -mount_dump_1_svc(struct svc_req *rqstp, void *argp, mountlist *res) +mount_dump_1_svc(struct svc_req *rqstp, void *UNUSED(argp), mountlist *res) { struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); @@ -221,7 +222,7 @@ mount_dump_1_svc(struct svc_req *rqstp, void *argp, mountlist *res) } bool_t -mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *resp) +mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *UNUSED(resp)) { struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); nfs_export *exp; @@ -245,7 +246,8 @@ mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *resp) } bool_t -mount_umntall_1_svc(struct svc_req *rqstp, void *argp, void *resp) +mount_umntall_1_svc(struct svc_req *rqstp, void *UNUSED(argp), + void *UNUSED(resp)) { /* Reload /etc/xtab if necessary */ auth_reload(); @@ -255,7 +257,7 @@ mount_umntall_1_svc(struct svc_req *rqstp, void *argp, void *resp) } bool_t -mount_export_1_svc(struct svc_req *rqstp, void *argp, exports *resp) +mount_export_1_svc(struct svc_req *rqstp, void *UNUSED(argp), exports *resp) { struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); @@ -266,7 +268,7 @@ mount_export_1_svc(struct svc_req *rqstp, void *argp, exports *resp) } bool_t -mount_exportall_1_svc(struct svc_req *rqstp, void *argp, exports *resp) +mount_exportall_1_svc(struct svc_req *rqstp, void *UNUSED(argp), exports *resp) { struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); @@ -536,22 +538,21 @@ static void free_exportlist(exports *elist) static void prune_clients(nfs_export *exp, struct exportnode *e) { - struct hostent *hp; + struct addrinfo *ai = NULL; struct groupnode *c, **cp; cp = &e->ex_groups; while ((c = *cp) != NULL) { if (client_gettype(c->gr_name) == MCL_FQDN - && (hp = gethostbyname(c->gr_name))) { - hp = hostent_dup(hp); - if (client_check(exp->m_client, hp)) { + && (ai = host_addrinfo(c->gr_name))) { + if (client_check(exp->m_client, ai)) { *cp = c->gr_next; xfree(c->gr_name); xfree(c); - xfree (hp); + freeaddrinfo(ai); continue; } - xfree (hp); + freeaddrinfo(ai); } cp = &(c->gr_next); } @@ -712,8 +713,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 +764,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);