fix cgi and simplify now we use regex

This commit is contained in:
prx 2022-08-18 14:12:38 +02:00
parent 34667eb018
commit fc5c2a1b41
2 changed files with 5 additions and 10 deletions

8
main.c
View File

@ -67,17 +67,13 @@ main(int argc, char **argv)
if (*cgi_dir)
if (do_cgi(chroot_dir, cgi_dir, path, hostname, query) == 0)
stop(EXIT_SUCCESS, NULL);
/* *** from here, cgi didn't run *** */
syslog(LOG_DAEMON, "path:%s", path);
/* *** from here, cgi didn't run ***
* check if path available
*/
/* check if path available */
check_path(path, sizeof(path), virtualhost, strlen(hostname));
/* split dir and filename */
split_dir_file(path, dir, sizeof(dir), file, sizeof(file));
syslog(LOG_DAEMON, "dir:%s", dir);
syslog(LOG_DAEMON, "file:%s", file);
/* go to dir */
if (*dir)

7
vger.c
View File

@ -220,7 +220,6 @@ do_cgi(const char *chroot_dir, const char *cgi_dir, const char *path, const char
/* check if path starts with cgi_dir
* compare beginning of path with cgi_dir
* path + 2 : skip "./"
* cgi_dir + strlen(chrootdir) (skip chrootdir)
*/
@ -229,7 +228,7 @@ do_cgi(const char *chroot_dir, const char *cgi_dir, const char *path, const char
while (*cgirp == '/')
estrlcpy(cgirp, cgirp+1, sizeof(cgirp));
if (strncmp(cgirp, path+2, strlen(cgirp)) != 0)
if (strncmp(cgirp, path, strlen(cgirp)) != 0)
return 1; /* not in cgi_dir, go to display_file */
/* set env variables for CGI
@ -250,11 +249,11 @@ do_cgi(const char *chroot_dir, const char *cgi_dir, const char *path, const char
*/
/* find next item after cgi_dir in path:
* path + 2 (skip "./") + strlen(cgirp) + 1 (skip '/')
* path + strlen(cgirp) + 1 (skip '/')
*/
/* cgi file to execute */
estrlcpy(cgifp, path + 2 + strlen(cgirp) + 1, sizeof(cgifp));
estrlcpy(cgifp, path + strlen(cgirp) + 1, sizeof(cgifp));
if (!(*cgifp)) /* problem with cgi file, abort */
return 1;