Fossil SCM

Fix the build on Windows and on builds that omit OpenSSL. Improved error messages.

drh 2021-12-26 21:50 ssl-server
Commit 637516c447d6e01f3aae84adfc219f6fbf3b148de381c842edd268016af505f1
2 files changed +2 -1 +17 -1
+2 -1
--- src/cgi.c
+++ src/cgi.c
@@ -2350,11 +2350,12 @@
23502350
}
23512351
}
23522352
if( iPort>mxPort ) return 1;
23532353
listen(listener,10);
23542354
fossil_print("Listening for %s requests on TCP port %d\n",
2355
- (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
2355
+ (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" :
2356
+ g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", iPort);
23562357
fflush(stdout);
23572358
if( zBrowser ){
23582359
assert( strstr(zBrowser,"%d")!=0 );
23592360
zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort);
23602361
#if defined(__CYGWIN__)
23612362
--- src/cgi.c
+++ src/cgi.c
@@ -2350,11 +2350,12 @@
2350 }
2351 }
2352 if( iPort>mxPort ) return 1;
2353 listen(listener,10);
2354 fossil_print("Listening for %s requests on TCP port %d\n",
2355 (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
 
2356 fflush(stdout);
2357 if( zBrowser ){
2358 assert( strstr(zBrowser,"%d")!=0 );
2359 zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort);
2360 #if defined(__CYGWIN__)
2361
--- src/cgi.c
+++ src/cgi.c
@@ -2350,11 +2350,12 @@
2350 }
2351 }
2352 if( iPort>mxPort ) return 1;
2353 listen(listener,10);
2354 fossil_print("Listening for %s requests on TCP port %d\n",
2355 (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" :
2356 g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", iPort);
2357 fflush(stdout);
2358 if( zBrowser ){
2359 assert( strstr(zBrowser,"%d")!=0 );
2360 zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort);
2361 #if defined(__CYGWIN__)
2362
+17 -1
--- src/main.c
+++ src/main.c
@@ -2841,16 +2841,18 @@
28412841
/*
28422842
** Check for options to "fossil server" or "fossil ui" that imply that
28432843
** SSL should be used, and initialize the SSL decoder.
28442844
*/
28452845
static void decode_ssl_options(void){
2846
+#if FOSSIL_ENABLE_SSL
28462847
const char *zCertFile = 0;
28472848
zCertFile = find_option("tls-cert-file",0,1);
28482849
if( zCertFile ){
28492850
g.httpUseSSL = 1;
28502851
ssl_init_server(zCertFile, zCertFile);
28512852
}
2853
+#endif
28522854
}
28532855
28542856
/*
28552857
** COMMAND: server*
28562858
** COMMAND: ui
@@ -3044,16 +3046,22 @@
30443046
** very first incoming TCP/IP connection to be processed. Used for
30453047
** debugging, since debugging across a fork() can be tricky
30463048
*/
30473049
if( find_option("debug-nofork",0,0)!=0 ){
30483050
flags |= HTTP_SERVER_NOFORK;
3051
+#if !defined(_WIN32)
3052
+ /* Disable the timeout during debugging */
30493053
zTimeout = "100000000";
3054
+#endif
30503055
}
30513056
/* We should be done with options.. */
30523057
verify_all_options();
30533058
30543059
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
3060
+ if( g.httpUseSSL && (flags & HTTP_SERVER_SCGI)!=0 ){
3061
+ fossil_fatal("SCGI does not (yet) support TLS-encrypted connections");
3062
+ }
30553063
if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){
30563064
/* If REPOSITORY arg is the root of a checkout,
30573065
** chdir to that checkout so that the current version
30583066
** gets highlighted in the timeline by default. */
30593067
const char * zDir = g.argv[2];
@@ -3215,26 +3223,34 @@
32153223
}
32163224
}
32173225
if( flags & HTTP_SERVER_SCGI ){
32183226
cgi_handle_scgi_request();
32193227
}else if( g.httpUseSSL ){
3228
+#if FOSSIL_ENABLE_SSL
32203229
g.httpSSLConn = ssl_new_server(0,-1);
3230
+#endif
32213231
cgi_handle_http_request(0);
32223232
}else{
32233233
cgi_handle_http_request(0);
32243234
}
32253235
process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList);
32263236
if( g.fAnyTrace ){
32273237
fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
32283238
getpid());
32293239
}
3240
+#if FOSSIL_ENABLE_SSL
32303241
if( g.httpUseSSL && g.httpSSLConn ){
32313242
ssl_close_server(g.httpSSLConn);
32323243
g.httpSSLConn = 0;
32333244
}
3234
-#else
3245
+#endif /* FOSSIL_ENABLE_SSL */
3246
+
3247
+#else /* WIN32 */
32353248
/* Win32 implementation */
3249
+ if( g.httpUseSSL ){
3250
+ fossil_fatal("TLS-encrypted server is not (yet) supported on Windows");
3251
+ }
32363252
if( allowRepoList ){
32373253
flags |= HTTP_SERVER_REPOLIST;
32383254
}
32393255
if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
32403256
win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile,
32413257
--- src/main.c
+++ src/main.c
@@ -2841,16 +2841,18 @@
2841 /*
2842 ** Check for options to "fossil server" or "fossil ui" that imply that
2843 ** SSL should be used, and initialize the SSL decoder.
2844 */
2845 static void decode_ssl_options(void){
 
2846 const char *zCertFile = 0;
2847 zCertFile = find_option("tls-cert-file",0,1);
2848 if( zCertFile ){
2849 g.httpUseSSL = 1;
2850 ssl_init_server(zCertFile, zCertFile);
2851 }
 
2852 }
2853
2854 /*
2855 ** COMMAND: server*
2856 ** COMMAND: ui
@@ -3044,16 +3046,22 @@
3044 ** very first incoming TCP/IP connection to be processed. Used for
3045 ** debugging, since debugging across a fork() can be tricky
3046 */
3047 if( find_option("debug-nofork",0,0)!=0 ){
3048 flags |= HTTP_SERVER_NOFORK;
 
 
3049 zTimeout = "100000000";
 
3050 }
3051 /* We should be done with options.. */
3052 verify_all_options();
3053
3054 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
 
 
 
