- Timestamp:
- Sep 25, 2024, 10:35:04 PM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/README
r159 r161 1 1 2 Tewi HTTPd version 1.0 7A2 Tewi HTTPd version 1.08 3 3 4 4 Original by Nishi <nishi@nishi.boats> -
trunk/Server/config.c
r156 r161 103 103 config.defined[0] = NULL; 104 104 gethostname(config.hostname, 1024); 105 #ifdef HAS_CHROOT 106 tw_add_define("HAS_CHROOT"); 107 #endif 105 108 } 106 109 … … 274 277 } 275 278 #endif 279 #ifdef HAS_CHROOT 280 } else if(cm_strcaseequ(r[0], "ChrootDirectory")) { 281 if(r[1] == NULL) { 282 cm_log("Config", "Missing path at line %d", ln); 283 stop = 1; 284 } else { 285 if(current->chroot_path != NULL) free(current->chroot_path); 286 current->chroot_path = cm_strdup(r[1]); 287 } 288 #endif 276 289 } else if(cm_strcaseequ(r[0], "ForceLog")) { 277 290 if(r[1] == NULL) { … … 346 359 if(current->root != NULL) free(current->root); 347 360 current->root = cm_strdup(strcmp(r[1], "/") == 0 ? "" : r[1]); 348 }349 } else if(cm_strcaseequ(r[0], "ServerRoot")) {350 if(r[1] == NULL) {351 cm_log("Config", "Missing path at line %d", ln);352 stop = 1;353 } else {354 if(config.server_root != NULL) free(config.server_root);355 config.server_root = cm_strdup(r[1]);356 361 } 357 362 } else if(cm_strcaseequ(r[0], "MIMEType")) { -
trunk/Server/server.c
r141 r161 280 280 } else if(code == 404) { 281 281 return "404 Not Found"; 282 } else if(code == 500) { 283 return "500 Internal Server Error"; 282 284 } else { 283 285 return "400 Bad Request"; … … 508 510 } 509 511 } 512 bool rej = false; 510 513 cm_log("Server", "Host is %s", vhost); 511 514 int port = s == NULL ? 80 : 443; … … 521 524 cm_log("Server", "Hostname is `%s', port is `%d'", host, port); 522 525 struct tw_config_entry* vhost_entry = tw_vhost_match(host, port); 526 #ifdef HAS_CHROOT 527 char* chrootpath = vhost_entry->chroot_path != NULL ? vhost_entry->chroot_path : config.root.chroot_path; 528 if(chrootpath != NULL) { 529 if(chdir(chrootpath) == 0) { 530 if(chroot(".") == 0) { 531 cm_log("Server", "Chroot successful"); 532 } 533 } else { 534 cm_log("Server", "chdir() failed, cannot chroot"); 535 tw_http_error(s, sock, 500, name, port, vhost_entry); 536 rej = true; 537 } 538 } 539 #endif 523 540 for(i = 0; i < config.module_count; i++) { 524 541 tw_mod_request_t mod_req = (tw_mod_request_t)tw_module_symbol(config.modules[i], "mod_request"); … … 545 562 char* path = cm_strcat(vhost_entry->root == NULL ? "" : vhost_entry->root, req.path); 546 563 cm_log("Server", "Filesystem path is %s", path); 547 bool rej = false;548 564 #ifdef __MINGW32__ 549 565 char* rpath = cm_strdup(path); … … 777 793 } 778 794 } else { 779 tw_http_error(s, sock, 404, name, port, vhost_entry); 795 if(!rej) { 796 tw_http_error(s, sock, 404, name, port, vhost_entry); 797 } 780 798 } 781 799 free(path); -
trunk/Server/tw_version.h
r159 r161 8 8 #endif 9 9 10 #define TW_VERSION "1.0 7A\0"10 #define TW_VERSION "1.08\0" 11 11 12 12 const char* tw_get_version(void); -
trunk/Tool/genconf.c
r132 r161 43 43 printf("\n"); 44 44 printf("DocumentRoot %s/www\n", argv[1]); 45 printf("\n");46 45 printf("BeginDirectory %s/www\n", argv[1]); 47 printf(" \tAllow all\n");46 printf(" Allow all\n"); 48 47 printf("EndDirectory\n", argv[1]); 49 48 }
Note:
See TracChangeset
for help on using the changeset viewer.