getvolbypath() would match a given path "/foo/barbaz" with an existing
volume path of "/foo/bar" because the strings where compared with
strnlen() where n is the length of "/foo/bar", ie we did a substring
match.
I faintly remember there was a reason for this, but I couldn't come up
with any sensible configuration of usage of dbd that would not also
work by simply using strcmp() instead of strmcmp().
Of course, in order for dbd to work with paths that included a
trailing slash, there's a need to adding some slash stripping code,
because our code (somehow) ensures (hopefully!) that in struct
vol.v_path is always stored with trailinsh slashes stripped.
Signed-off-by: Ralph Boehme <rb@sernet.de>
* FIX: xattrs on *BSD, bug #562
* NEW: afpd: support for using $u username variable in AFP volume
definitions. FR#90.
* FIX: xattrs on *BSD, bug #562
* NEW: afpd: support for using $u username variable in AFP volume
definitions. FR#90.
+* FIX: getvolbypath returns incorrect volume, bug #563
Changes in 3.1.1
================
Changes in 3.1.1
================
const char *secname, *basedir, *p = NULL, *subpath = NULL, *subpathconfig;
char *user = NULL, *prw;
regmatch_t match[1];
const char *secname, *basedir, *p = NULL, *subpath = NULL, *subpathconfig;
char *user = NULL, *prw;
regmatch_t match[1];
LOG(log_debug, logtype_afpd, "getvolbypath(\"%s\")", path);
LOG(log_debug, logtype_afpd, "getvolbypath(\"%s\")", path);
strlcat(abspath, "/", MAXPATHLEN);
strlcat(abspath, path, MAXPATHLEN);
path = abspath;
strlcat(abspath, "/", MAXPATHLEN);
strlcat(abspath, path, MAXPATHLEN);
path = abspath;
+ } else {
+ strlcpy(abspath, path, MAXPATHLEN);
+ path = abspath;
+ /* path now points to a copy of path in the abspath buffer */
+ /*
+ * Strip trailing slashes
+ */
+ abspath_len = strlen(abspath);
+ while (abspath[abspath_len - 1] == '/') {
+ abspath[abspath_len - 1] = 0;
+ abspath_len--;
+ }
for (tmp = Volumes; tmp; tmp = tmp->v_next) { /* (1) */
for (tmp = Volumes; tmp; tmp = tmp->v_next) { /* (1) */
- if (strncmp(path, tmp->v_path, strlen(tmp->v_path)) == 0) {
+ if (strcmp(path, tmp->v_path) == 0) {
+ LOG(log_debug, logtype_afpd, "getvolbypath: path(\"%s\") == volume(\"%s\")", path, tmp->v_path);
vol = tmp;
goto EC_CLEANUP;
vol = tmp;
goto EC_CLEANUP;
+ } else {
+ LOG(log_debug, logtype_afpd, "getvolbypath: path(\"%s\") != volume(\"%s\")", path, tmp->v_path);