From 4b2f63a5e581ecfa12abb2419310c4e62eb27134 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 20 Apr 2007 15:14:35 +1000 Subject: [PATCH] Don't hide my_name in statd. statd now passes the 'my_name' from the SM_MON call faithfully to the ha-callout and records it in the sm/ files. --- utils/statd/monitor.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c index bbc1dec..c447a26 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; @@ -274,7 +280,7 @@ void load_state(void) b = strchr(buf, '\n'); if (b) *b = 0; sscanf(buf, "%x %x %x %x ", - &addr, &prog, &vers, &proc); + &addr, &prog, &vers, &proc, myname); b = buf+36; for (i=0; imon_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)) { @@ -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; -- 2.39.5