X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fstatd%2Fmonitor.c;h=eadc43441fbd1e6a0ebeba00b6f5e6ca77754432;hb=6ab9cdacd2ea314a837c7affb840aeeec620cb66;hp=bbc1dec67f423de605cfbfd228fe09cd8e8a7df6;hpb=dda3455d8b96a7b078bc00c113e1af15ed421d5b;p=nfs-utils.git diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c index bbc1dec..eadc434 100644 --- a/utils/statd/monitor.c +++ b/utils/statd/monitor.c @@ -40,6 +40,7 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp) *my_name = argp->mon_id.my_id.my_name; struct my_id *id = &argp->mon_id.my_id; char *path; + char *cp; int fd; notify_list *clnt; struct in_addr my_addr; @@ -70,7 +71,6 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp) goto failure; } my_addr.s_addr = htonl(INADDR_LOOPBACK); - my_name = "127.0.0.1"; /* 2. Reject any registrations for non-lockd services. * @@ -127,6 +127,11 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp) goto failure; } + /* my_name must not have white space */ + for (cp=my_name ; *cp ; cp++) + if (*cp == ' ' || *cp == '\t' || *cp == '\r' || *cp == '\n') + *cp = '_'; + /* * Hostnames checked OK. * Now choose a hostname to use for matching. We cannot @@ -202,7 +207,7 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp) goto failure; } { - char buf[LINELEN + 1 + SM_MAXSTRLEN + 2]; + char buf[LINELEN + 1 + SM_MAXSTRLEN*2 + 4]; char *e; int i; e = buf + sprintf(buf, "%08x %08x %08x %08x ", @@ -211,7 +216,7 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp) for (i=0; ipriv[i])); if (e+1-buf != LINELEN) abort(); - e += sprintf(e, " %s\n", mon_name); + e += sprintf(e, " %s %s\n", mon_name, my_name); write(fd, buf, e-buf); } @@ -266,6 +271,7 @@ void load_state(void) while (fgets(buf, sizeof(buf), f) != NULL) { int addr, proc, prog, vers; char priv[SM_PRIV_SIZE]; + char *monname, *myname; char *b; int i; notify_list *clnt; @@ -282,7 +288,12 @@ void load_state(void) b += 2; } b++; - clnt = nlist_new("127.0.0.1", b, 0); + monname = b; + while (*b && *b != ' ') b++; + if (*b) *b++ = '\0'; + while (*b == ' ') b++; + myname = b; + clnt = nlist_new(myname, monname, 0); if (!clnt) break; NL_ADDR(clnt).s_addr = addr; @@ -317,6 +328,7 @@ sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp) char *mon_name = argp->mon_name, *my_name = argp->my_id.my_name; struct my_id *id = &argp->my_id; + char *cp; #ifdef RESTRICTED_STATD struct in_addr caller; #endif @@ -335,8 +347,12 @@ sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp) inet_ntoa(caller)); goto failure; } - my_name = "127.0.0.1"; #endif + /* my_name must not have white space */ + for (cp=my_name ; *cp ; cp++) + if (*cp == ' ' || *cp == '\t' || *cp == '\r' || *cp == '\n') + *cp = '_'; + /* Check if we're monitoring anyone. */ if (!(clnt = rtnl)) { @@ -364,8 +380,8 @@ sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp) /* PRC: do the HA callout: */ ha_callout("del-client", mon_name, my_name, -1); + xunlink(SM_DIR, clnt->dns_name, 1); nlist_free(&rtnl, clnt); - xunlink(SM_DIR, mon_name, 1); return (&result); } else @@ -402,7 +418,6 @@ sm_unmon_all_1_svc(struct my_id *argp, struct svc_req *rqstp) inet_ntoa(caller)); goto failure; } - my_name = "127.0.0.1"; #endif result.state = MY_STATE; @@ -430,8 +445,8 @@ sm_unmon_all_1_svc(struct my_id *argp, struct svc_req *rqstp) temp = NL_NEXT(clnt); /* PRC: do the HA callout: */ ha_callout("del-client", mon_name, my_name, -1); + xunlink(SM_DIR, clnt->dns_name, 1); nlist_free(&rtnl, clnt); - xunlink(SM_DIR, mon_name, 1); ++count; clnt = temp; } else