Index: build/config_vars.sh.in --- build/config_vars.sh.in.orig 2008-02-05 00:00:07.000000000 +0100 +++ build/config_vars.sh.in 2017-03-03 21:13:53.228964000 +0100 @@ -35,7 +35,7 @@ APU_CONFIG=@APU_CONFIG@ fi -APR_LIBTOOL="`${APR_CONFIG} --apr-libtool`" +APR_LIBTOOL="@prefix@/share/apache/build/libtool" APR_INCLUDEDIR="`${APR_CONFIG} --includedir`" APU_INCLUDEDIR="`${APU_CONFIG} --includedir`" Index: config.layout --- config.layout.orig 2012-02-27 23:57:18.000000000 +0100 +++ config.layout 2017-03-03 21:13:53.229125000 +0100 @@ -50,7 +50,7 @@ iconsdir: ${datadir}/icons htdocsdir: ${datadir}/htdocs manualdir: ${datadir}/manual - cgidir: ${datadir}/cgi-bin + cgidir: ${exec_prefix}/cgi includedir: ${prefix}/include+ localstatedir: ${prefix}/var+ runtimedir: ${localstatedir}/run Index: configure --- configure.orig 2017-01-09 18:36:17.000000000 +0100 +++ configure 2017-03-03 21:13:53.231018000 +0100 @@ -3891,6 +3891,11 @@ as_fn_error $? "APR not found. Please read the documentation." "$LINENO" 5 fi +if test "x${USE_BUNDLED_APR}" != "x" ; then + apr_found=reconfig + apr_config=srclib/apr/apr-1-config +fi + if test "$apr_found" = "reconfig"; then # save our work to this point; this allows the sub-package to use it @@ -4254,6 +4259,11 @@ as_fn_error $? "APR-util not found. Please read the documentation." "$LINENO" 5 fi +if test "x${USE_BUNDLED_APR}" != "x" ; then + apu_found=reconfig + apu_config=srclib/apr-util/apu-1-config +fi + # Catch some misconfigurations: case ${apr_found}.${apu_found} in reconfig.yes) Index: docs/conf/mime.types --- docs/conf/mime.types.orig 2016-06-30 19:10:32.000000000 +0200 +++ docs/conf/mime.types 2018-03-07 20:28:49.818091000 +0100 @@ -1047,14 +1047,14 @@ application/x-font-ghostscript gsf # application/x-font-libgrx application/x-font-linux-psf psf -application/x-font-otf otf +font/opentype otf application/x-font-pcf pcf application/x-font-snf snf # application/x-font-speedo # application/x-font-sunos-news application/x-font-ttf ttf ttc application/x-font-type1 pfa pfb pfm afm -application/x-font-woff woff +application/font-woff woff # application/x-font-vfont application/x-freearc arc application/x-futuresplash spl @@ -1458,6 +1458,7 @@ # text/ulpfec text/uri-list uri uris urls text/vcard vcard +text/vtt vtt # text/vnd.abc text/vnd.curl curl text/vnd.curl.dcurl dcurl @@ -1586,3 +1587,12 @@ video/x-sgi-movie movie video/x-smv smv x-conference/x-cooltalk ice + +text/cache-manifest manifest +application/x-chrome-extension crx +application/x-web-app-manifest+json webapp +text/x-component htc +text/x-markdown markdown md mkd +text/plain ini +application/wasm wasm + Index: docs/docroot/index.html --- docs/docroot/index.html.orig 2004-11-20 21:16:24.000000000 +0100 +++ docs/docroot/index.html 2017-03-03 21:13:53.231435000 +0100 @@ -1 +1,7 @@ -

It works!

\ No newline at end of file + + +

It works!

