X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmountd%2Fmountd.c;h=888fd8c92b3da19a42e3964407c680415ccfbe89;hp=deeaa07b6699d8af68fd8f4a128bf414f454fe89;hb=9ccfe0fa5a43dfc4453b09e328565a6c8f999fe4;hpb=4cacc965afc4fb03a465ffcc6cb3078aeadc3818 diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index deeaa07..888fd8c 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -88,6 +88,14 @@ unregister_services (void) pmap_unset (MOUNTPROG, MOUNTVERS_NFSV3); } +static void +cleanup_lockfiles (void) +{ + unlink(_PATH_XTABLCK); + unlink(_PATH_ETABLCK); + unlink(_PATH_RMTABLCK); +} + /* Wait for all worker child processes to exit and reap them */ static void wait_for_workers (void) @@ -154,6 +162,7 @@ fork_workers(void) /* in parent */ wait_for_workers(); unregister_services(); + cleanup_lockfiles(); xlog(L_NOTICE, "mountd: no more workers, exiting\n"); exit(0); } @@ -170,6 +179,7 @@ killer (int sig) kill(0, SIGTERM); wait_for_workers(); } + cleanup_lockfiles(); xlog (L_FATAL, "Caught signal %d, un-registering and exiting.", sig); } @@ -202,8 +212,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) { - struct sockaddr_in *addr = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); xlog(D_CALL, "dump request from %s.", inet_ntoa(addr->sin_addr)); *res = mountlist_list(); @@ -214,8 +223,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) { - struct sockaddr_in *sin - = (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); nfs_export *exp; char *p = *argp; char rpath[MAXPATHLEN+1]; @@ -242,15 +250,14 @@ mount_umntall_1_svc(struct svc_req *rqstp, void *argp, void *resp) /* Reload /etc/xtab if necessary */ auth_reload(); - mountlist_del_all((struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt)); + mountlist_del_all(nfs_getrpccaller_in(rqstp->rq_xprt)); return 1; } bool_t mount_export_1_svc(struct svc_req *rqstp, void *argp, exports *resp) { - struct sockaddr_in *addr = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); xlog(D_CALL, "export request from %s.", inet_ntoa(addr->sin_addr)); *resp = get_exportlist(); @@ -261,8 +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) { - struct sockaddr_in *addr = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt); xlog(D_CALL, "exportall request from %s.", inet_ntoa(addr->sin_addr)); *resp = get_exportlist(); @@ -284,8 +290,7 @@ mount_exportall_1_svc(struct svc_req *rqstp, void *argp, exports *resp) bool_t mount_pathconf_2_svc(struct svc_req *rqstp, dirpath *path, ppathcnf *res) { - struct sockaddr_in *sin - = (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); struct stat stb; nfs_export *exp; char rpath[MAXPATHLEN+1]; @@ -354,6 +359,11 @@ static void set_authflavors(struct mountres3_ok *ok, nfs_export *exp) flavors[i] = s->flav->fnum; i++; } + if (i == 0) { + /* default when there is no sec= option: */ + i = 1; + flavors[0] = AUTH_UNIX; + } ok->auth_flavors.auth_flavors_val = flavors; ok->auth_flavors.auth_flavors_len = i; } @@ -383,8 +393,7 @@ static struct nfs_fh_len * get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret, mountstat3 *error, int v3) { - struct sockaddr_in *sin = - (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt); + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); struct stat stb, estb; nfs_export *exp; struct nfs_fh_len *fh; @@ -463,8 +472,12 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret, return NULL; } } else { - if (exp->m_exported<1) + int did_export = 0; + retry: + if (exp->m_exported<1) { export_export(exp); + did_export = 1; + } if (!exp->m_xtabent) xtab_append(exp); @@ -478,6 +491,11 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret, fh = getfh_old ((struct sockaddr *) sin, stb.st_dev, stb.st_ino); } + if (fh == NULL && !did_export) { + exp->m_exported = 0; + goto retry; + } + if (fh == NULL) { xlog(L_WARNING, "getfh failed: %s", strerror(errno)); *error = NFSERR_ACCES;