Documentation Source Text

Check-in [216ba4ebe1]
Login

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

Overview
Comment:Send the SCGI environment variable with a value of "1" on SCGI requests.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 216ba4ebe1986376e80b14f4aefcb32a980a3eaad1f5729c4b197ad0cb0bb7b7
User & Date: drh 2019-02-15 21:21:24.455
Context
2019-02-16
15:41
Enhancements to the althttpd.c SCGI mechanism: Added the "fallback:" and "relight:" lines to the *.scgi specification file format. (check-in: 1c981267ee user: drh tags: trunk)
2019-02-15
21:21
Send the SCGI environment variable with a value of "1" on SCGI requests. (check-in: 216ba4ebe1 user: drh tags: trunk)
20:56
Extra security in althttpd.c. (check-in: 45c1cd9fae user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to misc/althttpd.c.
264
265
266
267
268
269
270

271
272
273
274
275
276
277
static int standalone = 0;       /* Run as a standalone server (no inetd) */
static int ipv6Only = 0;         /* Use IPv6 only */
static int ipv4Only = 0;         /* Use IPv4 only */
static struct rusage priorSelf;  /* Previously report SELF time */
static struct rusage priorChild; /* Previously report CHILD time */
static int mxAge = 120;          /* Cache-control max-age */
static char *default_path = "/bin:/usr/bin";  /* Default PATH variable */


/*
** Mapping between CGI variable names and values stored in
** global variables.
*/
static struct {
  char *zEnvName;







>







264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
static int standalone = 0;       /* Run as a standalone server (no inetd) */
static int ipv6Only = 0;         /* Use IPv6 only */
static int ipv4Only = 0;         /* Use IPv4 only */
static struct rusage priorSelf;  /* Previously report SELF time */
static struct rusage priorChild; /* Previously report CHILD time */
static int mxAge = 120;          /* Cache-control max-age */
static char *default_path = "/bin:/usr/bin";  /* Default PATH variable */
static char *zScgi = 0;          /* Value of the SCGI env variable */

/*
** Mapping between CGI variable names and values stored in
** global variables.
*/
static struct {
  char *zEnvName;
293
294
295
296
297
298
299

300
301
302
303
304
305
306
  { "PATH",                        &default_path },
  { "PATH_INFO",                   &zPathInfo },
  { "QUERY_STRING",                &zQueryString },
  { "REMOTE_ADDR",                 &zRemoteAddr },
  { "REQUEST_METHOD",              &zMethod },
  { "REQUEST_URI",                 &zScript },
  { "REMOTE_USER",                 &zRemoteUser },

  { "SCRIPT_DIRECTORY",            &zDir },
  { "SCRIPT_FILENAME",             &zFile },
  { "SCRIPT_NAME",                 &zRealScript },
  { "SERVER_NAME",                 &zServerName },
  { "SERVER_PORT",                 &zServerPort },
  { "SERVER_PROTOCOL",             &zProtocol },
};







>







294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
  { "PATH",                        &default_path },
  { "PATH_INFO",                   &zPathInfo },
  { "QUERY_STRING",                &zQueryString },
  { "REMOTE_ADDR",                 &zRemoteAddr },
  { "REQUEST_METHOD",              &zMethod },
  { "REQUEST_URI",                 &zScript },
  { "REMOTE_USER",                 &zRemoteUser },
  { "SCGI",                        &zScgi },
  { "SCRIPT_DIRECTORY",            &zDir },
  { "SCRIPT_FILENAME",             &zFile },
  { "SCRIPT_NAME",                 &zRealScript },
  { "SERVER_NAME",                 &zServerName },
  { "SERVER_PORT",                 &zServerPort },
  { "SERVER_PROTOCOL",             &zProtocol },
};
1315
1316
1317
1318
1319
1320
1321

1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340

1341
1342
1343
1344
1345
1346
1347
  if( s==0 ){
    Malfunction(706, "could not turn the socket into a FILE\n");
  }

  nHdrAlloc = 0;
  zHdr = 0;
  if( zContentLength==0 ) zContentLength = "0";

  for(i=0; i<(int)(sizeof(cgienv)/sizeof(cgienv[0])); i++){
    int n1, n2;
    if( cgienv[i].pzEnvValue[0]==0 ) continue;
    n1 = (int)strlen(cgienv[i].zEnvName);
    n2 = (int)strlen(*cgienv[i].pzEnvValue);
    if( n1+n2+2+nHdr >= nHdrAlloc ){
      nHdrAlloc = nHdr + n1 + n2 + 1000;
      zHdr = realloc(zHdr, nHdrAlloc);
      if( zHdr==0 ){
        Malfunction(706, "out of memory");
      }
    }
    memcpy(zHdr+nHdr, cgienv[i].zEnvName, n1);
    nHdr += n1;
    zHdr[nHdr++] = 0;
    memcpy(zHdr+nHdr, *cgienv[i].pzEnvValue, n2);
    nHdr += n2;
    zHdr[nHdr++] = 0;
  }

  fprintf(s,"%d:",(int)nHdr);
  fwrite(zHdr, 1, nHdr, s);
  fprintf(s,",");
  free(zHdr);
  if( zMethod[0]=='P'
   && atoi(zContentLength)>0 
   && (in = fopen(zTmpNam,"r"))!=0 ){







>



















>







1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
  if( s==0 ){
    Malfunction(706, "could not turn the socket into a FILE\n");
  }

  nHdrAlloc = 0;
  zHdr = 0;
  if( zContentLength==0 ) zContentLength = "0";
  zScgi = "1";
  for(i=0; i<(int)(sizeof(cgienv)/sizeof(cgienv[0])); i++){
    int n1, n2;
    if( cgienv[i].pzEnvValue[0]==0 ) continue;
    n1 = (int)strlen(cgienv[i].zEnvName);
    n2 = (int)strlen(*cgienv[i].pzEnvValue);
    if( n1+n2+2+nHdr >= nHdrAlloc ){
      nHdrAlloc = nHdr + n1 + n2 + 1000;
      zHdr = realloc(zHdr, nHdrAlloc);
      if( zHdr==0 ){
        Malfunction(706, "out of memory");
      }
    }
    memcpy(zHdr+nHdr, cgienv[i].zEnvName, n1);
    nHdr += n1;
    zHdr[nHdr++] = 0;
    memcpy(zHdr+nHdr, *cgienv[i].pzEnvValue, n2);
    nHdr += n2;
    zHdr[nHdr++] = 0;
  }
  zScgi = 0;
  fprintf(s,"%d:",(int)nHdr);
  fwrite(zHdr, 1, nHdr, s);
  fprintf(s,",");
  free(zHdr);
  if( zMethod[0]=='P'
   && atoi(zContentLength)>0 
   && (in = fopen(zTmpNam,"r"))!=0 ){