+ It works! Your OpenPKG based Apache HTTP server was successfully installed and started.
+ You now have to read the documentation and configure it according to your local demands. + + Index: modules/generators/mod_autoindex.c --- modules/generators/mod_autoindex.c.orig 2011-02-10 16:24:20.000000000 +0100 +++ modules/generators/mod_autoindex.c 2017-03-03 21:13:53.231795000 +0100 @@ -1574,17 +1574,17 @@ ++cols; } - ap_rputs("", r); + ap_rputs("", r); emit_link(r, "Name", K_NAME, keyid, direction, colargs, static_columns); if (!(autoindex_opts & SUPPRESS_LAST_MOD)) { - ap_rputs("", r); + ap_rputs("", r); emit_link(r, "Last modified", K_LAST_MOD, keyid, direction, colargs, static_columns); ++cols; } if (!(autoindex_opts & SUPPRESS_SIZE)) { - ap_rputs("", r); + ap_rputs("", r); emit_link(r, "Size", K_SIZE, keyid, direction, colargs, static_columns); ++cols; @@ -1678,7 +1678,14 @@ } if (autoindex_opts & TABLE_INDEXING) { - ap_rputs("", r); + char *class; + if (strcmp(t2, "Parent Directory") == 0) + class = "updir"; + else if (ar[x]->isdir) + class = "dir"; + else + class = "file"; + ap_rvputs(r, "", NULL); if (!(autoindex_opts & SUPPRESS_ICON)) { ap_rputs("", r); if (autoindex_opts & ICONS_ARE_LINKS) { @@ -1763,9 +1770,6 @@ desc_width), NULL); } } - else { - ap_rputs(" ", r); - } } ap_rputs("\n", r); } Index: modules/proxy/proxy_util.c --- modules/proxy/proxy_util.c.orig 2017-01-07 14:00:39.000000000 +0100 +++ modules/proxy/proxy_util.c 2017-03-03 21:16:01.739918000 +0100 @@ -1398,7 +1398,6 @@ return max_worker; } -#if APR_HAS_THREADS static void socket_cleanup(proxy_conn_rec *conn) { conn->sock = NULL; @@ -1407,6 +1406,7 @@ apr_pool_clear(conn->scpool); } +#if APR_HAS_THREADS static apr_status_t conn_pool_cleanup(void *theworker) { proxy_worker *worker = (proxy_worker *)theworker; Index: server/Makefile.in --- server/Makefile.in.orig 2011-04-14 18:37:58.000000000 +0200 +++ server/Makefile.in 2017-03-03 21:13:53.231925000 +0100 @@ -56,7 +56,8 @@ tmp=export_files_unsorted.txt; \ rm -f $$tmp && touch $$tmp; \ for dir in $(EXPORT_DIRS); do \ - ls $$dir/*.h >> $$tmp; \ + abs_dir=`cd $$dir && exec pwd`; \ + ls $$abs_dir/*.h >> $$tmp; \ done; \ for dir in $(EXPORT_DIRS_APR); do \ (ls $$dir/ap[ru].h $$dir/ap[ru]_*.h >> $$tmp 2>/dev/null); \ Index: support/Makefile.in --- support/Makefile.in.orig 2011-04-16 21:09:47.000000000 +0200 +++ support/Makefile.in 2017-03-03 21:13:53.232047000 +0100 @@ -22,12 +22,6 @@ chmod 755 $(DESTDIR)$(sbindir)/$$i; \ fi ; \ done - @if test -f "$(builddir)/envvars-std"; then \ - cp -p envvars-std $(DESTDIR)$(sbindir); \ - if test ! -f $(DESTDIR)$(sbindir)/envvars; then \ - cp -p envvars-std $(DESTDIR)$(sbindir)/envvars ; \ - fi ; \ - fi htpasswd_OBJECTS = htpasswd.lo htpasswd: $(htpasswd_OBJECTS) Index: support/ab.c --- support/ab.c.orig 2017-01-05 19:57:49.000000000 +0100 +++ support/ab.c 2017-03-03 21:13:53.232866000 +0100 @@ -156,25 +156,8 @@ #include "ap_config_auto.h" #endif -#if defined(HAVE_SSLC) +#if defined(HAVE_OPENSSL) -/* Libraries for RSA SSL-C */ -#include -#include -#include -#include -#include -#include -#include -#define USE_SSL -#define RSAREF -#define SK_NUM(x) sk_num(x) -#define SK_VALUE(x,y) sk_value(x,y) -typedef STACK X509_STACK_TYPE; - -#elif defined(HAVE_OPENSSL) - -/* Libraries on most systems.. */ #include #include #include @@ -211,6 +194,9 @@ #ifdef SSL_OP_NO_TLSv1_2 #define HAVE_TLSV1_X #endif +#ifdef SSL_OP_NO_TLSv1_2 +#define HAVE_TLSV1_X +#endif #endif #include @@ -232,19 +218,25 @@ /* maximum number of requests on a time limited test */ #define MAX_REQUESTS (INT_MAX > 50000 ? 50000 : INT_MAX) -/* good old state hostname */ -#define STATE_UNCONNECTED 0 -#define STATE_CONNECTING 1 /* TCP connect initiated, but we don't +/* connection state + * don't add enums or rearrange or otherwise change values without + * visiting set_conn_state() + */ +typedef enum { + STATE_UNCONNECTED = 0, + STATE_CONNECTING, /* TCP connect initiated, but we don't * know if it worked yet */ -#define STATE_CONNECTED 2 /* we know TCP connect completed */ -#define STATE_READ 3 + STATE_CONNECTED, /* we know TCP connect completed */ + STATE_READ +} connect_state_e; #define CBUFFSIZE (2048) struct connection { apr_pool_t *ctx; apr_socket_t *aprsock; + apr_pollfd_t pollfd; int state; apr_size_t read; /* amount of bytes read */ apr_size_t bread; /* amount of body read */ @@ -275,8 +267,8 @@ apr_interval_time_t time; /* time for connection */ }; -#define ap_min(a,b) ((a)<(b))?(a):(b) -#define ap_max(a,b) ((a)>(b))?(a):(b) +#define ap_min(a,b) (((a)<(b))?(a):(b)) +#define ap_max(a,b) (((a)>(b))?(a):(b)) #define ap_round_ms(a) ((apr_time_t)((a) + 500)/1000) #define ap_double_ms(a) ((double)(a)/1000.0) #define MAX_CONCURRENCY 20000 @@ -285,7 +277,9 @@ int verbosity = 0; /* no verbosity by default */ int recverrok = 0; /* ok to proceed after socket receive errors */ -int posting = 0; /* GET by default */ +enum {NO_METH = 0, GET, HEAD, PUT, POST} method = NO_METH; +const char *method_str[] = {"bug", "GET", "HEAD", "PUT", "POST"}; +int send_body = 0; /* non-zero if sending body with request */ int requests = 1; /* Number of requests to make */ int heartbeatres = 100; /* How often do we say we're alive */ int concurrency = 1; /* Number of multiple requests to make */ @@ -296,24 +290,26 @@ int windowsize = 0; /* we use the OS default window size */ char servername[1024]; /* name that server reports */ char *hostname; /* host name from URL */ -char *host_field; /* value of "Host:" header field */ -char *path; /* path name */ +const char *host_field; /* value of "Host:" header field */ +const char *path; /* path name */ char postfile[1024]; /* name of file containing post data */ char *postdata; /* *buffer containing data from postfile */ apr_size_t postlen = 0; /* length of data to be POSTed */ char content_type[1024];/* content type to put in POST header */ -char *cookie, /* optional cookie line */ - *auth, /* optional (basic/uuencoded) auhentication */ - *hdrs; /* optional arbitrary headers */ +const char *cookie, /* optional cookie line */ + *auth, /* optional (basic/uuencoded) auhentication */ + *hdrs; /* optional arbitrary headers */ apr_port_t port; /* port number */ char proxyhost[1024]; /* proxy host name */ int proxyport = 0; /* proxy port */ -char *connecthost; +const char *connecthost; +const char *myhost; apr_port_t connectport; -char *gnuplot; /* GNUplot file */ -char *csvperc; /* CSV Percentile file */ +const char *gnuplot; /* GNUplot file */ +const char *csvperc; /* CSV Percentile file */ char url[1024]; -char * fullurl, * colonhost; +const char *fullurl; +const char *colonhost; int isproxy = 0; apr_interval_time_t aprtimeout = apr_time_from_sec(30); /* timeout value */ @@ -372,6 +368,7 @@ apr_pollset_t *readbits; +apr_sockaddr_t *mysa; apr_sockaddr_t *destsa; #ifdef NOT_ASCII @@ -385,7 +382,7 @@ /* simple little function to write an error string and exit */ -static void err(char *s) +static void err(const char *s) { fprintf(stderr, "%s\n", s); if (done) @@ -395,7 +392,7 @@ /* simple little function to write an APR error string and exit */ -static void apr_err(char *s, apr_status_t rv) +static void apr_err(const char *s, apr_status_t rv) { char buf[120]; @@ -407,6 +404,45 @@ exit(rv); } +static void set_polled_events(struct connection *c, apr_int16_t new_reqevents) +{ + apr_status_t rv; + + if (c->pollfd.reqevents != new_reqevents) { + if (c->pollfd.reqevents != 0) { + rv = apr_pollset_remove(readbits, &c->pollfd); + if (rv != APR_SUCCESS) { + apr_err("apr_pollset_remove()", rv); + } + } + + if (new_reqevents != 0) { + c->pollfd.reqevents = new_reqevents; + rv = apr_pollset_add(readbits, &c->pollfd); + if (rv != APR_SUCCESS) { + apr_err("apr_pollset_add()", rv); + } + } + } +} + +static void set_conn_state(struct connection *c, connect_state_e new_state) +{ + apr_int16_t events_by_state[] = { + 0, /* for STATE_UNCONNECTED */ + APR_POLLOUT, /* for STATE_CONNECTING */ + APR_POLLIN, /* for STATE_CONNECTED; we don't poll in this state, + * so prepare for polling in the following state -- + * STATE_READ + */ + APR_POLLIN /* for STATE_READ */ + }; + + c->state = new_state; + + set_polled_events(c, events_by_state[new_state]); +} + /* --------------------------------------------------------- */ /* write out request to a connection - assumes we can write * (small) request out in one go into our new socket buffer @@ -472,7 +508,6 @@ static void ssl_rand_seed(void) { - int nDone = 0; int n, l; time_t t; pid_t pid; @@ -484,7 +519,6 @@ t = time(NULL); l = sizeof(time_t); RAND_seed((unsigned char *)&t, l); - nDone += l; /* * seed in the current process id (usually just 4 bytes) @@ -492,14 +526,12 @@ pid = getpid(); l = sizeof(pid_t); RAND_seed((unsigned char *)&pid, l); - nDone += l; /* * seed in some current state of the run-time stack (128 bytes) */ n = ssl_rand_choosenum(0, sizeof(stackdata)-128-1); RAND_seed(stackdata+n, 128); - nDone += 128; } static int ssl_print_connection_info(BIO *bio, SSL *ssl) @@ -509,6 +541,8 @@ BIO_printf(bio,"Transport Protocol :%s\n", SSL_get_version(ssl)); + BIO_printf(bio,"Transport Protocol :%s\n", SSL_get_version(ssl)); + c = SSL_get_current_cipher(ssl); BIO_printf(bio,"Cipher Suite Protocol :%s\n", SSL_CIPHER_get_version(c)); BIO_printf(bio,"Cipher Suite Name :%s\n",SSL_CIPHER_get_name(c)); @@ -522,6 +556,7 @@ static void ssl_print_cert_info(BIO *bio, X509 *cert) { X509_NAME *dn; + EVP_PKEY *pk; char buf[1024]; BIO_printf(bio, "Certificate version: %ld\n", X509_get_version(cert)+1); @@ -533,8 +568,10 @@ ASN1_UTCTIME_print(bio, X509_get_notAfter(cert)); BIO_printf(bio,"\n"); + pk = X509_get_pubkey(cert); BIO_printf(bio,"Public key is %d bits\n", - EVP_PKEY_bits(X509_get_pubkey(cert))); + EVP_PKEY_bits(pk)); + EVP_PKEY_free(pk); dn = X509_get_issuer_name(cert); X509_NAME_oneline(dn, buf, sizeof(buf)); @@ -561,7 +598,6 @@ for (i=1; issl); @@ -582,7 +618,6 @@ while (do_next) { int ret, ecode; - apr_pollfd_t new_pollfd; ret = SSL_do_handshake(c->ssl); ecode = SSL_get_error(c->ssl, ret); @@ -614,11 +649,7 @@ do_next = 0; break; case SSL_ERROR_WANT_READ: - new_pollfd.desc_type = APR_POLL_SOCKET; - new_pollfd.reqevents = APR_POLLIN; - new_pollfd.desc.s = c->aprsock; - new_pollfd.client_data = c; - apr_pollset_add(readbits, &new_pollfd); + set_polled_events(c, APR_POLLIN); do_next = 0; break; case SSL_ERROR_WANT_WRITE: @@ -642,6 +673,10 @@ static void write_request(struct connection * c) { + if (started >= requests) { + return; + } + do { apr_time_t tnow; apr_size_t l = c->rwrite; @@ -657,7 +692,7 @@ c->connect = tnow; c->rwrote = 0; c->rwrite = reqlen; - if (posting) + if (send_body) c->rwrite += postlen; } else if (tnow > c->connect + aprtimeout) { @@ -694,16 +729,9 @@ c->rwrite -= l; } while (c->rwrite); - c->state = STATE_READ; c->endwrite = lasttime = apr_time_now(); - { - apr_pollfd_t new_pollfd; - new_pollfd.desc_type = APR_POLL_SOCKET; - new_pollfd.reqevents = APR_POLLIN; - new_pollfd.desc.s = c->aprsock; - new_pollfd.client_data = c; - apr_pollset_add(readbits, &new_pollfd); - } + started++; + set_conn_state(c, STATE_READ); } /* --------------------------------------------------------- */ @@ -783,10 +811,9 @@ if (keepalive) printf("Keep-Alive requests: %d\n", doneka); printf("Total transferred: %" APR_INT64_T_FMT " bytes\n", totalread); - if (posting == 1) - printf("Total POSTed: %" APR_INT64_T_FMT "\n", totalposted); - if (posting == 2) - printf("Total PUT: %" APR_INT64_T_FMT "\n", totalposted); + if (send_body) + printf("Total body sent: %" APR_INT64_T_FMT "\n", + totalposted); printf("HTML transferred: %" APR_INT64_T_FMT " bytes\n", totalbread); /* avoid divide by zero */ @@ -799,7 +826,7 @@ (double) timetaken * 1000 / done); printf("Transfer rate: %.2f [Kbytes/sec] received\n", (double) totalread / 1024 / timetaken); - if (posting > 0) { + if (send_body) { printf(" %.2f kb/s sent\n", (double) totalposted / timetaken / 1024); printf(" %.2f kb/s total\n", @@ -1070,14 +1097,11 @@ printf("Total transferred:" "%" APR_INT64_T_FMT " bytes\n", trstring, tdstring, tdstring, totalread); - if (posting == 1) - printf("Total POSTed:" + if (send_body) + printf("Total body sent:" "%" APR_INT64_T_FMT "\n", - trstring, tdstring, tdstring, totalposted); - if (posting == 2) - printf("Total PUT:" - "%" APR_INT64_T_FMT "\n", - trstring, tdstring, tdstring, totalposted); + trstring, tdstring, + tdstring, totalposted); printf("HTML transferred:" "%" APR_INT64_T_FMT " bytes\n", trstring, tdstring, tdstring, totalbread); @@ -1086,11 +1110,11 @@ if (timetaken) { printf("Requests per second:" "%.2f\n", - trstring, tdstring, tdstring, (double) done * 1000 / timetaken); + trstring, tdstring, tdstring, (double) done / timetaken); printf("Transfer rate:" "%.2f kb/s received\n", trstring, tdstring, tdstring, (double) totalread / timetaken); - if (posting > 0) { + if (send_body) { printf(" " "%.2f kb/s sent\n", trstring, tdstring, tdstring, @@ -1179,18 +1203,30 @@ SOCK_STREAM, 0, c->ctx)) != APR_SUCCESS) { apr_err("socket", rv); } + + if (myhost) { + if ((rv = apr_socket_bind(c->aprsock, mysa)) != APR_SUCCESS) { + apr_err("bind", rv); + } + } + + c->pollfd.desc_type = APR_POLL_SOCKET; + c->pollfd.desc.s = c->aprsock; + c->pollfd.reqevents = 0; + c->pollfd.client_data = c; + if ((rv = apr_socket_opt_set(c->aprsock, APR_SO_NONBLOCK, 1)) != APR_SUCCESS) { apr_err("socket nonblock", rv); } if (windowsize != 0) { - rv = apr_socket_opt_set(c->aprsock, APR_SO_SNDBUF, + rv = apr_socket_opt_set(c->aprsock, APR_SO_SNDBUF, windowsize); if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) { apr_err("socket send buffer", rv); } - rv = apr_socket_opt_set(c->aprsock, APR_SO_RCVBUF, + rv = apr_socket_opt_set(c->aprsock, APR_SO_RCVBUF, windowsize); if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) { apr_err("socket receive buffer", rv); @@ -1223,21 +1259,12 @@ #endif if ((rv = apr_socket_connect(c->aprsock, destsa)) != APR_SUCCESS) { if (APR_STATUS_IS_EINPROGRESS(rv)) { - apr_pollfd_t new_pollfd; - c->state = STATE_CONNECTING; + set_conn_state(c, STATE_CONNECTING); c->rwrite = 0; - new_pollfd.desc_type = APR_POLL_SOCKET; - new_pollfd.reqevents = APR_POLLOUT; - new_pollfd.desc.s = c->aprsock; - new_pollfd.client_data = c; - apr_pollset_add(readbits, &new_pollfd); return; } else { - apr_pollfd_t remove_pollfd; - remove_pollfd.desc_type = APR_POLL_SOCKET; - remove_pollfd.desc.s = c->aprsock; - apr_pollset_remove(readbits, &remove_pollfd); + set_conn_state(c, STATE_UNCONNECTED); apr_socket_close(c->aprsock); err_conn++; if (bad++ > 10) { @@ -1245,15 +1272,14 @@ "\nTest aborted after 10 failures\n\n"); apr_err("apr_socket_connect()", rv); } - c->state = STATE_UNCONNECTED; + start_connect(c); return; } } /* connected first time */ - c->state = STATE_CONNECTED; - started++; + set_conn_state(c, STATE_CONNECTED); #ifdef USE_SSL if (c->ssl) { ssl_proceed_handshake(c); @@ -1301,21 +1327,15 @@ } } - { - apr_pollfd_t remove_pollfd; - remove_pollfd.desc_type = APR_POLL_SOCKET; - remove_pollfd.desc.s = c->aprsock; - apr_pollset_remove(readbits, &remove_pollfd); + set_conn_state(c, STATE_UNCONNECTED); #ifdef USE_SSL - if (c->ssl) { - SSL_shutdown(c->ssl); - SSL_free(c->ssl); - c->ssl = NULL; - } -#endif - apr_socket_close(c->aprsock); + if (c->ssl) { + SSL_shutdown(c->ssl); + SSL_free(c->ssl); + c->ssl = NULL; } - c->state = STATE_UNCONNECTED; +#endif + apr_socket_close(c->aprsock); /* connect again */ start_connect(c); @@ -1345,11 +1365,21 @@ good++; close_connection(c); } + else if (scode == SSL_ERROR_SYSCALL + && status == 0 + && c->read != 0) { + /* connection closed, but in violation of the protocol, after + * some data has already been read; this commonly happens, so + * let the length check catch any response errors + */ + good++; + close_connection(c); + } else if (scode != SSL_ERROR_WANT_WRITE && scode != SSL_ERROR_WANT_READ) { /* some fatal error: */ c->read = 0; - BIO_printf(bio_err, "SSL read failed - closing connection\n"); + BIO_printf(bio_err, "SSL read failed (%d) - closing connection\n", scode); ERR_print_errors(bio_err); close_connection(c); } @@ -1433,10 +1463,7 @@ } else { /* header is in invalid or too big - close connection */ - apr_pollfd_t remove_pollfd; - remove_pollfd.desc_type = APR_POLL_SOCKET; - remove_pollfd.desc.s = c->aprsock; - apr_pollset_remove(readbits, &remove_pollfd); + set_conn_state(c, STATE_UNCONNECTED); apr_socket_close(c->aprsock); err_response++; if (bad++ > 10) { @@ -1499,12 +1526,12 @@ if (cl) { c->keepalive = 1; /* response to HEAD doesn't have entity body */ - c->length = posting >= 0 ? atoi(cl + 16) : 0; + c->length = method != HEAD ? atoi(cl + 16) : 0; } /* The response may not have a Content-Length header */ if (!cl) { c->keepalive = 1; - c->length = 0; + c->length = 0; } } c->bread += c->cbx - (s + l - c->cbuff) + r - tocopy; @@ -1560,7 +1587,8 @@ static void test(void) { apr_time_t stoptime; - apr_int16_t rv; + apr_int16_t rtnev; + apr_status_t rv; int i; apr_status_t status; int snprintf_res = 0; @@ -1588,9 +1616,17 @@ con = calloc(concurrency, sizeof(struct connection)); + /* + * XXX: a way to calculate the stats without requiring O(requests) memory + * XXX: would be nice. + */ stats = calloc(requests, sizeof(struct data)); + if (stats == NULL || con == NULL) { + err("Cannot allocate memory for result statistics"); + } - if ((status = apr_pollset_create(&readbits, concurrency, cntxt, 0)) != APR_SUCCESS) { + if ((status = apr_pollset_create(&readbits, concurrency, cntxt, + APR_POLLSET_NOCOPY)) != APR_SUCCESS) { apr_err("apr_pollset_create failed", status); } @@ -1620,12 +1656,12 @@ } /* setup request */ - if (posting <= 0) { + if (!send_body) { snprintf_res = apr_snprintf(request, sizeof(_request), "%s %s HTTP/1.0\r\n" "%s" "%s" "%s" "%s" "\r\n", - (posting == 0) ? "GET" : "HEAD", + method_str[method], (isproxy) ? fullurl : path, keepalive ? "Connection: Keep-Alive\r\n" : "", cookie, auth, hdrs); @@ -1638,7 +1674,7 @@ "Content-type: %s\r\n" "%s" "\r\n", - (posting == 1) ? "POST" : "PUT", + method_str[method], (isproxy) ? fullurl : path, keepalive ? "Connection: Keep-Alive\r\n" : "", cookie, auth, @@ -1650,15 +1686,15 @@ } if (verbosity >= 2) - printf("INFO: %s header == \n---\n%s\n---\n", - (posting == 2) ? "PUT" : "POST", request); + printf("INFO: %s header == \n---\n%s\n---\n", + method_str[method], request); reqlen = strlen(request); /* - * Combine headers and (optional) post file into one contineous buffer + * Combine headers and (optional) post file into one continuous buffer */ - if (posting >= 1) { + if (send_body) { char *buff = malloc(postlen + reqlen + 1); if (!buff) { fprintf(stderr, "error creating request buffer: out of memory\n"); @@ -1680,9 +1716,21 @@ exit(1); } #endif /* NOT_ASCII */ + + if (myhost) { + /* This only needs to be done once */ + if ((rv = apr_sockaddr_info_get(&mysa, myhost, APR_UNSPEC, 0, 0, cntxt)) != APR_SUCCESS) { + char buf[120]; + apr_snprintf(buf, sizeof(buf), + "apr_sockaddr_info_get() for %s", myhost); + apr_err(buf, rv); + } + } - /* This only needs to be done once */ - if ((rv = apr_sockaddr_info_get(&destsa, connecthost, APR_UNSPEC, connectport, 0, cntxt)) + /* This too */ + if ((rv = apr_sockaddr_info_get(&destsa, connecthost, + myhost ? mysa->family : APR_UNSPEC, + connectport, 0, cntxt)) != APR_SUCCESS) { char buf[120]; apr_snprintf(buf, sizeof(buf), @@ -1694,7 +1742,7 @@ start = lasttime = apr_time_now(); stoptime = tlimit ? (start + apr_time_from_sec(tlimit)) : AB_MAX; -#ifdef SIGINT +#ifdef SIGINT /* Output the results if the user terminates the run early. */ apr_signal(SIGINT, output_results); #endif @@ -1707,24 +1755,19 @@ do { apr_int32_t n; - const apr_pollfd_t *pollresults; + const apr_pollfd_t *pollresults, *pollfd; n = concurrency; do { - status = apr_pollset_poll(readbits, aprtimeout, &n, &pollresults); + status = apr_pollset_poll(readbits, aprtimeout, &n, &pollresults); } while (APR_STATUS_IS_EINTR(status)); if (status != APR_SUCCESS) - apr_err("apr_poll", status); + apr_err("apr_pollset_poll", status); - if (!n) { - err("\nServer timed out\n\n"); - } - - for (i = 0; i < n; i++) { - const apr_pollfd_t *next_fd = &(pollresults[i]); + for (i = 0, pollfd = pollresults; i < n; i++, pollfd++) { struct connection *c; - c = next_fd->client_data; + c = pollfd->client_data; /* * If the connection isn't connected how can we check it? @@ -1732,7 +1775,7 @@ if (c->state == STATE_UNCONNECTED) continue; - rv = next_fd->rtnevents; + rtnev = pollfd->rtnevents; #ifdef USE_SSL if (c->state == STATE_CONNECTED && c->ssl && SSL_in_init(c->ssl)) { @@ -1753,22 +1796,25 @@ * connection is done and we loop here endlessly calling * apr_poll(). */ - if ((rv & APR_POLLIN) || (rv & APR_POLLPRI) || (rv & APR_POLLHUP)) + if ((rtnev & APR_POLLIN) || (rtnev & APR_POLLPRI) || (rtnev & APR_POLLHUP)) read_connection(c); - if ((rv & APR_POLLERR) || (rv & APR_POLLNVAL)) { + if ((rtnev & APR_POLLERR) || (rtnev & APR_POLLNVAL)) { bad++; err_except++; - start_connect(c); + /* avoid apr_poll/EINPROGRESS loop on HP-UX, let recv discover ECONNREFUSED */ + if (c->state == STATE_CONNECTING) { + read_connection(c); + } + else { + start_connect(c); + } continue; } - if (rv & APR_POLLOUT) { + if (rtnev & APR_POLLOUT) { if (c->state == STATE_CONNECTING) { - apr_pollfd_t remove_pollfd; rv = apr_socket_connect(c->aprsock, destsa); - remove_pollfd.desc_type = APR_POLL_SOCKET; - remove_pollfd.desc.s = c->aprsock; - apr_pollset_remove(readbits, &remove_pollfd); if (rv != APR_SUCCESS) { + set_conn_state(c, STATE_UNCONNECTED); apr_socket_close(c->aprsock); err_conn++; if (bad++ > 10) { @@ -1776,13 +1822,11 @@ "\nTest aborted after 10 failures\n\n"); apr_err("apr_socket_connect()", rv); } - c->state = STATE_UNCONNECTED; start_connect(c); continue; } else { - c->state = STATE_CONNECTED; - started++; + set_conn_state(c, STATE_CONNECTED); #ifdef USE_SSL if (c->ssl) ssl_proceed_handshake(c); @@ -1795,25 +1839,9 @@ write_request(c); } } - - /* - * When using a select based poll every time we check the bits - * are reset. In 1.3's ab we copied the FD_SET's each time - * through, but here we're going to check the state and if the - * connection is in STATE_READ or STATE_CONNECTING we'll add the - * socket back in as APR_POLLIN. - */ - if (c->state == STATE_READ) { - apr_pollfd_t new_pollfd; - new_pollfd.desc_type = APR_POLL_SOCKET; - new_pollfd.reqevents = APR_POLLIN; - new_pollfd.desc.s = c->aprsock; - new_pollfd.client_data = c; - apr_pollset_add(readbits, &new_pollfd); - } } } while (lasttime < stoptime && done < requests); - + if (heartbeatres) fprintf(stderr, "Finished %d requests\n", done); else @@ -1831,14 +1859,14 @@ static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 655654 $>"); + printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1430300 $>"); printf("Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n"); printf("Licensed to The Apache Software Foundation, http://www.apache.org/\n"); printf("\n"); } else { printf("

