patch-mini_httpd_c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. $Id$
  2. --- mini_httpd-1.19.orig/mini_httpd.c 2005-06-29 19:31:17.000000000 +0200
  3. +++ mini_httpd-1.19/mini_httpd.c 2007-01-20 19:48:49.000000000 +0100
  4. @@ -66,8 +66,14 @@
  5. #endif /* HAVE_SENDFILE */
  6. #ifdef USE_SSL
  7. +# ifdef HAVE_OPENSSL
  8. #include <openssl/ssl.h>
  9. #include <openssl/err.h>
  10. +# else /* HAVE_OPENSSL */
  11. +# ifdef HAVE_MATRIXSSL
  12. +# include "matrixssl_helper.h"
  13. +# endif /* HAVE_MATRIXSSL */
  14. +# endif /* HAVE_OPENSSL */
  15. #endif /* USE_SSL */
  16. extern char* crypt( const char* key, const char* setting );
  17. @@ -132,10 +138,10 @@ typedef long long int64_t;
  18. #define CGI_NICE 10
  19. #endif /* CGI_NICE */
  20. #ifndef CGI_PATH
  21. -#define CGI_PATH "/usr/local/bin:/usr/ucb:/bin:/usr/bin"
  22. +#define CGI_PATH "/usr/bin:/bin:/usr/sbin:/sbin"
  23. #endif /* CGI_PATH */
  24. #ifndef CGI_LD_LIBRARY_PATH
  25. -#define CGI_LD_LIBRARY_PATH "/usr/local/lib:/usr/lib"
  26. +#define CGI_LD_LIBRARY_PATH "/usr/lib:/lib"
  27. #endif /* CGI_LD_LIBRARY_PATH */
  28. #ifndef AUTH_FILE
  29. #define AUTH_FILE ".htpasswd"
  30. @@ -193,7 +199,13 @@ static int listen4_fd, listen6_fd;
  31. static int do_ssl;
  32. static char* certfile;
  33. static char* cipher;
  34. +#ifdef HAVE_OPENSSL
  35. static SSL_CTX* ssl_ctx;
  36. +#else /* HAVE_OPENSSL */
  37. + #ifdef HAVE_MATRIXSSL
  38. +static sslKeys_t* keys;
  39. + #endif /* HAVE_MATRIXSSL */
  40. +#endif /* HAVE_OPENSSL */
  41. #endif /* USE_SSL */
  42. static char cwd[MAXPATHLEN];
  43. static int got_hup;
  44. @@ -540,6 +552,7 @@ main( int argc, char** argv )
  45. #ifdef USE_SSL
  46. if ( do_ssl )
  47. {
  48. +# ifdef HAVE_OPENSSL
  49. SSL_load_error_strings();
  50. SSLeay_add_ssl_algorithms();
  51. ssl_ctx = SSL_CTX_new( SSLv23_server_method() );
  52. @@ -559,6 +572,17 @@ main( int argc, char** argv )
  53. exit( 1 );
  54. }
  55. }
  56. +# else /* HAVE_OPENSSL */
  57. +# ifdef HAVE_MATRIXSSL
  58. + matrixSslOpen();
  59. + if ( matrixSslReadKeys( &keys, certfile, certfile, NULL, NULL ) < 0 )
  60. + {
  61. + syslog( LOG_CRIT, "can't load certificate and/or private key\n");
  62. + (void) fprintf( stderr, "%s: can't load certificate and/or private key\n", argv0 );
  63. + exit( 1 );
  64. + }
  65. +# endif /* HAVE_MATRIXSSL */
  66. +# endif /* HAVE_OPENSSL */
  67. }
  68. #endif /* USE_SSL */
  69. @@ -1174,6 +1198,7 @@ handle_request( void )
  70. #ifdef USE_SSL
  71. if ( do_ssl )
  72. {
  73. +# ifdef HAVE_OPENSSL
  74. ssl = SSL_new( ssl_ctx );
  75. SSL_set_fd( ssl, conn_fd );
  76. if ( SSL_accept( ssl ) == 0 )
  77. @@ -1181,6 +1206,16 @@ handle_request( void )
  78. ERR_print_errors_fp( stderr );
  79. exit( 1 );
  80. }
  81. +# else /* HAVE_OPENSSL */
  82. +# ifdef HAVE_MATRIXSSL
  83. + ssl = SSL_new(keys);
  84. + SSL_set_fd( ssl, conn_fd );
  85. + if ( SSL_accept( ssl ) <= 0 )
  86. + {
  87. + perror( "SSL_accept" );
  88. + }
  89. +# endif /* HAVE_MATRIXSSL */
  90. +# endif /* HAVE_OPENSSL */
  91. }
  92. #endif /* USE_SSL */