3055 if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){
3056 /* If REPOSITORY arg is the root of a checkout,
3057 ** chdir to that checkout so that the current version
3058 ** gets highlighted in the timeline by default. */
3059 const char * zDir = g.argv[2];
@@ -3215,26 +3223,34 @@
3215 }
3216 }
3217 if( flags & HTTP_SERVER_SCGI ){
3218 cgi_handle_scgi_request();
3219 }else if( g.httpUseSSL ){
 
3220 g.httpSSLConn = ssl_new_server(0,-1);
 
3221 cgi_handle_http_request(0);
3222 }else{
3223 cgi_handle_http_request(0);
3224 }
3225 process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList);
3226 if( g.fAnyTrace ){
3227 fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
3228 getpid());
3229 }
 
3230 if( g.httpUseSSL && g.httpSSLConn ){
3231 ssl_close_server(g.httpSSLConn);
3232 g.httpSSLConn = 0;
3233 }
3234 #else
 
 
3235 /* Win32 implementation */
 
 
 
3236 if( allowRepoList ){
3237 flags |= HTTP_SERVER_REPOLIST;
3238 }
3239 if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
3240 win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile,
3241
--- src/main.c
+++ src/main.c
@@ -2841,16 +2841,18 @@
2841 /*
2842 ** Check for options to "fossil server" or "fossil ui" that imply that
2843 ** SSL should be used, and initialize the SSL decoder.
2844 */
2845 static void decode_ssl_options(void){
2846 #if FOSSIL_ENABLE_SSL
2847 const char *zCertFile = 0;
2848 zCertFile = find_option("tls-cert-file",0,1);
2849 if( zCertFile ){
2850 g.httpUseSSL = 1;
2851 ssl_init_server(zCertFile, zCertFile);
2852 }
2853 #endif
2854 }
2855
2856 /*
2857 ** COMMAND: server*
2858 ** COMMAND: ui
@@ -3044,16 +3046,22 @@
3046 ** very first incoming TCP/IP connection to be processed. Used for
3047 ** debugging, since debugging across a fork() can be tricky
3048 */
3049 if( find_option("debug-nofork",0,0)!=0 ){
3050 flags |= HTTP_SERVER_NOFORK;
3051 #if !defined(_WIN32)
3052 /* Disable the timeout during debugging */
3053 zTimeout = "100000000";
3054 #endif
3055 }
3056 /* We should be done with options.. */
3057 verify_all_options();
3058
3059 if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
3060 if( g.httpUseSSL && (flags & HTTP_SERVER_SCGI)!=0 ){
3061 fossil_fatal("SCGI does not (yet) support TLS-encrypted connections");
3062 }
3063 if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){
3064 /* If REPOSITORY arg is the root of a checkout,
3065 ** chdir to that checkout so that the current version
3066 ** gets highlighted in the timeline by default. */
3067 const char * zDir = g.argv[2];
@@ -3215,26 +3223,34 @@
3223 }
3224 }
3225 if( flags & HTTP_SERVER_SCGI ){
3226 cgi_handle_scgi_request();
3227 }else if( g.httpUseSSL ){
3228 #if FOSSIL_ENABLE_SSL
3229 g.httpSSLConn = ssl_new_server(0,-1);
3230 #endif
3231 cgi_handle_http_request(0);
3232 }else{
3233 cgi_handle_http_request(0);
3234 }
3235 process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList);
3236 if( g.fAnyTrace ){
3237 fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
3238 getpid());
3239 }
3240 #if FOSSIL_ENABLE_SSL
3241 if( g.httpUseSSL && g.httpSSLConn ){
3242 ssl_close_server(g.httpSSLConn);
3243 g.httpSSLConn = 0;
3244 }
3245 #endif /* FOSSIL_ENABLE_SSL */
3246
3247 #else /* WIN32 */
3248 /* Win32 implementation */
3249 if( g.httpUseSSL ){
3250 fossil_fatal("TLS-encrypted server is not (yet) supported on Windows");
3251 }
3252 if( allowRepoList ){
3253 flags |= HTTP_SERVER_REPOLIST;
3254 }
3255 if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
3256 win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile,
3257

Keyboard Shortcuts

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