fix cgi and simplify now we use regex
This commit is contained in:
parent
34667eb018
commit
fc5c2a1b41
8
main.c
8
main.c
|
@ -67,17 +67,13 @@ main(int argc, char **argv)
|
||||||
if (*cgi_dir)
|
if (*cgi_dir)
|
||||||
if (do_cgi(chroot_dir, cgi_dir, path, hostname, query) == 0)
|
if (do_cgi(chroot_dir, cgi_dir, path, hostname, query) == 0)
|
||||||
stop(EXIT_SUCCESS, NULL);
|
stop(EXIT_SUCCESS, NULL);
|
||||||
|
/* *** from here, cgi didn't run *** */
|
||||||
|
|
||||||
syslog(LOG_DAEMON, "path:%s", path);
|
/* check if path available */
|
||||||
/* *** from here, cgi didn't run ***
|
|
||||||
* check if path available
|
|
||||||
*/
|
|
||||||
check_path(path, sizeof(path), virtualhost, strlen(hostname));
|
check_path(path, sizeof(path), virtualhost, strlen(hostname));
|
||||||
|
|
||||||
/* split dir and filename */
|
/* split dir and filename */
|
||||||
split_dir_file(path, dir, sizeof(dir), file, sizeof(file));
|
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 */
|
/* go to dir */
|
||||||
if (*dir)
|
if (*dir)
|
||||||
|
|
7
vger.c
7
vger.c
|
@ -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
|
/* check if path starts with cgi_dir
|
||||||
* compare beginning of path with cgi_dir
|
* compare beginning of path with cgi_dir
|
||||||
* path + 2 : skip "./"
|
|
||||||
* cgi_dir + strlen(chrootdir) (skip chrootdir)
|
* 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 == '/')
|
while (*cgirp == '/')
|
||||||
estrlcpy(cgirp, cgirp+1, sizeof(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 */
|
return 1; /* not in cgi_dir, go to display_file */
|
||||||
|
|
||||||
/* set env variables for CGI
|
/* 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:
|
/* find next item after cgi_dir in path:
|
||||||
* path + 2 (skip "./") + strlen(cgirp) + 1 (skip '/')
|
* path + strlen(cgirp) + 1 (skip '/')
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* cgi file to execute */
|
/* 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 */
|
if (!(*cgifp)) /* problem with cgi file, abort */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue