Fossil SCM

Fixes and enhancements to SEE integration on Windows.

mistachkin 2020-06-08 23:11 trunk merge
Commit 57d8a71f4257418a8ccd12dd723d64bceda8de60d07a34ccc8379ed4baea9514
+28
--- src/db.c
+++ src/db.c
@@ -1182,10 +1182,36 @@
11821182
}
11831183
}else{
11841184
fossil_panic("failed to open pid %lu: %lu", processId, GetLastError());
11851185
}
11861186
}
1187
+
1188
+/*
1189
+** This function evaluates the specified TH1 script and attempts to parse
1190
+** its result as a colon-delimited triplet containing a process identifier,
1191
+** address, and size (in bytes) of the database encryption key. This is
1192
+** only necessary (or functional) on Windows.
1193
+*/
1194
+void db_read_saved_encryption_key_from_process_via_th1(
1195
+ const char *zConfig /* The TH1 script to evaluate. */
1196
+){
1197
+ int rc;
1198
+ char *zResult;
1199
+ Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_NEED_CONFIG | TH_INIT_NO_REPO);
1200
+ rc = Th_Eval(g.interp, 0, zConfig, -1);
1201
+ zResult = (char*)Th_GetResult(g.interp, 0);
1202
+ if( rc!=TH_OK ){
1203
+ fossil_fatal("script for pid key failed: %s", zResult);
1204
+ }
1205
+ if( zResult ){
1206
+ DWORD processId = 0;
1207
+ LPVOID pAddress = NULL;
1208
+ SIZE_T nSize = 0;
1209
+ parse_pid_key_value(zResult, &processId, &pAddress, &nSize);
1210
+ db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
1211
+ }
1212
+}
11871213
#endif /* defined(_WIN32) */
11881214
#endif /* USE_SEE */
11891215
11901216
/*
11911217
** If the database file zDbFile has a name that suggests that it is
@@ -1386,10 +1412,11 @@
13861412
int rc;
13871413
sqlite3_wal_checkpoint(g.db, 0);
13881414
rc = sqlite3_close(g.db);
13891415
if( g.fSqlTrace ) fossil_trace("-- db_close_config(%d)\n", rc);
13901416
g.db = 0;
1417
+ g.repositoryOpen = 0;
13911418
}else{
13921419
return;
13931420
}
13941421
fossil_free(g.zConfigDbName);
13951422
g.zConfigDbName = 0;
@@ -3932,10 +3959,11 @@
39323959
sqlite3_open(":memory:", &g.db);
39333960
rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
39343961
fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
39353962
sqlite3_close(g.db);
39363963
g.db = 0;
3964
+ g.repositoryOpen = 0;
39373965
}
39383966
39393967
/*
39403968
** COMMAND: test-without-rowid
39413969
**
39423970
--- src/db.c
+++ src/db.c
@@ -1182,10 +1182,36 @@
1182 }
1183 }else{
1184 fossil_panic("failed to open pid %lu: %lu", processId, GetLastError());
1185 }
1186 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1187 #endif /* defined(_WIN32) */
1188 #endif /* USE_SEE */
1189
1190 /*
1191 ** If the database file zDbFile has a name that suggests that it is
@@ -1386,10 +1412,11 @@
1386 int rc;
1387 sqlite3_wal_checkpoint(g.db, 0);
1388 rc = sqlite3_close(g.db);
1389 if( g.fSqlTrace ) fossil_trace("-- db_close_config(%d)\n", rc);
1390 g.db = 0;
 
1391 }else{
1392 return;
1393 }
1394 fossil_free(g.zConfigDbName);
1395 g.zConfigDbName = 0;
@@ -3932,10 +3959,11 @@
3932 sqlite3_open(":memory:", &g.db);
3933 rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
3934 fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
3935 sqlite3_close(g.db);
3936 g.db = 0;
 
3937 }
3938
3939 /*
3940 ** COMMAND: test-without-rowid
3941 **
3942
--- src/db.c
+++ src/db.c
@@ -1182,10 +1182,36 @@
1182 }
1183 }else{
1184 fossil_panic("failed to open pid %lu: %lu", processId, GetLastError());
1185 }
1186 }
1187
1188 /*
1189 ** This function evaluates the specified TH1 script and attempts to parse
1190 ** its result as a colon-delimited triplet containing a process identifier,
1191 ** address, and size (in bytes) of the database encryption key. This is
1192 ** only necessary (or functional) on Windows.
1193 */
1194 void db_read_saved_encryption_key_from_process_via_th1(
1195 const char *zConfig /* The TH1 script to evaluate. */
1196 ){
1197 int rc;
1198 char *zResult;
1199 Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_NEED_CONFIG | TH_INIT_NO_REPO);
1200 rc = Th_Eval(g.interp, 0, zConfig, -1);
1201 zResult = (char*)Th_GetResult(g.interp, 0);
1202 if( rc!=TH_OK ){
1203 fossil_fatal("script for pid key failed: %s", zResult);
1204 }
1205 if( zResult ){
1206 DWORD processId = 0;
1207 LPVOID pAddress = NULL;
1208 SIZE_T nSize = 0;
1209 parse_pid_key_value(zResult, &processId, &pAddress, &nSize);
1210 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
1211 }
1212 }
1213 #endif /* defined(_WIN32) */
1214 #endif /* USE_SEE */
1215
1216 /*
1217 ** If the database file zDbFile has a name that suggests that it is
@@ -1386,10 +1412,11 @@
1412 int rc;
1413 sqlite3_wal_checkpoint(g.db, 0);
1414 rc = sqlite3_close(g.db);
1415 if( g.fSqlTrace ) fossil_trace("-- db_close_config(%d)\n", rc);
1416 g.db = 0;
1417 g.repositoryOpen = 0;
1418 }else{
1419 return;
1420 }
1421 fossil_free(g.zConfigDbName);
1422 g.zConfigDbName = 0;
@@ -3932,10 +3959,11 @@
3959 sqlite3_open(":memory:", &g.db);
3960 rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
3961 fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
3962 sqlite3_close(g.db);
3963 g.db = 0;
3964 g.repositoryOpen = 0;
3965 }
3966
3967 /*
3968 ** COMMAND: test-without-rowid
3969 **
3970
+57 -28
--- src/main.c
+++ src/main.c
@@ -210,10 +210,14 @@
210210
Blob httpHeader; /* Complete text of the HTTP request header */
211211
UrlData url; /* Information about current URL */
212212
const char *zLogin; /* Login name. NULL or "" if not logged in. */
213213
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
214214
** SSL client identity */
215
+#if defined(_WIN32) && USE_SEE
216
+ const char *zPidKey; /* Saved value of the --usepidkey option. Only
217
+ * applicable when using SEE on Windows. */
218
+#endif
215219
int useLocalauth; /* No login required if from 127.0.0.1 */
216220
int noPswd; /* Logged in without password (on 127.0.0.1) */
217221
int userUid; /* Integer user id */
218222
int isHuman; /* True if access by a human, not a spider or bot */
219223
int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
@@ -758,10 +762,30 @@
758762
if( find_option("utc",0,0) ) g.fTimeFormat = 1;
759763
if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
760764
if( zChdir && file_chdir(zChdir, 0) ){
761765
fossil_fatal("unable to change directories to %s", zChdir);
762766
}
767
+#if defined(_WIN32) && USE_SEE
768
+ {
769
+ g.zPidKey = find_option("usepidkey",0,1);
770
+ if( g.zPidKey ){
771
+ DWORD processId = 0;
772
+ LPVOID pAddress = NULL;
773
+ SIZE_T nSize = 0;
774
+ parse_pid_key_value(g.zPidKey, &processId, &pAddress, &nSize);
775
+ db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
776
+ }else{
777
+ const char *zSeeDbConfig = find_option("seedbcfg",0,1);
778
+ if( !zSeeDbConfig ){
779
+ zSeeDbConfig = fossil_getenv("FOSSIL_SEE_DB_CONFIG");
780
+ }
781
+ if( zSeeDbConfig ){
782
+ db_read_saved_encryption_key_from_process_via_th1(zSeeDbConfig);
783
+ }
784
+ }
785
+ }
786
+#endif
763787
if( find_option("help",0,0)!=0 ){
764788
/* If --help is found anywhere on the command line, translate the command
765789
* to "fossil help cmdname" where "cmdname" is the first argument that
766790
* does not begin with a "-" character. If all arguments start with "-",
767791
* translate to "fossil help argv[1] argv[2]...". */
@@ -2345,10 +2369,43 @@
23452369
}else{
23462370
fossil_fatal("failed to parse pid key");
23472371
}
23482372
}
23492373
#endif
2374
+
2375
+/*
2376
+** WEBPAGE: test-pid
2377
+**
2378
+** Return the process identifier of the running Fossil server instance.
2379
+**
2380
+** Query parameters:
2381
+**
2382
+** usepidkey When present and available, also return the
2383
+** address and size, within this server process,
2384
+** of the saved database encryption key. This
2385
+** is only supported when using SEE on Windows.
2386
+*/
2387
+void test_pid_page(void){
2388
+ login_check_credentials();
2389
+ if( !g.perm.Setup ){ login_needed(0); return; }
2390
+#if defined(_WIN32) && USE_SEE
2391
+ if( P("usepidkey")!=0 ){
2392
+ if( g.zPidKey ){
2393
+ @ %s(g.zPidKey)
2394
+ return;
2395
+ }else{
2396
+ const char *zSavedKey = db_get_saved_encryption_key();
2397
+ size_t savedKeySize = db_get_saved_encryption_key_size();
2398
+ if( zSavedKey!=0 && savedKeySize>0 ){
2399
+ @ %lu(GetCurrentProcessId()):%p(zSavedKey):%u(savedKeySize)
2400
+ return;
2401
+ }
2402
+ }
2403
+ }
2404
+#endif
2405
+ @ %d(GETPID())
2406
+}
23502407
23512408
/*
23522409
** COMMAND: http*
23532410
**
23542411
** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
@@ -2413,13 +2470,10 @@
24132470
const char *zInFile;
24142471
const char *zOutFile;
24152472
int useSCGI;
24162473
int noJail;
24172474
int allowRepoList;
2418
-#if defined(_WIN32) && USE_SEE
2419
- const char *zPidKey;
2420
-#endif
24212475
24222476
Th_InitTraceLog();
24232477
24242478
/* The winhttp module passes the --files option as --files-urlenc with
24252479
** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2466,21 +2520,10 @@
24662520
cgi_replace_parameter("HTTPS","on");
24672521
}
24682522
zHost = find_option("host", 0, 1);
24692523
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
24702524
2471
-#if defined(_WIN32) && USE_SEE
2472
- zPidKey = find_option("usepidkey", 0, 1);
2473
- if( zPidKey ){
2474
- DWORD processId = 0;
2475
- LPVOID pAddress = NULL;
2476
- SIZE_T nSize = 0;
2477
- parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2478
- db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2479
- }
2480
-#endif
2481
-
24822525
/* We should be done with options.. */
24832526
verify_all_options();
24842527
24852528
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
24862529
g.cgiOutput = 1;
@@ -2695,13 +2738,10 @@
26952738
const char *zAltBase; /* Argument to the --baseurl option */
26962739
const char *zFileGlob; /* Static content must match this */
26972740
char *zIpAddr = 0; /* Bind to this IP address */
26982741
int fCreate = 0; /* The --create flag */
26992742
const char *zInitPage = 0; /* Start on this page. --page option */
2700
-#if defined(_WIN32) && USE_SEE
2701
- const char *zPidKey;
2702
-#endif
27032743
27042744
#if defined(_WIN32)
27052745
const char *zStopperFile; /* Name of file used to terminate server */
27062746
zStopperFile = find_option("stopper", 0, 1);
27072747
#endif
@@ -2745,21 +2785,10 @@
27452785
}
27462786
if( find_option("localhost", 0, 0)!=0 ){
27472787
flags |= HTTP_SERVER_LOCALHOST;
27482788
}
27492789
2750
-#if defined(_WIN32) && USE_SEE
2751
- zPidKey = find_option("usepidkey", 0, 1);
2752
- if( zPidKey ){
2753
- DWORD processId = 0;
2754
- LPVOID pAddress = NULL;
2755
- SIZE_T nSize = 0;
2756
- parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2757
- db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2758
- }
2759
-#endif
2760
-
27612790
/* We should be done with options.. */
27622791
verify_all_options();
27632792
27642793
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
27652794
if( isUiCmd ){
27662795
--- src/main.c
+++ src/main.c
@@ -210,10 +210,14 @@
210 Blob httpHeader; /* Complete text of the HTTP request header */
211 UrlData url; /* Information about current URL */
212 const char *zLogin; /* Login name. NULL or "" if not logged in. */
213 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
214 ** SSL client identity */
 
 
 
 
215 int useLocalauth; /* No login required if from 127.0.0.1 */
216 int noPswd; /* Logged in without password (on 127.0.0.1) */
217 int userUid; /* Integer user id */
218 int isHuman; /* True if access by a human, not a spider or bot */
219 int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
@@ -758,10 +762,30 @@
758 if( find_option("utc",0,0) ) g.fTimeFormat = 1;
759 if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
760 if( zChdir && file_chdir(zChdir, 0) ){
761 fossil_fatal("unable to change directories to %s", zChdir);
762 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763 if( find_option("help",0,0)!=0 ){
764 /* If --help is found anywhere on the command line, translate the command
765 * to "fossil help cmdname" where "cmdname" is the first argument that
766 * does not begin with a "-" character. If all arguments start with "-",
767 * translate to "fossil help argv[1] argv[2]...". */
@@ -2345,10 +2369,43 @@
2345 }else{
2346 fossil_fatal("failed to parse pid key");
2347 }
2348 }
2349 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2350
2351 /*
2352 ** COMMAND: http*
2353 **
2354 ** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
@@ -2413,13 +2470,10 @@
2413 const char *zInFile;
2414 const char *zOutFile;
2415 int useSCGI;
2416 int noJail;
2417 int allowRepoList;
2418 #if defined(_WIN32) && USE_SEE
2419 const char *zPidKey;
2420 #endif
2421
2422 Th_InitTraceLog();
2423
2424 /* The winhttp module passes the --files option as --files-urlenc with
2425 ** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2466,21 +2520,10 @@
2466 cgi_replace_parameter("HTTPS","on");
2467 }
2468 zHost = find_option("host", 0, 1);
2469 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2470
2471 #if defined(_WIN32) && USE_SEE
2472 zPidKey = find_option("usepidkey", 0, 1);
2473 if( zPidKey ){
2474 DWORD processId = 0;
2475 LPVOID pAddress = NULL;
2476 SIZE_T nSize = 0;
2477 parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2478 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2479 }
2480 #endif
2481
2482 /* We should be done with options.. */
2483 verify_all_options();
2484
2485 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2486 g.cgiOutput = 1;
@@ -2695,13 +2738,10 @@
2695 const char *zAltBase; /* Argument to the --baseurl option */
2696 const char *zFileGlob; /* Static content must match this */
2697 char *zIpAddr = 0; /* Bind to this IP address */
2698 int fCreate = 0; /* The --create flag */
2699 const char *zInitPage = 0; /* Start on this page. --page option */
2700 #if defined(_WIN32) && USE_SEE
2701 const char *zPidKey;
2702 #endif
2703
2704 #if defined(_WIN32)
2705 const char *zStopperFile; /* Name of file used to terminate server */
2706 zStopperFile = find_option("stopper", 0, 1);
2707 #endif
@@ -2745,21 +2785,10 @@
2745 }
2746 if( find_option("localhost", 0, 0)!=0 ){
2747 flags |= HTTP_SERVER_LOCALHOST;
2748 }
2749
2750 #if defined(_WIN32) && USE_SEE
2751 zPidKey = find_option("usepidkey", 0, 1);
2752 if( zPidKey ){
2753 DWORD processId = 0;
2754 LPVOID pAddress = NULL;
2755 SIZE_T nSize = 0;
2756 parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2757 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2758 }
2759 #endif
2760
2761 /* We should be done with options.. */
2762 verify_all_options();
2763
2764 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2765 if( isUiCmd ){
2766
--- src/main.c
+++ src/main.c
@@ -210,10 +210,14 @@
210 Blob httpHeader; /* Complete text of the HTTP request header */
211 UrlData url; /* Information about current URL */
212 const char *zLogin; /* Login name. NULL or "" if not logged in. */
213 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
214 ** SSL client identity */
215 #if defined(_WIN32) && USE_SEE
216 const char *zPidKey; /* Saved value of the --usepidkey option. Only
217 * applicable when using SEE on Windows. */
218 #endif
219 int useLocalauth; /* No login required if from 127.0.0.1 */
220 int noPswd; /* Logged in without password (on 127.0.0.1) */
221 int userUid; /* Integer user id */
222 int isHuman; /* True if access by a human, not a spider or bot */
223 int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
@@ -758,10 +762,30 @@
762 if( find_option("utc",0,0) ) g.fTimeFormat = 1;
763 if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
764 if( zChdir && file_chdir(zChdir, 0) ){
765 fossil_fatal("unable to change directories to %s", zChdir);
766 }
767 #if defined(_WIN32) && USE_SEE
768 {
769 g.zPidKey = find_option("usepidkey",0,1);
770 if( g.zPidKey ){
771 DWORD processId = 0;
772 LPVOID pAddress = NULL;
773 SIZE_T nSize = 0;
774 parse_pid_key_value(g.zPidKey, &processId, &pAddress, &nSize);
775 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
776 }else{
777 const char *zSeeDbConfig = find_option("seedbcfg",0,1);
778 if( !zSeeDbConfig ){
779 zSeeDbConfig = fossil_getenv("FOSSIL_SEE_DB_CONFIG");
780 }
781 if( zSeeDbConfig ){
782 db_read_saved_encryption_key_from_process_via_th1(zSeeDbConfig);
783 }
784 }
785 }
786 #endif
787 if( find_option("help",0,0)!=0 ){
788 /* If --help is found anywhere on the command line, translate the command
789 * to "fossil help cmdname" where "cmdname" is the first argument that
790 * does not begin with a "-" character. If all arguments start with "-",
791 * translate to "fossil help argv[1] argv[2]...". */
@@ -2345,10 +2369,43 @@
2369 }else{
2370 fossil_fatal("failed to parse pid key");
2371 }
2372 }
2373 #endif
2374
2375 /*
2376 ** WEBPAGE: test-pid
2377 **
2378 ** Return the process identifier of the running Fossil server instance.
2379 **
2380 ** Query parameters:
2381 **
2382 ** usepidkey When present and available, also return the
2383 ** address and size, within this server process,
2384 ** of the saved database encryption key. This
2385 ** is only supported when using SEE on Windows.
2386 */
2387 void test_pid_page(void){
2388 login_check_credentials();
2389 if( !g.perm.Setup ){ login_needed(0); return; }
2390 #if defined(_WIN32) && USE_SEE
2391 if( P("usepidkey")!=0 ){
2392 if( g.zPidKey ){
2393 @ %s(g.zPidKey)
2394 return;
2395 }else{
2396 const char *zSavedKey = db_get_saved_encryption_key();
2397 size_t savedKeySize = db_get_saved_encryption_key_size();
2398 if( zSavedKey!=0 && savedKeySize>0 ){
2399 @ %lu(GetCurrentProcessId()):%p(zSavedKey):%u(savedKeySize)
2400 return;
2401 }
2402 }
2403 }
2404 #endif
2405 @ %d(GETPID())
2406 }
2407
2408 /*
2409 ** COMMAND: http*
2410 **
2411 ** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
@@ -2413,13 +2470,10 @@
2470 const char *zInFile;
2471 const char *zOutFile;
2472 int useSCGI;
2473 int noJail;
2474 int allowRepoList;
 
 
 
2475
2476 Th_InitTraceLog();
2477
2478 /* The winhttp module passes the --files option as --files-urlenc with
2479 ** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2466,21 +2520,10 @@
2520 cgi_replace_parameter("HTTPS","on");
2521 }
2522 zHost = find_option("host", 0, 1);
2523 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2524
 
 
 
 
 
 
 
 
 
 
 
2525 /* We should be done with options.. */
2526 verify_all_options();
2527
2528 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2529 g.cgiOutput = 1;
@@ -2695,13 +2738,10 @@
2738 const char *zAltBase; /* Argument to the --baseurl option */
2739 const char *zFileGlob; /* Static content must match this */
2740 char *zIpAddr = 0; /* Bind to this IP address */
2741 int fCreate = 0; /* The --create flag */
2742 const char *zInitPage = 0; /* Start on this page. --page option */
 
 
 
