1
0
Fork 0

Allow document roots specified with relative paths

Closes #71

Implements this issue by transforming all relative paths into absolute
paths.
This commit is contained in:
fosslinux 2020-12-28 11:03:33 +11:00
parent 430e8f9ee0
commit 7a02ffd8ec
1 changed files with 12 additions and 0 deletions

View File

@ -524,8 +524,20 @@ int main(int argc, char *argv[])
/* Handle command line arguments */
parse_args(&st, argc, argv);
/* Initalize logging */
log_init(st.opt_syslog, st.debug);
/* Convert relative gopher roots to absolute roots */
if (st.server_root[0] != '/') {
char cwd[512];
getcwd(cwd, sizeof(cwd));
if (cwd == NULL) {
die(&st, NULL, "unable to get current path");
}
snprintf(buf, sizeof(buf), "%s/%s", cwd, st.server_root);
sstrlcpy(st.server_root, buf);
}
#ifdef __OpenBSD__
/* unveil(2) support.
*