Fossil SCM

Improved error message for when the error log is unavailable.

drh 2024-03-29 13:04 trunk
Commit e6b06b5d11b1a04102e702e9c50a5dfa97842b225b2662e0b6a52ebf14855b5e
2 files changed +4 -4 +18 -14
+4 -4
--- src/main.c
+++ src/main.c
@@ -226,10 +226,11 @@
226226
const char *zLogin; /* Login name. NULL or "" if not logged in. */
227227
const char *zCkoutAlias; /* doc/ uses this branch as an alias for "ckout" */
228228
const char *zMainMenuFile; /* --mainmenu FILE from server/ui/cgi */
229229
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
230230
** SSL client identity */
231
+ const char *zCgiFile; /* Name of the CGI file */
231232
#if USE_SEE
232233
const char *zPidKey; /* Saved value of the --usepidkey option. Only
233234
* applicable when using SEE on Windows or Linux. */
234235
#endif
235236
int useLocalauth; /* No login required if from 127.0.0.1 */
@@ -2348,11 +2349,10 @@
23482349
** go to that log file.
23492350
**
23502351
** See also: [[http]], [[server]], [[winsrv]]
23512352
*/
23522353
void cmd_cgi(void){
2353
- const char *zFile;
23542354
const char *zNotFound = 0;
23552355
char **azRedirect = 0; /* List of repositories to redirect to */
23562356
int nRedirect = 0; /* Number of entries in azRedirect */
23572357
Glob *pFileGlob = 0; /* Pattern for files */
23582358
int allowRepoList = 0; /* Allow lists of repository files */
@@ -2364,18 +2364,18 @@
23642364
fossil_binary_mode(g.httpIn);
23652365
g.cgiOutput = 1;
23662366
fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT);
23672367
/* Find the name of the CGI control file */
23682368
if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){
2369
- zFile = g.argv[2];
2369
+ g.zCgiFile = g.argv[2];
23702370
}else if( g.argc>=2 ){
2371
- zFile = g.argv[1];
2371
+ g.zCgiFile = g.argv[1];
23722372
}else{
23732373
cgi_panic("No CGI control file specified");
23742374
}
23752375
/* Read and parse the CGI control file. */
2376
- blob_read_from_file(&config, zFile, ExtFILE);
2376
+ blob_read_from_file(&config, g.zCgiFile, ExtFILE);
23772377
while( blob_line(&config, &line) ){
23782378
if( !blob_token(&line, &key) ) continue;
23792379
if( blob_buffer(&key)[0]=='#' ) continue;
23802380
if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){
23812381
/* repository: FILENAME
23822382
--- 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
--- src/security_audit.c
+++ src/security_audit.c
@@ -749,10 +749,27 @@
749749
@ <input type="submit" name="cancel" value="Cancel">
750750
@ </form>
751751
752752
style_finish_page();
753753
}
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
+}
754771
755772
/*
756773
** The maximum number of bytes of the error log to show by default.
757774
*/
758775
#define MXSHOWLOG 500000
@@ -776,24 +793,11 @@
776793
style_submenu_element("Test", "%R/test-warning");
777794
style_submenu_element("Refresh", "%R/errorlog");
778795
style_submenu_element("Log-Menu", "%R/setup-logmenu");
779796
780797
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();
795799
style_finish_page();
796800
return;
797801
}
798802
if( P("truncate1") && cgi_csrf_safe(2) ){
799803
fclose(fopen(g.zErrlog,"w"));
800804
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button