daemon: do not forbid user relative paths unconditionally under --base-path
Using base-path to relocate the server public space does not have anything to do with allowing or forbidding user relative paths. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 3, 2006 at 23:50 UTC
363f24c93695d26f5af584e99093689077b1c7dd
1 file changed
+8
-4
daemon.c
+8
-4
@@ -145,13 +145,17 @@ static char *path_ok(char *dir)
145
146
if (base_path) {
147
static char rpath[PATH_MAX];
148
- if (*dir != '/') {
149
- /* Forbid possible base-path evasion using ~paths. */
148
+ if (!strict_paths && *dir == '~')
149
+ ; /* allow user relative paths */
150
+ else if (*dir != '/') {
151
+ /* otherwise allow only absolute */
152
logerror("'%s': Non-absolute path denied (base-path active)", dir);
153
return NULL;
154
}
153
- snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
154
- dir = rpath;
155
+ else {
156
+ snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
157
+ dir = rpath;
158
+ }
159
}
160
161
path = enter_repo(dir, strict_paths);