Fossil SCM

Enhancements to SEE integration on Windows.

mistachkin 2016-11-01 23:34 trunk
Commit 7aeeb30286cc2f61891e4e24861d33435e765627
3 files changed +63 -2 +67 -4 +12
+63 -2
--- src/db.c
+++ src/db.c
@@ -27,11 +27,15 @@
2727
** (3) A local checkout database named "_FOSSIL_" or ".fslckout"
2828
** and located at the root of the local copy of the source tree.
2929
**
3030
*/
3131
#include "config.h"
32
-#if ! defined(_WIN32)
32
+#if defined(_WIN32)
33
+# if USE_SEE
34
+# include <windows.h>
35
+# endif
36
+#else
3337
# include <pwd.h>
3438
#endif
3539
#include <sqlite3.h>
3640
#include <sys/types.h>
3741
#include <sys/stat.h>
@@ -885,13 +889,21 @@
885889
886890
/*
887891
** This function returns the saved database encryption key -OR- zero if
888892
** no database encryption key is saved.
889893
*/
890
-static char *db_get_saved_encryption_key(){
894
+char *db_get_saved_encryption_key(){
891895
return zSavedKey;
892896
}
897
+
898
+/*
899
+** This function returns the size of the saved database encryption key
900
+** -OR- zero if no database encryption key is saved.
901
+*/
902
+size_t db_get_saved_encryption_key_size(){
903
+ return savedKeySize;
904
+}
893905
894906
/*
895907
** This function arranges for the database encryption key to be securely
896908
** saved in non-pagable memory (on platforms where this is possible).
897909
*/
@@ -950,10 +962,59 @@
950962
}
951963
}else{
952964
db_save_encryption_key(pKey);
953965
}
954966
}
967
+
968
+#if defined(_WIN32)
969
+/*
970
+** This function sets the saved database encryption key to one that gets
971
+** read from the specified Fossil parent process. This is only necessary
972
+** (or functional) on Windows.
973
+*/
974
+void db_read_saved_encryption_key_from_process(
975
+ DWORD processId, /* Identifier for Fossil parent process. */
976
+ LPVOID pAddress, /* Pointer to saved key buffer in the parent process. */
977
+ SIZE_T nSize /* Size of saved key buffer in the parent process. */
978
+){
979
+ void *p = NULL;
980
+ size_t n = 0;
981
+ size_t pageSize = 0;
982
+ HANDLE hProcess = NULL;
983
+
984
+ fossil_get_page_size(&pageSize);
985
+ assert( pageSize>0 );
986
+ if( nSize>pageSize ){
987
+ fossil_fatal("key too large: %u versus %u", nSize, pageSize);
988
+ }
989
+ p = fossil_secure_alloc_page(&n);
990
+ assert( p!=NULL );
991
+ assert( n==pageSize );
992
+ assert( n>=nSize );
993
+ hProcess = OpenProcess(PROCESS_VM_READ, FALSE, processId);
994
+ if( hProcess!=NULL ){
995
+ SIZE_T nRead = 0;
996
+ if( ReadProcessMemory(hProcess, pAddress, p, nSize, &nRead) ){
997
+ CloseHandle(hProcess);
998
+ if( nRead==nSize ){
999
+ db_unsave_encryption_key();
1000
+ zSavedKey = p;
1001
+ savedKeySize = n;
1002
+ }else{
1003
+ fossil_fatal("bad size read, %u out of %u bytes at %p from pid %lu",
1004
+ nRead, nSize, pAddress, processId);
1005
+ }
1006
+ }else{
1007
+ CloseHandle(hProcess);
1008
+ fossil_fatal("failed read, %u bytes at %p from pid %lu: %lu", nSize,
1009
+ pAddress, processId, GetLastError());
1010
+ }
1011
+ }else{
1012
+ fossil_fatal("failed to open pid %lu: %lu", processId, GetLastError());
1013
+ }
1014
+}
1015
+#endif /* defined(_WIN32) */
9551016
#endif /* USE_SEE */
9561017
9571018
/*
9581019
** If the database file zDbFile has a name that suggests that it is
9591020
** encrypted, then prompt for the database encryption key and return it
9601021
--- src/db.c
+++ src/db.c
@@ -27,11 +27,15 @@
27 ** (3) A local checkout database named "_FOSSIL_" or ".fslckout"
28 ** and located at the root of the local copy of the source tree.
29 **
30 */
31 #include "config.h"
32 #if ! defined(_WIN32)
 
 
 
 
33 # include <pwd.h>
34 #endif
35 #include <sqlite3.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
@@ -885,13 +889,21 @@
885
886 /*
887 ** This function returns the saved database encryption key -OR- zero if
888 ** no database encryption key is saved.
889 */
890 static char *db_get_saved_encryption_key(){
891 return zSavedKey;
892 }
 
 
 
 
 
 
 
 
893
894 /*
895 ** This function arranges for the database encryption key to be securely
896 ** saved in non-pagable memory (on platforms where this is possible).
897 */
@@ -950,10 +962,59 @@
950 }
951 }else{
952 db_save_encryption_key(pKey);
953 }
954 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
955 #endif /* USE_SEE */
956
957 /*
958 ** If the database file zDbFile has a name that suggests that it is
959 ** encrypted, then prompt for the database encryption key and return it
960
--- src/db.c
+++ src/db.c
@@ -27,11 +27,15 @@
27 ** (3) A local checkout database named "_FOSSIL_" or ".fslckout"
28 ** and located at the root of the local copy of the source tree.
29 **
30 */
31 #include "config.h"
32 #if defined(_WIN32)
33 # if USE_SEE
34 # include <windows.h>
35 # endif
36 #else
37 # include <pwd.h>
38 #endif
39 #include <sqlite3.h>
40 #include <sys/types.h>
41 #include <sys/stat.h>
@@ -885,13 +889,21 @@
889
890 /*
891 ** This function returns the saved database encryption key -OR- zero if
892 ** no database encryption key is saved.
893 */
894 char *db_get_saved_encryption_key(){
895 return zSavedKey;
896 }
897
898 /*
899 ** This function returns the size of the saved database encryption key
900 ** -OR- zero if no database encryption key is saved.
901 */
902 size_t db_get_saved_encryption_key_size(){
903 return savedKeySize;
904 }
905
906 /*
907 ** This function arranges for the database encryption key to be securely
908 ** saved in non-pagable memory (on platforms where this is possible).
909 */
@@ -950,10 +962,59 @@
962 }
963 }else{
964 db_save_encryption_key(pKey);
965 }
966 }
967
968 #if defined(_WIN32)
969 /*
970 ** This function sets the saved database encryption key to one that gets
971 ** read from the specified Fossil parent process. This is only necessary
972 ** (or functional) on Windows.
973 */
974 void db_read_saved_encryption_key_from_process(
975 DWORD processId, /* Identifier for Fossil parent process. */
976 LPVOID pAddress, /* Pointer to saved key buffer in the parent process. */
977 SIZE_T nSize /* Size of saved key buffer in the parent process. */
978 ){
979 void *p = NULL;
980 size_t n = 0;
981 size_t pageSize = 0;
982 HANDLE hProcess = NULL;
983
984 fossil_get_page_size(&pageSize);
985 assert( pageSize>0 );
986 if( nSize>pageSize ){
987 fossil_fatal("key too large: %u versus %u", nSize, pageSize);
988 }
989 p = fossil_secure_alloc_page(&n);
990 assert( p!=NULL );
991 assert( n==pageSize );
992 assert( n>=nSize );
993 hProcess = OpenProcess(PROCESS_VM_READ, FALSE, processId);
994 if( hProcess!=NULL ){
995 SIZE_T nRead = 0;
996 if( ReadProcessMemory(hProcess, pAddress, p, nSize, &nRead) ){
997 CloseHandle(hProcess);
998 if( nRead==nSize ){
999 db_unsave_encryption_key();
1000 zSavedKey = p;
1001 savedKeySize = n;
1002 }else{
1003 fossil_fatal("bad size read, %u out of %u bytes at %p from pid %lu",
1004 nRead, nSize, pAddress, processId);
1005 }
1006 }else{
1007 CloseHandle(hProcess);
1008 fossil_fatal("failed read, %u bytes at %p from pid %lu: %lu", nSize,
1009 pAddress, processId, GetLastError());
1010 }
1011 }else{
1012 fossil_fatal("failed to open pid %lu: %lu", processId, GetLastError());
1013 }
1014 }
1015 #endif /* defined(_WIN32) */
1016 #endif /* USE_SEE */
1017
1018 /*
1019 ** If the database file zDbFile has a name that suggests that it is
1020 ** encrypted, then prompt for the database encryption key and return it
1021
+67 -4
--- src/main.c
+++ src/main.c
@@ -18,20 +18,21 @@
1818
** This module codes the main() procedure that runs first when the
1919
** program is invoked.
2020
*/
2121
#include "VERSION.h"
2222
#include "config.h"
23
+#if defined(_WIN32)
24
+# include <windows.h>
25
+#endif
2326
#include "main.h"
2427
#include <string.h>
2528
#include <time.h>
2629
#include <fcntl.h>
2730
#include <sys/types.h>
2831
#include <sys/stat.h>
2932
#include <stdlib.h> /* atexit() */
30
-#if defined(_WIN32)
31
-# include <windows.h>
32
-#else
33
+#if !defined(_WIN32)
3334
# include <errno.h> /* errno global */
3435
#endif
3536
#ifdef FOSSIL_ENABLE_SSL
3637
# include "openssl/crypto.h"
3738
#endif
@@ -1929,10 +1930,41 @@
19291930
}
19301931
}
19311932
}
19321933
}
19331934
1935
+#if defined(_WIN32) && USE_SEE
1936
+/*
1937
+** This function attempts to parse a string value in the following
1938
+** format:
1939
+**
1940
+** "%lu:%p:%u"
1941
+**
1942
+** There are three parts, which must be delimited by colons. The
1943
+** first part is an unsigned long integer in base-10 (decimal) format.
1944
+** The second part is a numerical representation of a native pointer,
1945
+** in the appropriate implementation defined format. The third part
1946
+** is an unsigned integer in base-10 (decimal) format.
1947
+**
1948
+** If the specified value cannot be parsed, for any reason, a fatal
1949
+** error will be raised and the process will be terminated.
1950
+*/
1951
+void parse_pid_key_value(
1952
+ const char *zPidKey, /* The value to be parsed. */
1953
+ DWORD *pProcessId, /* The extracted process identifier. */
1954
+ LPVOID *ppAddress, /* The extracted pointer value. */
1955
+ SIZE_T *pnSize /* The extracted size value. */
1956
+){
1957
+ unsigned int nSize = 0;
1958
+ if( sscanf(zPidKey, "%lu:%p:%u", pProcessId, ppAddress, &nSize)==3 ){
1959
+ *pnSize = (SIZE_T)nSize;
1960
+ }else{
1961
+ fossil_fatal("failed to parse pid key");
1962
+ }
1963
+}
1964
+#endif
1965
+
19341966
/*
19351967
** undocumented format:
19361968
**
19371969
** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
19381970
**
@@ -1980,10 +2012,12 @@
19802012
** --notfound URL use URL as "HTTP 404, object not found" page.
19812013
** --repolist If REPOSITORY is directory, URL "/" lists all repos
19822014
** --scgi Interpret input as SCGI rather than HTTP
19832015
** --skin LABEL Use override skin LABEL
19842016
** --th-trace trace TH1 execution (for debugging purposes)
2017
+** --usepidkey Use saved encryption key from parent process. This is
2018
+** only necessary when using SEE on Windows.
19852019
**
19862020
** See also: cgi, server, winsrv
19872021
*/
19882022
void cmd_http(void){
19892023
const char *zIpAddr = 0;
@@ -1992,10 +2026,13 @@
19922026
const char *zAltBase;
19932027
const char *zFileGlob;
19942028
int useSCGI;
19952029
int noJail;
19962030
int allowRepoList;
2031
+#if defined(_WIN32) && USE_SEE
2032
+ const char *zPidKey;
2033
+#endif
19972034
19982035
Th_InitTraceLog();
19992036
20002037
/* The winhttp module passes the --files option as --files-urlenc with
20012038
** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2022,10 +2059,21 @@
20222059
zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
20232060
cgi_replace_parameter("HTTPS","on");
20242061
}
20252062
zHost = find_option("host", 0, 1);
20262063
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2064
+
2065
+#if defined(_WIN32) && USE_SEE
2066
+ zPidKey = find_option("usepidkey", 0, 1);
2067
+ if( zPidKey ){
2068
+ DWORD processId = 0;
2069
+ LPVOID pAddress = NULL;
2070
+ SIZE_T nSize = 0;
2071
+ parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2072
+ db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2073
+ }
2074
+#endif
20272075
20282076
/* We should be done with options.. */
20292077
verify_all_options();
20302078
20312079
if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
@@ -2183,11 +2231,12 @@
21832231
** -P|--port TCPPORT listen to request on port TCPPORT
21842232
** --th-trace trace TH1 execution (for debugging purposes)
21852233
** --repolist If REPOSITORY is dir, URL "/" lists repos.
21862234
** --scgi Accept SCGI rather than HTTP
21872235
** --skin LABEL Use override skin LABEL
2188
-
2236
+** --usepidkey Use saved encryption key from parent process. This is
2237
+** only necessary when using SEE on Windows.
21892238
**
21902239
** See also: cgi, http, winsrv
21912240
*/
21922241
void cmd_webserver(void){
21932242
int iPort, mxPort; /* Range of TCP ports allowed */
@@ -2204,10 +2253,13 @@
22042253
const char *zAltBase; /* Argument to the --baseurl option */
22052254
const char *zFileGlob; /* Static content must match this */
22062255
char *zIpAddr = 0; /* Bind to this IP address */
22072256
int fCreate = 0; /* The --create flag */
22082257
const char *zInitPage = 0; /* Start on this page. --page option */
2258
+#if defined(_WIN32) && USE_SEE
2259
+ const char *zPidKey;
2260
+#endif
22092261
22102262
#if defined(_WIN32)
22112263
const char *zStopperFile; /* Name of file used to terminate server */
22122264
zStopperFile = find_option("stopper", 0, 1);
22132265
#endif
@@ -2247,10 +2299,21 @@
22472299
g.sslNotAvailable = 1;
22482300
}
22492301
if( find_option("localhost", 0, 0)!=0 ){
22502302
flags |= HTTP_SERVER_LOCALHOST;
22512303
}
2304
+
2305
+#if defined(_WIN32) && USE_SEE
2306
+ zPidKey = find_option("usepidkey", 0, 1);
2307
+ if( zPidKey ){
2308
+ DWORD processId = 0;
2309
+ LPVOID pAddress = NULL;
2310
+ SIZE_T nSize = 0;
2311
+ parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2312
+ db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2313
+ }
2314
+#endif
22522315
22532316
/* We should be done with options.. */
22542317
verify_all_options();
22552318
22562319
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
22572320
--- src/main.c
+++ src/main.c
@@ -18,20 +18,21 @@
18 ** This module codes the main() procedure that runs first when the
19 ** program is invoked.
20 */
21 #include "VERSION.h"
22 #include "config.h"
 
 
 
23 #include "main.h"
24 #include <string.h>
25 #include <time.h>
26 #include <fcntl.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <stdlib.h> /* atexit() */
30 #if defined(_WIN32)
31 # include <windows.h>
32 #else
33 # include <errno.h> /* errno global */
34 #endif
35 #ifdef FOSSIL_ENABLE_SSL
36 # include "openssl/crypto.h"
37 #endif
@@ -1929,10 +1930,41 @@
1929 }
1930 }
1931 }
1932 }
1933
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1934 /*
1935 ** undocumented format:
1936 **
1937 ** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
1938 **
@@ -1980,10 +2012,12 @@
1980 ** --notfound URL use URL as "HTTP 404, object not found" page.
1981 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
1982 ** --scgi Interpret input as SCGI rather than HTTP
1983 ** --skin LABEL Use override skin LABEL
1984 ** --th-trace trace TH1 execution (for debugging purposes)
 
 
1985 **
1986 ** See also: cgi, server, winsrv
1987 */
1988 void cmd_http(void){
1989 const char *zIpAddr = 0;
@@ -1992,10 +2026,13 @@
1992 const char *zAltBase;
1993 const char *zFileGlob;
1994 int useSCGI;
1995 int noJail;
1996 int allowRepoList;
 
 
 
1997
1998 Th_InitTraceLog();
1999
2000 /* The winhttp module passes the --files option as --files-urlenc with
2001 ** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2022,10 +2059,21 @@
2022 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2023 cgi_replace_parameter("HTTPS","on");
2024 }
2025 zHost = find_option("host", 0, 1);
2026 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
 
 
 
 
 
 
 
 
 
 
 
2027
2028 /* We should be done with options.. */
2029 verify_all_options();
2030
2031 if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
@@ -2183,11 +2231,12 @@
2183 ** -P|--port TCPPORT listen to request on port TCPPORT
2184 ** --th-trace trace TH1 execution (for debugging purposes)
2185 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2186 ** --scgi Accept SCGI rather than HTTP
2187 ** --skin LABEL Use override skin LABEL
2188
 
2189 **
2190 ** See also: cgi, http, winsrv
2191 */
2192 void cmd_webserver(void){
2193 int iPort, mxPort; /* Range of TCP ports allowed */
@@ -2204,10 +2253,13 @@
2204 const char *zAltBase; /* Argument to the --baseurl option */
2205 const char *zFileGlob; /* Static content must match this */
2206 char *zIpAddr = 0; /* Bind to this IP address */
2207 int fCreate = 0; /* The --create flag */
2208 const char *zInitPage = 0; /* Start on this page. --page option */
 
 
 
2209
2210 #if defined(_WIN32)
2211 const char *zStopperFile; /* Name of file used to terminate server */
2212 zStopperFile = find_option("stopper", 0, 1);
2213 #endif
@@ -2247,10 +2299,21 @@
2247 g.sslNotAvailable = 1;
2248 }
2249 if( find_option("localhost", 0, 0)!=0 ){
2250 flags |= HTTP_SERVER_LOCALHOST;
2251 }
 
 
 
 
 
 
 
 
 
 
 
2252
2253 /* We should be done with options.. */
2254 verify_all_options();
2255
2256 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2257
--- src/main.c
+++ src/main.c
@@ -18,20 +18,21 @@
18 ** This module codes the main() procedure that runs first when the
19 ** program is invoked.
20 */
21 #include "VERSION.h"
22 #include "config.h"
23 #if defined(_WIN32)
24 # include <windows.h>
25 #endif
26 #include "main.h"
27 #include <string.h>
28 #include <time.h>
29 #include <fcntl.h>
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <stdlib.h> /* atexit() */
33 #if !defined(_WIN32)
 
 
34 # include <errno.h> /* errno global */
35 #endif
36 #ifdef FOSSIL_ENABLE_SSL
37 # include "openssl/crypto.h"
38 #endif
@@ -1929,10 +1930,41 @@
1930 }
1931 }
1932 }
1933 }
1934
1935 #if defined(_WIN32) && USE_SEE
1936 /*
1937 ** This function attempts to parse a string value in the following
1938 ** format:
1939 **
1940 ** "%lu:%p:%u"
1941 **
1942 ** There are three parts, which must be delimited by colons. The
1943 ** first part is an unsigned long integer in base-10 (decimal) format.
1944 ** The second part is a numerical representation of a native pointer,
1945 ** in the appropriate implementation defined format. The third part
1946 ** is an unsigned integer in base-10 (decimal) format.
1947 **
1948 ** If the specified value cannot be parsed, for any reason, a fatal
1949 ** error will be raised and the process will be terminated.
1950 */
1951 void parse_pid_key_value(
1952 const char *zPidKey, /* The value to be parsed. */
1953 DWORD *pProcessId, /* The extracted process identifier. */
1954 LPVOID *ppAddress, /* The extracted pointer value. */
1955 SIZE_T *pnSize /* The extracted size value. */
1956 ){
1957 unsigned int nSize = 0;
1958 if( sscanf(zPidKey, "%lu:%p:%u", pProcessId, ppAddress, &nSize)==3 ){
1959 *pnSize = (SIZE_T)nSize;
1960 }else{
1961 fossil_fatal("failed to parse pid key");
1962 }
1963 }
1964 #endif
1965
1966 /*
1967 ** undocumented format:
1968 **
1969 ** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
1970 **
@@ -1980,10 +2012,12 @@
2012 ** --notfound URL use URL as "HTTP 404, object not found" page.
2013 ** --repolist If REPOSITORY is directory, URL "/" lists all repos
2014 ** --scgi Interpret input as SCGI rather than HTTP
2015 ** --skin LABEL Use override skin LABEL
2016 ** --th-trace trace TH1 execution (for debugging purposes)
2017 ** --usepidkey Use saved encryption key from parent process. This is
2018 ** only necessary when using SEE on Windows.
2019 **
2020 ** See also: cgi, server, winsrv
2021 */
2022 void cmd_http(void){
2023 const char *zIpAddr = 0;
@@ -1992,10 +2026,13 @@
2026 const char *zAltBase;
2027 const char *zFileGlob;
2028 int useSCGI;
2029 int noJail;
2030 int allowRepoList;
2031 #if defined(_WIN32) && USE_SEE
2032 const char *zPidKey;
2033 #endif
2034
2035 Th_InitTraceLog();
2036
2037 /* The winhttp module passes the --files option as --files-urlenc with
2038 ** the argument being URL encoded, to avoid wildcard expansion in the
@@ -2022,10 +2059,21 @@
2059 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2060 cgi_replace_parameter("HTTPS","on");
2061 }
2062 zHost = find_option("host", 0, 1);
2063 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2064
2065 #if defined(_WIN32) && USE_SEE
2066 zPidKey = find_option("usepidkey", 0, 1);
2067 if( zPidKey ){
2068 DWORD processId = 0;
2069 LPVOID pAddress = NULL;
2070 SIZE_T nSize = 0;
2071 parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2072 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2073 }
2074 #endif
2075
2076 /* We should be done with options.. */
2077 verify_all_options();
2078
2079 if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
@@ -2183,11 +2231,12 @@
2231 ** -P|--port TCPPORT listen to request on port TCPPORT
2232 ** --th-trace trace TH1 execution (for debugging purposes)
2233 ** --repolist If REPOSITORY is dir, URL "/" lists repos.
2234 ** --scgi Accept SCGI rather than HTTP
2235 ** --skin LABEL Use override skin LABEL
2236 ** --usepidkey Use saved encryption key from parent process. This is
2237 ** only necessary when using SEE on Windows.
2238 **
2239 ** See also: cgi, http, winsrv
2240 */
2241 void cmd_webserver(void){
2242 int iPort, mxPort; /* Range of TCP ports allowed */
@@ -2204,10 +2253,13 @@
2253 const char *zAltBase; /* Argument to the --baseurl option */
2254 const char *zFileGlob; /* Static content must match this */
2255 char *zIpAddr = 0; /* Bind to this IP address */
2256 int fCreate = 0; /* The --create flag */
2257 const char *zInitPage = 0; /* Start on this page. --page option */
2258 #if defined(_WIN32) && USE_SEE
2259 const char *zPidKey;
2260 #endif
2261
2262 #if defined(_WIN32)
2263 const char *zStopperFile; /* Name of file used to terminate server */
2264 zStopperFile = find_option("stopper", 0, 1);
2265 #endif
@@ -2247,10 +2299,21 @@
2299 g.sslNotAvailable = 1;
2300 }
2301 if( find_option("localhost", 0, 0)!=0 ){
2302 flags |= HTTP_SERVER_LOCALHOST;
2303 }
2304
2305 #if defined(_WIN32) && USE_SEE
2306 zPidKey = find_option("usepidkey", 0, 1);
2307 if( zPidKey ){
2308 DWORD processId = 0;
2309 LPVOID pAddress = NULL;
2310 SIZE_T nSize = 0;
2311 parse_pid_key_value(zPidKey, &processId, &pAddress, &nSize);
2312 db_read_saved_encryption_key_from_process(processId, pAddress, nSize);
2313 }
2314 #endif
2315
2316 /* We should be done with options.. */
2317 verify_all_options();
2318
2319 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
2320
--- src/winhttp.c
+++ src/winhttp.c
@@ -306,10 +306,14 @@
306306
SOCKADDR_IN addr;
307307
int idCnt = 0;
308308
int iPort = mnPort;
309309
Blob options;
310310
wchar_t zTmpPath[MAX_PATH];
311
+#if USE_SEE
312
+ const char *zSavedKey = 0;
313
+ size_t savedKeySize = 0;
314
+#endif
311315
312316
blob_zero(&options);
313317
if( zBaseUrl ){
314318
blob_appendf(&options, " --baseurl %s", zBaseUrl);
315319
}
@@ -326,10 +330,18 @@
326330
blob_appendf(&options, " --th-trace");
327331
}
328332
if( flags & HTTP_SERVER_REPOLIST ){
329333
blob_appendf(&options, " --repolist");
330334
}
335
+#if USE_SEE
336
+ zSavedKey = db_get_saved_encryption_key();
337
+ savedKeySize = db_get_saved_encryption_key_size();
338
+ if( zSavedKey!=0 && savedKeySize>0 ){
339
+ blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
340
+ zSavedKey, savedKeySize);
341
+ }
342
+#endif
331343
if( WSAStartup(MAKEWORD(1,1), &wd) ){
332344
fossil_fatal("unable to initialize winsock");
333345
}
334346
while( iPort<=mxPort ){
335347
s = socket(AF_INET, SOCK_STREAM, 0);
336348
--- src/winhttp.c
+++ src/winhttp.c
@@ -306,10 +306,14 @@
306 SOCKADDR_IN addr;
307 int idCnt = 0;
308 int iPort = mnPort;
309 Blob options;
310 wchar_t zTmpPath[MAX_PATH];
 
 
 
 
311
312 blob_zero(&options);
313 if( zBaseUrl ){
314 blob_appendf(&options, " --baseurl %s", zBaseUrl);
315 }
@@ -326,10 +330,18 @@
326 blob_appendf(&options, " --th-trace");
327 }
328 if( flags & HTTP_SERVER_REPOLIST ){
329 blob_appendf(&options, " --repolist");
330 }
 
 
 
 
 
 
 
 
331 if( WSAStartup(MAKEWORD(1,1), &wd) ){
332 fossil_fatal("unable to initialize winsock");
333 }
334 while( iPort<=mxPort ){
335 s = socket(AF_INET, SOCK_STREAM, 0);
336
--- src/winhttp.c
+++ src/winhttp.c
@@ -306,10 +306,14 @@
306 SOCKADDR_IN addr;
307 int idCnt = 0;
308 int iPort = mnPort;
309 Blob options;
310 wchar_t zTmpPath[MAX_PATH];
311 #if USE_SEE
312 const char *zSavedKey = 0;
313 size_t savedKeySize = 0;
314 #endif
315
316 blob_zero(&options);
317 if( zBaseUrl ){
318 blob_appendf(&options, " --baseurl %s", zBaseUrl);
319 }
@@ -326,10 +330,18 @@
330 blob_appendf(&options, " --th-trace");
331 }
332 if( flags & HTTP_SERVER_REPOLIST ){
333 blob_appendf(&options, " --repolist");
334 }
335 #if USE_SEE
336 zSavedKey = db_get_saved_encryption_key();
337 savedKeySize = db_get_saved_encryption_key_size();
338 if( zSavedKey!=0 && savedKeySize>0 ){
339 blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
340 zSavedKey, savedKeySize);
341 }
342 #endif
343 if( WSAStartup(MAKEWORD(1,1), &wd) ){
344 fossil_fatal("unable to initialize winsock");
345 }
346 while( iPort<=mxPort ){
347 s = socket(AF_INET, SOCK_STREAM, 0);
348

Keyboard Shortcuts

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