Fossil

Check-in [dcf839e4]
Login

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

Overview
Comment:Do not assume that the method is CGI just because the GATEWAY_INTERFACE environment variable is set. Only do CGI if GATEWAY_INTERFACE is set and there either is no argument specified, or the specified argument is not a valid command. Ticket [e49f245975f89a8a9]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:dcf839e4a6cd787eda162f5d8b803850cf714f99
User & Date: drh 2010-11-04 19:58:16
Context
2010-11-06
16:57
merge from trunk check-in: 3ea66260 user: wolfgang tags: StvPrivateHook2
13:52
Change the anonymous login cookie name to include a hash of the base URL. Ticket [3edef69bf3e995ed2] check-in: 9dd6c431 user: drh tags: trunk
2010-11-04
19:58
Do not assume that the method is CGI just because the GATEWAY_INTERFACE environment variable is set. Only do CGI if GATEWAY_INTERFACE is set and there either is no argument specified, or the specified argument is not a valid command. Ticket [e49f245975f89a8a9] check-in: dcf839e4 user: drh tags: trunk
19:24
Fix a couple of minor issues with settings, as pointed out on the mailing list. check-in: cb2ff51c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

   221    221   /*
   222    222   ** This procedure runs first.
   223    223   */
   224    224   int main(int argc, char **argv){
   225    225     const char *zCmdName = "unknown";
   226    226     int idx;
   227    227     int rc;
          228  +  int mightBeCgi;
   228    229   
   229    230     sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
   230    231     g.now = time(0);
   231    232     g.argc = argc;
   232    233     g.argv = argv;
   233         -  if( getenv("GATEWAY_INTERFACE")!=0 ){
   234         -    zCmdName = "cgi";
   235         -  }else if( argc<2 ){
   236         -    fprintf(stderr, "Usage: %s COMMAND ...\n"
   237         -                    "\"%s help\" for a list of available commands\n"
   238         -                    "\"%s help COMMAND\" for specific details\n",
   239         -                    argv[0], argv[0], argv[0]);
   240         -    fossil_exit(1);
          234  +  mightBeCgi = getenv("GATEWAY_INTERFACE")!=0;
          235  +  if( argc<2 ){
          236  +    if( mightBeCgi ){
          237  +      zCmdName = "cgi";
          238  +    }else{
          239  +      fprintf(stderr, "Usage: %s COMMAND ...\n"
          240  +                      "\"%s help\" for a list of available commands\n"
          241  +                      "\"%s help COMMAND\" for specific details\n",
          242  +                      argv[0], argv[0], argv[0]);
          243  +      fossil_exit(1);
          244  +    }
   241    245     }else{
   242    246       g.fQuiet = find_option("quiet", 0, 0)!=0;
   243    247       g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
   244    248       g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
   245    249       g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
   246    250       g.zLogin = find_option("user", "U", 1);
   247    251       zCmdName = argv[1];
   248    252     }
   249    253     rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
          254  +  if( rc==1 && mightBeCgi ){
          255  +    rc = name_search("cgi", aCommand, count(aCommand), &idx);
          256  +  }
   250    257     if( rc==1 ){
   251    258       fprintf(stderr,"%s: unknown command: %s\n"
   252    259                      "%s: use \"help\" for more information\n",
   253    260                      argv[0], zCmdName, argv[0]);
   254    261       fossil_exit(1);
   255    262     }else if( rc==2 ){
   256    263       fprintf(stderr,"%s: ambiguous command prefix: %s\n"