Check-in [2304fb87ac]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Omit the /paniclog, /hacklog, and /logsummary pages. All those capabilities are now combined into the /errorlog page.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2304fb87ac93f4fc700f25722454e4d9dbebd56b78f61be2ea9b9dc35847e633
User & Date: drh 2025-03-17 11:38:29.501
Context
2025-03-17
11:40
Remove an unused variable in the previous check-in. check-in: d23912f089 user: drh tags: trunk
11:38
Omit the /paniclog, /hacklog, and /logsummary pages. All those capabilities are now combined into the /errorlog page. check-in: 2304fb87ac user: drh tags: trunk
2025-03-16
22:49
Improved help for the "test-which" command, explaining why it is retained even though we now have a "which" command without the "test-" prefix. check-in: b3f270ffd6 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/security_audit.c.
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818








819
820
821
822
823










824


825
826
827
828
829



830
831
832


833

834
835

836
837
838
839
840
841
842
    @ <blockquote><pre>
    @ errorlog: <i>FILENAME</i>
    @ </pre></blockquote>
    blob_reset(&fullname);
  }
}

/*
** The maximum number of bytes of the error log to show by default.
*/
#define MXSHOWLOG 500000

/*
** WEBPAGE: errorlog
**
** Show the content of the error log.  Only the administrator can view
** this page.








*/
void errorlog_page(void){
  i64 szFile;
  FILE *in;
  char *zLog;










  char z[10000];


  login_check_credentials();
  if( !g.perm.Admin ){
    login_needed(0);
    return;
  }



  style_header("Server Error Log");
  style_submenu_element("Test", "%R/test-warning");
  style_submenu_element("Refresh", "%R/errorlog");


  style_submenu_element("Log-Menu", "%R/setup-logmenu");

  style_submenu_element("Panics", "%R/paniclog");
  style_submenu_element("Non-Hacks", "%R/hacklog?not");


  if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
    no_error_log_available();
    style_finish_page();
    return;
  }
  if( P("truncate1") && cgi_csrf_safe(2) ){







<
<
<
<
<





>
>
>
>
>
>
>
>





>
>
>
>
>
>
>
>
>
>

>
>





>
>
>



>
>

>
|
<
>







802
803
804
805
806
807
808





809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855

856
857
858
859
860
861
862
863
    @ <blockquote><pre>
    @ errorlog: <i>FILENAME</i>
    @ </pre></blockquote>
    blob_reset(&fullname);
  }
}






/*
** WEBPAGE: errorlog
**
** Show the content of the error log.  Only the administrator can view
** this page.
**
**    y=0x01          Show only hack attempts
**    y=0x02          Show only panics and assertion faults
**    y=0x04          Show hung backoffice processes
**    y=0x40          Show other uncategorized messages
**
** If y is omitted or is zero, a count of the various message types is
** shown.
*/
void errorlog_page(void){
  i64 szFile;
  FILE *in;
  char *zLog;
  int hasType = 0;
  const char *zType = P("y");
  static const int eAllTypes = 0x47;
  long eType = 0;
  int bOutput = 0;
  int prevWasTime = 0;
  int nHack = 0;
  int nPanic = 0;
  int nOther = 0;
  int nHang = 0;
  char z[10000];
  char zTime[10000];

  login_check_credentials();
  if( !g.perm.Admin ){
    login_needed(0);
    return;
  }
  if( zType ){
    eType = strtol(zType,0,0) & eAllTypes;
  }
  style_header("Server Error Log");
  style_submenu_element("Test", "%R/test-warning");
  style_submenu_element("Refresh", "%R/errorlog");
  style_submenu_element("Download", "%R/errorlog?download");
  style_submenu_element("Truncate", "%R/errorlog?truncate");
  style_submenu_element("Log-Menu", "%R/setup-logmenu");
  if( eType ){
    style_submenu_element("Summary", "%R/errorlog");

  }

  if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
    no_error_log_available();
    style_finish_page();
    return;
  }
  if( P("truncate1") && cgi_csrf_safe(2) ){
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875

876
877
878
879

880
881
882
883
884
885
886

887
888
889


890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905


906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934




935










936
937
938

939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
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
    @ </form>
    style_finish_page();
    return;
  }
  zLog = file_canonical_name_dup(g.zErrlog);
  @ <p>The server error log at "%h(zLog)" is %,lld(szFile) bytes in size.
  fossil_free(zLog);
  style_submenu_element("Download", "%R/errorlog?download");
  style_submenu_element("Truncate", "%R/errorlog?truncate");
  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable to open that file for reading!</p>
    style_finish_page();
    return;
  }
  if( szFile>MXSHOWLOG && P("all")==0 ){
    @ <form action="%R/errorlog" method="POST">

    @ <p>Only the last %,d(MXSHOWLOG) bytes are shown.
    @ <input type="submit" name="all" value="Show All">
    @ </form>
    fseek(in, -MXSHOWLOG, SEEK_END);

  }
  @ <hr>
  @ <pre>
  while( fgets(z, sizeof(z), in) ){
    @ %h(z)\
  }
  fclose(in);

  @ </pre>
  style_finish_page();
}



