diff --git a/CHANGELOG b/CHANGELOG index 1387d49..0c498fc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -35,6 +35,7 @@ - fix included map wild card key lookup. - fix task cancelation at shutdown (more). - fix concurrent mount and expire race with nested submounts. +- fix colon escape handling. 13/7/2006 autofs-5.0.1 rc1 -------------------------- diff --git a/modules/parse_sun.c b/modules/parse_sun.c index c132422..190499c 100644 --- a/modules/parse_sun.c +++ b/modules/parse_sun.c @@ -508,25 +508,35 @@ static int sun_mount(struct autofs_point mountpoint = alloca(namelen + 1); sprintf(mountpoint, "%.*s", namelen, name); - what = alloca(loclen + 1); - if (*loc == ':') { - memcpy(what, loc + 1, loclen - 1); - what[loclen - 1] = '\0'; - } else { + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); + if (!strcmp(fstype, "nfs")) { + what = alloca(loclen + 1); memcpy(what, loc, loclen); what[loclen] = '\0'; - } - debug(ap->logopt, - MODPREFIX - "mounting root %s, mountpoint %s, what %s, fstype %s, options %s", - root, mountpoint, what, fstype, options); + debug(ap->logopt, MODPREFIX + "mounting root %s, mountpoint %s, " + "what %s, fstype %s, options %s", + root, mountpoint, what, fstype, options); - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); - if (!strcmp(fstype, "nfs")) { rv = mount_nfs->mount_mount(ap, root, mountpoint, strlen(mountpoint), what, fstype, options, mount_nfs->context); } else { + what = alloca(loclen + 1); + if (*loc == ':') { + loclen--; + memcpy(what, loc + 1, loclen); + what[loclen] = '\0'; + } else { + memcpy(what, loc, loclen); + what[loclen] = '\0'; + } + + debug(ap->logopt, MODPREFIX + "mounting root %s, mountpoint %s, " + "what %s, fstype %s, options %s", + root, mountpoint, what, fstype, options); + /* Generic mount routine */ rv = do_mount(ap, root, mountpoint, strlen(mountpoint), what, fstype, options); diff --git a/modules/replicated.c b/modules/replicated.c index aa484b3..7558383 100644 --- a/modules/replicated.c +++ b/modules/replicated.c @@ -587,14 +587,16 @@ int prune_host_list(struct host **list, while (this && this->proximity == proximity) { struct host *next = this->next; - status = get_vers_and_cost(this, vers); - if (!status) { - if (this == first) { - first = next; - if (next) - proximity = next->proximity; + if (this->name) { + status = get_vers_and_cost(this, vers); + if (!status) { + if (this == first) { + first = next; + if (next) + proximity = next->proximity; + } + delete_host(list, this); } - delete_host(list, this); } this = next; } @@ -674,11 +676,15 @@ int prune_host_list(struct host **list, this = first; while (this) { struct host *next = this->next; - status = get_supported_ver_and_cost(this, selected_version); - if (status) { - this->version = selected_version; - remove_host(list, this); + if (!this->name) add_host(&new, this); + else { + status = get_supported_ver_and_cost(this, selected_version); + if (status) { + this->version = selected_version; + remove_host(list, this); + add_host(&new, this); + } } this = next; } @@ -775,6 +781,34 @@ static int add_path(struct host *hosts, return 1; } +static int add_local_path(struct host **hosts, const char *path) +{ + struct host *new; + char *tmp; + + tmp = strdup(path); + if (!tmp) + return 0; + + new = malloc(sizeof(struct host)); + if (!new) { + free(tmp); + return 0; + } + + memset(new, 0, sizeof(struct host)); + + new->path = tmp; + new->proximity = PROXIMITY_LOCAL; + new->version = NFS_VERS_MASK; + new->name = new->addr = NULL; + new->weight = new->cost = 0; + + add_host(hosts, new); + + return 1; +} + int parse_location(struct host **hosts, const char *list) { char *str, *p, *delim; @@ -829,18 +863,25 @@ int parse_location(struct host **hosts, *next++ = '\0'; } - if (!add_host_addrs(hosts, p, weight)) { - if (empty) { + if (p != delim) { + if (!add_host_addrs(hosts, p, weight)) { + if (empty) { + p = next; + continue; + } + } + + if (!add_path(*hosts, path, strlen(path))) { + free_host_list(hosts); + free(str); + return 0; + } + } else { + if (!add_local_path(hosts, path)) { p = next; continue; } } - - if (!add_path(*hosts, path, strlen(path))) { - free_host_list(hosts); - free(str); - return 0; - } } else if (*delim != '\0') { *delim = '\0'; next = delim + 1;