Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Additional error diagnostics when the webserver fails. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
310ef51837b3118b1afcd60ac975185a |
User & Date: | drh 2007-12-21 22:13:45.000 |
Context
2007-12-23
| ||
12:56 | Get althttpd.c working on Mac OSX (check-in: b766f90b9f user: drh tags: trunk) | |
2007-12-21
| ||
22:13 | Additional error diagnostics when the webserver fails. (check-in: 310ef51837 user: drh tags: trunk) | |
2007-12-20
| ||
23:01 | Additional work toward denser hyperlinking in the documentation. (check-in: aa8a072b1b user: drh tags: trunk) | |
Changes
Changes to misc/althttpd.c.
︙ | ︙ | |||
174 175 176 177 178 179 180 | fprintf(log, "%s %s http://%s%s %s %s %d %d %g %g %g %g %d %d %s\n", zDate, zRemoteAddr, zHttpHost, zScript, zReferer, zReplyStatus, nIn, nOut, rScale*sTms.tms_utime, rScale*sTms.tms_stime, rScale*sTms.tms_cutime, rScale*sTms.tms_cstime, | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | fprintf(log, "%s %s http://%s%s %s %s %d %d %g %g %g %g %d %d %s\n", zDate, zRemoteAddr, zHttpHost, zScript, zReferer, zReplyStatus, nIn, nOut, rScale*sTms.tms_utime, rScale*sTms.tms_stime, rScale*sTms.tms_cutime, rScale*sTms.tms_cstime, (int)(now - beginTime), nRequest, zAgent ); fclose(log); nIn = nOut = 0; } } if( closeConnection ){ |
︙ | ︙ | |||
372 373 374 375 376 377 378 | MakeLogEntry(0); exit(0); } /* ** Tell the client that the server malfunctioned. */ | | > > | | > > > > > | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | MakeLogEntry(0); exit(0); } /* ** Tell the client that the server malfunctioned. */ static void Malfunction(int linenum, const char *zFormat, ...){ va_list ap; va_start(ap, zFormat); StartResponse("500 Server Malfunction"); nOut += printf( "Content-type: text/html\r\n" "\r\n" "<head><title>Server Malfunction</title></head>\n" "<body><h1>Server Malfunction</h1>\n" "<p>This web server has malfunctioned.\n\n" "(Error number: %d)</p>\n", linenum); if( zFormat ){ nOut += printf("<p>"); nOut += vprintf(zFormat, ap); nOut += printf("</p>\n\n"); } nOut += printf("</body>\n"); MakeLogEntry(0); exit(0); } /* ** Do a server redirect to the document specified. The document ** name not contain scheme or network location or the query string. |
︙ | ︙ | |||
517 518 519 520 521 522 523 | struct stat statbuf; /* Information about the file to be retrieved */ FILE *in; /* For reading from CGI scripts */ char zLine[1000]; /* A buffer for input lines or forming names */ /* Change directories to the root of the HTTP filesystem */ if( chdir(zRoot[0] ? zRoot : "/")!=0 ){ | > | > | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | struct stat statbuf; /* Information about the file to be retrieved */ FILE *in; /* For reading from CGI scripts */ char zLine[1000]; /* A buffer for input lines or forming names */ /* Change directories to the root of the HTTP filesystem */ if( chdir(zRoot[0] ? zRoot : "/")!=0 ){ char zBuf[1000]; Malfunction(__LINE__, "cannot chdir to [%s] from [%s]", zRoot, getcwd(zBuf,999)); } nRequest++; /* ** We must receive a complete header within 15 seconds */ signal(SIGALRM, Timeout); |
︙ | ︙ | |||
740 741 742 743 744 745 746 | } zHome = StrDup(zLine); /* Change directories to the root of the HTTP filesystem */ if( chdir(zHome)!=0 ){ | > | > | 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | } zHome = StrDup(zLine); /* Change directories to the root of the HTTP filesystem */ if( chdir(zHome)!=0 ){ char zBuf[1000]; Malfunction(__LINE__, "cannot chdir to [%s] from [%s]", zHome, getcwd(zBuf,999)); } /* Locate the file in the filesystem. We might have to append ** the name "index.html" in order to find it. Any excess path ** information is put into the zPathInfo variable. */ zLine[0] = '.'; |
︙ | ︙ | |||
841 842 843 844 845 846 847 | }; char *zBaseFilename; /* Filename without directory prefix */ /* If its executable, it must be a CGI program. Start by ** changing directories to the directory holding the program. */ if( chdir(zDir) ){ | > | > | 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 | }; char *zBaseFilename; /* Filename without directory prefix */ /* If its executable, it must be a CGI program. Start by ** changing directories to the directory holding the program. */ if( chdir(zDir) ){ char zBuf[1000]; Malfunction(__LINE__, "cannot chdir to [%s] from [%s]", zDir, getcwd(zBuf,999)); } /* Setup the environment appropriately. */ for(i=0; i<sizeof(cgienv)/sizeof(cgienv[0]); i++){ if( *cgienv[i].pzEnvValue ){ SetEnv(cgienv[i].zEnvName,*cgienv[i].pzEnvValue); |
︙ | ︙ | |||
1059 1060 1061 1062 1063 1064 1065 | argv += 2; argc -= 2; }else if( strcmp(argv[1],"-logfile")==0 ){ zLogFile = argv[2]; argv += 2; argc -= 2; }else{ | | | | | > > | | | 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | argv += 2; argc -= 2; }else if( strcmp(argv[1],"-logfile")==0 ){ zLogFile = argv[2]; argv += 2; argc -= 2; }else{ Malfunction(__LINE__, "unknown argument: [%s]", argv[1]); } } if( zRoot==0 ){ Malfunction(__LINE__, "no root directory specified"); } /* Change directories to the root of the HTTP filesystem */ if( chdir(zRoot)!=0 ){ Malfunction(__LINE__, "cannot change to directory [%s]", zRoot); } /* Attempt to go into a chroot jail as user zPermUser */ if( zPermUser ){ struct passwd *pwd = getpwnam(zPermUser); if( pwd ){ if( chroot(".")<0 ){ Malfunction(__LINE__, "unable to create chroot jail"); } setgid(pwd->pw_gid); setuid(pwd->pw_uid); zRoot = ""; }else{ Malfunction(__LINE__, "no home directory for user [%s]", zPermUser); } } if( getuid()==0 ){ Malfunction(__LINE__, "cannot run as root"); } /* Get the IP address from when the request originates */ { struct sockaddr_in remoteName; int size = sizeof(struct sockaddr_in); |
︙ | ︙ |