]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Don't hide my_name in statd.
authorNeil Brown <neilb@suse.de>
Fri, 20 Apr 2007 05:14:35 +0000 (15:14 +1000)
committerNeil Brown <neilb@suse.de>
Fri, 20 Apr 2007 05:14:35 +0000 (15:14 +1000)
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

index bbc1dec67f423de605cfbfd228fe09cd8e8a7df6..c447a269bb9b86f2c82091ff7844e6cb693977ac 100644 (file)
@@ -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;
                        *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;
        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);
                goto failure;
        }
        my_addr.s_addr = htonl(INADDR_LOOPBACK);
-       my_name = "127.0.0.1";
 
        /* 2.   Reject any registrations for non-lockd services.
         *
 
        /* 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;
        }
 
                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
        /*
         * 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;
        }
        {
                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 ",
                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();
                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);
        }
 
                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];
                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;
                        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 ",
                        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);
                        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++;
                                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;
                        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            *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
 #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;
        }
                        inet_ntoa(caller));
                goto failure;
        }
-       my_name = "127.0.0.1";
 #endif
 #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)) {
 
        /* 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;
        }
                        inet_ntoa(caller));
                goto failure;
        }
-       my_name = "127.0.0.1";
 #endif
 
        result.state = MY_STATE;
 #endif
 
        result.state = MY_STATE;