Fossil SCM
Add the /paniclog page, accessible only to administrators.
Commit
11f6b5b06cfd9aaea449a350ee3da31e2514edf131ead454f415c66be5ace49c
Parent
4644ebef642afe3…
2 files changed
+71
-1
+6
+71
-1
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -791,10 +791,11 @@ | ||
| 791 | 791 | ** this page. |
| 792 | 792 | */ |
| 793 | 793 | void errorlog_page(void){ |
| 794 | 794 | i64 szFile; |
| 795 | 795 | FILE *in; |
| 796 | + char *zLog; | |
| 796 | 797 | char z[10000]; |
| 797 | 798 | login_check_credentials(); |
| 798 | 799 | if( !g.perm.Admin ){ |
| 799 | 800 | login_needed(0); |
| 800 | 801 | return; |
| @@ -801,10 +802,11 @@ | ||
| 801 | 802 | } |
| 802 | 803 | style_header("Server Error Log"); |
| 803 | 804 | style_submenu_element("Test", "%R/test-warning"); |
| 804 | 805 | style_submenu_element("Refresh", "%R/errorlog"); |
| 805 | 806 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 807 | + style_submenu_element("Panics", "%R/paniclog"); | |
| 806 | 808 | |
| 807 | 809 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 808 | 810 | no_error_log_available(); |
| 809 | 811 | style_finish_page(); |
| 810 | 812 | return; |
| @@ -828,11 +830,13 @@ | ||
| 828 | 830 | @ <input type="submit" name="cancel" value="Cancel"> |
| 829 | 831 | @ </form> |
| 830 | 832 | style_finish_page(); |
| 831 | 833 | return; |
| 832 | 834 | } |
| 833 | - @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size. | |
| 835 | + zLog = file_canonical_name_dup(g.zErrlog); | |
| 836 | + @ <p>The server error log at "%h(zLog)" is %,lld(szFile) bytes in size. | |
| 837 | + fossil_free(zLog); | |
| 834 | 838 | style_submenu_element("Download", "%R/errorlog?download"); |
| 835 | 839 | style_submenu_element("Truncate", "%R/errorlog?truncate"); |
| 836 | 840 | in = fossil_fopen(g.zErrlog, "rb"); |
| 837 | 841 | if( in==0 ){ |
| 838 | 842 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| @@ -848,10 +852,76 @@ | ||
| 848 | 852 | } |
| 849 | 853 | @ <hr> |
| 850 | 854 | @ <pre> |
| 851 | 855 | while( fgets(z, sizeof(z), in) ){ |
| 852 | 856 | @ %h(z)\ |
| 857 | + } | |
| 858 | + fclose(in); | |
| 859 | + @ </pre> | |
| 860 | + style_finish_page(); | |
| 861 | +} | |
| 862 | + | |
| 863 | +/* | |
| 864 | +** WEBPAGE: paniclog | |
| 865 | +** | |
| 866 | +** Scan the error log for panics. Show all panic messages, ignoring all | |
| 867 | +** other error log entries. | |
| 868 | +*/ | |
| 869 | +void paniclog_page(void){ | |
| 870 | + i64 szFile; | |
| 871 | + char *zLog; | |
| 872 | + FILE *in; | |
| 873 | + int bOutput = 0; | |
| 874 | + int prevWasTime = 0; | |
| 875 | + char z[10000]; | |
| 876 | + char zTime[10000]; | |
| 877 | + | |
| 878 | + login_check_credentials(); | |
| 879 | + if( !g.perm.Admin ){ | |
| 880 | + login_needed(0); | |
| 881 | + return; | |
| 882 | + } | |
| 883 | + style_header("Server Panic Log"); | |
| 884 | + style_submenu_element("Log-Menu", "%R/setup-logmenu"); | |
| 885 | + | |
| 886 | + if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ | |
| 887 | + no_error_log_available(); | |
| 888 | + style_finish_page(); | |
| 889 | + return; | |
| 890 | + } | |
| 891 | + in = fossil_fopen(g.zErrlog, "rb"); | |
| 892 | + if( in==0 ){ | |
| 893 | + @ <p class='generalError'>Unable to open that file for reading!</p> | |
| 894 | + style_finish_page(); | |
| 895 | + return; | |
| 896 | + } | |
| 897 | + szFile = file_size(g.zErrlog, ExtFILE); | |
| 898 | + zLog = file_canonical_name_dup(g.zErrlog); | |
| 899 | + @ Panic messages contained within the %lld(szFile)-byte | |
| 900 | + @ <a href="%R/errorlog?all">error log</a> found at | |
| 901 | + @ "%h(zLog)". | |
| 902 | + fossil_free(zLog); | |
| 903 | + @ <hr> | |
| 904 | + @ <pre> | |
| 905 | + while( fgets(z, sizeof(z), in) ){ | |
| 906 | + if( prevWasTime | |
| 907 | + && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) | |
| 908 | + ){ | |
| 909 | + @ %h(zTime)\ | |
| 910 | + bOutput = 1; | |
| 911 | + } | |
| 912 | + if( strncmp(z, "--------", 8)==0 ){ | |
| 913 | + size_t n = strlen(z); | |
| 914 | + memcpy(zTime, z, n+1); | |
| 915 | + prevWasTime = 1; | |
| 916 | + bOutput = 0; | |
| 917 | + }else{ | |
| 918 | + prevWasTime = 0; | |
| 919 | + } | |
| 920 | + if( bOutput ){ | |
| 921 | + @ %h(z)\ | |
| 922 | + } | |
| 853 | 923 | } |
| 854 | 924 | fclose(in); |
| 855 | 925 | @ </pre> |
| 856 | 926 | style_finish_page(); |
| 857 | 927 | } |
| 858 | 928 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -791,10 +791,11 @@ | |
| 791 | ** this page. |
| 792 | */ |
| 793 | void errorlog_page(void){ |
| 794 | i64 szFile; |
| 795 | FILE *in; |
| 796 | char z[10000]; |
| 797 | login_check_credentials(); |
| 798 | if( !g.perm.Admin ){ |
| 799 | login_needed(0); |
| 800 | return; |
| @@ -801,10 +802,11 @@ | |
| 801 | } |
| 802 | style_header("Server Error Log"); |
| 803 | style_submenu_element("Test", "%R/test-warning"); |
| 804 | style_submenu_element("Refresh", "%R/errorlog"); |
| 805 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 806 | |
| 807 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 808 | no_error_log_available(); |
| 809 | style_finish_page(); |
| 810 | return; |
| @@ -828,11 +830,13 @@ | |
| 828 | @ <input type="submit" name="cancel" value="Cancel"> |
| 829 | @ </form> |
| 830 | style_finish_page(); |
| 831 | return; |
| 832 | } |
| 833 | @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size. |
| 834 | style_submenu_element("Download", "%R/errorlog?download"); |
| 835 | style_submenu_element("Truncate", "%R/errorlog?truncate"); |
| 836 | in = fossil_fopen(g.zErrlog, "rb"); |
| 837 | if( in==0 ){ |
| 838 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| @@ -848,10 +852,76 @@ | |
| 848 | } |
| 849 | @ <hr> |
| 850 | @ <pre> |
| 851 | while( fgets(z, sizeof(z), in) ){ |
| 852 | @ %h(z)\ |
| 853 | } |
| 854 | fclose(in); |
| 855 | @ </pre> |
| 856 | style_finish_page(); |
| 857 | } |
| 858 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -791,10 +791,11 @@ | |
| 791 | ** this page. |
| 792 | */ |
| 793 | void errorlog_page(void){ |
| 794 | i64 szFile; |
| 795 | FILE *in; |
| 796 | char *zLog; |
| 797 | char z[10000]; |
| 798 | login_check_credentials(); |
| 799 | if( !g.perm.Admin ){ |
| 800 | login_needed(0); |
| 801 | return; |
| @@ -801,10 +802,11 @@ | |
| 802 | } |
| 803 | style_header("Server Error Log"); |
| 804 | style_submenu_element("Test", "%R/test-warning"); |
| 805 | style_submenu_element("Refresh", "%R/errorlog"); |
| 806 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 807 | style_submenu_element("Panics", "%R/paniclog"); |
| 808 | |
| 809 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 810 | no_error_log_available(); |
| 811 | style_finish_page(); |
| 812 | return; |
| @@ -828,11 +830,13 @@ | |
| 830 | @ <input type="submit" name="cancel" value="Cancel"> |
| 831 | @ </form> |
| 832 | style_finish_page(); |
| 833 | return; |
| 834 | } |
| 835 | zLog = file_canonical_name_dup(g.zErrlog); |
| 836 | @ <p>The server error log at "%h(zLog)" is %,lld(szFile) bytes in size. |
| 837 | fossil_free(zLog); |
| 838 | style_submenu_element("Download", "%R/errorlog?download"); |
| 839 | style_submenu_element("Truncate", "%R/errorlog?truncate"); |
| 840 | in = fossil_fopen(g.zErrlog, "rb"); |
| 841 | if( in==0 ){ |
| 842 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| @@ -848,10 +852,76 @@ | |
| 852 | } |
| 853 | @ <hr> |
| 854 | @ <pre> |
| 855 | while( fgets(z, sizeof(z), in) ){ |
| 856 | @ %h(z)\ |
| 857 | } |
| 858 | fclose(in); |
| 859 | @ </pre> |
| 860 | style_finish_page(); |
| 861 | } |
| 862 | |
| 863 | /* |
| 864 | ** WEBPAGE: paniclog |
| 865 | ** |
| 866 | ** Scan the error log for panics. Show all panic messages, ignoring all |
| 867 | ** other error log entries. |
| 868 | */ |
| 869 | void paniclog_page(void){ |
| 870 | i64 szFile; |
| 871 | char *zLog; |
| 872 | FILE *in; |
| 873 | int bOutput = 0; |
| 874 | int prevWasTime = 0; |
| 875 | char z[10000]; |
| 876 | char zTime[10000]; |
| 877 | |
| 878 | login_check_credentials(); |
| 879 | if( !g.perm.Admin ){ |
| 880 | login_needed(0); |
| 881 | return; |
| 882 | } |
| 883 | style_header("Server Panic Log"); |
| 884 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 885 | |
| 886 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 887 | no_error_log_available(); |
| 888 | style_finish_page(); |
| 889 | return; |
| 890 | } |
| 891 | in = fossil_fopen(g.zErrlog, "rb"); |
| 892 | if( in==0 ){ |
| 893 | @ <p class='generalError'>Unable to open that file for reading!</p> |
| 894 | style_finish_page(); |
| 895 | return; |
| 896 | } |
| 897 | szFile = file_size(g.zErrlog, ExtFILE); |
| 898 | zLog = file_canonical_name_dup(g.zErrlog); |
| 899 | @ Panic messages contained within the %lld(szFile)-byte |
| 900 | @ <a href="%R/errorlog?all">error log</a> found at |
| 901 | @ "%h(zLog)". |
| 902 | fossil_free(zLog); |
| 903 | @ <hr> |
| 904 | @ <pre> |
| 905 | while( fgets(z, sizeof(z), in) ){ |
| 906 | if( prevWasTime |
| 907 | && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0) |
| 908 | ){ |
| 909 | @ %h(zTime)\ |
| 910 | bOutput = 1; |
| 911 | } |
| 912 | if( strncmp(z, "--------", 8)==0 ){ |
| 913 | size_t n = strlen(z); |
| 914 | memcpy(zTime, z, n+1); |
| 915 | prevWasTime = 1; |
| 916 | bOutput = 0; |
| 917 | }else{ |
| 918 | prevWasTime = 0; |
| 919 | } |
| 920 | if( bOutput ){ |
| 921 | @ %h(z)\ |
| 922 | } |
| 923 | } |
| 924 | fclose(in); |
| 925 | @ </pre> |
| 926 | style_finish_page(); |
| 927 | } |
| 928 |
+6
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -224,10 +224,16 @@ | ||
| 224 | 224 | blob_appendf(&desc,"In this repository, the error log is in the file" |
| 225 | 225 | "named \"%s\".", g.zErrlog); |
| 226 | 226 | } |
| 227 | 227 | setup_menu_entry("Error Log", "errorlog", blob_str(&desc)); |
| 228 | 228 | blob_reset(&desc); |
| 229 | + | |
| 230 | + setup_menu_entry("Panic Log", "paniclog", | |
| 231 | + "The panic log is a filtering of the Error Log that shows only the\n" | |
| 232 | + "most important messages - assertion faults, segmentation faults, and\n" | |
| 233 | + "similar malfunctions." | |
| 234 | + ); | |
| 229 | 235 | |
| 230 | 236 | setup_menu_entry("User Log", "user_log", |
| 231 | 237 | "The user log is a record of login attempts. The user log is stored\n" |
| 232 | 238 | "in the \"accesslog\" table of the respository.\n" |
| 233 | 239 | ); |
| 234 | 240 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -224,10 +224,16 @@ | |
| 224 | blob_appendf(&desc,"In this repository, the error log is in the file" |
| 225 | "named \"%s\".", g.zErrlog); |
| 226 | } |
| 227 | setup_menu_entry("Error Log", "errorlog", blob_str(&desc)); |
| 228 | blob_reset(&desc); |
| 229 | |
| 230 | setup_menu_entry("User Log", "user_log", |
| 231 | "The user log is a record of login attempts. The user log is stored\n" |
| 232 | "in the \"accesslog\" table of the respository.\n" |
| 233 | ); |
| 234 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -224,10 +224,16 @@ | |
| 224 | blob_appendf(&desc,"In this repository, the error log is in the file" |
| 225 | "named \"%s\".", g.zErrlog); |
| 226 | } |
| 227 | setup_menu_entry("Error Log", "errorlog", blob_str(&desc)); |
| 228 | blob_reset(&desc); |
| 229 | |
| 230 | setup_menu_entry("Panic Log", "paniclog", |
| 231 | "The panic log is a filtering of the Error Log that shows only the\n" |
| 232 | "most important messages - assertion faults, segmentation faults, and\n" |
| 233 | "similar malfunctions." |
| 234 | ); |
| 235 | |
| 236 | setup_menu_entry("User Log", "user_log", |
| 237 | "The user log is a record of login attempts. The user log is stored\n" |
| 238 | "in the \"accesslog\" table of the respository.\n" |
| 239 | ); |
| 240 |