]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mountd/fsloc.c
utils: Return status 0 on clean exits
[nfs-utils.git] / utils / mountd / fsloc.c
index 44b5b979cc34eecb374103e2e68dde547b89ca51..bc737d191cf8b830ea9d8c748b5a8695e32e87e1 100644 (file)
@@ -40,16 +40,17 @@ static void replicas_print(struct servers *sp)
 {
        int i;
        if (!sp) {
-               syslog(LOG_INFO, "NULL replicas pointer");
+               xlog(L_NOTICE, "NULL replicas pointer");
                return;
        }
-       syslog(LOG_INFO, "replicas listsize=%i", sp->h_num);
+       xlog(L_NOTICE, "replicas listsize=%i", sp->h_num);
        for (i=0; i<sp->h_num; i++) {
-               syslog(LOG_INFO, "%s:%s",
+               xlog(L_NOTICE, "    %s:%s",
                       sp->h_mp[i]->h_host, sp->h_mp[i]->h_path);
        }
 }
 
+#ifdef DEBUG
 /* Called by setting 'Method = stub' in config file.  Just returns
  * some syntactically correct gibberish for testing purposes.
  */
@@ -58,7 +59,7 @@ static struct servers *method_stub(char *key)
        struct servers *sp;
        struct mount_point *mp;
 
-       syslog(LOG_INFO, "called method_stub");
+       xlog(L_NOTICE, "called method_stub\n");
        sp = malloc(sizeof(struct servers));
        if (!sp)
                return NULL;
@@ -74,6 +75,7 @@ static struct servers *method_stub(char *key)
        sp->h_referral = 1;
        return sp;
 }
+#endif /* DEBUG */
 
 /* Scan @list, which is a NULL-terminated array of strings of the
  * form path@host[+host], and return corresponding servers structure.
@@ -99,7 +101,7 @@ static struct servers *parse_list(char **list)
                }
                cp = strchr(list[i], '@');
                if ((!cp) || list[i][0] != '/') {
-                       syslog(LOG_WARNING, "invalid entry '%s'", list[i]);
+                       xlog(L_WARNING, "invalid entry '%s'", list[i]);
                        continue; /* XXX Need better error handling */
                }
                res->h_mp[i] = mp;
@@ -118,23 +120,37 @@ static struct servers *parse_list(char **list)
  */
 static struct servers *method_list(char *data)
 {
-       char *copy, *ptr=data;
+       char *copy, *ptr=data, *p;
        char **list;
        int i, listsize;
        struct servers *rv=NULL;
+       bool v6esc = false;
 
-       syslog(LOG_INFO, "method_list(%s)\n", data);
+       xlog(L_NOTICE, "method_list(%s)", data);
        for (ptr--, listsize=1; ptr; ptr=index(ptr, ':'), listsize++)
                ptr++;
        list = malloc(listsize * sizeof(char *));
        copy = strdup(data);
        if (copy)
-               syslog(LOG_INFO, "converted to %s\n", copy);
+               xlog(L_NOTICE, "converted to %s", copy);
        if (list && copy) {
                ptr = copy;
-               for (i=0; i<listsize; i++) {
-                       list[i] = strsep(&ptr, ":");
+               for (p = ptr, i = 0; *p && i < listsize; p++) {
+                       if (*p == '[')
+                               v6esc = true;
+                       else if (*p == ']')
+                               v6esc = false;
+
+                       if (!v6esc && *p == ':') {
+                               *p = '\0';
+                               if (*ptr)
+                                       list[i++] = ptr;
+                               ptr = p + 1;
+                       }
                }
+               if (*ptr)
+                       list[i++] = ptr;
+               list[i] = NULL;
                rv = parse_list(list);
        }
        free(copy);
@@ -144,7 +160,7 @@ static struct servers *method_list(char *data)
 }
 
 /* Returns appropriately filled struct servers, or NULL if had a problem */
-struct servers *replicas_lookup(int method, char *data, char *key)
+struct servers *replicas_lookup(int method, char *data)
 {
        struct servers *sp=NULL;
        switch(method) {
@@ -160,11 +176,13 @@ struct servers *replicas_lookup(int method, char *data, char *key)
                if (sp)
                        sp->h_referral = 0;
                break;
+#ifdef DEBUG
        case FSLOC_STUB:
                sp = method_stub(data);
                break;
+#endif
        default:
-               syslog(LOG_WARNING, "Unknown method = %i", method);
+               xlog(L_WARNING, "Unknown method = %i", method);
        }
        replicas_print(sp);
        return sp;