[BACK]Return to main.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / libexec / httpd

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/libexec/httpd/main.c between version 1.5.8.3 and 1.6

version 1.5.8.3, 2017/03/07 07:16:08 version 1.6, 2013/10/12 17:24:07
Line 4 
Line 4 
 /* from: eterna: bozohttpd.c,v 1.159 2009/05/23 02:14:30 mrg Exp        */  /* from: eterna: bozohttpd.c,v 1.159 2009/05/23 02:14:30 mrg Exp        */
   
 /*  /*
  * Copyright (c) 1997-2016 Matthew R. Green   * Copyright (c) 1997-2011 Matthew R. Green
  * All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
Line 58 
Line 58 
 BOZO_DEAD static void  BOZO_DEAD static void
 usage(bozohttpd_t *httpd, char *progname)  usage(bozohttpd_t *httpd, char *progname)
 {  {
         bozowarn(httpd, "usage: %s [options] slashdir [virtualhostname]",          bozo_warn(httpd, "usage: %s [options] slashdir [virtualhostname]",
                         progname);                          progname);
         bozowarn(httpd, "options:");          bozo_warn(httpd, "options:");
 #ifndef NO_DEBUG  #ifndef NO_DEBUG
         bozowarn(httpd, "   -d\t\t\tenable debug support");          bozo_warn(httpd, "   -d\t\t\tenable debug support");
 #endif  
         bozowarn(httpd, "   -s\t\t\talways log to stderr");  
 #ifndef NO_DYNAMIC_CONTENT  
         bozowarn(httpd, "   -M arg t c c11\tadd this mime extenstion");  
 #endif  #endif
           bozo_warn(httpd, "   -s\t\t\talways log to stderr");
 #ifndef NO_USER_SUPPORT  #ifndef NO_USER_SUPPORT
         bozowarn(httpd, "   -u\t\t\tenable ~user/public_html support");          bozo_warn(httpd, "   -u\t\t\tenable ~user/public_html support");
         bozowarn(httpd, "   -p dir\t\tchange `public_html' directory name");          bozo_warn(httpd, "   -p dir\t\tchange `public_html' directory name]");
 #ifndef NO_CGIBIN_SUPPORT  
         bozowarn(httpd, "   -E\t\t\tenable CGI support for user dirs");  
 #endif  #endif
   #ifndef NO_DYNAMIC_CONTENT
           bozo_warn(httpd, "   -M arg t c c11\tadd this mime extenstion");
 #endif  #endif
 #ifndef NO_CGIBIN_SUPPORT  #ifndef NO_CGIBIN_SUPPORT
 #ifndef NO_DYNAMIC_CONTENT  #ifndef NO_DYNAMIC_CONTENT
         bozowarn(httpd, "   -C arg prog\t\tadd this CGI handler");          bozo_warn(httpd, "   -C arg prog\t\tadd this CGI handler");
 #endif  #endif
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -c cgibin\t\tenable cgi-bin support in this directory");                  "   -c cgibin\t\tenable cgi-bin support in this directory");
 #endif  #endif
 #ifndef NO_LUA_SUPPORT  #ifndef NO_LUA_SUPPORT
         bozowarn(httpd, "   -L arg script\tadd this Lua script");          bozo_warn(httpd, "   -L arg script\tadd this Lua script");
 #endif  #endif
         bozowarn(httpd, "   -I port\t\tbind or use on this port");          bozo_warn(httpd, "   -I port\t\tbind or use on this port");
 #ifndef NO_DAEMON_MODE  #ifndef NO_DAEMON_MODE
         bozowarn(httpd, "   -b\t\t\tbackground and go into daemon mode");          bozo_warn(httpd, "   -b\t\t\tbackground and go into daemon mode");
         bozowarn(httpd, "   -f\t\t\tkeep daemon mode in the foreground");          bozo_warn(httpd, "   -f\t\t\tkeep daemon mode in the foreground");
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -i address\t\tbind on this address (daemon mode only)");                  "   -i address\t\tbind on this address (daemon mode only)");
         bozowarn(httpd, "   -P pidfile\t\tpath to the pid file to create");          bozo_warn(httpd, "   -P pidfile\t\tpath to the pid file to create");
 #endif  #endif
         bozowarn(httpd, "   -S version\t\tset server version string");          bozo_warn(httpd, "   -S version\t\tset server version string");
         bozowarn(httpd, "   -t dir\t\tchroot to `dir'");          bozo_warn(httpd, "   -t dir\t\tchroot to `dir'");
         bozowarn(httpd, "   -U username\t\tchange user to `user'");          bozo_warn(httpd, "   -U username\t\tchange user to `user'");
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -e\t\t\tdon't clean the environment (-t and -U only)");                  "   -e\t\t\tdon't clean the environment (-t and -U only)");
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -v virtualroot\tenable virtual host support "                  "   -v virtualroot\tenable virtual host support "
                 "in this directory");                  "in this directory");
         bozowarn(httpd, "   -V\t\tUnknown virtual hosts go to `slashdir'");          bozo_warn(httpd,
                   "   -r\t\t\tmake sure sub-pages come from "
                   "this host via referrer");
 #ifndef NO_DIRINDEX_SUPPORT  #ifndef NO_DIRINDEX_SUPPORT
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -X\t\t\tenable automatic directory index support");                  "   -X\t\t\tenable automatic directory index support");
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -H\t\t\thide files starting with a period (.)"                  "   -H\t\t\thide files starting with a period (.)"
                 " in index mode");                  " in index mode");
 #endif  #endif
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -x index\t\tchange default `index.html' file name");                  "   -x index\t\tchange default `index.html' file name");
 #ifndef NO_SSL_SUPPORT  #ifndef NO_SSL_SUPPORT
         bozowarn(httpd,          bozo_warn(httpd,
                 "   -z ciphers\t\tspecify SSL ciphers");  
         bozowarn(httpd,  
                 "   -Z cert privkey\tspecify path to server certificate"                  "   -Z cert privkey\tspecify path to server certificate"
                         " and private key file\n"                          " and private key file\n"
                 "\t\t\tin pem format and enable bozohttpd in SSL mode");                  "\t\t\tin pem format and enable bozohttpd in SSL mode");
 #endif /* NO_SSL_SUPPORT */  #endif /* NO_SSL_SUPPORT */
         bozowarn(httpd, "   -G print version number and exit");          bozo_err(httpd, 1, "%s failed to start", progname);
         bozoerr(httpd, 1, "%s failed to start", progname);  
 }  }
   
 int  int