2743
2744 #if defined(_WIN32)
2745 const char *zStopperFile; /* Name of file used to terminate server */
2746 zStopperFile = find_option("stopper", 0, 1);
2747 #endif
@@ -2745,21 +2785,10 @@
2785 }
2786 if( find_option("localhost", 0, 0)!=0 ){
2787 flags |= HTTP_SERVER_LOCALHOST;
2788 }
2789
 
 
 
 
 
 
 
 
 
 
 
2790 /* We should be done with options.. */
2791 verify_all_options();
2792
2793 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2794 if( isUiCmd ){
2795
+57 -28
--- src/main.c
+++ src/main.c
@@ -210,10 +210,14 @@
210210
Blob httpHeader; /* Complete text of the HTTP request header */
211211
UrlData url; /* Information about current URL */
212212
const char *zLogin; /* Login name. NULL or "" if not logged in. */
213213
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
214214
** SSL client identity */
215
+#if defined(_WIN32) && USE_SEE
216
+ const char *zPidKey; /* Saved value of the --usepidkey option. Only
217
+ * applicable when using SEE on Windows. */
218
+#endif
215219
int useLocalauth; /* No login required if from 127.0.0.1 */
216220
int noPswd; /* Logged in without password (on 127.0.0.1) */
217221
int userUid; /* Integer user id */
218222
int isHuman; /* True if access by a human, not a spider or bot */
219223
int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
@@ -758,10 +762,30 @@
758762
if( find_option("utc",0,0) ) g.fTimeFormat = 1;
759763
if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
760764
if( zChdir && file_chdir(zChdir, 0) ){
761765
fossil_fatal("unable to change directories to %s", zChdir);
762766
}
767
+#if defined(_WIN32) && USE_SEE
768
+ {
769
+ g.zPidKey = find_option("usepidkey",0,1);
770
+ if( g.zPidKey ){
771
+ DWORD processId = 0;
772
+ LPVOID pAddress = NULL;
773
+ SIZE_T nSize = 0;
774
+ parse_pid_key_value(g.zPidKey, &processId, &pAddress, &nSize);
775
+ db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
776
+ }else{
777
+ const char *zSeeDbConfig = find_option("seedbcfg",0,1);
778
+ if( !zSeeDbConfig ){
779
+ zSeeDbConfig = fossil_getenv("FOSSIL_SEE_DB_CONFIG");
780
+ }
781
+ if( zSeeDbConfig ){
782
+ db_read_saved_encryption_key_from_process_via_th1(zSeeDbConfig);
783
+ }
784
+ }
785
+ }
786
+#endif
763787
if( find_option("help",0,0)!=0 ){
764788
/* If --help is found anywhere on the command line, translate the command
765789
* to "fossil help cmdname" where "cmdname" is the first argument that
766790
* does not begin with a "-" character. If all arguments start with "-",
767791
* translate to "fossil help argv[1] argv[2]...". */
@@ -2345,10 +2369,43 @@
23452369
}else{
23462370
fossil_fatal("failed to parse pid key");
23472371
}
23482372
}
23492373
#endif
2374
+
2375
+/*
2376
+** WEBPAGE: test-pid
2377
+**
2378
+** Return the process identifier of the running Fossil server instance.
2379
+**
2380
+** Query parameters:
2381
+**
2382
+** usepidkey When present and available, also return the
2383
+** address and size, within this server process,
2384
+** of the saved database encryption key. This
2385
+** is only supported when using SEE on Windows.
2386
+*/
2387
+void test_pid_page(void){
2388
+ login_check_credentials();
2389
+ if( !g.perm.Setup ){ login_needed(0); return; }
2390
+#if defined(_WIN32) && USE_SEE
2391
+ if( P("usepidkey")!=0 ){
2392
+ if( g.zPidKey ){
2393
+ @ %s(g.zPidKey)
2394
+ return;
2395
+ }else{
2396
+ const char *zSavedKey = db_get_saved_encryption_key();
2397
+ size_t savedKeySize = db_get_saved_encryption_key_size();
2398
+ if( zSavedKey!=0 && savedKeySize>0 ){
2399
+ @ %lu(GetCurrentProcessId()):%p(zSavedKey):%u(savedKeySize)
2400
+ return;
2401
+ }
2402
+ }
2403
+ }
2404
+#endif
2405
+ @ %d(GETPID())
2406
+}
23502407
23512408
/*
23522409
** COMMAND: http*
23532410
**
23542411
** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
@@ -2413,13 +2470,10 @@
24132470
const char *zInFile;
24142471
const char *zOutFile;
24152472
int useSCGI;
24162473
int noJail;
24172474
int allowRepoList;
2418
-#if defined(_WIN32) && USE_SEE
2419
- const char *zPidKey;
2420
-#endif
24212475
24222476
Th_InitTraceLog();
24232477
24242478
/* The winhttp module passes the --files option as --files-urlenc with
24252479
** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2466,21 +2520,10 @@
24662520
cgi_replace_parameter("HTTPS","on");
24672521
}
24682522
zHost = find_option("host", 0, 1);
24692523
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
24702524
2471
-#if defined(_WIN32) && USE_SEE
2472
- zPidKey = find_option("usepidkey", 0, 1);
2473
- if( zPidKey ){
2474
- DWORD processId = 0;
2475
- LPVOID pAddress = NULL;
2476
- SIZE_T nSize = 0;
2477
- parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2478
- db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2479
- }
2480
-#endif
2481
-
24822525
/* We should be done with options.. */
24832526
verify_all_options();
24842527
24852528
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
24862529
g.cgiOutput = 1;
@@ -2695,13 +2738,10 @@
26952738
const char *zAltBase; /* Argument to the --baseurl option */
26962739
const char *zFileGlob; /* Static content must match this */
26972740
char *zIpAddr = 0; /* Bind to this IP address */
26982741
int fCreate = 0; /* The --create flag */
26992742
const char *zInitPage = 0; /* Start on this page. --page option */
2700
-#if defined(_WIN32) && USE_SEE
2701
- const char *zPidKey;
2702
-#endif
27032743
27042744
#if defined(_WIN32)
27052745
const char *zStopperFile; /* Name of file used to terminate server */
27062746
zStopperFile = find_option("stopper", 0, 1);
27072747
#endif
@@ -2745,21 +2785,10 @@
27452785
}
27462786
if( find_option("localhost", 0, 0)!=0 ){
27472787
flags |= HTTP_SERVER_LOCALHOST;
27482788
}
27492789
2750
-#if defined(_WIN32) && USE_SEE
2751
- zPidKey = find_option("usepidkey", 0, 1);
2752
- if( zPidKey ){
2753
- DWORD processId = 0;
2754
- LPVOID pAddress = NULL;
2755
- SIZE_T nSize = 0;
2756
- parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2757
- db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2758
- }
2759
-#endif
2760
-
27612790
/* We should be done with options.. */
27622791
verify_all_options();
27632792
27642793
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
27652794
if( isUiCmd ){
27662795
--- src/main.c
+++ src/main.c
@@ -210,10 +210,14 @@
210 Blob httpHeader; /* Complete text of the HTTP request header */
211 UrlData url; /* Information about current URL */
212 const char *zLogin; /* Login name. NULL or "" if not logged in. */
213 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
214 ** SSL client identity */
 
 
 
 
215 int useLocalauth; /* No login required if from 127.0.0.1 */
216 int noPswd; /* Logged in without password (on 127.0.0.1) */
217 int userUid; /* Integer user id */
218 int isHuman; /* True if access by a human, not a spider or bot */
219 int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
@@ -758,10 +762,30 @@
758 if( find_option("utc",0,0) ) g.fTimeFormat = 1;
759 if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
760 if( zChdir && file_chdir(zChdir, 0) ){
761 fossil_fatal("unable to change directories to %s", zChdir);
762 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763 if( find_option("help",0,0)!=0 ){
764 /* If --help is found anywhere on the command line, translate the command
765 * to "fossil help cmdname" where "cmdname" is the first argument that
766 * does not begin with a "-" character. If all arguments start with "-",
767 * translate to "fossil help argv[1] argv[2]...". */
@@ -2345,10 +2369,43 @@
2345 }else{
2346 fossil_fatal("failed to parse pid key");
2347 }
2348 }
2349 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2350
2351 /*
2352 ** COMMAND: http*
2353 **
2354 ** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
@@ -2413,13 +2470,10 @@
2413 const char *zInFile;
2414 const char *zOutFile;
2415 int useSCGI;
2416 int noJail;
2417 int allowRepoList;
2418 #if defined(_WIN32) && USE_SEE
2419 const char *zPidKey;
2420 #endif
2421
2422 Th_InitTraceLog();
2423
2424 /* The winhttp module passes the --files option as --files-urlenc with
2425 ** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2466,21 +2520,10 @@
2466 cgi_replace_parameter("HTTPS","on");
2467 }
2468 zHost = find_option("host", 0, 1);
2469 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2470
2471 #if defined(_WIN32) && USE_SEE
2472 zPidKey = find_option("usepidkey", 0, 1);
2473 if( zPidKey ){
2474 DWORD processId = 0;
2475 LPVOID pAddress = NULL;
2476 SIZE_T nSize = 0;
2477 parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2478 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2479 }
2480 #endif
2481
2482 /* We should be done with options.. */
2483 verify_all_options();
2484
2485 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2486 g.cgiOutput = 1;
@@ -2695,13 +2738,10 @@
2695 const char *zAltBase; /* Argument to the --baseurl option */
2696 const char *zFileGlob; /* Static content must match this */
2697 char *zIpAddr = 0; /* Bind to this IP address */
2698 int fCreate = 0; /* The --create flag */
2699 const char *zInitPage = 0; /* Start on this page. --page option */
2700 #if defined(_WIN32) && USE_SEE
2701 const char *zPidKey;
2702 #endif
2703
2704 #if defined(_WIN32)
2705 const char *zStopperFile; /* Name of file used to terminate server */
2706 zStopperFile = find_option("stopper", 0, 1);
2707 #endif
@@ -2745,21 +2785,10 @@
2745 }
2746 if( find_option("localhost", 0, 0)!=0 ){
2747 flags |= HTTP_SERVER_LOCALHOST;
2748 }
2749
2750 #if defined(_WIN32) && USE_SEE
2751 zPidKey = find_option("usepidkey", 0, 1);
2752 if( zPidKey ){
2753 DWORD processId = 0;
2754 LPVOID pAddress = NULL;
2755 SIZE_T nSize = 0;
2756 parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2757 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2758 }
2759 #endif
2760
2761 /* We should be done with options.. */
2762 verify_all_options();
2763
2764 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2765 if( isUiCmd ){
2766
--- src/main.c
+++ src/main.c
@@ -210,10 +210,14 @@
210 Blob httpHeader; /* Complete text of the HTTP request header */
211 UrlData url; /* Information about current URL */
212 const char *zLogin; /* Login name. NULL or "" if not logged in. */
213 const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
214 ** SSL client identity */
215 #if defined(_WIN32) && USE_SEE
216 const char *zPidKey; /* Saved value of the --usepidkey option. Only
217 * applicable when using SEE on Windows. */
218 #endif
219 int useLocalauth; /* No login required if from 127.0.0.1 */
220 int noPswd; /* Logged in without password (on 127.0.0.1) */
221 int userUid; /* Integer user id */
222 int isHuman; /* True if access by a human, not a spider or bot */
223 int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
@@ -758,10 +762,30 @@
762 if( find_option("utc",0,0) ) g.fTimeFormat = 1;
763 if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
764 if( zChdir && file_chdir(zChdir, 0) ){
765 fossil_fatal("unable to change directories to %s", zChdir);
766 }
767 #if defined(_WIN32) && USE_SEE
768 {
769 g.zPidKey = find_option("usepidkey",0,1);
770 if( g.zPidKey ){
771 DWORD processId = 0;
772 LPVOID pAddress = NULL;
773 SIZE_T nSize = 0;
774 parse_pid_key_value(g.zPidKey, &processId, &pAddress, &nSize);
775 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
776 }else{
777 const char *zSeeDbConfig = find_option("seedbcfg",0,1);
778 if( !zSeeDbConfig ){
779 zSeeDbConfig = fossil_getenv("FOSSIL_SEE_DB_CONFIG");
780 }
781 if( zSeeDbConfig ){
782 db_read_saved_encryption_key_from_process_via_th1(zSeeDbConfig);
783 }
784 }
785 }
786 #endif
787 if( find_option("help",0,0)!=0 ){
788 /* If --help is found anywhere on the command line, translate the command
789 * to "fossil help cmdname" where "cmdname" is the first argument that
790 * does not begin with a "-" character. If all arguments start with "-",
791 * translate to "fossil help argv[1] argv[2]...". */
@@ -2345,10 +2369,43 @@
2369 }else{
2370 fossil_fatal("failed to parse pid key");
2371 }
2372 }
2373 #endif
2374
2375 /*
2376 ** WEBPAGE: test-pid
2377 **
2378 ** Return the process identifier of the running Fossil server instance.
2379 **
2380 ** Query parameters:
2381 **
2382 ** usepidkey When present and available, also return the
2383 ** address and size, within this server process,
2384 ** of the saved database encryption key. This
2385 ** is only supported when using SEE on Windows.
2386 */
2387 void test_pid_page(void){
2388 login_check_credentials();
2389 if( !g.perm.Setup ){ login_needed(0); return; }
2390 #if defined(_WIN32) && USE_SEE
2391 if( P("usepidkey")!=0 ){
2392 if( g.zPidKey ){
2393 @ %s(g.zPidKey)
2394 return;
2395 }else{
2396 const char *zSavedKey = db_get_saved_encryption_key();
2397 size_t savedKeySize = db_get_saved_encryption_key_size();
2398 if( zSavedKey!=0 && savedKeySize>0 ){
2399 @ %lu(GetCurrentProcessId()):%p(zSavedKey):%u(savedKeySize)
2400 return;
2401 }
2402 }
2403 }
2404 #endif
2405 @ %d(GETPID())
2406 }
2407
2408 /*
2409 ** COMMAND: http*
2410 **
2411 ** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
@@ -2413,13 +2470,10 @@
2470 const char *zInFile;
2471 const char *zOutFile;
2472 int useSCGI;
2473 int noJail;
2474 int allowRepoList;
 
 
 
2475
2476 Th_InitTraceLog();
2477
2478 /* The winhttp module passes the --files option as --files-urlenc with
2479 ** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2466,21 +2520,10 @@
2520 cgi_replace_parameter("HTTPS","on");
2521 }
2522 zHost = find_option("host", 0, 1);
2523 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2524
 
 
 
 
 
 
 
 
 
 
 
2525 /* We should be done with options.. */
2526 verify_all_options();
2527
2528 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2529 g.cgiOutput = 1;
@@ -2695,13 +2738,10 @@
2738 const char *zAltBase; /* Argument to the --baseurl option */
2739 const char *zFileGlob; /* Static content must match this */
2740 char *zIpAddr = 0; /* Bind to this IP address */
2741 int fCreate = 0; /* The --create flag */
2742 const char *zInitPage = 0; /* Start on this page. --page option */
 
 
 