/*
** WEBPAGE: paniclog
**
** Scan the error log for panics.  Show all panic messages, ignoring all
** other error log entries.
*/
void paniclog_page(void){
  i64 szFile;
  char *zLog;
  FILE *in;
  int bOutput = 0;
  int prevWasTime = 0;
  char z[10000];
  char zTime[10000];



  login_check_credentials();
  if( !g.perm.Admin ){
    login_needed(0);
    return;
  }
  style_header("Server Panic Log");
  style_submenu_element("Log-Menu", "%R/setup-logmenu");

  if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
    no_error_log_available();
    style_finish_page();
    return;
  }
  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable to open that file for reading!</p>
    style_finish_page();
    return;
  }
  szFile = file_size(g.zErrlog, ExtFILE);
  zLog = file_canonical_name_dup(g.zErrlog);
  @ Panic messages contained within the %lld(szFile)-byte 
  @ <a href="%R/errorlog?all">error log</a> found at
  @ "%h(zLog)".
  fossil_free(zLog);
  @ <hr>
  @ <pre>
  while( fgets(z, sizeof(z), in) ){
    if( prevWasTime




     && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0)










    ){
      @ %h(zTime)\
      bOutput = 1;

    }
    if( strncmp(z, "--------", 8)==0 ){
      size_t n = strlen(z);
      memcpy(zTime, z, n+1);
      prevWasTime = 1;
      bOutput = 0;
    }else{
      prevWasTime = 0;
    }
    if( bOutput ){
      @ %h(z)\
    }
  }
  fclose(in);
  @ </pre>
  style_finish_page();
}

/*
** WEBPAGE: hacklog
**
** Scan the error log for "possible hack attempt" entries  Show hack
** attempt messages only, omitting all others.  Or if the "not" query
** parameter is present, show only messages that are not hack attempts.
*/
void hacklog_page(void){
  i64 szFile;
  char *zLog;
  FILE *in;
  int bOutput = 0;
  int prevWasTime = 0;
  int isNot = P("not")!=0;
  char z[10000];
  char zTime[10000];

  login_check_credentials();
  if( !g.perm.Admin ){
    login_needed(0);
    return;
  }
  style_header("Server Hack Log");
  style_submenu_element("Log-Menu", "%R/setup-logmenu");

  if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
    no_error_log_available();
    style_finish_page();
    return;
  }
  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable to open that file for reading!</p>
    style_finish_page();
    return;
  }
  szFile = file_size(g.zErrlog, ExtFILE);
  zLog = file_canonical_name_dup(g.zErrlog);
  @ %s(isNot?"Non-hack":"Hack") messages contained within the %lld(szFile)-byte 
  @ <a href="%R/errorlog?all">error log</a> found at
  @ "%h(zLog)".
  fossil_free(zLog);
  @ <hr>
  @ <pre>
  while( fgets(z, sizeof(z), in) ){
    if( prevWasTime 
     && ((strncmp(z,"possible hack attempt - 418 ", 27)==0) ^ isNot)
    ){
      @ %h(zTime)\
      bOutput = 1;
    }
    if( strncmp(z, "--------", 8)==0 ){
      size_t n = strlen(z);
      memcpy(zTime, z, n+1);
      prevWasTime = 1;
      bOutput = 0;
    }else{
      prevWasTime = 0;
    }
    if( bOutput ){
      @ %h(z)\
    }
  }
  fclose(in);
  @ </pre>
  style_finish_page();
}

