summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rw-r--r--support/ab.c42
-rw-r--r--support/apxs.in5
-rw-r--r--support/htdbm.c13
-rw-r--r--support/htpasswd.c23
-rw-r--r--support/log_server_status.in88
-rw-r--r--support/split-logfile.in11
6 files changed, 113 insertions, 69 deletions
diff --git a/support/ab.c b/support/ab.c
index e464dc26..5a6f2a09 100644
--- a/support/ab.c
+++ b/support/ab.c
@@ -1186,8 +1186,10 @@ static void start_connect(struct connection * c)
apr_err("socket", rv);
}
- if ((rv = apr_socket_bind(c->aprsock, mysa)) != APR_SUCCESS) {
- apr_err("bind", rv);
+ if (myhost) {
+ if ((rv = apr_socket_bind(c->aprsock, mysa)) != APR_SUCCESS) {
+ apr_err("bind", rv);
+ }
}
c->pollfd.desc_type = APR_POLL_SOCKET;
@@ -1345,11 +1347,21 @@ static void read_connection(struct connection * c)
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);
}
@@ -1686,17 +1698,21 @@ static void test(void)
exit(1);
}
#endif /* NOT_ASCII */
-
- /* 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);
+
+ 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 too */
- if ((rv = apr_sockaddr_info_get(&destsa, connecthost, APR_UNSPEC, connectport, 0, cntxt))
+ 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),
@@ -1825,14 +1841,14 @@ static void test(void)
static void copyright(void)
{
if (!use_html) {
- printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1178079 $>");
+ printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1373084 $>");
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("<p>\n");
- printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i><br>\n", AP_AB_BASEREVISION, "$Revision: 1178079 $");
+ printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i><br>\n", AP_AB_BASEREVISION, "$Revision: 1373084 $");
printf(" Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
printf(" Licensed to The Apache Software Foundation, http://www.apache.org/<br>\n");
printf("</p>\n<p>\n");
diff --git a/support/apxs.in b/support/apxs.in
index 39ff16cd..8bdc2dac 100644
--- a/support/apxs.in
+++ b/support/apxs.in
@@ -39,6 +39,8 @@ my $CFG_TARGET = get_vars("progname");
my $CFG_SYSCONFDIR = get_vars("sysconfdir");
my $CFG_CFLAGS = join ' ', map { get_vars($_) }
qw(SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS);
+my $CFG_LDFLAGS = join ' ', map { get_vars($_) }
+ qw(LDFLAGS NOTEST_LDFLAGS SH_LDFLAGS);
my $includedir = get_vars("includedir");
my $CFG_INCLUDEDIR = eval qq("$includedir");
my $CFG_CC = get_vars("CC");
@@ -448,6 +450,7 @@ if ($opt_c) {
$opt .= " -l$opt_l";
}
+ my $ldflags = "$CFG_LDFLAGS";
if ($opt_p == 1) {
my $apr_libs=`$apr_config --cflags --ldflags --link-libtool --libs`;
@@ -466,7 +469,7 @@ if ($opt_c) {
$opt .= " -rpath $CFG_LIBEXECDIR -module -avoid-version $apr_ldflags";
}
- push(@cmds, "$libtool $ltflags --mode=link $CFG_CC -o $dso_file $opt $lo");
+ push(@cmds, "$libtool $ltflags --mode=link $CFG_CC $ldflags -o $dso_file $opt $lo");
# execute the commands
&execute_cmds(@cmds);
diff --git a/support/htdbm.c b/support/htdbm.c
index f9a02bd4..4898ed8c 100644
--- a/support/htdbm.c
+++ b/support/htdbm.c
@@ -288,6 +288,9 @@ static apr_status_t htdbm_make(htdbm_t *htdbm)
{
char cpw[MAX_STRING_LEN];
char salt[9];
+#if (!(defined(WIN32) || defined(NETWARE)))
+ char *cbuf;
+#endif
switch (htdbm->alg) {
case ALG_APSHA:
@@ -315,7 +318,15 @@ static apr_status_t htdbm_make(htdbm_t *htdbm)
(void) srand((int) time((time_t *) NULL));
to64(&salt[0], rand(), 8);
salt[8] = '\0';
- apr_cpystrn(cpw, crypt(htdbm->userpass, salt), sizeof(cpw) - 1);
+ cbuf = crypt(htdbm->userpass, salt);
+ if (cbuf == NULL) {
+ char errbuf[128];
+
+ fprintf(stderr, "crypt() failed: %s\n",
+ apr_strerror(errno, errbuf, sizeof errbuf));
+ exit(ERR_PWMISMATCH);
+ }
+ apr_cpystrn(cpw, cbuf, sizeof(cpw) - 1);
fprintf(stderr, "CRYPT is now deprecated, use MD5 instead!\n");
#endif
default:
diff --git a/support/htpasswd.c b/support/htpasswd.c
index f67076ff..31e76621 100644
--- a/support/htpasswd.c
+++ b/support/htpasswd.c
@@ -174,6 +174,9 @@ static int mkrecord(char *user, char *record, apr_size_t rlen, char *passwd,
char pwv[MAX_STRING_LEN];
char salt[9];
apr_size_t bufsize;
+#if CRYPT_ALGO_SUPPORTED
+ char *cbuf;
+#endif
if (passwd != NULL) {
pw = passwd;
@@ -226,7 +229,16 @@ static int mkrecord(char *user, char *record, apr_size_t rlen, char *passwd,
to64(&salt[0], rand(), 8);
salt[8] = '\0';
- apr_cpystrn(cpw, crypt(pw, salt), sizeof(cpw) - 1);
+ cbuf = crypt(pw, salt);
+ if (cbuf == NULL) {
+ char errbuf[128];
+
+ apr_snprintf(record, rlen-1, "crypt() failed: %s",
+ apr_strerror(errno, errbuf, sizeof errbuf));
+ return ERR_PWMISMATCH;
+ }
+
+ apr_cpystrn(cpw, cbuf, sizeof(cpw) - 1);
if (strlen(pw) > 8) {
char *truncpw = strdup(pw);
truncpw[8] = '\0';
@@ -271,9 +283,10 @@ static void usage(void)
" (default)"
"." NL);
apr_file_printf(errfile, " -d Force CRYPT encryption of the password"
- "." NL);
+ " (8 chars max, insecure)." NL);
apr_file_printf(errfile, " -p Do not encrypt the password (plaintext)." NL);
- apr_file_printf(errfile, " -s Force SHA encryption of the password." NL);
+ apr_file_printf(errfile, " -s Force SHA encryption of the password"
+ " (insecure)." NL);
apr_file_printf(errfile, " -b Use the password from the command line "
"rather than prompting for it." NL);
apr_file_printf(errfile, " -D Delete the specified user." NL);
@@ -507,7 +520,7 @@ int main(int argc, const char * const argv[])
/*
* Check that this existing file is readable and writable.
*/
- if (!accessible(pool, pwfilename, APR_READ | APR_APPEND)) {
+ if (!accessible(pool, pwfilename, APR_FOPEN_READ|APR_FOPEN_WRITE)) {
apr_file_printf(errfile, "%s: cannot open file %s for "
"read/write access" NL, argv[0], pwfilename);
exit(ERR_FILEPERM);
@@ -526,7 +539,7 @@ int main(int argc, const char * const argv[])
/*
* As it doesn't exist yet, verify that we can create it.
*/
- if (!accessible(pool, pwfilename, APR_CREATE | APR_WRITE)) {
+ if (!accessible(pool, pwfilename, APR_FOPEN_WRITE|APR_FOPEN_CREATE)) {
apr_file_printf(errfile, "%s: cannot create file %s" NL,
argv[0], pwfilename);
exit(ERR_FILEPERM);
diff --git a/support/log_server_status.in b/support/log_server_status.in
index b788ab19..ba08d7e5 100644
--- a/support/log_server_status.in
+++ b/support/log_server_status.in
@@ -25,54 +25,52 @@
# it to a file. Make sure the directory $wherelog is writable by the
# user who runs this script.
#
-require 'sys/socket.ph';
+use IO::Socket;
+use strict;
+use warnings;
-$wherelog = "/var/log/graph/"; # Logs will be like "/var/log/graph/19960312"
-$server = "localhost"; # Name of server, could be "www.foo.com"
-$port = "80"; # Port on server
-$request = "/status/?auto"; # Request to send
+my $wherelog = "@exp_logfiledir@/"; # Logs will be like "@exp_logfiledir@/19960312"
+my $server = "localhost"; # Name of server, could be "www.foo.com"
+my $port = "@PORT@"; # Port on server
+my $request = "/server-status/?auto"; # Request to send
-sub tcp_connect
-{
- local($host,$port) =@_;
- $sockaddr='S n a4 x8';
- chop($hostname=`hostname`);
- $port=(getservbyname($port, 'tcp'))[2] unless $port =~ /^\d+$/;
- $me=pack($sockaddr,&AF_INET,0,(gethostbyname($hostname))[4]);
- $them=pack($sockaddr,&AF_INET,$port,(gethostbyname($host))[4]);
- socket(S,&PF_INET,&SOCK_STREAM,(getprotobyname('tcp'))[2]) ||
- die "socket: $!";
- bind(S,$me) || return "bind: $!";
- connect(S,$them) || return "connect: $!";
- select(S);
- $| = 1;
- select(stdout);
- return "";
-}
+my @ltime = localtime(time);
-### Main
+my $day =
+ $ltime[5] + 1900
+ . sprintf( "%02d", $ltime[4] + 1 )
+ . sprintf( "%02d", $ltime[3] );
-{
- $year=`date +%y`;
- chomp($year);
- $year += ($year < 70) ? 2000 : 1900;
- $date = $year . `date +%m%d:%H%M%S`;
- chomp($date);
- ($day,$time)=split(/:/,$date);
- $res=&tcp_connect($server,$port);
- open(OUT,">>$wherelog$day");
- if ($res) {
- print OUT "$time:-1:-1:-1:-1:$res\n";
- exit 1;
- }
- print S "GET $request\n";
- while (<S>) {
- $requests=$1 if ( m|^BusyServers:\ (\S+)|);
- $idle=$1 if ( m|^IdleServers:\ (\S+)|);
- $number=$1 if ( m|sses:\ (\S+)|);
- $cpu=$1 if (m|^CPULoad:\ (\S+)|);
- }
- print OUT "$time:$requests:$idle:$number:$cpu\n";
-}
+my $time =
+ sprintf( "%02d", $ltime[2] )
+ . sprintf( "%02d", $ltime[1] )
+ . sprintf( "%02d", $ltime[0] );
+
+open(OUT,">>$wherelog$day");
+my $socket = new IO::Socket::INET(
+ PeerAddr => $server,
+ PeerPort => $port,
+ Proto => "tcp",
+ Type => SOCK_STREAM
+ )
+ or do {
+ print OUT "$time:-1:-1:-1:-1:$@\n";
+ close OUT;
+ die "Couldn't connect to $server:$port : $@\n";
+ };
+$| = 1;
+
+print $socket
+ "GET $request HTTP/1.1\r\nHost: $server\r\nConnection: close\r\n\r\n\r\n";
+
+my ( $requests, $idle, $number, $cpu );
+while (<$socket>) {
+ $requests = $1 if (m|^BusyWorkers:\ (\S+)|);
+ $idle = $1 if (m|^IdleWorkers:\ (\S+)|);
+ $number = $1 if (m|sses:\ (\S+)|);
+ $cpu = $1 if (m|^CPULoad:\ (\S+)|);
+}
+print OUT "$time:$requests:$idle:$number:$cpu\n";
+close OUT;
diff --git a/support/split-logfile.in b/support/split-logfile.in
index 061162e8..59eda713 100644
--- a/support/split-logfile.in
+++ b/support/split-logfile.in
@@ -26,22 +26,25 @@
# The combined log file is read from stdin. Records read
# will be appended to any existing log files.
#
-%is_open = ();
+use strict;
+use warnings;
-while ($log_line = <STDIN>) {
+my %is_open = ();
+
+while (my $log_line = <STDIN>) {
#
# Get the first token from the log record; it's the
# identity of the virtual host to which the record
# applies.
#
- ($vhost) = split (/\s/, $log_line);
+ my ($vhost) = split (/\s/, $log_line);
#
# Normalize the virtual host name to all lowercase.
# If it's blank, the request was handled by the default
# server, so supply a default name. This shouldn't
# happen, but caution rocks.
#
- $vhost = lc ($vhost) or "access";
+ $vhost = lc ($vhost) || "access";
#
# if the vhost contains a "/" or "\", it is illegal so just use
# the default log to avoid any security issues due if it is interprted