Line 130  main(int argc, char **argv)
Line 126  main(int argc, char **argv)
         bozohttpd_t      httpd;          bozohttpd_t      httpd;
         bozoprefs_t      prefs;          bozoprefs_t      prefs;
         char            *progname;          char            *progname;
         const char      *val;  
         int              c;          int              c;
   
         (void) memset(&httpd, 0x0, sizeof(httpd));          (void) memset(&httpd, 0x0, sizeof(httpd));
Line 145  main(int argc, char **argv)
Line 140  main(int argc, char **argv)
   
         bozo_set_defaults(&httpd, &prefs);          bozo_set_defaults(&httpd, &prefs);
   
         /*  
          * -r option was removed, do not reuse it for a while  
          */  
   
         while ((c = getopt(argc, argv,          while ((c = getopt(argc, argv,
             "C:EGHI:L:M:P:S:U:VXZ:bc:defhi:np:st:uv:x:z:")) != -1) {              "C:HI:L:M:P:S:U:VXZ:bc:defhi:np:rst:uv:x:z:")) != -1) {
                 switch (c) {                  switch(c) {
   
                 case 'L':                  case 'L':
 #ifdef NO_LUA_SUPPORT  #ifdef NO_LUA_SUPPORT
                         bozoerr(&httpd, 1,                          bozo_err(&httpd, 1,
                                 "Lua support is not enabled");                                  "Lua support is not enabled");
                         /* NOTREACHED */                          /* NOTREACHED */
 #else  #else
Line 168  main(int argc, char **argv)
Line 159  main(int argc, char **argv)
 #endif /* NO_LUA_SUPPORT */  #endif /* NO_LUA_SUPPORT */
                 case 'M':                  case 'M':
 #ifdef NO_DYNAMIC_CONTENT  #ifdef NO_DYNAMIC_CONTENT
                         bozoerr(&httpd, 1,                          bozo_err(&httpd, 1,
                                 "dynamic mime content support is not enabled");                                  "dynamic mime content support is not enabled");
                         /* NOTREACHED */                          /* NOTREACHED */
 #else  #else
Line 182  main(int argc, char **argv)
Line 173  main(int argc, char **argv)
 #endif /* NO_DYNAMIC_CONTENT */  #endif /* NO_DYNAMIC_CONTENT */
   
                 case 'n':                  case 'n':
                         bozo_set_pref(&httpd, &prefs, "numeric", "true");                          bozo_set_pref(&prefs, "numeric", "true");
                           break;
   
                   case 'r':
                           bozo_set_pref(&prefs, "trusted referal", "true");
                         break;                          break;
   
                 case 's':                  case 's':
                         bozo_set_pref(&httpd, &prefs, "log to stderr", "true");                          bozo_set_pref(&prefs, "log to stderr", "true");
                         break;                          break;
   
                 case 'S':                  case 'S':
                         bozo_set_pref(&httpd, &prefs, "server software",                          bozo_set_pref(&prefs, "server software", optarg);
                                       optarg);  
                         break;                          break;
                 case 'Z':                  case 'Z':
 #ifdef NO_SSL_SUPPORT  #ifdef NO_SSL_SUPPORT
                         bozoerr(&httpd, 1, "ssl support is not enabled");                          bozo_err(&httpd, 1, "ssl support is not enabled");
                         /* NOT REACHED */                          /* NOT REACHED */
 #else  #else
                         /* make sure there's two arguments */                          /* make sure there's two arguments */
Line 204  main(int argc, char **argv)
Line 198  main(int argc, char **argv)
                         bozo_ssl_set_opts(&httpd, optarg, argv[optind++]);                          bozo_ssl_set_opts(&httpd, optarg, argv[optind++]);
                         break;                          break;
 #endif /* NO_SSL_SUPPORT */  #endif /* NO_SSL_SUPPORT */
   
                 case 'z':  
 #ifdef NO_SSL_SUPPORT  
                         bozoerr(&httpd, 1, "ssl support is not enabled");  
                         /* NOT REACHED */  
 #else  
                         bozo_ssl_set_ciphers(&httpd, optarg);  
                         break;  
 #endif /* NO_SSL_SUPPORT */  
   
                 case 'U':                  case 'U':
                         bozo_set_pref(&httpd, &prefs, "username", optarg);                          bozo_set_pref(&prefs, "username", optarg);
                         break;                          break;
   
                 case 'V':                  case 'V':
                         bozo_set_pref(&httpd, &prefs, "unknown slash", "true");                          bozo_set_pref(&prefs, "unknown slash", "true");
                         break;                          break;
   
                 case 'v':                  case 'v':
                         bozo_set_pref(&httpd, &prefs, "virtual base", optarg);                          bozo_set_pref(&prefs, "virtual base", optarg);
                         break;                          break;
   
                 case 'x':                  case 'x':
                         bozo_set_pref(&httpd, &prefs, "index.html", optarg);                          bozo_set_pref(&prefs, "index.html", optarg);
                         break;                          break;
   
                 case 'I':                  case 'I':
                         bozo_set_pref(&httpd, &prefs, "port number", optarg);                          bozo_set_pref(&prefs, "port number", optarg);
                         break;                          break;
   
 #ifdef NO_DAEMON_MODE  #ifdef NO_DAEMON_MODE
Line 240  main(int argc, char **argv)
Line 224  main(int argc, char **argv)
                 case 'f':                  case 'f':
                 case 'i':                  case 'i':
                 case 'P':                  case 'P':
                         bozoerr(&httpd, 1, "Daemon mode is not enabled");                          bozo_err(&httpd, 1, "Daemon mode is not enabled");
                         /* NOTREACHED */                          /* NOTREACHED */
 #else  #else
                 case 'b':                  case 'b':
Line 249  main(int argc, char **argv)
Line 233  main(int argc, char **argv)
                          * background == 2 (aka, -b -b) means to                           * background == 2 (aka, -b -b) means to
                          * only process 1 per kid                           * only process 1 per kid
                          */                           */
                         val = bozo_get_pref(&prefs, "background") == NULL ?                          if (bozo_get_pref(&prefs, "background") == NULL) {
                             "1" : "2";                                  bozo_set_pref(&prefs, "background", "1");
                         bozo_set_pref(&httpd, &prefs, "background", val);                          } else {
                                   bozo_set_pref(&prefs, "background", "2");
                           }
                         break;                          break;
   
                 case 'e':                  case 'e':
                         bozo_set_pref(&httpd, &prefs, "dirty environment",                          bozo_set_pref(&prefs, "dirty environment", "true");
                                       "true");  
                         break;                          break;
   
                 case 'f':                  case 'f':
                         bozo_set_pref(&httpd, &prefs, "foreground", "true");                          bozo_set_pref(&prefs, "foreground", "true");
                         break;                          break;
   
                 case 'i':                  case 'i':
                         bozo_set_pref(&httpd, &prefs, "bind address", optarg);                          bozo_set_pref(&prefs, "bind address", optarg);
                         break;                          break;
   
                 case 'P':                  case 'P':
                         bozo_set_pref(&httpd, &prefs, "pid file", optarg);                          bozo_set_pref(&prefs, "pid file", optarg);
                         break;                          break;
 #endif /* NO_DAEMON_MODE */  #endif /* NO_DAEMON_MODE */
   
 #ifdef NO_CGIBIN_SUPPORT  #ifdef NO_CGIBIN_SUPPORT
                 case 'c':                  case 'c':
                 case 'C':                  case 'C':
                         bozoerr(&httpd, 1, "CGI is not enabled");                          bozo_err(&httpd, 1, "CGI is not enabled");
                         /* NOTREACHED */                          /* NOTREACHED */
 #else  #else
                 case 'c':                  case 'c':
Line 284  main(int argc, char **argv)
Line 269  main(int argc, char **argv)
   
                 case 'C':                  case 'C':
 #  ifdef NO_DYNAMIC_CONTENT  #  ifdef NO_DYNAMIC_CONTENT
                         bozoerr(&httpd, 1,                          bozo_err(&httpd, 1,
                                 "dynamic CGI handler support is not enabled");                                  "dynamic CGI handler support is not enabled");
                         /* NOTREACHED */                          /* NOTREACHED */
 #  else  #  else
Line 301  main(int argc, char **argv)
Line 286  main(int argc, char **argv)
                         httpd.debug++;                          httpd.debug++;
 #ifdef NO_DEBUG  #ifdef NO_DEBUG
                         if (httpd.debug == 1)                          if (httpd.debug == 1)
                                 bozowarn(&httpd, "Debugging is not enabled");                                  bozo_warn(&httpd, "Debugging is not enabled");
 #endif /* NO_DEBUG */  #endif /* NO_DEBUG */
                         break;                          break;
   
                 case 't':  
                         bozo_set_pref(&httpd, &prefs, "chroot dir", optarg);  
                         break;  
   
 #ifdef NO_USER_SUPPORT  #ifdef NO_USER_SUPPORT
                 case 'p':                  case 'p':
                   case 't':
                 case 'u':                  case 'u':
                 case 'E':                          bozo_err(&httpd, 1, "User support is not enabled");
                         bozoerr(&httpd, 1, "User support is not enabled");  
                         /* NOTREACHED */                          /* NOTREACHED */
 #else  #else
                 case 'p':                  case 'p':
                         bozo_set_pref(&httpd, &prefs, "public_html", optarg);                          bozo_set_pref(&prefs, "public_html", optarg);
                         break;                          break;
   
                 case 'u':                  case 't':
                         bozo_set_pref(&httpd, &prefs, "enable users", "true");                          bozo_set_pref(&prefs, "chroot dir", optarg);
                         break;                          break;
 #ifndef NO_CGIBIN_SUPPORT  
                 case 'E':                  case 'u':
                         bozo_set_pref(&httpd, &prefs, "enable user cgibin",                          bozo_set_pref(&prefs, "enable users", "true");
                                       "true");  
                         break;                          break;
 #else  
                 case 'E':  
                         bozoerr(&httpd, 1, "CGI is not enabled");  
                         /* NOTREACHED */  
 #endif /* NO_CGIBIN_SPPORT */  
 #endif /* NO_USER_SUPPORT */  #endif /* NO_USER_SUPPORT */
   
 #ifdef NO_DIRINDEX_SUPPORT  #ifdef NO_DIRINDEX_SUPPORT
                 case 'H':                  case 'H':
                 case 'X':                  case 'X':
                         bozoerr(&httpd, 1,                          bozo_err(&httpd, 1,
                                 "directory indexing is not enabled");                                  "directory indexing is not enabled");
                         /* NOTREACHED */                          /* NOTREACHED */
 #else  #else
                 case 'H':                  case 'H':
                         bozo_set_pref(&httpd, &prefs, "hide dots", "true");                          bozo_set_pref(&prefs, "hide dots", "true");
                         break;                          break;
   
                 case 'X':                  case 'X':
                         bozo_set_pref(&httpd, &prefs, "directory indexing",                          bozo_set_pref(&prefs, "directory indexing", "true");
                                       "true");  
                         break;                          break;
   
 #endif /* NO_DIRINDEX_SUPPORT */  #endif /* NO_DIRINDEX_SUPPORT */
   
                 case 'G':  
                         {  
                                 char    version[128];  
   
                                 bozo_get_version(version, sizeof(version));  
                                 printf("bozohttpd version %s\n", version);  
                         }  
                         return 0;  
   
                 default:                  default:
                         usage(&httpd, progname);                          usage(&httpd, progname);
                         /* NOTREACHED */                          /* NOTREACHED */

Legend:
Removed from v.1.5.8.3  
changed lines
  Added in v.1.6

CVSweb <webmaster@jp.NetBSD.org>