Changeset 161 in Main for trunk/Server/server.c
- Timestamp:
- Sep 25, 2024, 10:35:04 PM (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.