/*
** WEBPAGE: logsummary
**
** Scan the error log and count the various kinds of entries.
*/
void logsummary_page(void){
  i64 szFile;
  char *zLog;
  FILE *in;
  int prevWasTime = 0;
  int nHack = 0;
  int nPanic = 0;
  int nOther = 0;
  int nTotal = 0;
  char z[10000];

  login_check_credentials();
  if( !g.perm.Admin ){
    login_needed(0);
    return;
  }
  style_header("Server Hack Log");
  style_submenu_element("Log-Menu", "%R/setup-logmenu");

  if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
    no_error_log_available();
    style_finish_page();
    return;
  }
  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable to open that file for reading!</p>
    style_finish_page();
    return;
  }
  szFile = file_size(g.zErrlog, ExtFILE);
  zLog = file_canonical_name_dup(g.zErrlog);
  @ Summary of messages contained within the %lld(szFile)-byte 
  @ <a href="%R/errorlog?all">error log</a> found at
  @ "%h(zLog)".
  fossil_free(zLog);
  @ <hr>
  while( fgets(z, sizeof(z), in) ){
    if( prevWasTime 
     && (strncmp(z,"possible hack attempt - 418 ", 27)==0)
    ){
      nHack++;
      prevWasTime = 0;
      continue;
    }
    if( prevWasTime
     && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0)
    ){
      nPanic++;
      prevWasTime = 0;
      continue;
    }
    if( prevWasTime ) nOther++;
    if( strncmp(z, "--------", 8)==0 ){
      nTotal++;
      prevWasTime = 1;
      continue;
    }
    prevWasTime = 0;
  }
  fclose(in);
  @ <p><table border="a" cellspacing="0" cellpadding="5">
  @ <tr><td align="right">%d(nPanic)</td>
  if( nPanic>0 ){
    @     <td><a href="./paniclog">Panics</a></td>
  } else {
    @     <td>Panics</td>
  }
  @ <tr><td align="right">%d(nHack)</td>
  if( nHack>0 ){
    @     <td><a href="./hacklog">Hack Attempts</a></td>




  }else{
    @     <td>Hack Attempts</td>
  }
  @ <tr><td align="right">%d(nOther)</td>









  @     <td>Other</td>

  @ <tr><td align="right">%d(nTotal)</td>
  @     <td>Total Messages</td>
  @ </table>

  style_finish_page();
}







<
<






|
|
>
|
<
|
|
>
|
<
|
<
|
|
<
>
|
<
|
>
>
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
>
>
<
<
<
<
<
<
<
|
<
<
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<

|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
|
|
<
>









|




<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|
|
<
<
<
<
<
<
<
<
<
<
|
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
|
|
>
>
>
>
|
|
|
|
>
>
>
>
>
>
>
>
>
|
>
|
|
|
>


880
881
882
883
884
885
886


887
888
889
890
891
892
893
894
895
896

897
898
899
900

901

902
903

904
905

906
907
908
909
910













911
912
913







914




915














916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934

935
936
937
938
939
940
941
942
943
944
945
946
947
948
949



950
































































951

952
953










954


955




















