2743
2744 #if defined(_WIN32)
2745 const char *zStopperFile; /* Name of file used to terminate server */
2746 zStopperFile = find_option("stopper", 0, 1);
2747 #endif
@@ -2745,21 +2785,10 @@
2785 }
2786 if( find_option("localhost", 0, 0)!=0 ){
2787 flags |= HTTP_SERVER_LOCALHOST;
2788 }
2789
 
 
 
 
 
 
 
 
 
 
 
2790 /* We should be done with options.. */
2791 verify_all_options();
2792
2793 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2794 if( isUiCmd ){
2795
--- src/repolist.c
+++ src/repolist.c
@@ -141,10 +141,12 @@
141141
}
142142
n = db_int(0, "SELECT count(*) FROM sfile");
143143
if( n==0 ){
144144
sqlite3_close(g.db);
145145
g.db = 0;
146
+ g.repositoryOpen = 0;
147
+ g.localOpen = 0;
146148
return 0;
147149
}else{
148150
Stmt q;
149151
double rNow;
150152
blob_append_sql(&html,
151153
--- src/repolist.c
+++ src/repolist.c
@@ -141,10 +141,12 @@
141 }
142 n = db_int(0, "SELECT count(*) FROM sfile");
143 if( n==0 ){
144 sqlite3_close(g.db);
145 g.db = 0;
 
 
146 return 0;
147 }else{
148 Stmt q;
149 double rNow;
150 blob_append_sql(&html,
151
--- src/repolist.c
+++ src/repolist.c
@@ -141,10 +141,12 @@
141 }
142 n = db_int(0, "SELECT count(*) FROM sfile");
143 if( n==0 ){
144 sqlite3_close(g.db);
145 g.db = 0;
146 g.repositoryOpen = 0;
147 g.localOpen = 0;
148 return 0;
149 }else{
150 Stmt q;
151 double rNow;
152 blob_append_sql(&html,
153
+7 -5
--- src/th_main.c
+++ src/th_main.c
@@ -30,11 +30,12 @@
3030
#define TH_INIT_NONE ((u32)0x00000000) /* No flags. */
3131
#define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */
3232
#define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */
3333
#define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */
3434
#define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */
35
-#define TH_INIT_MASK ((u32)0x0000000F) /* All possible init flags. */
35
+#define TH_INIT_NO_REPO ((u32)0x00000010) /* Skip opening repository. */
36
+#define TH_INIT_MASK ((u32)0x0000001F) /* All possible init flags. */
3637
3738
/*
3839
** Useful and/or "well-known" combinations of flag values.
3940
*/
4041
#define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */
@@ -44,13 +45,13 @@
4445
4546
/*
4647
** Flags set by functions in this file to keep track of integration state
4748
** information. These flags should not be used outside of this file.
4849
*/
49
-#define TH_STATE_CONFIG ((u32)0x00000010) /* We opened the config. */
50
-#define TH_STATE_REPOSITORY ((u32)0x00000020) /* We opened the repository. */
51
-#define TH_STATE_MASK ((u32)0x00000030) /* All possible state flags. */
50
+#define TH_STATE_CONFIG ((u32)0x00000020) /* We opened the config. */
51
+#define TH_STATE_REPOSITORY ((u32)0x00000040) /* We opened the repository. */
52
+#define TH_STATE_MASK ((u32)0x00000060) /* All possible state flags. */
5253
5354
#ifdef FOSSIL_ENABLE_TH1_HOOKS
5455
/*
5556
** These are the "well-known" TH1 error messages that occur when no hook is
5657
** registered to be called prior to executing a command or processing a web
@@ -2085,10 +2086,11 @@
20852086
int wasInit = 0;
20862087
int needConfig = flags & TH_INIT_NEED_CONFIG;
20872088
int forceReset = flags & TH_INIT_FORCE_RESET;
20882089
int forceTcl = flags & TH_INIT_FORCE_TCL;
20892090
int forceSetup = flags & TH_INIT_FORCE_SETUP;
2091
+ int noRepo = flags & TH_INIT_NO_REPO;
20902092
static unsigned int aFlags[] = { 0, 1, WIKI_LINKSONLY };
20912093
static int anonFlag = LOGIN_ANON;
20922094
static int zeroInt = 0;
20932095
static struct _Command {
20942096
const char *zName;
@@ -2152,11 +2154,11 @@
21522154
** This function uses several settings which may be defined in the
21532155
** repository and/or the global configuration. Since the caller
21542156
** passed a non-zero value for the needConfig parameter, make sure
21552157
** the necessary database connections are open prior to continuing.
21562158
*/
2157
- Th_OpenConfig(1);
2159
+ Th_OpenConfig(!noRepo);
21582160
}
21592161
if( forceReset || forceTcl || g.interp==0 ){
21602162
int created = 0;
21612163
int i;
21622164
if( g.interp==0 ){
21632165
--- src/th_main.c
+++ src/th_main.c
@@ -30,11 +30,12 @@
30 #define TH_INIT_NONE ((u32)0x00000000) /* No flags. */
31 #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */
32 #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */
33 #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */
34 #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */
35 #define TH_INIT_MASK ((u32)0x0000000F) /* All possible init flags. */
 
36
37 /*
38 ** Useful and/or "well-known" combinations of flag values.
39 */
40 #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */
@@ -44,13 +45,13 @@
44
45 /*
46 ** Flags set by functions in this file to keep track of integration state
47 ** information. These flags should not be used outside of this file.
48 */
49 #define TH_STATE_CONFIG ((u32)0x00000010) /* We opened the config. */
50 #define TH_STATE_REPOSITORY ((u32)0x00000020) /* We opened the repository. */
51 #define TH_STATE_MASK ((u32)0x00000030) /* All possible state flags. */
52
53 #ifdef FOSSIL_ENABLE_TH1_HOOKS
54 /*
55 ** These are the "well-known" TH1 error messages that occur when no hook is
56 ** registered to be called prior to executing a command or processing a web
@@ -2085,10 +2086,11 @@
2085 int wasInit = 0;
2086 int needConfig = flags & TH_INIT_NEED_CONFIG;
2087 int forceReset = flags & TH_INIT_FORCE_RESET;
2088 int forceTcl = flags & TH_INIT_FORCE_TCL;
2089 int forceSetup = flags & TH_INIT_FORCE_SETUP;
 
2090 static unsigned int aFlags[] = { 0, 1, WIKI_LINKSONLY };
2091 static int anonFlag = LOGIN_ANON;
2092 static int zeroInt = 0;
2093 static struct _Command {
2094 const char *zName;
@@ -2152,11 +2154,11 @@
2152 ** This function uses several settings which may be defined in the
2153 ** repository and/or the global configuration. Since the caller
2154 ** passed a non-zero value for the needConfig parameter, make sure
2155 ** the necessary database connections are open prior to continuing.
2156 */
2157 Th_OpenConfig(1);
2158 }
2159 if( forceReset || forceTcl || g.interp==0 ){
2160 int created = 0;
2161 int i;
2162 if( g.interp==0 ){
2163
--- src/th_main.c
+++ src/th_main.c
@@ -30,11 +30,12 @@
30 #define TH_INIT_NONE ((u32)0x00000000) /* No flags. */
31 #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */
32 #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */
33 #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */
34 #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */
35 #define TH_INIT_NO_REPO ((u32)0x00000010) /* Skip opening repository. */
36 #define TH_INIT_MASK ((u32)0x0000001F) /* All possible init flags. */
37
38 /*
39 ** Useful and/or "well-known" combinations of flag values.
40 */
41 #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */
@@ -44,13 +45,13 @@
45
46 /*
47 ** Flags set by functions in this file to keep track of integration state
48 ** information. These flags should not be used outside of this file.
49 */
50 #define TH_STATE_CONFIG ((u32)0x00000020) /* We opened the config. */
51 #define TH_STATE_REPOSITORY ((u32)0x00000040) /* We opened the repository. */
52 #define TH_STATE_MASK ((u32)0x00000060) /* All possible state flags. */
53
54 #ifdef FOSSIL_ENABLE_TH1_HOOKS
55 /*
56 ** These are the "well-known" TH1 error messages that occur when no hook is
57 ** registered to be called prior to executing a command or processing a web
@@ -2085,10 +2086,11 @@
2086 int wasInit = 0;
2087 int needConfig = flags & TH_INIT_NEED_CONFIG;
2088 int forceReset = flags & TH_INIT_FORCE_RESET;
2089 int forceTcl = flags & TH_INIT_FORCE_TCL;
2090 int forceSetup = flags & TH_INIT_FORCE_SETUP;
2091 int noRepo = flags & TH_INIT_NO_REPO;
2092 static unsigned int aFlags[] = { 0, 1, WIKI_LINKSONLY };
2093 static int anonFlag = LOGIN_ANON;
2094 static int zeroInt = 0;
2095 static struct _Command {
2096 const char *zName;
@@ -2152,11 +2154,11 @@
2154 ** This function uses several settings which may be defined in the
2155 ** repository and/or the global configuration. Since the caller
2156 ** passed a non-zero value for the needConfig parameter, make sure
2157 ** the necessary database connections are open prior to continuing.
2158 */
2159 Th_OpenConfig(!noRepo);
2160 }
2161 if( forceReset || forceTcl || g.interp==0 ){
2162 int created = 0;
2163 int i;
2164 if( g.interp==0 ){
2165

Keyboard Shortcuts

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