diff --git a/Module/Makefile b/Module/Makefile index fcf8c4b..14f6922 100644 --- a/Module/Makefile +++ b/Module/Makefile @@ -3,15 +3,15 @@ include $(PWD)/Platform/$(PLATFORM).mk .PHONY: all clean -.SUFFIXES: .c .o .so +.SUFFIXES: .c .o $(LIB) -all: mod_example.so mod_cgi.so +all: mod_cgi$(LIB) -.o.so: +.o$(LIB): $(CC) $(LDFLAGS) -shared -o $@ $< ../Common/common.a $(LIBS) .c.o: - $(CC) $(CFLAGS) -fPIC -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< clean: rm -f *.o *.so *.a diff --git a/Module/mod_cgi.c b/Module/mod_cgi.c index b4ec678..42df82f 100644 --- a/Module/mod_cgi.c +++ b/Module/mod_cgi.c @@ -2,6 +2,8 @@ #include "../Server/tw_module.h" +#include + int mod_init(struct tw_config* config, struct tw_tool* tools) { tools->log("CGI", "Initializing CGI module"); tools->add_version("CGI/1.1"); @@ -9,8 +11,10 @@ int mod_init(struct tw_config* config, struct tw_tool* tools) { } int mod_config(struct tw_tool* tools, char** argv, int argc) { - printf("args %d\n", argc); - return TW_CONFIG_ERROR; + if(cm_strcaseequ(argv[0], "AllowCGI")) { + return TW_CONFIG_PARSED; + } + return TW_CONFIG_NOTME; } int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_PASS; } diff --git a/Module/mod_example.c b/Module/mod_example.c index fb22373..6e8d9e2 100644 --- a/Module/mod_example.c +++ b/Module/mod_example.c @@ -1,4 +1,5 @@ /* $Id$ */ +/* This module will accept all directives, and always return 403 on the access. */ #include "../Server/tw_module.h" @@ -8,4 +9,6 @@ int mod_init(struct tw_config* config, struct tw_tool* tools) { return 0; } +int mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_PARSED; } + int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_ERROR(403); } diff --git a/Platform/generic.mk b/Platform/generic.mk index 5e45edb..2b73ed0 100644 --- a/Platform/generic.mk +++ b/Platform/generic.mk @@ -2,7 +2,7 @@ CC = cc AR = ar -CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common +CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC LDFLAGS = LIBS = EXEC = diff --git a/Platform/linux.mk b/Platform/linux.mk index 57ba10c..7c2b603 100644 --- a/Platform/linux.mk +++ b/Platform/linux.mk @@ -2,7 +2,7 @@ CC = cc AR = ar -CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -D_DEFAULT_SOURCE +CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -D_DEFAULT_SOURCE -fPIC LDFLAGS = LIBS = EXEC = diff --git a/Platform/win64.mk b/Platform/win64.mk index b353c38..265225b 100644 --- a/Platform/win64.mk +++ b/Platform/win64.mk @@ -4,7 +4,7 @@ PREFIX = C:/Tewi CC = x86_64-w64-mingw32-gcc AR = x86_64-w64-mingw32-ar -CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I $(PWD)/openssl/include +CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I $(PWD)/openssl/include -fPIC LDFLAGS = -L $(PWD)/openssl/lib LIBS = -lws2_32 EXEC = .exe diff --git a/example.conf b/example.conf index 9e662c5..3a63a02 100644 --- a/example.conf +++ b/example.conf @@ -29,3 +29,7 @@ DocumentRoot /var/www BeginDirectory / Allow all EndDirectory + +BeginDirectory /var/www/cgi-bin + AllowCGI +EndDirectory