Fossil SCM
Improved error message for when the error log is unavailable.
Commit
e6b06b5d11b1a04102e702e9c50a5dfa97842b225b2662e0b6a52ebf14855b5e
Parent
b28badb7411b90b…
2 files changed
+4
-4
+18
-14
+4
-4
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -226,10 +226,11 @@ | ||
| 226 | 226 | const char *zLogin; /* Login name. NULL or "" if not logged in. */ |
| 227 | 227 | const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */ |
| 228 | 228 | const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */ |
| 229 | 229 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 230 | 230 | ** SSL client identity */ |
| 231 | + const char *zCgiFile; /* Name of the CGI file */ | |
| 231 | 232 | #if USE_SEE |
| 232 | 233 | const char *zPidKey; /* Saved value of the --usepidkey option. Only |
| 233 | 234 | * applicable when using SEE on Windows or Linux. */ |
| 234 | 235 | #endif |
| 235 | 236 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| @@ -2348,11 +2349,10 @@ | ||
| 2348 | 2349 | ** go to that log file. |
| 2349 | 2350 | ** |
| 2350 | 2351 | ** See also: [[http]], [[server]], [[winsrv]] |
| 2351 | 2352 | */ |
| 2352 | 2353 | void cmd_cgi(void){ |
| 2353 | - const char *zFile; | |
| 2354 | 2354 | const char *zNotFound = 0; |
| 2355 | 2355 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2356 | 2356 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2357 | 2357 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2358 | 2358 | int allowRepoList = 0; /* Allow lists of repository files */ |
| @@ -2364,18 +2364,18 @@ | ||
| 2364 | 2364 | fossil_binary_mode(g.httpIn); |
| 2365 | 2365 | g.cgiOutput = 1; |
| 2366 | 2366 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2367 | 2367 | /* Find the name of the CGI control file */ |
| 2368 | 2368 | if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ |
| 2369 | - zFile = g.argv[2]; | |
| 2369 | + g.zCgiFile = g.argv[2]; | |
| 2370 | 2370 | }else if( g.argc>=2 ){ |
| 2371 | - zFile = g.argv[1]; | |
| 2371 | + g.zCgiFile = g.argv[1]; | |
| 2372 | 2372 | }else{ |
| 2373 | 2373 | cgi_panic("No CGI control file specified"); |
| 2374 | 2374 | } |
| 2375 | 2375 | /* Read and parse the CGI control file. */ |
| 2376 | - blob_read_from_file(&config, zFile, ExtFILE); | |
| 2376 | + blob_read_from_file(&config, g.zCgiFile, ExtFILE); | |
| 2377 | 2377 | while( blob_line(&config, &line) ){ |
| 2378 | 2378 | if( !blob_token(&line, &key) ) continue; |
| 2379 | 2379 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2380 | 2380 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2381 | 2381 | /* repository: FILENAME |
| 2382 | 2382 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -226,10 +226,11 @@ | |
| 226 | const char *zLogin; /* Login name. NULL or "" if not logged in. */ |
| 227 | const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */ |
| 228 | const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */ |
| 229 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 230 | ** SSL client identity */ |
| 231 | #if USE_SEE |
| 232 | const char *zPidKey; /* Saved value of the --usepidkey option. Only |
| 233 | * applicable when using SEE on Windows or Linux. */ |
| 234 | #endif |
| 235 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| @@ -2348,11 +2349,10 @@ | |
| 2348 | ** go to that log file. |
| 2349 | ** |
| 2350 | ** See also: [[http]], [[server]], [[winsrv]] |
| 2351 | */ |
| 2352 | void cmd_cgi(void){ |
| 2353 | const char *zFile; |
| 2354 | const char *zNotFound = 0; |
| 2355 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2356 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2357 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2358 | int allowRepoList = 0; /* Allow lists of repository files */ |
| @@ -2364,18 +2364,18 @@ | |
| 2364 | fossil_binary_mode(g.httpIn); |
| 2365 | g.cgiOutput = 1; |
| 2366 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2367 | /* Find the name of the CGI control file */ |
| 2368 | if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ |
| 2369 | zFile = g.argv[2]; |
| 2370 | }else if( g.argc>=2 ){ |
| 2371 | zFile = g.argv[1]; |
| 2372 | }else{ |
| 2373 | cgi_panic("No CGI control file specified"); |
| 2374 | } |
| 2375 | /* Read and parse the CGI control file. */ |
| 2376 | blob_read_from_file(&config, zFile, ExtFILE); |
| 2377 | while( blob_line(&config, &line) ){ |
| 2378 | if( !blob_token(&line, &key) ) continue; |
| 2379 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2380 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2381 | /* repository: FILENAME |
| 2382 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -226,10 +226,11 @@ | |
| 226 | const char *zLogin; /* Login name. NULL or "" if not logged in. */ |
| 227 | const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */ |
| 228 | const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */ |
| 229 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 230 | ** SSL client identity */ |
| 231 | const char *zCgiFile; /* Name of the CGI file */ |
| 232 | #if USE_SEE |
| 233 | const char *zPidKey; /* Saved value of the --usepidkey option. Only |
| 234 | * applicable when using SEE on Windows or Linux. */ |
| 235 | #endif |
| 236 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| @@ -2348,11 +2349,10 @@ | |
| 2349 | ** go to that log file. |
| 2350 | ** |
| 2351 | ** See also: [[http]], [[server]], [[winsrv]] |
| 2352 | */ |
| 2353 | void cmd_cgi(void){ |
| 2354 | const char *zNotFound = 0; |
| 2355 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2356 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2357 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2358 | int allowRepoList = 0; /* Allow lists of repository files */ |
| @@ -2364,18 +2364,18 @@ | |
| 2364 | fossil_binary_mode(g.httpIn); |
| 2365 | g.cgiOutput = 1; |
| 2366 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2367 | /* Find the name of the CGI control file */ |
| 2368 | if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ |
| 2369 | g.zCgiFile = g.argv[2]; |
| 2370 | }else if( g.argc>=2 ){ |
| 2371 | g.zCgiFile = g.argv[1]; |
| 2372 | }else{ |
| 2373 | cgi_panic("No CGI control file specified"); |
| 2374 | } |
| 2375 | /* Read and parse the CGI control file. */ |
| 2376 | blob_read_from_file(&config, g.zCgiFile, ExtFILE); |
| 2377 | while( blob_line(&config, &line) ){ |
| 2378 | if( !blob_token(&line, &key) ) continue; |
| 2379 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2380 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2381 | /* repository: FILENAME |
| 2382 |
+18
-14
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -749,10 +749,27 @@ | ||
| 749 | 749 | @ <input type="submit" name="cancel" value="Cancel"> |
| 750 | 750 | @ </form> |
| 751 | 751 | |
| 752 | 752 | style_finish_page(); |
| 753 | 753 | } |
| 754 | + | |
| 755 | +/* | |
| 756 | +** Output a message explaining that no error log is available. | |
| 757 | +*/ | |
| 758 | +static void no_error_log_available(void){ | |
| 759 | + @ <p>No error log is configured. | |
| 760 | + if( g.zCgiFile==0 ){ | |
| 761 | + @ To create an error log, add the "--errorlog FILENAME" | |
| 762 | + @ command-line option to the command that launches the Fossil server. | |
| 763 | + }else{ | |
| 764 | + @ To create an error log, edit the CGI control file "%h(g.zCgiFile)" | |
| 765 | + @ to add line like this: | |
| 766 | + @ <blockquote><pre> | |
| 767 | + @ errorlog: <i>FILENAME</i> | |
| 768 | + @ </pre></blockquote> | |
| 769 | + } | |
| 770 | +} | |
| 754 | 771 | |
| 755 | 772 | /* |
| 756 | 773 | ** The maximum number of bytes of the error log to show by default. |
| 757 | 774 | */ |
| 758 | 775 | #define MXSHOWLOG 500000 |
| @@ -776,24 +793,11 @@ | ||
| 776 | 793 | style_submenu_element("Test", "%R/test-warning"); |
| 777 | 794 | style_submenu_element("Refresh", "%R/errorlog"); |
| 778 | 795 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 779 | 796 | |
| 780 | 797 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 781 | - @ <p>To create a server error log: | |
| 782 | - @ <ol> | |
| 783 | - @ <li><p> | |
| 784 | - @ If the server is running as CGI, then create a line in the CGI file | |
| 785 | - @ like this: | |
| 786 | - @ <blockquote><pre> | |
| 787 | - @ errorlog: <i>FILENAME</i> | |
| 788 | - @ </pre></blockquote> | |
| 789 | - @ <li><p> | |
| 790 | - @ If the server is running using one of | |
| 791 | - @ the "fossil http" or "fossil server" commands then add | |
| 792 | - @ a command-line option "--errorlog <i>FILENAME</i>" to that | |
| 793 | - @ command. | |
| 794 | - @ </ol> | |
| 798 | + no_error_log_available(); | |
| 795 | 799 | style_finish_page(); |
| 796 | 800 | return; |
| 797 | 801 | } |
| 798 | 802 | if( P("truncate1") && cgi_csrf_safe(2) ){ |
| 799 | 803 | fclose(fopen(g.zErrlog,"w")); |
| 800 | 804 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -749,10 +749,27 @@ | |
| 749 | @ <input type="submit" name="cancel" value="Cancel"> |
| 750 | @ </form> |
| 751 | |
| 752 | style_finish_page(); |
| 753 | } |
| 754 | |
| 755 | /* |
| 756 | ** The maximum number of bytes of the error log to show by default. |
| 757 | */ |
| 758 | #define MXSHOWLOG 500000 |
| @@ -776,24 +793,11 @@ | |
| 776 | style_submenu_element("Test", "%R/test-warning"); |
| 777 | style_submenu_element("Refresh", "%R/errorlog"); |
| 778 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 779 | |
| 780 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 781 | @ <p>To create a server error log: |
| 782 | @ <ol> |
| 783 | @ <li><p> |
| 784 | @ If the server is running as CGI, then create a line in the CGI file |
| 785 | @ like this: |
| 786 | @ <blockquote><pre> |
| 787 | @ errorlog: <i>FILENAME</i> |
| 788 | @ </pre></blockquote> |
| 789 | @ <li><p> |
| 790 | @ If the server is running using one of |
| 791 | @ the "fossil http" or "fossil server" commands then add |
| 792 | @ a command-line option "--errorlog <i>FILENAME</i>" to that |
| 793 | @ command. |
| 794 | @ </ol> |
| 795 | style_finish_page(); |
| 796 | return; |
| 797 | } |
| 798 | if( P("truncate1") && cgi_csrf_safe(2) ){ |
| 799 | fclose(fopen(g.zErrlog,"w")); |
| 800 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -749,10 +749,27 @@ | |
| 749 | @ <input type="submit" name="cancel" value="Cancel"> |
| 750 | @ </form> |
| 751 | |
| 752 | style_finish_page(); |
| 753 | } |
| 754 | |
| 755 | /* |
| 756 | ** Output a message explaining that no error log is available. |
| 757 | */ |
| 758 | static void no_error_log_available(void){ |
| 759 | @ <p>No error log is configured. |
| 760 | if( g.zCgiFile==0 ){ |
| 761 | @ To create an error log, add the "--errorlog FILENAME" |
| 762 | @ command-line option to the command that launches the Fossil server. |
| 763 | }else{ |
| 764 | @ To create an error log, edit the CGI control file "%h(g.zCgiFile)" |
| 765 | @ to add line like this: |
| 766 | @ <blockquote><pre> |
| 767 | @ errorlog: <i>FILENAME</i> |
| 768 | @ </pre></blockquote> |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** The maximum number of bytes of the error log to show by default. |
| 774 | */ |
| 775 | #define MXSHOWLOG 500000 |
| @@ -776,24 +793,11 @@ | |
| 793 | style_submenu_element("Test", "%R/test-warning"); |
| 794 | style_submenu_element("Refresh", "%R/errorlog"); |
| 795 | style_submenu_element("Log-Menu", "%R/setup-logmenu"); |
| 796 | |
| 797 | if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){ |
| 798 | no_error_log_available(); |
| 799 | style_finish_page(); |
| 800 | return; |
| 801 | } |
| 802 | if( P("truncate1") && cgi_csrf_safe(2) ){ |
| 803 | fclose(fopen(g.zErrlog,"w")); |
| 804 |