956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
    @ </form>
    style_finish_page();
    return;
  }
  zLog = file_canonical_name_dup(g.zErrlog);
  @ <p>The server error log at "%h(zLog)" is %,lld(szFile) bytes in size.
  fossil_free(zLog);


  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable to open that file for reading!</p>
    style_finish_page();
    return;
  }
  if( eType==0 ){
    /* will do a summary */
  }else if( (eType&eAllTypes)!=eAllTypes ){
    @ Only the following types of messages displayed:

    @ <ul>
    if( eType & 0x01 ){
      @ <li>Hack attempts
    }

    if( eType & 0x02 ){

      @ <li>Panics and assertion faults
    }

    if( eType & 0x04 ){
      @ <li>Hung backoffice processes

    }
    if( eType & 0x40 ){
      @ <li>Other uncategorized messages
    }
    @ </ul>













  }
  @ <hr>
  if( eType ){







    @ <pre>




  }














  while( fgets(z, sizeof(z), in) ){
    if( prevWasTime ){
      if( strncmp(z,"possible hack attempt - 418 ", 27)==0 ){
        bOutput = (eType & 0x01)!=0;
        nHack++;
      }else
      if( (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) ){
        bOutput = (eType & 0x02)!=0;
        nPanic++;
      }else
      if( sqlite3_strglob("warning: backoffice process * still *",z)==0 ){
        bOutput = (eType & 0x04)!=0;
        nHang++;
      }else{
        bOutput = (eType & 0x40)!=0;
        nOther++;
      }
      if( bOutput ){
        @ %h(zTime)\

      }
    }
    if( strncmp(z, "--------", 8)==0 ){
      size_t n = strlen(z);
      memcpy(zTime, z, n+1);
      prevWasTime = 1;
      bOutput = 0;
    }else{
      prevWasTime = 0;
    }
    if( bOutput && eType ){
      @ %h(z)\
    }
  }
  fclose(in);



  if( eType ){
































































    @ </pre>

  }
  if( eType==0 ){










    int nNonHack = nPanic+nHang+nOther;


    int nTotal = nNonHack + nHack;




















































    @ <p><table border="a" cellspacing="0" cellpadding="5">
    @ <tr><td align="right">%d(nPanic)</td>
    if( nPanic>0 ){
      @     <td><a href="./errorlog?y=2">Panics</a></td>
    } else {
      @     <td>Panics</td>
    }
    @ <tr><td align="right">%d(nHack)</td>
    if( nHack>0 ){
      @     <td><a href="./errorlog?y=1">Hack Attempts</a></td>
      if( nNonHack ){
        @ <tr><td align="right">%d(nNonHack)</td>
        @ <td><a href="%R/errorlog?y=70">Other than hack attempts</a></td>
      }
    }else{
      @     <td>Hack Attempts</td>
    }
    @ <tr><td align="right">%d(nHang)</td>
    if( nHang>0 ){
      @     <td><a href="./errorlog?y=4/">Hung Backoffice</a></td>
    }else{
      @     <td>Hung Backoffice</td>
    }
    @ <tr><td align="right">%d(nHang)</td>
    if( nOther>0 ){
      @     <td><a href="./errorlog?y=64/">Other</a></td>
    }else{
      @     <td>Other</td>
    }
    @ <tr><td align="right">%d(nTotal)</td>
    @     <td><a href="./errorlog">All Messages</a></td>
    @ </table>
  }
  style_finish_page();
}
Changes to src/setup.c.
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
    blob_appendf(&desc,"In this repository, the error log is the file "
       "named \"%s\".", g.zErrlog);
    bErrLog = 1;
  }
  setup_menu_entry("Error Log", bErrLog ? "errorlog" : 0, blob_str(&desc));
  blob_reset(&desc);

  @ <tr><td><td><td>
  @ &mdash;&mdash;
  @ <i>The remaining links are subsets of the Error Log</i>
  @ &mdash;&mdash;
  @ </td>  

  setup_menu_entry("Error Summary", bErrLog ? "logsummary" : 0,
    "Counts of the various message types seen in the Error Log.\n"
  );
  setup_menu_entry("Panic Log", bErrLog ? "paniclog" : 0,
    "Only the most important messages in the Error Log:\n"
    "assertion faults, segmentation faults, and similar malfunctions.\n"
  );
  setup_menu_entry("Hack Log", bErrLog ? "hacklog" : 0,
    "All code-418 hack attempts in the Error Log"
  );
  setup_menu_entry("Non-Hack Log", bErrLog ? "hacklog?not" : 0,
    "All log messages that are not code-418 hack attempts"
  );

  @ </table>
  style_finish_page();
}

/*
** Generate a checkbox for an attribute.
*/







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







262
263
264
265
266
267
268




















269
270
271
272
273
274
275
    blob_appendf(&desc,"In this repository, the error log is the file "
       "named \"%s\".", g.zErrlog);
    bErrLog = 1;
  }
  setup_menu_entry("Error Log", bErrLog ? "errorlog" : 0, blob_str(&desc));
  blob_reset(&desc);





















  @ </table>
  style_finish_page();
}

/*
** Generate a checkbox for an attribute.
*/