X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmountd%2Fmountd.c;h=5204faa62b4a1d6b7f750c4923818f9fcec7df51;hb=dbeba43bd33ce41bc3c5c95615176e59eb76f00c;hp=c1d18d4cebc9b37b1f227d7de33fe1aaf4ccfaaf;hpb=93608a52655abf5ac23404c4b5cc05fe575a9c04;p=nfs-utils.git diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index c1d18d4..5204faa 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -29,7 +29,7 @@ extern void cache_open(void); extern struct nfs_fh_len *cache_get_filehandle(nfs_export *exp, int len, char *p); -extern void cache_export(nfs_export *exp); +extern int cache_export(nfs_export *exp); extern void my_svc_run(void); @@ -37,6 +37,7 @@ static void usage(const char *, int exitcode); static exports get_exportlist(void); static struct nfs_fh_len *get_rootfh(struct svc_req *, dirpath *, mountstat3 *, int v3); +int reverse_resolve = 0; int new_cache = 0; /* PRC: a high-availability callout program can be specified with -H @@ -66,6 +67,7 @@ static struct option longopts[] = { "ha-callout", 1, 0, 'H' }, { "state-directory-path", 1, 0, 's' }, { "num-threads", 1, 0, 't' }, + { "reverse-lookup", 0, 0, 'r' }, { NULL, 0, 0, 0 } }; @@ -225,14 +227,11 @@ mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *resp) if (!(exp = auth_authenticate("unmount", sin, p))) { return 1; } - if (new_cache) { - if (strcmp(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname)) - mountlist_del(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname); - mountlist_del(exp->m_client->m_hostname, p); - } else { - mountlist_del(exp->m_client->m_hostname, p); + + if (!new_cache) export_reset (exp); - } + + mountlist_del(inet_ntoa(sin->sin_addr), p); return 1; } @@ -417,12 +416,17 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, mountstat3 *error, int v3) */ struct nfs_fh_len *fh; - cache_export(exp); + if (cache_export(exp)) { + *error = NFSERR_ACCES; + return NULL; + } fh = cache_get_filehandle(exp, v3?64:32, p); if (fh == NULL) *error = NFSERR_ACCES; - else + else { *error = NFS_OK; + mountlist_add(inet_ntoa(sin->sin_addr), p); + } return fh; } else { struct nfs_fh_len *fh; @@ -443,7 +447,7 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, mountstat3 *error, int v3) stb.st_dev, stb.st_ino); } if (fh != NULL) { - mountlist_add(exp->m_client->m_hostname, p); + mountlist_add(inet_ntoa(sin->sin_addr), p); *error = NFS_OK; export_reset (exp); return fh; @@ -459,14 +463,19 @@ static exports get_exportlist(void) { static exports elist = NULL; + static time_t etime = 0; + time_t atime; struct exportnode *e, *ne; struct groupnode *g, *ng, *c, **cp; nfs_export *exp; int i; - if (!auth_reload() && elist) + atime = auth_reload(); + if (elist && atime == etime) return elist; + etime = atime; + for (e = elist; e != NULL; e = ne) { ne = e->ex_next; for (g = e->ex_groups; g != NULL; g = ng) { @@ -558,7 +567,7 @@ main(int argc, char **argv) /* Parse the command line options and arguments. */ opterr = 0; - while ((c = getopt_long(argc, argv, "o:n:Fd:f:p:P:hH:N:V:vs:t:", longopts, NULL)) != EOF) + while ((c = getopt_long(argc, argv, "o:nFd:f:p:P:hH:N:V:vrs:t:", longopts, NULL)) != EOF) switch (c) { case 'o': descriptors = atoi(optarg); @@ -598,6 +607,9 @@ main(int argc, char **argv) case 'n': _rpcfdtype = SOCK_DGRAM; break; + case 'r': + reverse_resolve = 1; + break; case 's': if ((state_dir = xstrdup(optarg)) == NULL) { fprintf(stderr, "%s: xstrdup(%s) failed!\n",