Fossil

Check-in [0d72caae15]
Login

Check-in [0d72caae15]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Adds the Apache-style REQUEST_SCHEME environment variable to the /ext environment so that CGIs can determine whether they're running in HTTP or HTTPS. <i>Later:</i> See alternative implementation at [f101e94da1f80571]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | ext-request-scheme
Files: files | file ages | folders
SHA3-256: 0d72caae1592769e00ad0752757449c51a37a5a6dcac9b84a378e9b8ef744808
User & Date: stephan 2020-12-12 08:15:50
Original Comment: Adds the Apache-style REQUEST_SCHEME environment variable to the /ext environment so that CGIs can determine whether they're running in HTTP or HTTPS.
References
2020-12-12
14:05
Attempt to provide support for the REQUEST_SCHEMA and SERVER_NAME environment variables in CGI support. This is an alternative implementation of [0d72caae1592769e|check-in 0d72caae1592769e]. Discussion on [forum:/forumpost/cba707d7bd|forum thread cba707d7bd] and [forum:/forumpost/cb17013d06|cb17013d06]. ... (check-in: f101e94da1 user: drh tags: trunk)
Context
2020-12-12
08:15
Adds the Apache-style REQUEST_SCHEME environment variable to the /ext environment so that CGIs can determine whether they're running in HTTP or HTTPS. <i>Later:</i> See alternative implementation at [f101e94da1f80571] ... (Closed-Leaf check-in: 0d72caae15 user: stephan tags: ext-request-scheme)
01:20
Spell out the word "times" rather than use the unicode "x" character. ... (check-in: f0a86f3cac user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/extcgi.c.

65
66
67
68
69
70
71


72
73
74
75
76
77
78
   "HTTP_REFERER",
   "HTTP_USER_AGENT",
   "PATH_INFO",
   "QUERY_STRING",
   "REMOTE_ADDR",
   "REMOTE_USER",
   "REQUEST_METHOD",


   "REQUEST_URI",
   "SCRIPT_DIRECTORY",
   "SCRIPT_FILENAME",
   "SCRIPT_NAME",
   "SERVER_NAME",
   "SERVER_PORT",
   "SERVER_PROTOCOL",







>
>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
   "HTTP_REFERER",
   "HTTP_USER_AGENT",
   "PATH_INFO",
   "QUERY_STRING",
   "REMOTE_ADDR",
   "REMOTE_USER",
   "REQUEST_METHOD",
   "REQUEST_SCHEME", /* non-standard but supported by Apache 2.4+
                     ** Holds either "http" or "https". */
   "REQUEST_URI",
   "SCRIPT_DIRECTORY",
   "SCRIPT_FILENAME",
   "SCRIPT_NAME",
   "SERVER_NAME",
   "SERVER_PORT",
   "SERVER_PROTOCOL",
264
265
266
267
268
269
270



271
272
273
274
275
276
277
  cgi_set_parameter_nocopy("FOSSIL_NONCE", style_nonce(), 0);
  cgi_set_parameter_nocopy("FOSSIL_REPOSITORY", g.zRepositoryName, 0);
  cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
  cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
     db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
             g.zLogin ? g.zLogin : "nobody"), 0);
  cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");



  for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
    (void)P(azCgiEnv[i]);
  }
  fossil_clearenv();
  for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
    const char *zVal = P(azCgiEnv[i]);
    if( zVal ) fossil_setenv(azCgiEnv[i], zVal);







>
>
>







266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
  cgi_set_parameter_nocopy("FOSSIL_NONCE", style_nonce(), 0);
  cgi_set_parameter_nocopy("FOSSIL_REPOSITORY", g.zRepositoryName, 0);
  cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
  cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
     db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
             g.zLogin ? g.zLogin : "nobody"), 0);
  cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");
  cgi_replace_parameter("REQUEST_SCHEME",
                        strncmp(g.zTop, "https:", 6)==0
                        ? "https" : "http");
  for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
    (void)P(azCgiEnv[i]);
  }
  fossil_clearenv();
  for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
    const char *zVal = P(azCgiEnv[i]);
    if( zVal ) fossil_setenv(azCgiEnv[i], zVal);

Changes to www/serverext.wiki.

166
167
168
169
170
171
172

173
174
175
176
177
178
179
Fossil adds the following:

  *  FOSSIL_CAPABILITIES
  *  FOSSIL_NONCE
  *  FOSSIL_REPOSITORY
  *  FOSSIL_URI
  *  FOSSIL_USER


The FOSSIL_USER string is the name of the logged-in user.  This variable
is missing or is an empty string if the user is not logged in.  The
FOSSIL_CAPABILITIES string is a list of 
[./caps/ref.html|Fossil capabilities] that
indicate what permissions the user has on the Fossil repository.
The FOSSIL_REPOSITORY environment variable gives the filename of the







>







166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Fossil adds the following:

  *  FOSSIL_CAPABILITIES
  *  FOSSIL_NONCE
  *  FOSSIL_REPOSITORY
  *  FOSSIL_URI
  *  FOSSIL_USER
  *  REQUEST_SCHEME (as used by Apache: "http" or "https")

The FOSSIL_USER string is the name of the logged-in user.  This variable
is missing or is an empty string if the user is not logged in.  The
FOSSIL_CAPABILITIES string is a list of 
[./caps/ref.html|Fossil capabilities] that
indicate what permissions the user has on the Fossil repository.
The FOSSIL_REPOSITORY environment variable gives the filename of the