summaryrefslogtreecommitdiffstats
path: root/utils/statd
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2007-04-20 15:14:35 +1000
committerNeil Brown <neilb@suse.de>2007-04-20 15:14:35 +1000
commit4b2f63a5e581ecfa12abb2419310c4e62eb27134 (patch)
tree48b157883910222e55aa5b347d63fb88ccceee40 /utils/statd
parentb6e8ae4797839df8731fd74ac2390dbf6e4759a7 (diff)
downloadnfs-utils-4b2f63a5e581ecfa12abb2419310c4e62eb27134.tar.gz
nfs-utils-4b2f63a5e581ecfa12abb2419310c4e62eb27134.tar.xz
nfs-utils-4b2f63a5e581ecfa12abb2419310c4e62eb27134.zip
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.
Diffstat (limited to 'utils/statd')
-rw-r--r--utils/statd/monitor.c29
1 files 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; i<SM_PRIV_SIZE; i++)
e += sprintf(e, "%02x", 0xff & (argp->priv[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; i<SM_PRIV_SIZE; i++) {
sscanf(b, "%2x", &p);
@@ -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)) {
@@ -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;