From: Nishi Date: Wed, 18 Sep 2024 12:45:02 +0000 (+0000) Subject: add ServerRoot X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=88f3bf775037e009df6229d06c01c11fd4723cce;p=tewi.git add ServerRoot git-svn-id: file:///raid/svn-personal/tewi/trunk@61 8739d7e6-ffea-ec47-b151-bdff447c6205 --- diff --git a/Server/config.c b/Server/config.c index 18957f0..a61ded1 100644 --- a/Server/config.c +++ b/Server/config.c @@ -232,6 +232,13 @@ int tw_config_read(const char* path) { if(current->sslcert != NULL) free(current->sslcert); current->sslcert = cm_strdup(r[1]); } + } else if(cm_strcaseequ(r[0], "ServerRoot")) { + if(r[1] == NULL) { + cm_log("Config", "Missing path at line %d", ln); + stop = 1; + } else { + chdir(r[1]); + } } else if(cm_strcaseequ(r[0], "DocumentRoot")) { if(r[1] == NULL) { cm_log("Config", "Missing path at line %d", ln); diff --git a/Server/install.nsi b/Server/install.nsi index b0a60cf..ec67f26 100644 --- a/Server/install.nsi +++ b/Server/install.nsi @@ -13,17 +13,25 @@ Section CreateDirectory "$INSTDIR\etc" CreateDirectory "$INSTDIR\www" CreateDirectory "$INSTDIR\www\icons" + CreateDirectory "$INSTDIR\modules" CreateDirectory "$INSTDIR\bin" + SetOutPath "$INSTDIR" + File /oname=LICENSE.txt "../LICENSE" SetOutPath "$INSTDIR\bin" File "tewi.exe" + SetOutPath "$INSTDIR\modules" + File "../Module/*.dll" SetOutPath "$INSTDIR\etc" - File /oname=tewi.conf.default "../example-win.conf" + SetOverWrite off + File /oname=tewi.conf "../example-win.conf" SetOutPath "$INSTDIR\www" File /oname=index.html "../itworks.html" SetOutPath "$INSTDIR\www\icons" File "../Icons/*.png" + SetOverWrite on CreateDirectory "$SMPROGRAMS\Tewi HTTPd" + CreateShortcut "$SMPROGRAMS\Tewi HTTPd\License.lnk" "$INSTDIR\LICENSE.txt" "" CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd.lnk" "$INSTDIR\bin\tewi.exe" "" CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd (verbose).lnk" "$INSTDIR\bin\tewi.exe" "-v" CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Uninstall Tewi HTTPd.lnk" "$INSTDIR\uninstall.exe" "" @@ -32,8 +40,6 @@ Section WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteUninstaller "$INSTDIR\uninstall.exe" - - MessageBox MB_ICONEXCLAMATION|MB_OK "Example config is installed as $INSTDIR\etc\tewi.conf.default,$\r$\nBut Tewi HTTPd will try to use $INSTDIR\etc\tewi.conf." SectionEnd Section "Uninstall" diff --git a/Server/server.c b/Server/server.c index 7fa31c4..330ad67 100644 --- a/Server/server.c +++ b/Server/server.c @@ -482,6 +482,7 @@ void tw_server_pass(int sock, bool ssl, int port, SOCKADDR addr) { tw_http_error(s, sock, 403, name, port); } else if(S_ISDIR(st.st_mode)) { if(req.path[strlen(req.path) - 1] != '/') { + cm_log("Server", "Accessing directory without the slash at the end"); char* headers[3] = {"Location", cm_strcat(req.path, "/"), NULL}; _tw_process_page(s, sock, tw_http_status(308), NULL, NULL, NULL, 0, headers, 0, 0); free(headers[1]); diff --git a/example-win.conf b/example-win.conf index a92b5d0..490402a 100644 --- a/example-win.conf +++ b/example-win.conf @@ -1,29 +1,31 @@ -# $Id$ -# This is an example config - -Listen 80 -#ListenSSL 443 - -#SSLKey key.pem -#SSLCertificate cert.pem - -MIMEType all application/octet-stream -MIMEType .html text/html -MIMEType .txt text/plain -MIMEType .png image/png - -Icon all /icons/unknown.png -Icon text/* /icons/text.png -Icon image/* /icons/image.png -Icon misc/dir /icons/folder.png -Icon misc/parent /icons/parent.png - -DirectoryIndex index.html - -Readme README - -DocumentRoot C:/Tewi/www - -BeginDirectory C:/Tewi/www - Allow all -EndDirectory +# $Id$ +# This is an example config + +ServerRoot C:/Tewi + +Listen 80 +#ListenSSL 443 + +#SSLKey key.pem +#SSLCertificate cert.pem + +MIMEType all application/octet-stream +MIMEType .html text/html +MIMEType .txt text/plain +MIMEType .png image/png + +Icon all /icons/unknown.png +Icon text/* /icons/text.png +Icon image/* /icons/image.png +Icon misc/dir /icons/folder.png +Icon misc/parent /icons/parent.png + +DirectoryIndex index.html + +Readme README + +DocumentRoot C:/Tewi/www + +BeginDirectory C:/Tewi/www + Allow all +EndDirectory