- } else
- module_chdir = module_dir;
-
- /* We do a change_dir() that doesn't actually call chdir()
- * just to make a relative path absolute. */
- strlcpy(line, curr_dir, sizeof line);
- if (!change_dir(module_chdir, CD_SKIP_CHDIR))
- goto chdir_failed;
- if (strcmp(curr_dir, module_chdir) != 0
- && (module_chdir = strdup(curr_dir)) == NULL) /* MEMORY LEAK */
- out_of_memory("rsync_module");
- change_dir(line, CD_SKIP_CHDIR); /* Restore curr_dir. */
-
- module_dirlen = clean_fname(module_dir, CFN_COLLAPSE_DOT_DOT_DIRS | CFN_DROP_TRAILING_DOT_DIR);
+ } else {
+ if (!(module_chdir = normalize_path(module_dir, False, &module_dirlen)))
+ return path_failure(f_out, module_dir, False);
+ full_module_path = module_dir = module_chdir;
+ }