\n"); - printf(" This is ApacheBench, Version %s <%s>
\n", AP_AB_BASEREVISION, "$Revision: 655654 $"); + printf(" This is ApacheBench, Version %s <%s>
\n", AP_AB_BASEREVISION, "$Revision: 1430300 $"); printf(" Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
\n"); printf(" Licensed to The Apache Software Foundation, http://www.apache.org/
\n"); printf("

\n

\n"); @@ -1857,12 +1885,16 @@ */ fprintf(stderr, "Options are:\n"); fprintf(stderr, " -n requests Number of requests to perform\n"); - fprintf(stderr, " -c concurrency Number of multiple requests to make\n"); - fprintf(stderr, " -t timelimit Seconds to max. wait for responses\n"); + fprintf(stderr, " -c concurrency Number of multiple requests to make at a time\n"); + fprintf(stderr, " -t timelimit Seconds to max. to spend on benchmarking\n"); + fprintf(stderr, " This implies -n 50000\n"); + fprintf(stderr, " -s timeout Seconds to max. wait for each response\n"); + fprintf(stderr, " Default is 30 seconds\n"); fprintf(stderr, " -b windowsize Size of TCP send/receive buffer, in bytes\n"); + fprintf(stderr, " -B address Address to bind to when making outgoing connections\n"); fprintf(stderr, " -p postfile File containing data to POST. Remember also to set -T\n"); fprintf(stderr, " -u putfile File containing data to PUT. Remember also to set -T\n"); - fprintf(stderr, " -T content-type Content-type header for POSTing, eg.\n"); + fprintf(stderr, " -T content-type Content-type header to use for POST/PUT data, eg.\n"); fprintf(stderr, " 'application/x-www-form-urlencoded'\n"); fprintf(stderr, " Default is 'text/plain'\n"); fprintf(stderr, " -v verbosity How much troubleshooting info to print\n"); @@ -1871,7 +1903,7 @@ fprintf(stderr, " -x attributes String to insert as table attributes\n"); fprintf(stderr, " -y attributes String to insert as tr attributes\n"); fprintf(stderr, " -z attributes String to insert as td or th attributes\n"); - fprintf(stderr, " -C attribute Add cookie, eg. 'Apache=1234. (repeatable)\n"); + fprintf(stderr, " -C attribute Add cookie, eg. 'Apache=1234'. (repeatable)\n"); fprintf(stderr, " -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'\n"); fprintf(stderr, " Inserted after all normal header lines. (repeatable)\n"); fprintf(stderr, " -A attribute Add Basic WWW Authentication, the attributes\n"); @@ -1883,6 +1915,7 @@ fprintf(stderr, " -k Use HTTP KeepAlive feature\n"); fprintf(stderr, " -d Do not show percentiles served table.\n"); fprintf(stderr, " -S Do not show confidence estimators and warnings.\n"); + fprintf(stderr, " -q Do not show progress when doing more than 150 requests\n"); fprintf(stderr, " -g filename Output collected data to gnuplot format file.\n"); fprintf(stderr, " -e filename Output CSV file with percentages served\n"); fprintf(stderr, " -r Don't exit on socket receive errors.\n"); @@ -1918,7 +1951,7 @@ /* split URL into parts */ -static int parse_url(char *url) +static int parse_url(const char *url) { char *cp; char *h; @@ -1949,9 +1982,7 @@ if ((cp = strchr(url, '/')) == NULL) return 1; - h = apr_palloc(cntxt, cp - url + 1); - memcpy(h, url, cp - url); - h[cp - url] = '\0'; + h = apr_pstrmemdup(cntxt, url, cp - url); rv = apr_parse_addr_port(&hostname, &scope_id, &port, h, cntxt); if (rv != APR_SUCCESS || !hostname || scope_id) { return 1; @@ -1988,9 +2019,9 @@ /* ------------------------------------------------------- */ -/* read data to POST from file, save contents and length */ +/* read data to POST/PUT from file, save contents and length */ -static int open_postfile(const char *pfile) +static apr_status_t open_postfile(const char *pfile) { apr_file_t *postfd; apr_finfo_t finfo; @@ -2023,7 +2054,7 @@ return rv; } apr_file_close(postfd); - return 0; + return APR_SUCCESS; } /* ------------------------------------------------------- */ @@ -2031,11 +2062,11 @@ /* sort out command-line args and call test */ int main(int argc, const char * const argv[]) { - int r, l; + int l; char tmp[1024]; apr_status_t status; apr_getopt_t *opt; - const char *optarg; + const char *opt_arg; char c; #ifdef USE_SSL AB_SSL_METHOD_CONST SSL_METHOD *meth = SSLv23_client_method(); @@ -2072,15 +2103,17 @@ } #endif + myhost = NULL; /* 0.0.0.0 or :: */ + apr_getopt_init(&opt, cntxt, argc, argv); - while ((status = apr_getopt(opt, "n:c:t:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:Sq" + while ((status = apr_getopt(opt, "n:c:t:s:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:SqB:" #ifdef USE_SSL "Z:f:" #endif - ,&c, &optarg)) == APR_SUCCESS) { + ,&c, &opt_arg)) == APR_SUCCESS) { switch (c) { case 'n': - requests = atoi(optarg); + requests = atoi(opt_arg); if (requests <= 0) { err("Invalid number of requests\n"); } @@ -2092,76 +2125,77 @@ heartbeatres = 0; break; case 'c': - concurrency = atoi(optarg); + concurrency = atoi(opt_arg); break; case 'b': - windowsize = atoi(optarg); + windowsize = atoi(opt_arg); break; case 'i': - if (posting > 0) - err("Cannot mix POST/PUT and HEAD\n"); - posting = -1; + if (method != NO_METH) + err("Cannot mix HEAD with other methods\n"); + method = HEAD; break; case 'g': - gnuplot = strdup(optarg); + gnuplot = strdup(opt_arg); break; case 'd': percentile = 0; break; case 'e': - csvperc = strdup(optarg); + csvperc = strdup(opt_arg); break; case 'S': confidence = 0; break; + case 's': + aprtimeout = apr_time_from_sec(atoi(opt_arg)); /* timeout value */ + break; case 'p': - if (posting != 0) - err("Cannot mix POST and HEAD\n"); - if (0 == (r = open_postfile(optarg))) { - posting = 1; - } - else if (postdata) { - exit(r); + if (method != NO_METH) + err("Cannot mix POST with other methods\n"); + if (open_postfile(opt_arg) != APR_SUCCESS) { + exit(1); } + method = POST; + send_body = 1; break; case 'u': - if (posting != 0) - err("Cannot mix PUT and HEAD\n"); - if (0 == (r = open_postfile(optarg))) { - posting = 2; - } - else if (postdata) { - exit(r); + if (method != NO_METH) + err("Cannot mix PUT with other methods\n"); + if (open_postfile(opt_arg) != APR_SUCCESS) { + exit(1); } + method = PUT; + send_body = 1; break; case 'r': recverrok = 1; break; case 'v': - verbosity = atoi(optarg); + verbosity = atoi(opt_arg); break; case 't': - tlimit = atoi(optarg); + tlimit = atoi(opt_arg); requests = MAX_REQUESTS; /* need to size data array on * something */ break; case 'T': - strcpy(content_type, optarg); + strcpy(content_type, opt_arg); break; case 'C': - cookie = apr_pstrcat(cntxt, "Cookie: ", optarg, "\r\n", NULL); + cookie = apr_pstrcat(cntxt, "Cookie: ", opt_arg, "\r\n", NULL); break; case 'A': /* * assume username passwd already to be in colon separated form. * Ready to be uu-encoded. */ - while (apr_isspace(*optarg)) - optarg++; - if (apr_base64_encode_len(strlen(optarg)) > sizeof(tmp)) { + while (apr_isspace(*opt_arg)) + opt_arg++; + if (apr_base64_encode_len(strlen(opt_arg)) > sizeof(tmp)) { err("Authentication credentials too long\n"); } - l = apr_base64_encode(tmp, optarg, strlen(optarg)); + l = apr_base64_encode(tmp, opt_arg, strlen(opt_arg)); tmp[l] = '\0'; auth = apr_pstrcat(cntxt, auth, "Authorization: Basic ", tmp, @@ -2171,27 +2205,27 @@ /* * assume username passwd already to be in colon separated form. */ - while (apr_isspace(*optarg)) - optarg++; - if (apr_base64_encode_len(strlen(optarg)) > sizeof(tmp)) { + while (apr_isspace(*opt_arg)) + opt_arg++; + if (apr_base64_encode_len(strlen(opt_arg)) > sizeof(tmp)) { err("Proxy credentials too long\n"); } - l = apr_base64_encode(tmp, optarg, strlen(optarg)); + l = apr_base64_encode(tmp, opt_arg, strlen(opt_arg)); tmp[l] = '\0'; auth = apr_pstrcat(cntxt, auth, "Proxy-Authorization: Basic ", tmp, "\r\n", NULL); break; case 'H': - hdrs = apr_pstrcat(cntxt, hdrs, optarg, "\r\n", NULL); + hdrs = apr_pstrcat(cntxt, hdrs, opt_arg, "\r\n", NULL); /* * allow override of some of the common headers that ab adds */ - if (strncasecmp(optarg, "Host:", 5) == 0) { + if (strncasecmp(opt_arg, "Host:", 5) == 0) { opt_host = 1; - } else if (strncasecmp(optarg, "Accept:", 7) == 0) { + } else if (strncasecmp(opt_arg, "Accept:", 7) == 0) { opt_accept = 1; - } else if (strncasecmp(optarg, "User-Agent:", 11) == 0) { + } else if (strncasecmp(opt_arg, "User-Agent:", 11) == 0) { opt_useragent = 1; } break; @@ -2204,7 +2238,7 @@ */ case 'x': use_html = 1; - tablestring = optarg; + tablestring = opt_arg; break; case 'X': { @@ -2212,22 +2246,22 @@ /* * assume proxy-name[:port] */ - if ((p = strchr(optarg, ':'))) { + if ((p = strchr(opt_arg, ':'))) { *p = '\0'; p++; proxyport = atoi(p); } - strcpy(proxyhost, optarg); + strcpy(proxyhost, opt_arg); isproxy = 1; } break; case 'y': use_html = 1; - trstring = optarg; + trstring = opt_arg; break; case 'z': use_html = 1; - tdstring = optarg; + tdstring = opt_arg; break; case 'h': usage(argv[0]); @@ -2235,28 +2269,31 @@ case 'V': copyright(); return 0; + case 'B': + myhost = apr_pstrdup(cntxt, opt_arg); + break; #ifdef USE_SSL case 'Z': - ssl_cipher = strdup(optarg); + ssl_cipher = strdup(opt_arg); break; case 'f': - if (strncasecmp(optarg, "ALL", 3) == 0) { + if (strncasecmp(opt_arg, "ALL", 3) == 0) { meth = SSLv23_client_method(); #ifndef OPENSSL_NO_SSL2 - } else if (strncasecmp(optarg, "SSL2", 4) == 0) { + } else if (strncasecmp(opt_arg, "SSL2", 4) == 0) { meth = SSLv2_client_method(); #endif #ifndef OPENSSL_NO_SSL3 - } else if (strncasecmp(optarg, "SSL3", 4) == 0) { + } else if (strncasecmp(opt_arg, "SSL3", 4) == 0) { meth = SSLv3_client_method(); #endif #ifdef HAVE_TLSV1_X - } else if (strncasecmp(optarg, "TLS1.1", 6) == 0) { + } else if (strncasecmp(opt_arg, "TLS1.1", 6) == 0) { meth = TLSv1_1_client_method(); - } else if (strncasecmp(optarg, "TLS1.2", 6) == 0) { + } else if (strncasecmp(opt_arg, "TLS1.2", 6) == 0) { meth = TLSv1_2_client_method(); #endif - } else if (strncasecmp(optarg, "TLS1", 4) == 0) { + } else if (strncasecmp(opt_arg, "TLS1", 4) == 0) { meth = TLSv1_client_method(); } break; @@ -2269,6 +2306,10 @@ usage(argv[0]); } + if (method == NO_METH) { + method = GET; + } + if (parse_url(apr_pstrdup(cntxt, opt->argv[opt->ind++]))) { fprintf(stderr, "%s: invalid URL\n", argv[0]); usage(argv[0]); @@ -2312,6 +2353,10 @@ exit(1); } SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL); +#ifdef SSL_MODE_RELEASE_BUFFERS + /* Keep memory usage as low as possible */ + SSL_CTX_set_mode (ssl_ctx, SSL_MODE_RELEASE_BUFFERS); +#endif if (ssl_cipher != NULL) { if (!SSL_CTX_set_cipher_list(ssl_ctx, ssl_cipher)) { fprintf(stderr, "error setting cipher list [%s]\n", ssl_cipher); Index: support/apachectl.in --- support/apachectl.in.orig 2006-07-12 05:38:44.000000000 +0200 +++ support/apachectl.in 2017-03-03 21:13:53.232983000 +0100 @@ -43,11 +43,6 @@ # the path to your httpd binary, including options if necessary HTTPD='@exp_sbindir@/@progname@' # -# pick up any necessary environment variables -if test -f @exp_sbindir@/envvars; then - . @exp_sbindir@/envvars -fi -# # a command that outputs a formatted text version of the HTML at the # url given on the command line. Designed for lynx, however other # programs may work. Index: support/apxs.in --- support/apxs.in.orig 2010-05-10 22:02:56.000000000 +0200 +++ support/apxs.in 2017-03-03 21:13:53.233161000 +0100 @@ -80,6 +80,7 @@ # the "+" metacharacter at the format string to allow a list to be built by # subsequent occurrences of the same option. sub Getopts { + no warnings 'deprecated'; my ($argumentative, @ARGV) = @_; my $errs = 0; local $_; @@ -189,9 +190,6 @@ my $httpd = get_vars("sbindir") . "/" . get_vars("progname"); $httpd = eval qq("$httpd"); $httpd = eval qq("$httpd"); -my $envvars = get_vars("sbindir") . "/envvars"; -$envvars = eval qq("$envvars"); -$envvars = eval qq("$envvars"); #allow apxs to be run from the source tree, before installation if ($0 =~ m:support/apxs$:) { @@ -203,7 +201,7 @@ exit 1; } -unless (grep /mod_so/, `. $envvars && $httpd -l`) { +unless (grep /mod_so/, `$httpd -l`) { error("Sorry, no shared object support for Apache"); error("available under your platform. Make sure"); error("the Apache module mod_so is compiled into"); @@ -337,8 +335,7 @@ exit(1); } -my $libtool = `$apr_config --apr-libtool`; -chomp($libtool); +my $libtool = "$prefix/share/apache/build/libtool"; my $apr_includedir = `$apr_config --includes`; chomp($apr_includedir); Index: support/htdigest.c --- support/htdigest.c.orig 2013-04-26 16:58:20.000000000 +0200 +++ support/htdigest.c 2017-03-03 21:13:53.233337000 +0100 @@ -122,7 +122,7 @@ } -static void add_password(const char *user, const char *realm, apr_file_t *f) +static void add_password(const char *user, const char *realm, const char *pw0, apr_file_t *f) { char *pw; apr_md5_ctx_t context; @@ -133,6 +133,9 @@ unsigned int i; apr_size_t len = sizeof(pwin); + if (pw0 != NULL) + pw = pw0; + else { if (apr_password_get("New password: ", pwin, &len) != APR_SUCCESS) { apr_file_printf(errfile, "password too long"); cleanup_tempfile_and_exit(5); @@ -144,6 +147,7 @@ cleanup_tempfile_and_exit(1); } pw = pwin; + } apr_file_printf(f, "%s:%s:", user, realm); /* Do MD5 stuff */ @@ -164,7 +168,7 @@ static void usage(void) { - apr_file_printf(errfile, "Usage: htdigest [-c] passwordfile realm username\n"); + apr_file_printf(errfile, "Usage: htdigest [-c] passwordfile realm username [password]\n"); apr_file_printf(errfile, "The -c flag creates a new file.\n"); exit(1); } @@ -191,6 +195,8 @@ char *dirname; char user[MAX_STRING_LEN]; char realm[MAX_STRING_LEN]; + char *password = NULL; + char passwordb[MAX_STRING_LEN]; char line[3 * MAX_STRING_LEN]; char l[3 * MAX_STRING_LEN]; char w[MAX_STRING_LEN]; @@ -212,9 +218,7 @@ #endif apr_signal(SIGINT, (void (*)(int)) interrupted); - if (argc == 5) { - if (strcmp(argv[1], "-c")) - usage(); + if ((argc == 5 || argc == 6) && strcmp(argv[1], "-c") == 0) { rv = apr_file_open(&f, argv[2], APR_WRITE | APR_CREATE, APR_OS_DEFAULT, cntxt); if (rv != APR_SUCCESS) { @@ -225,15 +229,19 @@ apr_strerror(rv, errmsg, sizeof errmsg)); exit(1); } + if (argc == 6) { + apr_cpystrn(passwordb, argv[5], sizeof(passwordb)); + password = passwordb; + } apr_cpystrn(user, argv[4], sizeof(user)); apr_cpystrn(realm, argv[3], sizeof(realm)); apr_file_printf(errfile, "Adding password for %s in realm %s.\n", user, realm); - add_password(user, realm, f); + add_password(user, realm, password, f); apr_file_close(f); exit(0); } - else if (argc != 4) + else if (argc != 4 && argc != 5) usage(); if (apr_temp_dir_get((const char**)&dirname, cntxt) != APR_SUCCESS) { @@ -256,6 +264,10 @@ } apr_cpystrn(user, argv[3], sizeof(user)); apr_cpystrn(realm, argv[2], sizeof(realm)); + if (argc == 5) { + apr_cpystrn(passwordb, argv[4], sizeof(passwordb)); + password = passwordb; + } found = 0; while (!(get_line(line, sizeof(line), f))) { @@ -273,13 +285,13 @@ else { apr_file_printf(errfile, "Changing password for user %s in realm %s\n", user, realm); - add_password(user, realm, tfp); + add_password(user, realm, password, tfp); found = 1; } } if (!found) { apr_file_printf(errfile, "Adding user %s in realm %s\n", user, realm); - add_password(user, realm, tfp); + add_password(user, realm, password, tfp); } apr_file_close(f); Index: server/core.c --- server/core.c +++ server/core.c @@ -1809,6 +1809,12 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, /* method has not been registered yet, but resorce restriction * is always checked before method handling, so register it. */ + if (cmd->pool == cmd->temp_pool) { + /* In .htaccess, we can't globally register new methods. */ + return apr_psprintf(cmd->pool, "Could not register method '%s' " + "for %s from .htaccess configuration", + method, cmd->cmd->name); + } methnum = ap_method_register(cmd->pool, method); }