Fossil SCM
Omit the /paniclog, /hacklog, and /logsummary pages. All those capabilities are now combined into the /errorlog page.
Commit
2304fb87ac93f4fc700f25722454e4d9dbebd56b78f61be2ea9b9dc35847e633
Parent
b3f270ffd657c22…
2 files changed
+115
-235
-20
+115
-235
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -804,37 +804,58 @@ | ||
| 804 | 804 | @ </pre></blockquote> |
| 805 | 805 | blob_reset(&fullname); |
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | -/* | |
| 810 | -** The maximum number of bytes of the error log to show by default. | |
| 811 | -*/ | |
| 812 | -#define MXSHOWLOG 500000 | |
| 813 | - | |
| 814 | 809 | /* |
| 815 | 810 | ** WEBPAGE: errorlog |
| 816 | 811 | ** |
| 817 | 812 | ** Show the content of the error log. Only the administrator can view |
| 818 | 813 | ** this page. |
| 814 | +** | |
| 815 | +** y=0x01 Show only hack attempts | |
| 816 | +** y=0x02 Show only panics and assertion faults | |
| 817 | +** y=0x04 Show hung backoffice processes | |
| 818 | +** y=0x40 Show other uncategorized messages | |
| 819 | +** | |
| 820 | +** If y is omitted or is zero, a count of the various message types is | |
| 821 | +** shown. | |
| 819 | 822 | */ |
| 820 | 823 | void errorlog_page(void){ |
| 821 | 824 | i64 szFile; |
| 822 | 825 | FILE *in; |
| 823 | 826 | char *zLog; |
| 827 | + int hasType = 0; | |
| 828 | + const char *zType = P("y"); | |
| 829 | + static const int eAllTypes = 0x47; | |
| 830 | + long eType = 0; | |
| 831 | + int bOutput = 0; | |
| 832 | + int prevWasTime = 0; | |
| 833 | + int nHack = 0; | |
| 834 | + int nPanic = 0; | |
| 835 | + int nOther = 0; | |
| 836 | + int nHang = 0; | |
| 824 | 837 | char z[10000]; |
| 838 | + char zTime[10000]; | |
| 839 | + | |
| 825 | 840 | login_check_credentials(); |
| 826 | 841 | if( !g.perm.Admin ){ |
| 827 | 842 | login_needed(0); |
| 828 | 843 | return; |
| 829 | 844 | } |
| 845 | + if( zType ){ | |
| 846 | + eType = strtol(zType,0,0) & eAllTypes; | |
| 847 | + } | |
| 830 | 848 | style_header("Server Error Log"); |
| 831 | 849 | style_submenu_element("Test", "%R/test-warning"); |
| 832 | 850 | style_submenu_element("Refresh", "%R/errorlog"); |
| 851 | + style_submenu_element("Download", "%R/errorlog?download"); | |
| 852 | + style_submenu_element("Truncate", "%R/errorlog?truncate"); | |
| 833 | 853 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 834 | - style_submenu_element("Panics", "%R/paniclog"); | |
| 835 | - style_submenu_element("Non-Hacks", "%R/hacklog?not"); | |
| 854 | + if( eType ){ | |
| 855 | + style_submenu_element("Summary", "%R/errorlog"); | |
| 856 | + } | |
| 836 | 857 | |
| 837 | 858 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 838 | 859 | no_error_log_available(); |
| 839 | 860 | style_finish_page(); |
| 840 | 861 | return; |
| @@ -861,250 +882,109 @@ | ||
| 861 | 882 | return; |
| 862 | 883 | } |
| 863 | 884 | zLog = file_canonical_name_dup(g.zErrlog); |
| 864 | 885 | @ <p>The server error log at "%h(zLog)" is %,lld(szFile) bytes in size. |
| 865 | 886 | fossil_free(zLog); |
| 866 | - style_submenu_element("Download", "%R/errorlog?download"); | |
| 867 | - style_submenu_element("Truncate", "%R/errorlog?truncate"); | |
| 868 | 887 | in = fossil_fopen(g.zErrlog, "rb"); |
| 869 | 888 | if( in==0 ){ |
| 870 | 889 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| 871 | 890 | style_finish_page(); |
| 872 | 891 | return; |
| 873 | 892 | } |
| 874 | - if( szFile>MXSHOWLOG && P("all")==0 ){ | |
| 875 | - @ <form action="%R/errorlog" method="POST"> | |
| 876 | - @ <p>Only the last %,d(MXSHOWLOG) bytes are shown. | |
| 877 | - @ <input type="submit" name="all" value="Show All"> | |
| 878 | - @ </form> | |
| 879 | - fseek(in, -MXSHOWLOG, SEEK_END); | |
| 880 | - } | |
| 881 | - @ <hr> | |
| 882 | - @ <pre> | |
| 883 | - while( fgets(z, sizeof(z), in) ){ | |
| 884 | - @ %h(z)\ | |
| 885 | - } | |
| 886 | - fclose(in); | |
| 887 | - @ </pre> | |
| 888 | - style_finish_page(); | |
| 889 | -} | |
| 890 | - | |
| 891 | -/* | |
| 892 | -** WEBPAGE: paniclog | |
| 893 | -** | |
| 894 | -** Scan the error log for panics. Show all panic messages, ignoring all | |
| 895 | -** other error log entries. | |
| 896 | -*/ | |
| 897 | -void paniclog_page(void){ | |
| 898 | - i64 szFile; | |
| 899 | - char *zLog; | |
| 900 | - FILE *in; | |
| 901 | - int bOutput = 0; | |
| 902 | - int prevWasTime = 0; | |
| 903 | - char z[10000]; | |
| 904 | - char zTime[10000]; | |
| 905 | - | |
| 906 | - login_check_credentials(); | |
| 907 | - if( !g.perm.Admin ){ | |
| 908 | - login_needed(0); | |
| 909 | - return; | |
| 910 | - } | |
| 911 | - style_header("Server Panic Log"); | |
| 912 | - style_submenu_element("Log-Menu", "%R/setup-logmenu"); | |
| 913 | - | |
| 914 | - if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ | |
| 915 | - no_error_log_available(); | |
| 916 | - style_finish_page(); | |
| 917 | - return; | |
| 918 | - } | |
| 919 | - in = fossil_fopen(g.zErrlog, "rb"); | |
| 920 | - if( in==0 ){ | |
| 921 | - @ <p class='generalError'>Unable to open that file for reading!</p> | |
| 922 | - style_finish_page(); | |
| 923 | - return; | |
| 924 | - } | |
| 925 | - szFile = file_size(g.zErrlog, ExtFILE); | |
| 926 | - zLog = file_canonical_name_dup(g.zErrlog); | |
| 927 | - @ Panic messages contained within the %lld(szFile)-byte | |
| 928 | - @ <a href="%R/errorlog?all">error log</a> found at | |
| 929 | - @ "%h(zLog)". | |
| 930 | - fossil_free(zLog); | |
| 931 | - @ <hr> | |
| 932 | - @ <pre> | |
| 933 | - while( fgets(z, sizeof(z), in) ){ | |
| 934 | - if( prevWasTime | |
| 935 | - && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) | |
| 936 | - ){ | |
| 937 | - @ %h(zTime)\ | |
| 938 | - bOutput = 1; | |
| 893 | + if( eType==0 ){ | |
| 894 | + /* will do a summary */ | |
| 895 | + }else if( (eType&eAllTypes)!=eAllTypes ){ | |
| 896 | + @ Only the following types of messages displayed: | |
| 897 | + @ <ul> | |
| 898 | + if( eType & 0x01 ){ | |
| 899 | + @ <li>Hack attempts | |
| 900 | + } | |
| 901 | + if( eType & 0x02 ){ | |
| 902 | + @ <li>Panics and assertion faults | |
| 903 | + } | |
| 904 | + if( eType & 0x04 ){ | |
| 905 | + @ <li>Hung backoffice processes | |
| 906 | + } | |
| 907 | + if( eType & 0x40 ){ | |
| 908 | + @ <li>Other uncategorized messages | |
| 909 | + } | |
| 910 | + @ </ul> | |
| 911 | + } | |
| 912 | + @ <hr> | |
| 913 | + if( eType ){ | |
| 914 | + @ <pre> | |
| 915 | + } | |
| 916 | + while( fgets(z, sizeof(z), in) ){ | |
| 917 | + if( prevWasTime ){ | |
| 918 | + if( strncmp(z,"possible hack attempt - 418 ", 27)==0 ){ | |
| 919 | + bOutput = (eType & 0x01)!=0; | |
| 920 | + nHack++; | |
| 921 | + }else | |
| 922 | + if( (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) ){ | |
| 923 | + bOutput = (eType & 0x02)!=0; | |
| 924 | + nPanic++; | |
| 925 | + }else | |
| 926 | + if( sqlite3_strglob("warning: backoffice process * still *",z)==0 ){ | |
| 927 | + bOutput = (eType & 0x04)!=0; | |
| 928 | + nHang++; | |
| 929 | + }else{ | |
| 930 | + bOutput = (eType & 0x40)!=0; | |
| 931 | + nOther++; | |
| 932 | + } | |
| 933 | + if( bOutput ){ | |
| 934 | + @ %h(zTime)\ | |
| 935 | + } | |
| 939 | 936 | } |
| 940 | 937 | if( strncmp(z, "--------", 8)==0 ){ |
| 941 | 938 | size_t n = strlen(z); |
| 942 | 939 | memcpy(zTime, z, n+1); |
| 943 | 940 | prevWasTime = 1; |
| 944 | 941 | bOutput = 0; |
| 945 | 942 | }else{ |
| 946 | 943 | prevWasTime = 0; |
| 947 | 944 | } |
| 948 | - if( bOutput ){ | |
| 949 | - @ %h(z)\ | |
| 950 | - } | |
| 951 | - } | |
| 952 | - fclose(in); | |
| 953 | - @ </pre> | |
| 954 | - style_finish_page(); | |
| 955 | -} | |
| 956 | - | |
| 957 | -/* | |
| 958 | -** WEBPAGE: hacklog | |
| 959 | -** | |
| 960 | -** Scan the error log for "possible hack attempt" entries Show hack | |
| 961 | -** attempt messages only, omitting all others. Or if the "not" query | |
| 962 | -** parameter is present, show only messages that are not hack attempts. | |
| 963 | -*/ | |
| 964 | -void hacklog_page(void){ | |
| 965 | - i64 szFile; | |
| 966 | - char *zLog; | |
| 967 | - FILE *in; | |
| 968 | - int bOutput = 0; | |
| 969 | - int prevWasTime = 0; | |
| 970 | - int isNot = P("not")!=0; | |
| 971 | - char z[10000]; | |
| 972 | - char zTime[10000]; | |
| 973 | - | |
| 974 | - login_check_credentials(); | |
| 975 | - if( !g.perm.Admin ){ | |
| 976 | - login_needed(0); | |
| 977 | - return; | |
| 978 | - } | |
| 979 | - style_header("Server Hack Log"); | |
| 980 | - style_submenu_element("Log-Menu", "%R/setup-logmenu"); | |
| 981 | - | |
| 982 | - if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ | |
| 983 | - no_error_log_available(); | |
| 984 | - style_finish_page(); | |
| 985 | - return; | |
| 986 | - } | |
| 987 | - in = fossil_fopen(g.zErrlog, "rb"); | |
| 988 | - if( in==0 ){ | |
| 989 | - @ <p class='generalError'>Unable to open that file for reading!</p> | |
| 990 | - style_finish_page(); | |
| 991 | - return; | |
| 992 | - } | |
| 993 | - szFile = file_size(g.zErrlog, ExtFILE); | |
| 994 | - zLog = file_canonical_name_dup(g.zErrlog); | |
| 995 | - @ %s(isNot?"Non-hack":"Hack") messages contained within the %lld(szFile)-byte | |
| 996 | - @ <a href="%R/errorlog?all">error log</a> found at | |
| 997 | - @ "%h(zLog)". | |
| 998 | - fossil_free(zLog); | |
| 999 | - @ <hr> | |
| 1000 | - @ <pre> | |
| 1001 | - while( fgets(z, sizeof(z), in) ){ | |
| 1002 | - if( prevWasTime | |
| 1003 | - && ((strncmp(z,"possible hack attempt - 418 ", 27)==0) ^ isNot) | |
| 1004 | - ){ | |
| 1005 | - @ %h(zTime)\ | |
| 1006 | - bOutput = 1; | |
| 1007 | - } | |
| 1008 | - if( strncmp(z, "--------", 8)==0 ){ | |
| 1009 | - size_t n = strlen(z); | |
| 1010 | - memcpy(zTime, z, n+1); | |
| 1011 | - prevWasTime = 1; | |
| 1012 | - bOutput = 0; | |
| 1013 | - }else{ | |
| 1014 | - prevWasTime = 0; | |
| 1015 | - } | |
| 1016 | - if( bOutput ){ | |
| 1017 | - @ %h(z)\ | |
| 1018 | - } | |
| 1019 | - } | |
| 1020 | - fclose(in); | |
| 1021 | - @ </pre> | |
| 1022 | - style_finish_page(); | |
| 1023 | -} | |
| 1024 | - | |
| 1025 | -/* | |
| 1026 | -** WEBPAGE: logsummary | |
| 1027 | -** | |
| 1028 | -** Scan the error log and count the various kinds of entries. | |
| 1029 | -*/ | |
| 1030 | -void logsummary_page(void){ | |
| 1031 | - i64 szFile; | |
| 1032 | - char *zLog; | |
| 1033 | - FILE *in; | |
| 1034 | - int prevWasTime = 0; | |
| 1035 | - int nHack = 0; | |
| 1036 | - int nPanic = 0; | |
| 1037 | - int nOther = 0; | |
| 1038 | - int nTotal = 0; | |
| 1039 | - char z[10000]; | |
| 1040 | - | |
| 1041 | - login_check_credentials(); | |
| 1042 | - if( !g.perm.Admin ){ | |
| 1043 | - login_needed(0); | |
| 1044 | - return; | |
| 1045 | - } | |
| 1046 | - style_header("Server Hack Log"); | |
| 1047 | - style_submenu_element("Log-Menu", "%R/setup-logmenu"); | |
| 1048 | - | |
| 1049 | - if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ | |
| 1050 | - no_error_log_available(); | |
| 1051 | - style_finish_page(); | |
| 1052 | - return; | |
| 1053 | - } | |
| 1054 | - in = fossil_fopen(g.zErrlog, "rb"); | |
| 1055 | - if( in==0 ){ | |
| 1056 | - @ <p class='generalError'>Unable to open that file for reading!</p> | |
| 1057 | - style_finish_page(); | |
| 1058 | - return; | |
| 1059 | - } | |
| 1060 | - szFile = file_size(g.zErrlog, ExtFILE); | |
| 1061 | - zLog = file_canonical_name_dup(g.zErrlog); | |
| 1062 | - @ Summary of messages contained within the %lld(szFile)-byte | |
| 1063 | - @ <a href="%R/errorlog?all">error log</a> found at | |
| 1064 | - @ "%h(zLog)". | |
| 1065 | - fossil_free(zLog); | |
| 1066 | - @ <hr> | |
| 1067 | - while( fgets(z, sizeof(z), in) ){ | |
| 1068 | - if( prevWasTime | |
| 1069 | - && (strncmp(z,"possible hack attempt - 418 ", 27)==0) | |
| 1070 | - ){ | |
| 1071 | - nHack++; | |
| 1072 | - prevWasTime = 0; | |
| 1073 | - continue; | |
| 1074 | - } | |
| 1075 | - if( prevWasTime | |
| 1076 | - && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) | |
| 1077 | - ){ | |
| 1078 | - nPanic++; | |
| 1079 | - prevWasTime = 0; | |
| 1080 | - continue; | |
| 1081 | - } | |
| 1082 | - if( prevWasTime ) nOther++; | |
| 1083 | - if( strncmp(z, "--------", 8)==0 ){ | |
| 1084 | - nTotal++; | |
| 1085 | - prevWasTime = 1; | |
| 1086 | - continue; | |
| 1087 | - } | |
| 1088 | - prevWasTime = 0; | |
| 1089 | - } | |
| 1090 | - fclose(in); | |
| 1091 | - @ <p><table border="a" cellspacing="0" cellpadding="5"> | |
| 1092 | - @ <tr><td align="right">%d(nPanic)</td> | |
| 1093 | - if( nPanic>0 ){ | |
| 1094 | - @ <td><a href="./paniclog">Panics</a></td> | |
| 1095 | - } else { | |
| 1096 | - @ <td>Panics</td> | |
| 1097 | - } | |
| 1098 | - @ <tr><td align="right">%d(nHack)</td> | |
| 1099 | - if( nHack>0 ){ | |
| 1100 | - @ <td><a href="./hacklog">Hack Attempts</a></td> | |
| 1101 | - }else{ | |
| 1102 | - @ <td>Hack Attempts</td> | |
| 1103 | - } | |
| 1104 | - @ <tr><td align="right">%d(nOther)</td> | |
| 1105 | - @ <td>Other</td> | |
| 1106 | - @ <tr><td align="right">%d(nTotal)</td> | |
| 1107 | - @ <td>Total Messages</td> | |
| 1108 | - @ </table> | |
| 945 | + if( bOutput && eType ){ | |
| 946 | + @ %h(z)\ | |
| 947 | + } | |
| 948 | + } | |
| 949 | + fclose(in); | |
| 950 | + if( eType ){ | |
| 951 | + @ </pre> | |
| 952 | + } | |
| 953 | + if( eType==0 ){ | |
| 954 | + int nNonHack = nPanic+nHang+nOther; | |
| 955 | + int nTotal = nNonHack + nHack; | |
| 956 | + @ <p><table border="a" cellspacing="0" cellpadding="5"> | |
| 957 | + @ <tr><td align="right">%d(nPanic)</td> | |
| 958 | + if( nPanic>0 ){ | |
| 959 | + @ <td><a href="./errorlog?y=2">Panics</a></td> | |
| 960 | + } else { | |
| 961 | + @ <td>Panics</td> | |
| 962 | + } | |
| 963 | + @ <tr><td align="right">%d(nHack)</td> | |
| 964 | + if( nHack>0 ){ | |
| 965 | + @ <td><a href="./errorlog?y=1">Hack Attempts</a></td> | |
| 966 | + if( nNonHack ){ | |
| 967 | + @ <tr><td align="right">%d(nNonHack)</td> | |
| 968 | + @ <td><a href="%R/errorlog?y=70">Other than hack attempts</a></td> | |
| 969 | + } | |
| 970 | + }else{ | |
| 971 | + @ <td>Hack Attempts</td> | |
| 972 | + } | |
| 973 | + @ <tr><td align="right">%d(nHang)</td> | |
| 974 | + if( nHang>0 ){ | |
| 975 | + @ <td><a href="./errorlog?y=4/">Hung Backoffice</a></td> | |
| 976 | + }else{ | |
| 977 | + @ <td>Hung Backoffice</td> | |
| 978 | + } | |
| 979 | + @ <tr><td align="right">%d(nHang)</td> | |
| 980 | + if( nOther>0 ){ | |
| 981 | + @ <td><a href="./errorlog?y=64/">Other</a></td> | |
| 982 | + }else{ | |
| 983 | + @ <td>Other</td> | |
| 984 | + } | |
| 985 | + @ <tr><td align="right">%d(nTotal)</td> | |
| 986 | + @ <td><a href="./errorlog">All Messages</a></td> | |
| 987 | + @ </table> | |
| 988 | + } | |
| 1109 | 989 | style_finish_page(); |
| 1110 | 990 | } |
| 1111 | 991 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -804,37 +804,58 @@ | |
| 804 | @ </pre></blockquote> |
| 805 | blob_reset(&fullname); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | /* |
| 810 | ** The maximum number of bytes of the error log to show by default. |
| 811 | */ |
| 812 | #define MXSHOWLOG 500000 |
| 813 | |
| 814 | /* |
| 815 | ** WEBPAGE: errorlog |
| 816 | ** |
| 817 | ** Show the content of the error log. Only the administrator can view |
| 818 | ** this page. |
| 819 | */ |
| 820 | void errorlog_page(void){ |
| 821 | i64 szFile; |
| 822 | FILE *in; |
| 823 | char *zLog; |
| 824 | char z[10000]; |
| 825 | login_check_credentials(); |
| 826 | if( !g.perm.Admin ){ |
| 827 | login_needed(0); |
| 828 | return; |
| 829 | } |
| 830 | style_header("Server Error Log"); |
| 831 | style_submenu_element("Test", "%R/test-warning"); |
| 832 | style_submenu_element("Refresh", "%R/errorlog"); |
| 833 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 834 | style_submenu_element("Panics", "%R/paniclog"); |
| 835 | style_submenu_element("Non-Hacks", "%R/hacklog?not"); |
| 836 | |
| 837 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 838 | no_error_log_available(); |
| 839 | style_finish_page(); |
| 840 | return; |
| @@ -861,250 +882,109 @@ | |
| 861 | return; |
| 862 | } |
| 863 | zLog = file_canonical_name_dup(g.zErrlog); |
| 864 | @ <p>The server error log at "%h(zLog)" is %,lld(szFile) bytes in size. |
| 865 | fossil_free(zLog); |
| 866 | style_submenu_element("Download", "%R/errorlog?download"); |
| 867 | style_submenu_element("Truncate", "%R/errorlog?truncate"); |
| 868 | in = fossil_fopen(g.zErrlog, "rb"); |
| 869 | if( in==0 ){ |
| 870 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| 871 | style_finish_page(); |
| 872 | return; |
| 873 | } |
| 874 | if( szFile>MXSHOWLOG && P("all")==0 ){ |
| 875 | @ <form action="%R/errorlog" method="POST"> |
| 876 | @ <p>Only the last %,d(MXSHOWLOG) bytes are shown. |
| 877 | @ <input type="submit" name="all" value="Show All"> |
| 878 | @ </form> |
| 879 | fseek(in, -MXSHOWLOG, SEEK_END); |
| 880 | } |
| 881 | @ <hr> |
| 882 | @ <pre> |
| 883 | while( fgets(z, sizeof(z), in) ){ |
| 884 | @ %h(z)\ |
| 885 | } |
| 886 | fclose(in); |
| 887 | @ </pre> |
| 888 | style_finish_page(); |
| 889 | } |
| 890 | |
| 891 | /* |
| 892 | ** WEBPAGE: paniclog |
| 893 | ** |
| 894 | ** Scan the error log for panics. Show all panic messages, ignoring all |
| 895 | ** other error log entries. |
| 896 | */ |
| 897 | void paniclog_page(void){ |
| 898 | i64 szFile; |
| 899 | char *zLog; |
| 900 | FILE *in; |
| 901 | int bOutput = 0; |
| 902 | int prevWasTime = 0; |
| 903 | char z[10000]; |
| 904 | char zTime[10000]; |
| 905 | |
| 906 | login_check_credentials(); |
| 907 | if( !g.perm.Admin ){ |
| 908 | login_needed(0); |
| 909 | return; |
| 910 | } |
| 911 | style_header("Server Panic Log"); |
| 912 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 913 | |
| 914 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 915 | no_error_log_available(); |
| 916 | style_finish_page(); |
| 917 | return; |
| 918 | } |
| 919 | in = fossil_fopen(g.zErrlog, "rb"); |
| 920 | if( in==0 ){ |
| 921 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| 922 | style_finish_page(); |
| 923 | return; |
| 924 | } |
| 925 | szFile = file_size(g.zErrlog, ExtFILE); |
| 926 | zLog = file_canonical_name_dup(g.zErrlog); |
| 927 | @ Panic messages contained within the %lld(szFile)-byte |
| 928 | @ <a href="%R/errorlog?all">error log</a> found at |
| 929 | @ "%h(zLog)". |
| 930 | fossil_free(zLog); |
| 931 | @ <hr> |
| 932 | @ <pre> |
| 933 | while( fgets(z, sizeof(z), in) ){ |
| 934 | if( prevWasTime |
| 935 | && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) |
| 936 | ){ |
| 937 | @ %h(zTime)\ |
| 938 | bOutput = 1; |
| 939 | } |
| 940 | if( strncmp(z, "--------", 8)==0 ){ |
| 941 | size_t n = strlen(z); |
| 942 | memcpy(zTime, z, n+1); |
| 943 | prevWasTime = 1; |
| 944 | bOutput = 0; |
| 945 | }else{ |
| 946 | prevWasTime = 0; |
| 947 | } |
| 948 | if( bOutput ){ |
| 949 | @ %h(z)\ |
| 950 | } |
| 951 | } |
| 952 | fclose(in); |
| 953 | @ </pre> |
| 954 | style_finish_page(); |
| 955 | } |
| 956 | |
| 957 | /* |
| 958 | ** WEBPAGE: hacklog |
| 959 | ** |
| 960 | ** Scan the error log for "possible hack attempt" entries Show hack |
| 961 | ** attempt messages only, omitting all others. Or if the "not" query |
| 962 | ** parameter is present, show only messages that are not hack attempts. |
| 963 | */ |
| 964 | void hacklog_page(void){ |
| 965 | i64 szFile; |
| 966 | char *zLog; |
| 967 | FILE *in; |
| 968 | int bOutput = 0; |
| 969 | int prevWasTime = 0; |
| 970 | int isNot = P("not")!=0; |
| 971 | char z[10000]; |
| 972 | char zTime[10000]; |
| 973 | |
| 974 | login_check_credentials(); |
| 975 | if( !g.perm.Admin ){ |
| 976 | login_needed(0); |
| 977 | return; |
| 978 | } |
| 979 | style_header("Server Hack Log"); |
| 980 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 981 | |
| 982 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 983 | no_error_log_available(); |
| 984 | style_finish_page(); |
| 985 | return; |
| 986 | } |
| 987 | in = fossil_fopen(g.zErrlog, "rb"); |
| 988 | if( in==0 ){ |
| 989 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| 990 | style_finish_page(); |
| 991 | return; |
| 992 | } |
| 993 | szFile = file_size(g.zErrlog, ExtFILE); |
| 994 | zLog = file_canonical_name_dup(g.zErrlog); |
| 995 | @ %s(isNot?"Non-hack":"Hack") messages contained within the %lld(szFile)-byte |
| 996 | @ <a href="%R/errorlog?all">error log</a> found at |
| 997 | @ "%h(zLog)". |
| 998 | fossil_free(zLog); |
| 999 | @ <hr> |
| 1000 | @ <pre> |
| 1001 | while( fgets(z, sizeof(z), in) ){ |
| 1002 | if( prevWasTime |
| 1003 | && ((strncmp(z,"possible hack attempt - 418 ", 27)==0) ^ isNot) |
| 1004 | ){ |
| 1005 | @ %h(zTime)\ |
| 1006 | bOutput = 1; |
| 1007 | } |
| 1008 | if( strncmp(z, "--------", 8)==0 ){ |
| 1009 | size_t n = strlen(z); |
| 1010 | memcpy(zTime, z, n+1); |
| 1011 | prevWasTime = 1; |
| 1012 | bOutput = 0; |
| 1013 | }else{ |
| 1014 | prevWasTime = 0; |
| 1015 | } |
| 1016 | if( bOutput ){ |
| 1017 | @ %h(z)\ |
| 1018 | } |
| 1019 | } |
| 1020 | fclose(in); |
| 1021 | @ </pre> |
| 1022 | style_finish_page(); |
| 1023 | } |
| 1024 | |
| 1025 | /* |
| 1026 | ** WEBPAGE: logsummary |
| 1027 | ** |
| 1028 | ** Scan the error log and count the various kinds of entries. |
| 1029 | */ |
| 1030 | void logsummary_page(void){ |
| 1031 | i64 szFile; |
| 1032 | char *zLog; |
| 1033 | FILE *in; |
| 1034 | int prevWasTime = 0; |
| 1035 | int nHack = 0; |
| 1036 | int nPanic = 0; |
| 1037 | int nOther = 0; |
| 1038 | int nTotal = 0; |
| 1039 | char z[10000]; |
| 1040 | |
| 1041 | login_check_credentials(); |
| 1042 | if( !g.perm.Admin ){ |
| 1043 | login_needed(0); |
| 1044 | return; |
| 1045 | } |
| 1046 | style_header("Server Hack Log"); |
| 1047 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 1048 | |
| 1049 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 1050 | no_error_log_available(); |
| 1051 | style_finish_page(); |
| 1052 | return; |
| 1053 | } |
| 1054 | in = fossil_fopen(g.zErrlog, "rb"); |
| 1055 | if( in==0 ){ |
| 1056 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| 1057 | style_finish_page(); |
| 1058 | return; |
| 1059 | } |
| 1060 | szFile = file_size(g.zErrlog, ExtFILE); |
| 1061 | zLog = file_canonical_name_dup(g.zErrlog); |
| 1062 | @ Summary of messages contained within the %lld(szFile)-byte |
| 1063 | @ <a href="%R/errorlog?all">error log</a> found at |
| 1064 | @ "%h(zLog)". |
| 1065 | fossil_free(zLog); |
| 1066 | @ <hr> |
| 1067 | while( fgets(z, sizeof(z), in) ){ |
| 1068 | if( prevWasTime |
| 1069 | && (strncmp(z,"possible hack attempt - 418 ", 27)==0) |
| 1070 | ){ |
| 1071 | nHack++; |
| 1072 | prevWasTime = 0; |
| 1073 | continue; |
| 1074 | } |
| 1075 | if( prevWasTime |
| 1076 | && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) |
| 1077 | ){ |
| 1078 | nPanic++; |
| 1079 | prevWasTime = 0; |
| 1080 | continue; |
| 1081 | } |
| 1082 | if( prevWasTime ) nOther++; |
| 1083 | if( strncmp(z, "--------", 8)==0 ){ |
| 1084 | nTotal++; |
| 1085 | prevWasTime = 1; |
| 1086 | continue; |
| 1087 | } |
| 1088 | prevWasTime = 0; |
| 1089 | } |
| 1090 | fclose(in); |
| 1091 | @ <p><table border="a" cellspacing="0" cellpadding="5"> |
| 1092 | @ <tr><td align="right">%d(nPanic)</td> |
| 1093 | if( nPanic>0 ){ |
| 1094 | @ <td><a href="./paniclog">Panics</a></td> |
| 1095 | } else { |
| 1096 | @ <td>Panics</td> |
| 1097 | } |
| 1098 | @ <tr><td align="right">%d(nHack)</td> |
| 1099 | if( nHack>0 ){ |
| 1100 | @ <td><a href="./hacklog">Hack Attempts</a></td> |
| 1101 | }else{ |
| 1102 | @ <td>Hack Attempts</td> |
| 1103 | } |
| 1104 | @ <tr><td align="right">%d(nOther)</td> |
| 1105 | @ <td>Other</td> |
| 1106 | @ <tr><td align="right">%d(nTotal)</td> |
| 1107 | @ <td>Total Messages</td> |
| 1108 | @ </table> |
| 1109 | style_finish_page(); |
| 1110 | } |
| 1111 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -804,37 +804,58 @@ | |
| 804 | @ </pre></blockquote> |
| 805 | blob_reset(&fullname); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | /* |
| 810 | ** WEBPAGE: errorlog |
| 811 | ** |
| 812 | ** Show the content of the error log. Only the administrator can view |
| 813 | ** this page. |
| 814 | ** |
| 815 | ** y=0x01 Show only hack attempts |
| 816 | ** y=0x02 Show only panics and assertion faults |
| 817 | ** y=0x04 Show hung backoffice processes |
| 818 | ** y=0x40 Show other uncategorized messages |
| 819 | ** |
| 820 | ** If y is omitted or is zero, a count of the various message types is |
| 821 | ** shown. |
| 822 | */ |
| 823 | void errorlog_page(void){ |
| 824 | i64 szFile; |
| 825 | FILE *in; |
| 826 | char *zLog; |
| 827 | int hasType = 0; |
| 828 | const char *zType = P("y"); |
| 829 | static const int eAllTypes = 0x47; |
| 830 | long eType = 0; |
| 831 | int bOutput = 0; |
| 832 | int prevWasTime = 0; |
| 833 | int nHack = 0; |
| 834 | int nPanic = 0; |
| 835 | int nOther = 0; |
| 836 | int nHang = 0; |
| 837 | char z[10000]; |
| 838 | char zTime[10000]; |
| 839 | |
| 840 | login_check_credentials(); |
| 841 | if( !g.perm.Admin ){ |
| 842 | login_needed(0); |
| 843 | return; |
| 844 | } |
| 845 | if( zType ){ |
| 846 | eType = strtol(zType,0,0) & eAllTypes; |
| 847 | } |
| 848 | style_header("Server Error Log"); |
| 849 | style_submenu_element("Test", "%R/test-warning"); |
| 850 | style_submenu_element("Refresh", "%R/errorlog"); |
| 851 | style_submenu_element("Download", "%R/errorlog?download"); |
| 852 | style_submenu_element("Truncate", "%R/errorlog?truncate"); |
| 853 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 854 | if( eType ){ |
| 855 | style_submenu_element("Summary", "%R/errorlog"); |
| 856 | } |
| 857 | |
| 858 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 859 | no_error_log_available(); |
| 860 | style_finish_page(); |
| 861 | return; |
| @@ -861,250 +882,109 @@ | |
| 882 | return; |
| 883 | } |
| 884 | zLog = file_canonical_name_dup(g.zErrlog); |
| 885 | @ <p>The server error log at "%h(zLog)" is %,lld(szFile) bytes in size. |
| 886 | fossil_free(zLog); |
| 887 | in = fossil_fopen(g.zErrlog, "rb"); |
| 888 | if( in==0 ){ |
| 889 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| 890 | style_finish_page(); |
| 891 | return; |
| 892 | } |
| 893 | if( eType==0 ){ |
| 894 | /* will do a summary */ |
| 895 | }else if( (eType&eAllTypes)!=eAllTypes ){ |
| 896 | @ Only the following types of messages displayed: |
| 897 | @ <ul> |
| 898 | if( eType & 0x01 ){ |
| 899 | @ <li>Hack attempts |
| 900 | } |
| 901 | if( eType & 0x02 ){ |
| 902 | @ <li>Panics and assertion faults |
| 903 | } |
| 904 | if( eType & 0x04 ){ |
| 905 | @ <li>Hung backoffice processes |
| 906 | } |
| 907 | if( eType & 0x40 ){ |
| 908 | @ <li>Other uncategorized messages |
| 909 | } |
| 910 | @ </ul> |
| 911 | } |
| 912 | @ <hr> |
| 913 | if( eType ){ |
| 914 | @ <pre> |
| 915 | } |
| 916 | while( fgets(z, sizeof(z), in) ){ |
| 917 | if( prevWasTime ){ |
| 918 | if( strncmp(z,"possible hack attempt - 418 ", 27)==0 ){ |
| 919 | bOutput = (eType & 0x01)!=0; |
| 920 | nHack++; |
| 921 | }else |
| 922 | if( (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) ){ |
| 923 | bOutput = (eType & 0x02)!=0; |
| 924 | nPanic++; |
| 925 | }else |
| 926 | if( sqlite3_strglob("warning: backoffice process * still *",z)==0 ){ |
| 927 | bOutput = (eType & 0x04)!=0; |
| 928 | nHang++; |
| 929 | }else{ |
| 930 | bOutput = (eType & 0x40)!=0; |
| 931 | nOther++; |
| 932 | } |
| 933 | if( bOutput ){ |
| 934 | @ %h(zTime)\ |
| 935 | } |
| 936 | } |
| 937 | if( strncmp(z, "--------", 8)==0 ){ |
| 938 | size_t n = strlen(z); |
| 939 | memcpy(zTime, z, n+1); |
| 940 | prevWasTime = 1; |
| 941 | bOutput = 0; |
| 942 | }else{ |
| 943 | prevWasTime = 0; |
| 944 | } |
| 945 | if( bOutput && eType ){ |
| 946 | @ %h(z)\ |
| 947 | } |
| 948 | } |
| 949 | fclose(in); |
| 950 | if( eType ){ |
| 951 | @ </pre> |
| 952 | } |
| 953 | if( eType==0 ){ |
| 954 | int nNonHack = nPanic+nHang+nOther; |
| 955 | int nTotal = nNonHack + nHack; |
| 956 | @ <p><table border="a" cellspacing="0" cellpadding="5"> |
| 957 | @ <tr><td align="right">%d(nPanic)</td> |
| 958 | if( nPanic>0 ){ |
| 959 | @ <td><a href="./errorlog?y=2">Panics</a></td> |
| 960 | } else { |
| 961 | @ <td>Panics</td> |
| 962 | } |
| 963 | @ <tr><td align="right">%d(nHack)</td> |
| 964 | if( nHack>0 ){ |
| 965 | @ <td><a href="./errorlog?y=1">Hack Attempts</a></td> |
| 966 | if( nNonHack ){ |
| 967 | @ <tr><td align="right">%d(nNonHack)</td> |
| 968 | @ <td><a href="%R/errorlog?y=70">Other than hack attempts</a></td> |
| 969 | } |
| 970 | }else{ |
| 971 | @ <td>Hack Attempts</td> |
| 972 | } |
| 973 | @ <tr><td align="right">%d(nHang)</td> |
| 974 | if( nHang>0 ){ |
| 975 | @ <td><a href="./errorlog?y=4/">Hung Backoffice</a></td> |
| 976 | }else{ |
| 977 | @ <td>Hung Backoffice</td> |
| 978 | } |
| 979 | @ <tr><td align="right">%d(nHang)</td> |
| 980 | if( nOther>0 ){ |
| 981 | @ <td><a href="./errorlog?y=64/">Other</a></td> |
| 982 | }else{ |
| 983 | @ <td>Other</td> |
| 984 | } |
| 985 | @ <tr><td align="right">%d(nTotal)</td> |
| 986 | @ <td><a href="./errorlog">All Messages</a></td> |
| 987 | @ </table> |
| 988 | } |
| 989 | style_finish_page(); |
| 990 | } |
| 991 |
-20
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -264,30 +264,10 @@ | ||
| 264 | 264 | bErrLog = 1; |
| 265 | 265 | } |
| 266 | 266 | setup_menu_entry("Error Log", bErrLog ? "errorlog" : 0, blob_str(&desc)); |
| 267 | 267 | blob_reset(&desc); |
| 268 | 268 | |
| 269 | - @ <tr><td><td><td> | |
| 270 | - @ —— | |
| 271 | - @ <i>The remaining links are subsets of the Error Log</i> | |
| 272 | - @ —— | |
| 273 | - @ </td> | |
| 274 | - | |
| 275 | - setup_menu_entry("Error Summary", bErrLog ? "logsummary" : 0, | |
| 276 | - "Counts of the various message types seen in the Error Log.\n" | |
| 277 | - ); | |
| 278 | - setup_menu_entry("Panic Log", bErrLog ? "paniclog" : 0, | |
| 279 | - "Only the most important messages in the Error Log:\n" | |
| 280 | - "assertion faults, segmentation faults, and similar malfunctions.\n" | |
| 281 | - ); | |
| 282 | - setup_menu_entry("Hack Log", bErrLog ? "hacklog" : 0, | |
| 283 | - "All code-418 hack attempts in the Error Log" | |
| 284 | - ); | |
| 285 | - setup_menu_entry("Non-Hack Log", bErrLog ? "hacklog?not" : 0, | |
| 286 | - "All log messages that are not code-418 hack attempts" | |
| 287 | - ); | |
| 288 | - | |
| 289 | 269 | @ </table> |
| 290 | 270 | style_finish_page(); |
| 291 | 271 | } |
| 292 | 272 | |
| 293 | 273 | /* |
| 294 | 274 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -264,30 +264,10 @@ | |
| 264 | bErrLog = 1; |
| 265 | } |
| 266 | setup_menu_entry("Error Log", bErrLog ? "errorlog" : 0, blob_str(&desc)); |
| 267 | blob_reset(&desc); |
| 268 | |
| 269 | @ <tr><td><td><td> |
| 270 | @ —— |
| 271 | @ <i>The remaining links are subsets of the Error Log</i> |
| 272 | @ —— |
| 273 | @ </td> |
| 274 | |
| 275 | setup_menu_entry("Error Summary", bErrLog ? "logsummary" : 0, |
| 276 | "Counts of the various message types seen in the Error Log.\n" |
| 277 | ); |
| 278 | setup_menu_entry("Panic Log", bErrLog ? "paniclog" : 0, |
| 279 | "Only the most important messages in the Error Log:\n" |
| 280 | "assertion faults, segmentation faults, and similar malfunctions.\n" |
| 281 | ); |
| 282 | setup_menu_entry("Hack Log", bErrLog ? "hacklog" : 0, |
| 283 | "All code-418 hack attempts in the Error Log" |
| 284 | ); |
| 285 | setup_menu_entry("Non-Hack Log", bErrLog ? "hacklog?not" : 0, |
| 286 | "All log messages that are not code-418 hack attempts" |
| 287 | ); |
| 288 | |
| 289 | @ </table> |
| 290 | style_finish_page(); |
| 291 | } |
| 292 | |
| 293 | /* |
| 294 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -264,30 +264,10 @@ | |
| 264 | bErrLog = 1; |
| 265 | } |
| 266 | setup_menu_entry("Error Log", bErrLog ? "errorlog" : 0, blob_str(&desc)); |
| 267 | blob_reset(&desc); |
| 268 | |
| 269 | @ </table> |
| 270 | style_finish_page(); |
| 271 | } |
| 272 | |
| 273 | /* |
| 274 |