| ︙ | | | ︙ | |
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
|
**
** HOME: PATH Shorthand for "setenv: HOME PATH"
**
** debug: FILE Causing debugging information to be written
** into FILE.
**
** errorlog: FILE Warnings, errors, and panics written to FILE.
**
** extroot: DIR Directory that is the root of the sub-CGI tree
** on the /ext page.
**
** redirect: REPO URL Extract the "name" query parameter and search
** REPO for a check-in or ticket that matches the
** value of "name", then redirect to URL. There
|
>
>
>
|
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
|
**
** HOME: PATH Shorthand for "setenv: HOME PATH"
**
** debug: FILE Causing debugging information to be written
** into FILE.
**
** errorlog: FILE Warnings, errors, and panics written to FILE.
**
** timeout: SECONDS Do not run for longer than SECONDS. The default
** timeout is 300 seconds.
**
** extroot: DIR Directory that is the root of the sub-CGI tree
** on the /ext page.
**
** redirect: REPO URL Extract the "name" query parameter and search
** REPO for a check-in or ticket that matches the
** value of "name", then redirect to URL. There
|
| ︙ | | | ︙ | |
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
|
zFile = g.argv[1];
}
g.httpOut = stdout;
g.httpIn = stdin;
fossil_binary_mode(g.httpOut);
fossil_binary_mode(g.httpIn);
g.cgiOutput = 1;
blob_read_from_file(&config, zFile, ExtFILE);
while( blob_line(&config, &line) ){
if( !blob_token(&line, &key) ) continue;
if( blob_buffer(&key)[0]=='#' ) continue;
if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){
/* repository: FILENAME
**
|
>
|
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
|
zFile = g.argv[1];
}
g.httpOut = stdout;
g.httpIn = stdin;
fossil_binary_mode(g.httpOut);
fossil_binary_mode(g.httpIn);
g.cgiOutput = 1;
fossil_set_timeout(300);
blob_read_from_file(&config, zFile, ExtFILE);
while( blob_line(&config, &line) ){
if( !blob_token(&line, &key) ) continue;
if( blob_buffer(&key)[0]=='#' ) continue;
if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){
/* repository: FILENAME
**
|
| ︙ | | | ︙ | |
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
|
/* extroot: DIRECTORY
**
** Enables the /ext webpage to use sub-cgi rooted at DIRECTORY
*/
g.zExtRoot = mprintf("%s", blob_str(&value));
blob_reset(&value);
continue;
}
if( blob_eq(&key, "HOME:") && blob_token(&line, &value) ){
/* HOME: VALUE
**
** Set CGI parameter "HOME" to VALUE. This is legacy. Use
** setenv: instead.
*/
|
>
>
>
>
>
>
>
>
>
|
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
|
/* extroot: DIRECTORY
**
** Enables the /ext webpage to use sub-cgi rooted at DIRECTORY
*/
g.zExtRoot = mprintf("%s", blob_str(&value));
blob_reset(&value);
continue;
}
if( blob_eq(&key, "timeout:") && blob_token(&line, &value) ){
/* timeout: SECONDS
**
** Set an alarm() that kills the process after SECONDS. The
** default value is 300 seconds.
*/
fossil_set_timeout(atoi(blob_str(&value)));
continue;
}
if( blob_eq(&key, "HOME:") && blob_token(&line, &value) ){
/* HOME: VALUE
**
** Set CGI parameter "HOME" to VALUE. This is legacy. Use
** setenv: instead.
*/
|
| ︙ | | | ︙ | |
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
|
}
return 0;
}
#endif
#endif
/*
** Send a time-out reply
*/
void sigalrm_handler(int x){
fossil_panic("TIMEOUT");
}
/*
** COMMAND: server*
** COMMAND: ui
**
** Usage: %fossil server ?OPTIONS? ?REPOSITORY?
** or: %fossil ui ?OPTIONS? ?REPOSITORY?
|
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
|
}
return 0;
}
#endif
#endif
/*
** Respond to a SIGALRM by writing a message to the error log (if there
** is one) and exiting.
*/
static void sigalrm_handler(int x){
fossil_panic("TIMEOUT");
}
/*
** Arrange to timeout using SIGALRM after N seconds. Or if N==0, cancel
** any pending timeout.
**
** Bugs:
** (1) This only works on unix systems.
** (2) Any call to sleep() or sqlite3_sleep() will cancel the alarm.
*/
void fossil_set_timeout(int N){
#ifndef _WIN32
signal(SIGALRM, sigalrm_handler);
alarm(N);
#endif
}
/*
** COMMAND: server*
** COMMAND: ui
**
** Usage: %fossil server ?OPTIONS? ?REPOSITORY?
** or: %fossil ui ?OPTIONS? ?REPOSITORY?
|
| ︙ | | | ︙ | |
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
|
const char *zBrowser; /* Name of web browser program */
char *zBrowserCmd = 0; /* Command to launch the web browser */
int isUiCmd; /* True if command is "ui", not "server' */
const char *zNotFound; /* The --notfound option or NULL */
int flags = 0; /* Server flags */
#if !defined(_WIN32)
int noJail; /* Do not enter the chroot jail */
const char *zMaxLatency; /* Maximum runtime of any single HTTP request */
#endif
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
|
|
|
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
|
const char *zBrowser; /* Name of web browser program */
char *zBrowserCmd = 0; /* Command to launch the web browser */
int isUiCmd; /* True if command is "ui", not "server' */
const char *zNotFound; /* The --notfound option or NULL */
int flags = 0; /* Server flags */
#if !defined(_WIN32)
int noJail; /* Do not enter the chroot jail */
const char *zTimeout = "300"; /* Max runtime of any single HTTP request */
#endif
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
|
| ︙ | | | ︙ | |
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
|
zFileGlob = z;
}else{
zFileGlob = find_option("files",0,1);
}
skin_override();
#if !defined(_WIN32)
noJail = find_option("nojail",0,0)!=0;
zMaxLatency = find_option("max-latency",0,1);
#endif
g.useLocalauth = find_option("localauth", 0, 0)!=0;
Th_InitTraceLog();
zPort = find_option("port", "P", 1);
isUiCmd = g.argv[1][0]=='u';
if( isUiCmd ){
zInitPage = find_option("page", 0, 1);
|
|
|
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
|
zFileGlob = z;
}else{
zFileGlob = find_option("files",0,1);
}
skin_override();
#if !defined(_WIN32)
noJail = find_option("nojail",0,0)!=0;
zTimeout = find_option("max-latency",0,1);
#endif
g.useLocalauth = find_option("localauth", 0, 0)!=0;
Th_InitTraceLog();
zPort = find_option("port", "P", 1);
isUiCmd = g.argv[1][0]=='u';
if( isUiCmd ){
zInitPage = find_option("page", 0, 1);
|
| ︙ | | | ︙ | |
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
|
** client connection, a child process is created, file descriptors 0
** and 1 are bound to that connection, and the child returns.
**
** So, when control reaches this point, we are running as a
** child process, the HTTP or SCGI request is pending on file
** descriptor 0 and the reply should be written to file descriptor 1.
*/
if( zMaxLatency ){
signal(SIGALRM, sigalrm_handler);
alarm(atoi(zMaxLatency));
}
g.httpIn = stdin;
g.httpOut = stdout;
#if !defined(_WIN32)
signal(SIGSEGV, sigsegv_handler);
signal(SIGPIPE, sigpipe_handler);
|
|
<
|
|
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
|
** client connection, a child process is created, file descriptors 0
** and 1 are bound to that connection, and the child returns.
**
** So, when control reaches this point, we are running as a
** child process, the HTTP or SCGI request is pending on file
** descriptor 0 and the reply should be written to file descriptor 1.
*/
if( zTimeout ){
fossil_set_timeout(atoi(zTimeout));
}
g.httpIn = stdin;
g.httpOut = stdout;
#if !defined(_WIN32)
signal(SIGSEGV, sigsegv_handler);
signal(SIGPIPE, sigpipe_handler);
|
| ︙ | | | ︙ | |