pen-0.32.0/0000755000175000017500000000000012624555212007363 500000000000000pen-0.32.0/pen_poll.h0000644000175000017500000000003512514665761011273 00000000000000extern void poll_init(void); pen-0.32.0/client.h0000644000175000017500000000105412531277031010727 00000000000000#include #include #ifndef WINDOWS #include #else #include #endif #define CLIENTS_MAX 2048 /* max clients */ #define TRACKING_TIME 0 /* how long a client is remembered */ typedef struct { time_t last; /* last time this client made a connection */ struct sockaddr_storage addr; int server; /* server used last time */ long connects; uint64_t csx, crx; } client; extern client *clients; extern int clients_max; extern int store_client(struct sockaddr_storage *); extern void expand_clienttable(int); pen-0.32.0/configure.ac0000644000175000017500000000620012624554450011572 00000000000000dnl Process this file with autoconf to produce a configure script. AC_INIT([pen],[0.32.0]) AC_CONFIG_SRCDIR([pen.c]) AC_CONFIG_HEADERS(config.h) AM_INIT_AUTOMAKE dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S AC_ISC_POSIX dnl Checks for libraries. AC_CHECK_LIB(socket, main) AC_CHECK_LIB(nsl, main) dnl Next line is for Solaris AC_CHECK_LIB(resolv, inet_aton) dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_MAJOR dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM if test "$GCC" = "yes"; then CFLAGS="-Wall $CFLAGS" fi dnl Checks for library functions. dnl AC_CHECK_FUNC(inet_aton, AC_DEFINE(HAVE_INET_ATON, 1, [#undef HAVE_INET_ATON])) AC_CHECK_FUNC(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO, 1, [#undef HAVE_GETADDRINFO])) AC_CHECK_FUNC(accept4, AC_DEFINE(HAVE_ACCEPT4, 1, [#undef HAVE_ACCEPT4])) dnl Check things for pen AC_CHECK_HEADERS([sys/select.h]) AC_ARG_ENABLE(profiling, [ --enable-profiling enable profiling], [ if test "$withval" != "no"; then CFLAGS="$CFLAGS -pg" fi ]) AC_ARG_ENABLE(debugging, AS_HELP_STRING([--enable-debugging], [enable debugging messages])) AS_IF([test "$enable_debugging" != "no"], [CFLAGS="$CFLAGS -DDEBUGGING"]) AC_ARG_WITH(daemon, [ --with-daemon use daemon() if available], [ if test "$withval" != "no"; then AC_CHECK_FUNC(daemon, AC_DEFINE([HAVE_DAEMON], 1, [#undef HAVE_DAEMON])) fi ]) AC_ARG_WITH(poll, AS_HELP_STRING([--with-poll], [use poll() if available])) AS_IF([test "$with_poll" != "no"], AC_CHECK_FUNC(poll, AC_DEFINE([HAVE_POLL], 1, [#undef HAVE_POLL]))) AC_ARG_WITH(epoll, AS_HELP_STRING([--with-epoll], [use epoll if available])) AS_IF([test "$with_epoll" != "no"], AC_CHECK_FUNC(epoll_create1, AC_DEFINE([HAVE_EPOLL], 1, [#undef HAVE_EPOLL]))) AC_ARG_WITH(kqueue, AS_HELP_STRING([--with-kqueue], [use kqueue() if available])) AS_IF([test "$with_kqueue" != "no"], AC_CHECK_FUNC(kqueue, AC_DEFINE([HAVE_KQUEUE], 1, [#undef HAVE_KQUEUE]))) AC_ARG_WITH(fd_setsize, [ --with-fd_setsize=N set FD_SETSIZE to N (see INSTALL)], [ if test "$withval" != "no"; then AC_DEFINE_UNQUOTED([FD_SETSIZE], $withval, [#undef FD_SETSIZE]) fi ]) AC_ARG_WITH(ssl, AS_HELP_STRING([--with-ssl], [use SSL (default /usr/local/ssl)])) AS_IF([test "$with_ssl" != "no"], AC_CHECK_LIB(crypto, main) AC_CHECK_LIB(ssl, main)) dnl Some people think the EC stuff is patented and needs to be stripped out AC_CHECK_FUNC(EC_KEY_new_by_curve_name, AC_DEFINE([HAVE_EC_KEY], 1, [#undef HAVE_EC_KEY])) AC_ARG_WITH(geoip, AS_HELP_STRING([--with-geoip], [use libgeoip])) AS_IF([test "$with_geoip" != "no"], AC_CHECK_LIB([GeoIP], [GeoIP_country_code_by_addr])) AC_ARG_WITH(dsr, AS_HELP_STRING([--with-dsr], [enable direct server return])) AS_IF([test "$with_dsr" != "no"], [ AC_CHECK_HEADERS([linux/if_packet.h]) AC_CHECK_HEADERS([net/netmap_user.h])]) docdir='${prefix}/doc/pen' AC_ARG_WITH(docdir, [ --with-docdir=DIR install docs in DIR [[PREFIX/doc/pen]]], [ if test "$withval" != "yes" && test "$withval" != "no"; then docdir=$withval fi ]) AC_SUBST(docdir) AC_CONFIG_FILES([Makefile]) AC_OUTPUT pen-0.32.0/mergelogs.c0000644000175000017500000002065112526565545011452 00000000000000/* mergelogs.c Copyright (C) 2001-2015 Ulric Eriksson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include "diag.h" #include "memory.h" #include "settings.h" #define KEEP_MAX 100 /* how much to keep from the URI */ typedef struct { char *a; /* server name */ char *fn; /* log file name */ FILE *fp; /* file pointer, or NULL if eof */ time_t t; /* time stamp from last line */ char cli[1024]; /* client address */ char tim[1024]; /* time string */ char uri[1024]; /* uri */ char b1[1024], b2[1024], b3[1024]; /* misc text */ } server; static server *servers; static int nservers; static char *pfile; static int jitter = 600; /* 10 minutes */ static FILE *pfp; static int tz = 0; static int cache_penlog = 1; static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static void usage(void) { printf("Usage: mergelogs -p penlog [-j jitter] \\\n" " server1:logfile1 [server2:logfile2 ...]\n\n" " -c Do not use penlog cache\n" " -d Debugging (repeat for more)\n" " -p penlog Log file from pen\n" " -j jitter Jitter in seconds [2]\n" " -r filename Where to put rejects\n" " -t seconds Timezone\n" " server:logfile Web server address and name of logfile\n"); exit(0); } static int options(int argc, char **argv) { int c; while ((c = getopt(argc, argv, "p:a:j:t:cd")) != -1) { switch (c) { case 'p': pfile = optarg; break; case 'j': jitter = atoi(optarg); break; case 't': tz = atoi(optarg); break; case 'c': cache_penlog = 0; break; case 'd': debuglevel++; break; default: usage(); } } return optind; } static int mon2num(char *p) { int i; for (i = 0; i < 12; i++) if (!strcmp(p, months[i])) return i; return -1; } static char *num2mon(int m) { if (m < 0 || m > 11) return "no such month"; return months[m]; } static void thenp(char *b, time_t t) { struct tm *tms = localtime(&t); snprintf(b, 1024, "%02d/%s/%04d:%02d:%02d:%02d +0000", tms->tm_mday, num2mon(tms->tm_mon), tms->tm_year+1900, tms->tm_hour, tms->tm_min, tms->tm_sec); } /* Time format: 09/Jan/2002:00:27:15 +0100 */ static time_t whenp(char *p, struct tm *tms) { char dd[100], mm[100], yy[100]; char hh[100], mi[100], ss[100], tz[100]; time_t t; tz[0] = '\0'; sscanf(p, "%[^/]/%[^/]/%[^:]:%[^:]:%[^:]:%s %s", dd, mm, yy, hh, mi, ss, tz); tms->tm_sec = atoi(ss); tms->tm_min = atoi(mi); tms->tm_hour = atoi(hh); tms->tm_mday = atoi(dd); tms->tm_mon = mon2num(mm); tms->tm_year = atoi(yy)-1900; t = mktime(tms); if (t != -1 && strlen(tz) == 5) { int d = 60*atoi(tz+3); tz[3] = '\0'; d += 3600*atoi(tz+1); if (tz[0] == '+') t -= d; else t += d; } return t; } static void read_server_line(int s) { char b[1024]; struct tm tms; int n; do { if (fgets(b, sizeof b, servers[s].fp) == NULL) { fclose(servers[s].fp); servers[s].fp = NULL; return; } n = sscanf(b, "%[^ ] %[^[][%[^]]]%[^\"]\"%[^\"]\"%[^\n]", servers[s].cli, servers[s].b1, servers[s].tim, servers[s].b2, servers[s].uri, servers[s].b3); if (n == 6) { servers[s].t = whenp(servers[s].tim, &tms); } else if (debuglevel) { debug("Read %d fields", n); } } while (n != 6); } static int oldest_server(void) { int i, n = -1; time_t t = -1; for (i = 0; i < nservers; i++) { if (servers[i].fp) { if (t == -1 || servers[i].t < t) { n = i; t = servers[i].t; } } } return n; } typedef struct { char *cli; /* client address */ int ser; /* server index (in servers array) */ time_t t; /* time stamp */ char *uri; /* uri */ } pencache; static pencache *pc; static int npc; static int server2num(char *s) { int i; for (i = 0; i < nservers; i++) { if (!strcmp(servers[i].a, s)) return i; } return -1; } /* cache relevant penlog lines to speed up the search */ static void best_client1(char *p, char *s, long t, char *u) { char b[1024], from[1024], to[1024], uri[1024]; long when, td, ntd; int i, j; int ser = server2num(s); /* first remove all entries that are older than (t-jitter) */ for (i = 0; i < npc; i++) { if (pc[i].t >= (t-jitter)) break; } if (i) { if (debuglevel) debug("uncache %d lines\n", i); for (j = 0; j < i; j++) { if (debuglevel >= 2) { debug("uncache '%s %ld %d %s'", pc[j].cli, pc[j].t, pc[j].ser, pc[j].uri); } free(pc[j].cli); free(pc[j].uri); } while (j < npc) { pc[j-i] = pc[j]; j++; } npc -= i; } /* then add entries until eof or newer than (t+jitter) */ for (;;) { if (npc > 0 && pc[npc-1].t > (t+jitter)) break; if (feof(pfp)) break; if (fgets(b, sizeof b, pfp) == NULL) break; pc = pen_realloc(pc, (npc+1)*sizeof *pc); if (debuglevel) debug("pc = %p, b = '%s'", pc, b); if (sscanf(b, "%s %ld %s %[^\n]", from, &when, to, uri) != 4) { continue; } pc[npc].cli = pen_strdup(from); pc[npc].ser = server2num(to); pc[npc].t = when-tz; pc[npc].uri = pen_strdup(uri); if (debuglevel >= 2) { debug("cache '%s %ld %d %s'", pc[npc].cli, pc[npc].t, pc[npc].ser, pc[npc].uri); } npc++; } /* now search the cache for a best match */ snprintf(p, 1024, "%s", s); td = LONG_MAX; for (i = 0; i < npc; i++) { if (ser != pc[i].ser) continue; if (strcmp(u, pc[i].uri)) continue; ntd = labs(t-pc[i].t); if (ntd < td) { td = ntd; snprintf(p, 1024, "%s", pc[i].cli); } } } /* same again, this time without the cache */ static void best_client0(char *p, char *s, long t, char *u) { char b[1024], from[1024], to[1024], uri[1024]; long when, td, ntd; rewind(pfp); snprintf(p, 1024, "%s", s); /* default is client = server */ td = LONG_MAX; while (fgets(b, sizeof b, pfp)) { if (sscanf(b, "%s %ld %s %[^\n]", from, &when, to, uri) != 4) { continue; } if (strcmp(s, to)) continue; if (strcmp(u, uri)) continue; when -= tz; ntd = labs(t-when); if (ntd < td) { td = ntd; snprintf(p, 1024, "%s", from); } } if (debuglevel && td > 600) { debug("Warning: time difference %ld", td); } } static void best_client(char *p, char *s, long t, char *u) { if (cache_penlog) best_client1(p, s, t, u); else best_client0(p, s, t, u); } int main(int argc, char **argv) { int i, n, s; n = options(argc, argv); argc -= n; argv += n; if (argc < 1) { usage(); } if (pfile == NULL) error("pfile null"); pfp = fopen(pfile, "r"); if (pfp == NULL) error("pfp null"); s = 0; servers = pen_calloc(argc, sizeof *servers); for (i = 0; i < argc; i++) { servers[s].a = pen_strdup(argv[i]); servers[s].fn = strchr(servers[s].a, ':'); if (servers[s].fn == NULL) error("Bogus server '%s'\n", argv[i]); *servers[s].fn++ = '\0'; servers[s].fp = fopen(servers[s].fn, "r"); if (servers[s].fp == NULL) error("Can't open logfile '%s'\n", servers[s].fn); read_server_line(s); nservers++; s++; } /* Example log lines: 10.0.18.6 - - [09/Jan/2002:00:28:50 +0100] "GET /robots.txt HTTP/1.0" 404 268 10.0.18.6 - - [09/Jan/2002:00:28:50 +0100] "GET /news.html HTTP/1.0" 200 4017 That is: client, whatever, whatever, [timestamp], "URI", code, size. */ while ((s = oldest_server()) != -1) { char cli[1024], tim[1024]; thenp(tim, servers[s].t); best_client(cli, servers[s].a, servers[s].t, servers[s].uri); if (debuglevel >= 2) { debug("\tclient = '%s' => '%s'", servers[s].cli, cli); debug("\ttime = '%s' => %d => '%s'", servers[s].cli, cli, servers[s].tim, (int)servers[s].t, tim); debug("\turi = '%s'", servers[s].uri); } printf("%s %s[%s]%s\"%s\"%s\n", cli, servers[s].b1, tim, servers[s].b2, servers[s].uri, servers[s].b3); read_server_line(s); } fclose(pfp); return 0; } pen-0.32.0/penctl.cgi0000755000175000017500000002202612507562420011260 00000000000000#!/bin/sh # Copyright (C) 2002-2015 Ulric Eriksson # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA. PENCTL=penctl #set -x header() { if test -z "$1"; then TITLE=Penctl else TITLE="$1" fi cat << EOF $TITLE

$TITLE

EOF } footer() { cat << EOF EOF } errorpage() { header "Error" echo "$1" footer exit 0 } get_query() { echo "$QUERY_STRING"|tr '&' '\n'|grep "^$1="|cut -f 2 -d =|sed -e 's,%2F,/,g' -e 's,%..,,g' } statuspage() { test -z "$SERVER" && errorpage "No server" test -z "$PORT" && errorpage "No port" $PENCTL $SERVER:$PORT status 2> /path/to/tmp/penctl.cgi if test "$?" != "0"; then errorpage "`cat /path/to/tmp/penctl.cgi`" fi echo "
" echo '' echo '' echo '' echo "
" } # testmode modelist setting testmode() { echo "$1"|egrep "no(\+| )$2" > /dev/null 2>&1 if test "$?" = "0"; then echo "no" else echo "yes" fi } # setmode setting old new setmode() { if test "$2" != "$3"; then if test "$3" = "yes"; then $PENCTL $SERVER:$PORT $1 else $PENCTL $SERVER:$PORT no $1 fi fi } settingspage() { test -z "$SERVER" && errorpage "No server" test -z "$PORT" && errorpage "No port" OLDMODE=`get_query oldmode` if test ! -z "$OLDMODE"; then BLACKLIST=`get_query blacklist` test -z "$BLACKLIST" || $PENCTL $SERVER:$PORT blacklist $BLACKLIST DEBUG=`get_query debug` test -z "$DEBUG" || $PENCTL $SERVER:$PORT debug $DEBUG LOG=`get_query log` test -z "$LOG" || $PENCTL $SERVER:$PORT log $LOG TIMEOUT=`get_query timeout` test -z "$TIMEOUT" || $PENCTL $SERVER:$PORT timeout $TIMEOUT TRACKING=`get_query tracking` test -z "$TRACKING" || $PENCTL $SERVER:$PORT tracking $TRACKING WEB_STATS=`get_query web_stats` test -z "$WEB_STATS" || $PENCTL $SERVER:$PORT web_stats $WEB_STATS x=`testmode "$OLDMODE" block` BLOCK=`get_query block` setmode "block" "$x" "$BLOCK" x=`testmode "$OLDMODE" delayed_forward` DFORWARD=`get_query dforward` setmode "dforward" "$x" "$DFORWARD" x=`testmode "$OLDMODE" hash` HASH=`get_query hash` setmode "hash" "$x" "$HASH" # HTTP=`get_query http` # setmode "$OLDMODE" "$x" "$HTTP" x=`testmode "$OLDMODE" roundrobin` ROUNDROBIN=`get_query roundrobin` setmode "roundrobin" "$x" "$ROUNDROBIN" x=`testmode "$OLDMODE" stubborn` STUBBORN=`get_query stubborn` setmode "stubborn" "$x" "$STUBBORN" fi cat << EOF 1>&2 BLOCK="$BLOCK" DFORWARD="$DFORWARD" HASH="$HASH" ROUNDROBIN="$ROUNDROBIN" STUBBORN="$STUBBORN" EOF header "Global Settings" BLACKLIST=`$PENCTL $SERVER:$PORT blacklist` CLIENTS_MAX=`$PENCTL $SERVER:$PORT clients_max` CONN_MAX=`$PENCTL $SERVER:$PORT conn_max` DEBUG=`$PENCTL $SERVER:$PORT debug` LISTEN=`$PENCTL $SERVER:$PORT listen` LOG=`$PENCTL $SERVER:$PORT log` MODE=`$PENCTL $SERVER:$PORT mode` echo "

MODE=$MODE

" BLOCK=`testmode "$MODE" block` DFORWARD=`testmode "$MODE" delayed_forward` HASH=`testmode "$MODE" hash` ROUNDROBIN=`testmode "$MODE" roundrobin` STUBBORN=`testmode "$MODE" stubborn` PID=`$PENCTL $SERVER:$PORT pid` TIMEOUT=`$PENCTL $SERVER:$PORT timeout` TRACKING=`$PENCTL $SERVER:$PORT tracking` WEB_STATS=`$PENCTL $SERVER:$PORT web_stats` BLOCKCHECKED="" test x$BLOCK = xyes && BLOCKCHECKED=checked DFORWARDCHECKED="" test x$DFORWARD = xyes && DFORWARDCHECKED=checked HASHCHECKED="" test x$HASH = xyes && HASHCHECKED=checked ROUNDROBINCHECKED="" test x$ROUNDROBIN = xyes && ROUNDROBINCHECKED=checked STUBBORNCHECKED="" test x$STUBBORN = xyes && STUBBORNCHECKED=checked cat << EOF
Blacklist time
Max # of clients$CLIENTS_MAX
Max # of connections$CONN_MAX
Debug level
Listening port$LISTEN
Logging destination
Blocking
Delayed forward
Hash
Roundrobin
Stubborn
Process ID$PID
Connect timeout
Client tracking
Web status report
EOF footer } managepage() { test -z "$SERVER" && errorpage "No server" test -z "$PORT" && errorpage "No port" N=0 A=`get_query "A.$N"` while test ! -z "$A"; do P=`get_query "P.$N"` M=`get_query "M.$N"` H=`get_query "H.$N"` T=`get_query "T.$N"` x="" test -z "$A" || x="$x address $A" test -z "$P" || x="$x port $P" test -z "$M" || x="$x max $M" test -z "$H" || x="$x hard $H" test -z "$T" || x="$x blacklist $T" test -z "$x" || $PENCTL $SERVER:$PORT server $N $x # N=`echo $N+1|bc` N=$((N+1)) A=`get_query "A.$N"` done header "Manage Servers" cat << EOF
Server Address Port Conn Max Hard Sx Rx Blacklist EOF $PENCTL $SERVER:$PORT servers | while read N a A p P c C m M h H s S r R; do cat << EOF
$N $C $S $R EOF done cat << EOF
EOF } mainpage() { header cat << EOF
Server
Port
EOF footer } echo Content-type: text/html echo echo "This script has not been updated in many years and is unfit for public consumption" exit SERVER=`get_query server` PORT=`get_query port` MODE=`get_query mode` case "$MODE" in Status ) statuspage ;; Manage ) managepage ;; Settings ) settingspage ;; * ) mainpage ;; esac pen-0.32.0/penlogd.10000644000175000017500000000315512527416603011023 00000000000000.TH PENLOGD 1 LOCAL .SH NAME penlogd - consolidate web server logs .SH SYNOPSIS .B penlogd [-fd] [-j dir] [-l logfile] [-n N] [-p pidfile] [-u user] port .SH EXAMPLE penlogd -l /var/log/access_log -p /var/run/penlogd.pid 10000 .SH DESCRIPTION .I Penlogd receives log entries from Pen and from each of the web servers. It consolidates the entries by replacing the source addresses in each entry with the "real" client address and writes the result to stdout or to the file given on the command line. This completely removes the need for postprocessing with mergelogs, since the logs are already merged. Pen must be instructed to send its log to penlogd. See HOWTO and pen man page for details. Sending penlogd a HUP signal will make it close and reopen the logfile, unless it is logging to stdout. Rotate the log like this: mv access_log access_log.1 kill -HUP `cat ` where is the file containing pen's process id. Sending penlogd a TERM signal will make it close the log file and exit cleanly. .SH OPTIONS .TP -d Turn on debugging. The output goes to stderr if we are running in the foreground (see -f) and to syslog (facility user, priority debug) otherwise. .TP -f Stay in foreground. .TP -j \fIdir\fR Run in a chroot environment. .TP -l \fIlogfile\fR Write output into logfile. .TP -n \fIN\fR Number of pen log entries to cache (default 1000). .TP -p \fIpidfile\fR Write process id into pidfile. .TP -u \fIuser\fR Run as a different user. .TP port The UDP port where penlogd receives log entries. .SH SEE ALSO pen(1), penlog(1), webresolve(1) .SH AUTHOR Copyright (C) 2002-2015 Ulric Eriksson, . pen-0.32.0/ssl.c0000644000175000017500000002664112554727213010265 00000000000000#include "config.h" #ifdef HAVE_LIBSSL #include #include #include #include #include #include #include #include #include "ssl.h" #include "client.h" #include "conn.h" #include "pen.h" #include "diag.h" #include "memory.h" #include "server.h" char ssl_compat; char require_peer_cert; char ssl_protocol; char *certfile; char *keyfile; char *cacert_dir; char *cacert_file; char *ssl_sni_path; SSL_CTX *ssl_context = NULL; long ssl_options; char *ssl_ciphers; int ssl_session_id_context = 1; int ssl_client_renegotiation_interval = 3600; /* one hour, effectively disabled */ unsigned char ocsp_resp_data[OCSP_RESP_MAX]; long ocsp_resp_len = 0; char *ocsp_resp_file = NULL; static int ssl_verify_cb(int ok, X509_STORE_CTX *ctx) { char buffer[256]; X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), buffer, sizeof(buffer)); if (ok) { debug("SSL: Certificate OK: %s", buffer); } else { switch (ctx->error) { case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: debug("SSL: Cert error: CA not known: %s", buffer); break; case X509_V_ERR_CERT_NOT_YET_VALID: debug("SSL: Cert error: Cert not yet valid: %s", buffer); break; case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: debug("SSL: Cert error: illegal \'not before\' field: %s", buffer); break; case X509_V_ERR_CERT_HAS_EXPIRED: debug("SSL: Cert error: Cert expired: %s", buffer); break; case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: debug("SSL: Cert error: invalid \'not after\' field: %s", buffer); break; default: debug("SSL: Cert error: unknown error %d in %s", ctx->error, buffer); break; } } return ok; } static RSA *ssl_temp_rsa_cb(SSL *ssl, int export, int keylength) { static RSA *rsa = NULL; if (rsa == NULL) rsa = RSA_generate_key(512, RSA_F4, NULL, NULL); return rsa; } static void ssl_info_cb(const SSL *ssl, int where, int ret) { int st = SSL_get_state(ssl); const char *state = SSL_state_string_long(ssl); const char *type = SSL_alert_type_string_long(ret); const char *desc = SSL_alert_desc_string_long(ret); connection *conn = SSL_get_app_data(ssl); int renegotiating = 0; DEBUG(3, "ssl_info_cb(ssl=%p, where=%d, ret=%d)", ssl, where, ret); if (where & SSL_CB_LOOP) DEBUG(3, "\tSSL_CB_LOOP"); if (where & SSL_CB_EXIT) DEBUG(3, "\tSSL_CB_EXIT"); if (where & SSL_CB_READ) DEBUG(3, "\tSSL_CB_READ"); if (where & SSL_CB_WRITE) DEBUG(3, "\tSSL_CB_WRITE"); if (where & SSL_CB_ALERT) DEBUG(3, "\tSSL_CB_ALERT"); if (where & SSL_CB_READ_ALERT) DEBUG(3, "\tSSL_CB_READ_ALERT"); if (where & SSL_CB_WRITE_ALERT) DEBUG(3, "\tSSL_CB_WRITE_ALERT"); if (where & SSL_CB_ACCEPT_LOOP) DEBUG(3, "\tSSL_CB_ACCEPT_LOOP"); if (where & SSL_CB_ACCEPT_EXIT) DEBUG(3, "\tSSL_CB_ACCEPT_EXIT"); if (where & SSL_CB_CONNECT_LOOP) DEBUG(3, "\tSSL_CB_CONNECT_LOOP"); if (where & SSL_CB_CONNECT_EXIT) DEBUG(3, "\tSSL_CB_CONNECT_EXIT"); if (where & SSL_CB_HANDSHAKE_START) DEBUG(3, "\tSSL_CB_HANDSHAKE_START"); if (where & SSL_CB_HANDSHAKE_DONE) DEBUG(3, "\tSSL_CB_HANDSHAKE_DONE"); DEBUG(3, "SSL state = %s", state); DEBUG(3, "Alert type = %s", type); DEBUG(3, "Alert description = %s", desc); if (st == SSL3_ST_SR_CLNT_HELLO_A) { DEBUG(3, "\tSSL3_ST_SR_CLNT_HELLO_A"); renegotiating = 1; } else if (st == SSL23_ST_SR_CLNT_HELLO_A) { DEBUG(3, "\tSSL23_ST_SR_CLNT_HELLO_A"); renegotiating = 1; } if (conn == NULL) { debug("Whoops, no conn info"); } else { DEBUG(3, "Connection in state %d from client %d to server %d", conn->state, conn->client, conn->server); if (renegotiating) { int reneg_time = now-conn->reneg; conn->reneg = now; DEBUG(3, "Client asks for renegotiation"); DEBUG(3, "Last time was %d seconds ago", reneg_time); if (reneg_time < ssl_client_renegotiation_interval) { debug("That's more often than we care for"); conn->state = CS_CLOSED; } } } } static struct sni { char *name; SSL_CTX *ssl_context; unsigned char ocsp_resp_data[OCSP_RESP_MAX]; int ocsp_resp_len; time_t ocsp_resp_time; struct sni *next; } *sni_list; static SSL_CTX *ssl_create_context(char *keyfile, char *certfile, char *cacert_dir, char *cacert_file); static struct sni *lookup_sni(const char *name) { struct sni *s; for (s = sni_list; s; s = s->next) if (!strcmp(s->name, name)) break; if (s == NULL) { char keyfile[1024], certfile[1024], cacert_file[1024]; s = pen_malloc(sizeof *s); s->name = pen_strdup(name); s->next = sni_list; sni_list = s; snprintf(keyfile, sizeof keyfile, "%s/%s.key", ssl_sni_path, name); snprintf(certfile, sizeof certfile, "%s/%s.crt", ssl_sni_path, name); snprintf(cacert_file, sizeof cacert_file, "%s/%s.ca", ssl_sni_path, name); s->ocsp_resp_len = 0; s->ocsp_resp_time = 0; /* never */ s->ssl_context = ssl_create_context(keyfile, certfile, NULL, cacert_file); } return s; } static long read_ocsp(const char *fn, unsigned char *data) { int f = open(fn, O_RDONLY); long len = 0; DEBUG(3, "Read ocsp response from '%s'", fn); if (f == -1) { DEBUG(3, "Can't read file"); } else { len = read(f, data, OCSP_RESP_MAX); DEBUG(3, "Read %ld bytes of ocsp response", len); close(f); } if (len < 0) len = 0; return len; } static int ssl_stapling_cb(SSL *ssl, void *p) { connection *conn = SSL_get_app_data(ssl); unsigned char *data, *ocsp_resp_copy; long len = 0; if (conn == NULL) { debug("Whoops, no conn info"); return SSL_TLSEXT_ERR_ALERT_FATAL; } else { DEBUG(3, "ssl_stapling_cb() called for connection from client %d to server %d", conn->client, conn->server); } if (SSL_get_SSL_CTX(ssl) != ssl_context) { const char *n; char ocsp_file[1024]; struct sni *s; DEBUG(3, "stapling for sni context"); n = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name); if (n == NULL) { DEBUG(3, "SNI hostname null, giving up"); return SSL_TLSEXT_ERR_NOACK; } s = lookup_sni(n); if (now-s->ocsp_resp_time > 3600) { /* seems about right */ snprintf(ocsp_file, sizeof ocsp_file, "%s/%s.ocsp", ssl_sni_path, n); s->ocsp_resp_len = read_ocsp(ocsp_file, s->ocsp_resp_data); s->ocsp_resp_time = now; } len = s->ocsp_resp_len; data = s->ocsp_resp_data; } else { DEBUG(3, "stapling for default context"); if (ocsp_resp_file) { ocsp_resp_len = read_ocsp(ocsp_resp_file, ocsp_resp_data); free(ocsp_resp_file); ocsp_resp_file = NULL; } len = ocsp_resp_len; data = ocsp_resp_data; } if (len == 0) { DEBUG(3, "No ocsp data"); return SSL_TLSEXT_ERR_NOACK; } ocsp_resp_copy = pen_malloc(len); memcpy(ocsp_resp_copy, data, len); SSL_set_tlsext_status_ocsp_resp(ssl, ocsp_resp_copy, len); return SSL_TLSEXT_ERR_OK; } static int ssl_sni_cb(SSL *ssl, int *foo, void *arg) { const char *n; struct sni *s; n = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name); if (n == NULL) { DEBUG(3, "SNI hostname null, giving up"); return SSL_TLSEXT_ERR_NOACK; } DEBUG(3, "ssl_sni_cb() => name = '%s'", n); if (ssl_sni_path == NULL) { DEBUG(3, "ssl_sni_path not set, giving up"); return SSL_TLSEXT_ERR_NOACK; } s = lookup_sni(n); if (s->ssl_context == NULL) return SSL_TLSEXT_ERR_NOACK; SSL_set_SSL_CTX(ssl, s->ssl_context); return SSL_TLSEXT_ERR_OK; } static SSL_CTX *ssl_create_context(char *keyfile, char *certfile, char *cacert_dir, char *cacert_file) { int n, err; SSL_CTX *ssl_context; if (certfile == NULL || *certfile == 0) { debug("SSL: No cert file specified in config file!"); debug("The server MUST have a certificate!"); return NULL; } if (keyfile == NULL || *keyfile == 0) keyfile = certfile; if (cacert_dir != NULL && *cacert_dir == 0) cacert_dir = NULL; if (cacert_file != NULL && *cacert_file == 0) cacert_file = NULL; switch (ssl_protocol) { #if 0 case SRV_SSL_V2: ssl_context = SSL_CTX_new(SSLv2_method()); break; #endif #ifndef OPENSSL_NO_SSL3 case SRV_SSL_V3: ssl_context = SSL_CTX_new(SSLv3_method()); break; #endif default: case SRV_SSL_V23: ssl_context = SSL_CTX_new(SSLv23_method()); break; case SRV_SSL_TLS1: ssl_context = SSL_CTX_new(TLSv1_method()); break; } if (ssl_context == NULL) { err = ERR_get_error(); debug("SSL: Error allocating context: %s", ERR_error_string(err, NULL)); return NULL; } DEBUG(1, "ssl_options = 0x%lx", ssl_options); if (ssl_options) { SSL_CTX_set_options(ssl_context, ssl_options); } if (ssl_compat) { SSL_CTX_set_options(ssl_context, SSL_OP_ALL); } DEBUG(1, "ssl_ciphers = '%s'", ssl_ciphers); if (ssl_ciphers) { n = SSL_CTX_set_cipher_list(ssl_context, ssl_ciphers); if (n == 0) { err = ERR_get_error(); DEBUG(3, "SSL_CTX_set_cipher_list(ssl_context, %s) returns %d (%s)", ssl_ciphers, n, err); } } if (!SSL_CTX_use_certificate_file(ssl_context, certfile, SSL_FILETYPE_PEM)) { err = ERR_get_error(); debug("SSL: error reading certificate from file %s: %s", certfile, ERR_error_string(err, NULL)); return NULL; } if (!SSL_CTX_use_PrivateKey_file(ssl_context, keyfile, SSL_FILETYPE_PEM)) { err = ERR_get_error(); debug("SSL: error reading private key from file %s: %s", keyfile, ERR_error_string(err, NULL)); return NULL; } if (!SSL_CTX_check_private_key(ssl_context)) { debug("SSL: Private key does not match public key in cert!"); return NULL; } if (cacert_dir != NULL || cacert_file != NULL) { if (!SSL_CTX_load_verify_locations(ssl_context, cacert_file, cacert_dir)) { err = ERR_get_error(); debug("SSL: Error error setting CA cert locations: %s", ERR_error_string(err, NULL)); cacert_file = cacert_dir = NULL; } } if (cacert_dir == NULL && cacert_file == NULL) { /* no verify locations loaded */ debug("SSL: No verify locations, trying default"); if (!SSL_CTX_set_default_verify_paths(ssl_context)) { err = ERR_get_error(); debug("SSL: Error error setting default CA cert location: %s", ERR_error_string(err, NULL)); debug("continuing anyway..."); } } SSL_CTX_set_tmp_rsa_callback(ssl_context, ssl_temp_rsa_cb); SSL_CTX_set_info_callback(ssl_context, ssl_info_cb); SSL_CTX_set_tlsext_status_cb(ssl_context, ssl_stapling_cb); SSL_CTX_set_tlsext_servername_callback(ssl_context, ssl_sni_cb); if (require_peer_cert) { SSL_CTX_set_verify(ssl_context, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, ssl_verify_cb); } else { SSL_CTX_set_verify(ssl_context, SSL_VERIFY_NONE, ssl_verify_cb); } SSL_CTX_set_client_CA_list(ssl_context, SSL_load_client_CA_file(certfile)); /* permit large writes to be split up in several records */ SSL_CTX_set_mode(ssl_context, SSL_MODE_ENABLE_PARTIAL_WRITE|SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); DEBUG(3, "SSL_CTX_get_session_cache_mode() returns %d", SSL_CTX_get_session_cache_mode(ssl_context)); SSL_CTX_set_session_cache_mode(ssl_context, SSL_SESS_CACHE_SERVER); #if defined(HAVE_EC_KEY) && defined(NID_X9_62_prime256v1) EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); if (ecdh == NULL) { debug("EC_KEY_new_by_curve_name failure"); } else { if (SSL_CTX_set_tmp_ecdh(ssl_context, ecdh) != 1) { debug("SSL_CTX_set_tmp_ecdh failure"); } else { DEBUG(1, "ECDH Initialized with NIST P-256"); } EC_KEY_free(ecdh); } #endif SSL_CTX_set_session_id_context(ssl_context, (void *)&ssl_session_id_context, sizeof ssl_session_id_context); return ssl_context; } int ssl_init(void) { SSL_load_error_strings(); SSLeay_add_ssl_algorithms(); ssl_context = ssl_create_context(keyfile, certfile, cacert_dir, cacert_file); if (ssl_context == NULL) { error("Unable to create default context"); } return 0; } #endif /* HAVE_LIBSSL */ pen-0.32.0/penlog.c0000644000175000017500000000412512516364701010736 00000000000000/* Copyright (C) 2000-2015 Ulric Eriksson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include "diag.h" #define MAXBUF 1024 int main(int argc, char **argv) { int sk; struct addrinfo *client, *server; struct addrinfo hints; char buf[MAXBUF]; int n; if (argc < 3) { error("Usage: %s server_ip server_port [my_ip]", argv[0]); } memset(&hints, 0, sizeof hints); hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_ADDRCONFIG; n = getaddrinfo(argv[1], argv[2], &hints, &server); if (n != 0) { error("getaddrinfo: %s", gai_strerror(n)); } sk = socket(server->ai_family, server->ai_socktype, server->ai_protocol); if (sk == -1) { error("Problem creating socket"); } if (argc > 3) { /* set local address */ memset(&hints, 0, sizeof hints); hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_ADDRCONFIG; n = getaddrinfo(argv[3], NULL, &hints, &client); if (n != 0) { error("getaddrinfo: %s", gai_strerror(n)); } if (bind(sk, client->ai_addr, client->ai_addrlen) != 0) { error("Problem creating socket"); } } while (fgets(buf, sizeof buf, stdin)) { n = sendto(sk, buf, strlen(buf), 0, server->ai_addr, server->ai_addrlen); if (n < 0) { debug("Problem sending data: %s", strerror(errno)); } } return 0; } pen-0.32.0/missing0000755000175000017500000001533012423346767010716 00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pen-0.32.0/settings.c0000644000175000017500000000040712531541655011313 00000000000000#include "config.h" #ifndef WINDOWS #include #else #include #endif int foreground; int abort_on_error = 0; int multi_accept = 100; int tcp_fastclose = 0; int keepalive = 0; int protoid = SOCK_STREAM; int udp = 0; int transparent = 0; pen-0.32.0/kqueue.c0000644000175000017500000000564012521104515010743 00000000000000#include "config.h" #include #include #include #include #include "conn.h" #include "diag.h" #include "event.h" #include "memory.h" #ifdef HAVE_KQUEUE #include #include #include static int kq; static struct kevent *kev, *kev_out; static int nfds, maxevents; static int count; static int pindex; static void kqueue_event_add(int fd, int events) { DEBUG(2, "kqueue_event_add(fd=%d, events=%d)", fd, events); if (events & EVENT_READ) { EV_SET(&kev[nfds], fd, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); } else { EV_SET(&kev[nfds], fd, EVFILT_READ, EV_ADD|EV_DISABLE, 0, 0, 0); } nfds++; if (events & EVENT_WRITE) { EV_SET(&kev[nfds], fd, EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); } else { EV_SET(&kev[nfds], fd, EVFILT_WRITE, EV_ADD|EV_DISABLE, 0, 0, 0); } nfds++; } static void kqueue_event_arm(int fd, int events) { DEBUG(2, "kqueue_event_arm(fd=%d, events=%d)", fd, events); if (events & EVENT_READ) { EV_SET(&kev[nfds], fd, EVFILT_READ, EV_ENABLE, 0, 0, 0); } else { EV_SET(&kev[nfds], fd, EVFILT_READ, EV_DISABLE, 0, 0, 0); } nfds++; if (events & EVENT_WRITE) { EV_SET(&kev[nfds], fd, EVFILT_WRITE, EV_ENABLE, 0, 0, 0); } else { EV_SET(&kev[nfds], fd, EVFILT_WRITE, EV_DISABLE, 0, 0, 0); } nfds++; } /* The only time we call event_delete is when we are about to close the fd, so we can save this operation since the fd will be deleted automatically. */ static void kqueue_event_delete(int fd) { DEBUG(2, "kqueue_event_delete(fd=%d)", fd); ; } static void kqueue_event_wait(void) { struct timespec tv; DEBUG(2, "kqueue_event_wait()"); tv.tv_sec = timeout; tv.tv_nsec = 0; count = kevent(kq, kev, nfds, kev_out, maxevents, &tv); DEBUG(2, "kevent returns %d", count); if (count < 0 && errno != EINTR) { error("Error on kevent: %s", strerror(errno)); } pindex = -1; nfds = 0; } static int kqueue_event_fd(int *revents) { int events = 0; DEBUG(2, "kqueue_event_fd(revents=%p)", revents); pindex++; if (pindex >= count) return -1; DEBUG(3, "\tkev_out[%d] = {filter=%d, ident=%d}", pindex, kev_out[pindex].filter, kev_out[pindex].ident); if (kev_out[pindex].filter == EVFILT_READ) events |= EVENT_READ; if (kev_out[pindex].filter == EVFILT_WRITE) events |= EVENT_WRITE; *revents = events; return kev_out[pindex].ident; } void kqueue_init(void) { kq = kqueue(); if (kq == -1) { error("Error creating kernel queue: %s", strerror(errno)); } maxevents = connections_max*2+2; kev = pen_malloc(maxevents*sizeof *kev); kev_out = pen_malloc(maxevents*sizeof *kev_out); event_add = kqueue_event_add; event_arm = kqueue_event_arm; event_delete = kqueue_event_delete; event_wait = kqueue_event_wait; event_fd = kqueue_event_fd; nfds = 0; } #else void kqueue_init(void) { debug("You don't have kqueue"); exit(EXIT_FAILURE); } #endif pen-0.32.0/penlogd.c0000644000175000017500000001667612516404152011113 00000000000000/* Copyright (C) 2002-2015 Ulric Eriksson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "diag.h" #include "settings.h" #define PEN_MAX 1000 /* make that at least 1000 for prod */ /* This structure is statically allocated, which is wasteful but saves us from frequest memory allocation. */ static struct penlog { struct in_addr addr; char client[100]; char request[100]; } *penlog; static int pen_n = 0; /* next slot in buffer */ static int unbuffer = 0; static char *logfile = NULL; static FILE *logfp; static char *pidfile = NULL; static int loopflag = 1; static int do_restart_log = 0; static int pen_max = PEN_MAX; static char *user = NULL, *jail = NULL; static struct sigaction hupaction, termaction; static void restart_log(int dummy) { do_restart_log = 1; sigaction(SIGHUP, &hupaction, NULL); } static void quit(int dummy) { loopflag = 0; } static void store_web(char *b, int n, struct in_addr addr) { char request[1024]; char *p, *q; int i, m; b[n] = '\0'; if (debuglevel > 1) debug("store_web(%s, %d)", b, n); p = strchr(b, '"'); if (p == NULL) { debug("bogus web line %s", b); return; } p++; q = strchr(p, '"'); if (q == NULL) { debug("bogus line %s", b); return; } memcpy(request, p, q-p); request[q-p] = '\0'; if (q-p < 100) m = q-p; else m = 100; i = pen_n-1; if (i < 0) i = pen_max-1; while (i != pen_n) { if (penlog[i].request[0] && addr.s_addr == penlog[i].addr.s_addr && !strncmp(request, penlog[i].request, m)) { break; } i--; if (i < 0) i = pen_max-1; } if (i == pen_n) { /* no match */ fwrite(b, 1, n, logfp); } else { fputs(penlog[i].client, logfp); p = strchr(b, ' '); if (p == NULL) { if (debuglevel) debug("Ugly"); return; } fwrite(p, 1, n-(p-b), logfp); } } static void store_pen(char *b, int n) { char client[100], server[100], request[100]; #ifdef HAVE_INET_ATON struct in_addr addr; #else struct hostent *hp; #endif b[n] = '\0'; if (sscanf(b, "+ %99[^ ] %99[^ ] %99[^\n]", client, server, request) != 3) { debug("discarding bogus pen line %s", b); return; } if (debuglevel > 1) debug("store_pen(%i: %s, %s, %s)",pen_n, client, server, request); #ifdef HAVE_INET_ATON if (inet_aton(server, &addr) == 0) { debug("bogus address %s", server); return; } penlog[pen_n].addr = addr; #else hp = gethostbyname(server); memcpy(&penlog[pen_n].addr, hp->h_addr, hp->h_length); #endif strncpy(penlog[pen_n].client, client, 100); strncpy(penlog[pen_n].request, request, 100); pen_n++; if (pen_n >= pen_max) pen_n = 0; } static void usage(void) { printf("Usage:\n" " penlogd [options] port\n" "\n" " -d debugging on\n" " -f stay in foreground\n" " -j dir run in chroot\n" " -l file write log to file\n" " -b unbuffer output (Testing Only!)\n" " -n N number of pen log entries to cache [1000]\n" " -p file write pid to file\n" " -u user run as alternative user\n"); exit(0); } static void background(void) { #ifdef HAVE_DAEMON daemon(0, 0); #else int childpid; if ((childpid = fork()) < 0) { error("Can't fork"); } else { if (childpid > 0) exit(0); /* parent */ } setsid(); signal(SIGCHLD, SIG_IGN); #endif } static int options(int argc, char **argv) { int c; while ((c = getopt(argc, argv, "j:l:n:p:u:dfb")) != -1) { switch (c) { case 'd': debuglevel++; break; case 'b': unbuffer = 1; break; case 'f': foreground = 1; break; case 'j': jail = optarg; break; case 'l': logfile = optarg; break; case 'n': pen_max = atoi(optarg); break; case 'p': pidfile = optarg; break; case 'u': user = optarg; break; default: usage(); } } return optind; } int main(int argc, char **argv) { struct passwd *pwd = NULL; struct sockaddr_in a; socklen_t len; int ld, p; char b[1024]; int n = options(argc, argv); argc -= n; argv += n; if (argc < 1 || (p = atoi(argv[0])) == 0) { usage(); exit(0); } penlog = malloc(pen_max * sizeof *penlog); if (!penlog) error("Can't allocate penlog"); if (!foreground) background(); if (user) { if (debuglevel) debug("Run as user %s", user); pwd = getpwnam(user); if (pwd == NULL) error("Can't getpwnam(%s)", user); } if (jail) { if (debuglevel) debug("Run in %s", jail); if (chroot(jail) == -1) error("Can't chroot(%s)", jail); } if (pwd) { if (setuid(pwd->pw_uid) == -1) error("Can't setuid(%d)", (int)pwd->pw_uid); } if (logfile) { if (debuglevel) debug("Logging to %s", logfile); logfp = fopen(logfile, "a"); if (!logfp) error("Can't open logfile %s", logfile); if (unbuffer) setvbuf(logfp, (char *)NULL, _IOLBF, 0); } else { if (debuglevel) debug("Logging to stdout"); logfp = stdout; } if (pidfile) { FILE *pidfp = fopen(pidfile, "w"); if (debuglevel) { debug("Writing pid %d to %s", (int)getpid(), pidfile); } if (!pidfp) error("Can't create pidfile %s", pidfile); fprintf(pidfp, "%d", (int)getpid()); fclose(pidfp); } if ((ld = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { error("Problem creating socket"); } a.sin_family = AF_INET; a.sin_addr.s_addr = htonl(INADDR_ANY); a.sin_port = htons(p); if (bind(ld, (struct sockaddr *) &a, sizeof(a)) < 0) { error("Problem binding"); } len = sizeof a; if (getsockname(ld, (struct sockaddr *) &a, &len) < 0) { error("Error getsockname"); } hupaction.sa_handler = restart_log; sigemptyset(&hupaction.sa_mask); hupaction.sa_flags = 0; sigaction(SIGHUP, &hupaction, NULL); termaction.sa_handler = quit; sigemptyset(&termaction.sa_mask); termaction.sa_flags = 0; sigaction(SIGTERM, &termaction, NULL); loopflag = 1; if (debuglevel) debug("Enter main loop\n"); while (loopflag) { if (do_restart_log) { if (debuglevel) debug("Reopen log file %s", logfile); if (logfp != stdout) { fclose(logfp); logfp = fopen(logfile, "a"); if (!logfp) error("Can't open %s", logfile); if (unbuffer) setvbuf(logfp, (char *)NULL, _IOLBF, 0); } do_restart_log = 0; } n = recvfrom(ld, b, sizeof b, 0, (struct sockaddr *) &a, &len); if (n < 0) { if (errno != EINTR) debug("Error receiving data: %s", strerror(errno)); continue; } b[n] = 0; #if 0 /* what on earth would send us something like that? */ if (strstr(b, "Host:")) { continue; /* do nothing */ #endif if (b[0] == '+') { store_pen(b, n); } else { store_web(b, n, a.sin_addr); } } if (debuglevel) debug("Exit main loop"); if (logfp) fclose(logfp); if (pidfile) unlink(pidfile); return 0; } pen-0.32.0/client.c0000644000175000017500000000464112622544530010731 00000000000000#include "config.h" #include #ifndef WINDOWS #include #endif #include "client.h" #include "conn.h" #include "diag.h" #include "memory.h" #include "netconv.h" #include "pen.h" #include "server.h" client *clients; int clients_max = 0; int client_acl; /* Store client and return index */ int store_client(struct sockaddr_storage *cli) { int i; int empty = -1; /* first empty slot */ int oldest = -1; /* in case we need to recycle */ struct sockaddr_in *si; struct sockaddr_in6 *si6; int family = cli->ss_family; unsigned long ad = 0; void *ad6 = 0; if (family == AF_INET) { si = (struct sockaddr_in *)cli; ad = si->sin_addr.s_addr; } else if (family == AF_INET6) { si6 = (struct sockaddr_in6 *)cli; ad6 = &si6->sin6_addr; } for (i = 0; i < clients_max; i++) { /* look for client with same family and address */ if (family == clients[i].addr.ss_family) { if (family == AF_UNIX) break; if (family == AF_INET) { si = (struct sockaddr_in *)&clients[i].addr; if (ad == si->sin_addr.s_addr) break; } if (family == AF_INET6) { si6 = (struct sockaddr_in6 *)&clients[i].addr; if (!memcmp(ad6, &si6->sin6_addr, sizeof *ad6)) break; } } /* recycle slots of client that haven't been used for some time */ if (tracking_time > 0 && clients[i].last+tracking_time < now) { /* too old, recycle */ clients[i].last = 0; } /* we already have an empty slot but keep looking for known client */ if (empty != -1) continue; /* remember this empty slot in case we need it later */ if (clients[i].last == 0) { empty = i; continue; } /* and if we can't find any reusable slot we'll reuse the oldest one */ if (oldest == -1 || (clients[i].last < clients[oldest].last)) { oldest = i; } } /* reset statistics in case this is a "new" client */ if (i == clients_max) { if (empty != -1) i = empty; else i = oldest; DEBUG(2, "Resetting client stats for slot %d", i); clients[i].connects = 0; clients[i].csx = 0; clients[i].crx = 0; clients[i].server = NO_SERVER; } clients[i].last = now; clients[i].addr = *cli; clients[i].connects++; DEBUG(2, "Client %s has index %d", pen_ntoa(cli), i); return i; } void expand_clienttable(int size) { if (size <= clients_max) return; /* nothing to do */ clients = pen_realloc(clients, size*sizeof *clients); memset(&clients[clients_max], 0, (size-clients_max)*sizeof clients[0]); clients_max = size; } pen-0.32.0/depcomp0000755000175000017500000005601612423346767010702 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pen-0.32.0/README0000644000175000017500000000446712566550425010204 00000000000000 This is pen, a load balancer for udp and tcp based protocols such as dns, http or smtp. It allows several servers to appear as one to the outside and automatically detects servers that are down and distributes clients among the available servers. This gives high availability and scalable performance. The load balancing algorithm keeps track of clients and will try to send them back to the server they visited the last time. The client table has a number of slots (default 2048, settable through command-line arguments). When the table is full, the least recently used one will be thrown out to make room for the new one. This is superior to a simple round-robin algorithm, which sends a client that connects repeatedly to different servers. Doing so breaks applications that maintain state between connections in the server, including most modern web applications. When pen detects that a server is unavailable, it scans for another starting with the server after the most recently used one. That way we get load balancing and "fair" failover for free. Correctly configured, pen can ensure that a server farm is always available, even when individual servers are brought down for maintenance or reconfiguration. The final single point of failure, pen itself, can be eliminated by running pen on several servers, using vrrp to decide which is active. A side-effect of load-balancing web servers is that several logfiles are produced, and by default, Pen operates in a proxy mode that makes all accesses seem to come from the load balancer. The program penlogd solves this problem by merging pen's log file with the ones produced by the web servers. See penlogd(1) and penlog(1) for details. The Direct Server Return and Transparent Reverse Proxy modes make accesses seem to come directly from the client. Multiple logfiles are still created, and Penlogd can still be used to consolidate them automatically. This load balancer is known to work on FreeBSD, Linux, HP-UX and Solaris. Other Unixes should work as well, possibly requiring trivial changes. Success stories or problem reports are welcome. If pen is started with the -w option, statistics are saved in html format when a USR1 signal is received. The cgi script penstats can be used to simplify this; it must be edited to reflect local conditions. I am Ulric Eriksson, ulric@siag.nu. pen-0.32.0/select.c0000644000175000017500000000474712524651724010746 00000000000000#include "config.h" #include #include #include #include #ifdef WINDOWS #include #endif #if defined HAVE_SYS_SELECT_H && !defined WINDOWS /* because windows doesn't have it */ #include #endif //#include "pen.h" #include "conn.h" #include "diag.h" #include "event.h" static fd_set w_read, w_write; static fd_set w_r_copy, w_w_copy; static int w_max; static void select_event_ctl(int fd, int events) { DEBUG(2, "select_event_ctl(fd=%d, events=%d)", fd, events); if (events & EVENT_READ) FD_SET(fd, &w_read); else FD_CLR(fd, &w_read); if (events & EVENT_WRITE) FD_SET(fd, &w_write); else FD_CLR(fd, &w_write); if (events) { if (fd >= w_max) w_max = fd+1; } } static void select_event_add(int fd, int events) { DEBUG(2, "select_event_add(fd=%d, events=%d)", fd, events); select_event_ctl(fd, events); } static void select_event_arm(int fd, int events) { DEBUG(2, "select_event_arm(fd=%d, events=%d)", fd, events); select_event_ctl(fd, events); } static void select_event_delete(int fd) { DEBUG(2, "select_event_delete(fd=%d)", fd); FD_CLR(fd, &w_read); FD_CLR(fd, &w_write); } static int fd; static void select_event_wait(void) { int n, err; struct timeval tv; DEBUG(2, "select_event_wait()"); tv.tv_sec = timeout; tv.tv_usec = 0; memcpy(&w_r_copy, &w_read, sizeof w_read); memcpy(&w_w_copy, &w_write, sizeof w_write); fd = -1; n = select(w_max, &w_r_copy, &w_w_copy, 0, &tv); err = socket_errno; DEBUG(2, "select returns %d, socket_errno=%d", n, err); if (n < 0 && err != EINTR) { error("Error on select: %s", strerror(errno)); } } static int select_event_fd(int *revents) { int events = 0; DEBUG(2, "select_event_fd(revents=%p)", revents); for (fd++; fd < w_max; fd++) { if (FD_ISSET(fd, &w_r_copy)) events |= EVENT_READ; if (FD_ISSET(fd, &w_w_copy)) events |= EVENT_WRITE; if (events) { *revents = events; return fd; } } return -1; } void select_init(void) { DEBUG(2, "select_init()"); if ((connections_max*2+10) > FD_SETSIZE) { error("Number of simultaneous connections to large.\n" "Maximum is %d, or re-build pen with larger FD_SETSIZE", (FD_SETSIZE-10)/2); } FD_ZERO(&w_read); FD_ZERO(&w_write); w_max = 0; event_add = select_event_add; event_arm = select_event_arm; event_delete = select_event_delete; event_wait = select_event_wait; event_fd = select_event_fd; } pen-0.32.0/dsr.c0000644000175000017500000004271112624554430010245 00000000000000#include "config.h" #include #include #include #include "acl.h" #include "pen.h" #include "diag.h" #include "memory.h" #include "server.h" #include "settings.h" int tarpit_acl = -1; #if defined(HAVE_LINUX_IF_PACKET_H) || defined(HAVE_NET_NETMAP_USER_H) #include #include #include #include #include #include #include #include #include #include #include static char *mac2str(unsigned char *b) { static char p[100]; snprintf(p, sizeof p, "%02x:%02x:%02x:%02x:%02x:%02x", b[0], b[1], b[2], b[3], b[4], b[5]); return p; } static char *type2str(int type) { switch (type) { case 0x0800: return "IPv4"; case 0x0806: return "ARP"; case 0x8100: return "802.1Q"; case 0x86DD: return "IPv6"; default: return "Unknown"; } } static char *proto2str(int proto) { switch (proto) { case 0x01: return "ICMP"; case 0x06: return "TCP"; case 0x17: return "UDP"; default: return "Other"; } } static void hexdump(uint8_t *b, int n) { int i; for (i = 0; i < n; i++) { printf("%02x ", b[i]); if ((i % 8) == 7) printf("\n"); } if (i % 8) printf("\n"); } #define MAXBUF 32000 #define MAC_DST(f) (uint8_t *)(f) #define MAC_SRC(f) (uint8_t *)(f+6) #define ETHERTYPE(f) (uint16_t *)(f+12) #define PAYLOAD(f) (f+14) #define ARP_HTYPE(f) (uint16_t *)(PAYLOAD(f)) #define ARP_PTYPE(f) (uint16_t *)(PAYLOAD(f)+2) #define ARP_HLEN(f) (uint8_t *)(PAYLOAD(f)+4) #define ARP_PLEN(f) (uint8_t *)(PAYLOAD(f)+5) #define ARP_OPER(f) (uint16_t *)(PAYLOAD(f)+6) #define ARP_SHA(f) (uint8_t *)(PAYLOAD(f)+8) #define ARP_SPA(f) (struct in_addr *)(PAYLOAD(f)+14) #define ARP_THA(f) (uint8_t *)(PAYLOAD(f)+18) #define ARP_TPA(f) (struct in_addr *)(PAYLOAD(f)+24) #define IPV4_IHL(f) (uint8_t *)(PAYLOAD(f)) #define IPV4_PROTOCOL(f) (uint8_t *)(PAYLOAD(f)+9) #define IPV4_SRC(f) (struct in_addr *)(PAYLOAD(f)+12) #define IPV4_DST(f) (struct in_addr *)(PAYLOAD(f)+16) static int port; static uint8_t *buf; static struct in_addr our_ip_addr; static uint8_t our_hw_addr[6]; /* OS specific features */ #ifdef HAVE_LINUX_IF_PACKET_H #include #include static int dsr_init_os(char *dsr_if) { int fd, n, ifindex; struct ifreq ifr; struct sockaddr_ll sll; fd = socket_nb(AF_PACKET, SOCK_RAW, IPPROTO_RAW); buf = pen_malloc(MAXBUF); memset(&ifr, 0, sizeof ifr); /* display mac */ strncpy(ifr.ifr_name, dsr_if, IFNAMSIZ-1); n = ioctl(fd, SIOCGIFHWADDR, &ifr); if (n == -1) debug("ioctl: %s", strerror(errno)); memcpy(our_hw_addr, ifr.ifr_hwaddr.sa_data, 6); DEBUG(2, "Our hw addr: %s\n", mac2str(our_hw_addr)); /* display interface number */ ioctl(fd, SIOCGIFINDEX, &ifr); ifindex = ifr.ifr_ifindex; DEBUG(2, "Index = %d", ifindex); /* bind to interface */ memset(&sll, 0, sizeof sll); sll.sll_family = AF_PACKET; sll.sll_ifindex = ifindex; sll.sll_protocol = htons(ETH_P_ALL); if (bind(fd, (struct sockaddr *)&sll, sizeof sll) == -1) { error("bind: %s", strerror(errno)); } return fd; } static int send_packet(int fd, const void *b, int len) { int n = sendto(fd, b, len, 0, NULL, 0); if (n == -1) { /* fail */ DEBUG(2, "Can't send %d bytes: %s", len, strerror(errno)); } return n; } static int recv_packet(int fd, void *buf) { int n = recvfrom(fd, buf, MAXBUF, 0, NULL, NULL); DEBUG(2, "Received %d bytes", n); return n; } static int max_pkts(void) { return multi_accept; } #else /* HAVE_NET_NETMAP_USER_H */ #include #include #define NETMAP_WITH_LIBS #include static struct nm_desc *d; static int dsr_init_os(char *dsr_if) { int fd; struct ifaddrs *ifa, *a; struct sockaddr_dl *dl; if (getifaddrs(&ifa)) { error("Can't get list of interfaces: %s", strerror(errno)); } for (a = ifa; a; a = a->ifa_next) { if ((a->ifa_addr->sa_family == AF_LINK) && (strcmp(a->ifa_name, dsr_if) == 0)) { break; } } if (a == NULL) { error("Can't find interface %s", dsr_if); } dl = (struct sockaddr_dl *)a->ifa_addr; memcpy(our_hw_addr, dl->sdl_data+dl->sdl_nlen, 6); DEBUG(2, "Our hw addr: %s\n", mac2str(our_hw_addr)); char ifname[100]; snprintf(ifname, sizeof ifname, "netmap:%s", dsr_if); d = nm_open(ifname, NULL, 0, 0); DEBUG(2, "first_tx_ring = %d, last_tx_ring = %d, first_rx_ring = %d, last_rx_ring = %d", d->first_tx_ring, d->last_tx_ring, d->first_rx_ring, d->last_rx_ring); fd = NETMAP_FD(d); buf = pen_malloc(MAXBUF); return fd; } static int send_packet(int fd, const void *b, int len) { int n = nm_inject(d, b, len); if (n == 0) { /* fail */ DEBUG(2, "Can't send %d bytes", len); return -1; } return n; } static int recv_packet(int fd, void *buf) { int n; struct nm_pkthdr h; uint8_t *b = nm_nextpkt(d, &h); if (b == NULL) return -1; n = h.caplen; DEBUG(2, "Received %d bytes", n); memcpy(buf, b, n); return n; } static int max_pkts(void) { int in, out, m; m = multi_accept; in = nm_ring_space(NETMAP_RXRING(d->nifp, 0)); if (in < m) m = in; out = nm_ring_space(NETMAP_TXRING(d->nifp, 0)); if (out < m) m = out; DEBUG(3, "multi_accept = %d, in = %d, out = %d => m = %d", multi_accept, in, out, m); return m; } #endif /* returns a raw socket or -1 for failure */ int dsr_init(char *dsr_if, char *listenport) { char *dsr_ip, *dsr_port; dsr_ip = strtok(listenport, ":"); dsr_port = strtok(NULL, ":"); if (dsr_port) port = atoi(dsr_port); else port = 0; if (inet_aton(dsr_ip, &our_ip_addr) == 0) { debug("Address %s is not valid", dsr_ip); return -1; } return dsr_init_os(dsr_if); } void send_arp_request(int fd, struct in_addr *a) { debug("MAC_DST(%p) = %p", buf, MAC_DST(buf)); memset(MAC_DST(buf), 0xff, 6); memcpy(MAC_SRC(buf), our_hw_addr, 6); *ETHERTYPE(buf) = htons(0x0806); *ARP_HTYPE(buf) = htons(1); *ARP_PTYPE(buf) = htons(0x0800); *ARP_HLEN(buf) = 6; *ARP_PLEN(buf) = 4; *ARP_OPER(buf) = htons(1); memcpy(ARP_SHA(buf), our_hw_addr, 6); memset(ARP_SPA(buf), 0, 4); memset(ARP_THA(buf), 0, 6); memcpy(ARP_TPA(buf), a, 4); hexdump(buf, 42); DEBUG(2, "Sending arp request"); send_packet(fd, buf, 42); } static void store_hwaddr(struct in_addr *ip, uint8_t *hw) { int server; DEBUG(2, "Storing ARP reply"); DEBUG(2, "Real address %s has hardware address %s", inet_ntoa(*ip), mac2str(hw)); for (server = 0; server < nservers; server++) { struct sockaddr_storage *a = &servers[server].addr; if (a->ss_family == AF_INET) { struct sockaddr_in *si = (struct sockaddr_in *)a; if (memcmp(ip, &(si->sin_addr), 4) == 0) { memcpy(servers[server].hwaddr, hw, 6); } } } } /* returns 1 if this is an arp request for us, 0 otherwise */ static int our_arp(uint16_t arp_htype, uint16_t arp_ptype, uint16_t arp_oper, struct sockaddr_in *dest) { if ((arp_htype != 1) || (arp_ptype != 0x0800) || (arp_oper != 1)) return 0; if (memcmp(&dest->sin_addr.s_addr, &our_ip_addr, 4) == 0) return 1; return match_acl(tarpit_acl, (struct sockaddr_storage *)dest); } static void arp_frame(int fd, int n) { uint16_t arp_htype, arp_ptype, arp_oper; struct sockaddr_in dest; memcpy(&dest.sin_addr.s_addr, ARP_TPA(buf), 4); dest.sin_family = AF_INET; DEBUG(2, "ARP"); arp_htype = ntohs(*ARP_HTYPE(buf)); arp_ptype = ntohs(*ARP_PTYPE(buf)); arp_oper = ntohs(*ARP_OPER(buf)); DEBUG(2, "Hardware type: %d / %s", arp_htype, arp_htype == 1 ? "Ethernet" : "Other"); DEBUG(2, "Protocol type: 0x%x / %s", arp_ptype, arp_ptype == 0x0800 ? "IPv4" : "Other"); DEBUG(2, "Operation: %d / %s", arp_oper, arp_oper == 1 ? "Request" : "Reply"); DEBUG(2, "Sender hardware address: %s", mac2str(ARP_SHA(buf))); DEBUG(2, "Sender protocol address: %s", inet_ntoa(*ARP_SPA(buf))); DEBUG(2, "Target hardware address: %s", mac2str(ARP_THA(buf))); DEBUG(2, "Target protocol address: %s", inet_ntoa(*ARP_TPA(buf))); if (our_arp(arp_htype, arp_ptype, arp_oper, &dest)) { hexdump(buf, n); DEBUG(2, "We should reply to this."); memcpy(MAC_DST(buf), ARP_SHA(buf), 6); memcpy(MAC_SRC(buf), our_hw_addr, 6); *ARP_OPER(buf) = htons(2); memcpy(ARP_THA(buf), ARP_SHA(buf), 6); memcpy(ARP_TPA(buf), ARP_SPA(buf), 4); memcpy(ARP_SHA(buf), our_hw_addr, 6); // memcpy(ARP_SPA(buf), &our_ip_addr, 4); memcpy(ARP_SPA(buf), &dest.sin_addr.s_addr, 4); DEBUG(2, "Sending %d bytes", n); n = send_packet(fd, buf, n); } else if ((arp_htype == 1) && (arp_ptype == 0x0800) && (arp_oper == 2)) { store_hwaddr(ARP_SPA(buf), ARP_SHA(buf)); } } static int real_hw_known(int server) { static uint8_t zero[6] = {0, 0, 0, 0, 0, 0}; return (memcmp(servers[server].hwaddr, zero, 6) != 0); } #define HASH_INDEX_SIZE 256 static uint16_t hash_index[HASH_INDEX_SIZE]; static int rebuild_hash_index(void) { int i, j; int t; /* number of slots to fill */ int *s; /* how many slots should each server occupy */ int ls; /* number of live, available servers */ int tw; /* total weights of all available servers */ int w; DEBUG(3, "rebuild_hash_index()"); s = pen_malloc(nservers*sizeof *s); /* first count how many servers we have */ ls = 0; tw = 0; for (i = 0; i < nservers; i++) { if (server_is_unavailable(i)) { s[i] = -1; } else { if (servers[i].weight > 0) { s[i] = servers[i].weight; } else { s[i] = 1; } tw += s[i]; ls++; } } DEBUG(3, "%d servers with total weight %d", ls, tw); if (tw == 0) { debug("No available servers, can't rebuild"); free(s); return 0; /* without setting ALG_HASH_VALID */ } t = HASH_INDEX_SIZE; for (i = 0; i < nservers; i++) { if (s[i] == -1) continue; w = t*s[i]/tw; t -= w; tw -= s[i]; s[i] = w; DEBUG(3, "Server %d gets %d slots; %d weight and %d slots remaining", i, w, tw, t); } t = HASH_INDEX_SIZE; j = 0; for (i = 0; t; i = (i+3) % HASH_INDEX_SIZE) { while (s[j] <= 0) j++; hash_index[i] = j; s[j]--; t--; } #if 0 for (i = 0; i < HASH_INDEX_SIZE; i++) { printf("%d ", hash_index[i]); } printf("\n"); #endif /* finally claim that the hash index is up to date */ server_alg |= ALG_HASH_VALID; free(s); return 1; } static int hash(struct in_addr *a, uint16_t port) { uint8_t *p = (uint8_t *)&a->s_addr; int h = p[0]^p[1]^p[2]^p[3]; if (server_alg & ALG_ROUNDROBIN) { p = (uint8_t *)&port; h = h^p[0]^p[1]; } return h; } static int select_server(struct in_addr *a, uint16_t port) { int h = hash(a, port); int i; if ((server_alg & ALG_HASH_VALID) == 0) { if (!rebuild_hash_index()) return NO_SERVER; /* failure */ } i = hash_index[h]; DEBUG(3, "select_server returning server %d for hash %d", i, h); return i; } #define TCP_SEGMENT(f, i) (PAYLOAD(f)+i) #define TCP_SRC_PORT(f, i) (uint16_t *)(TCP_SEGMENT(f, i)) #define TCP_DST_PORT(f, i) (uint16_t *)(TCP_SEGMENT(f, i)+2) #define TCP_SEQ_NR(f, i) (uint32_t *)(TCP_SEGMENT(f, i)+4) #define TCP_ACK_NR(f, i) (uint32_t *)(TCP_SEGMENT(f, i)+8) #define TCP_FLAGS(f, i) (uint16_t *)(TCP_SEGMENT(f, i)+12) #define TCP_WINDOW(f, i) (uint16_t *)(TCP_SEGMENT(f, i)+14) #define TCP_CHECKSUM(f, i) (uint16_t *)(TCP_SEGMENT(f, i)+16) #define TCP_URGENT(f, i) (uint16_t *)(TCP_SEGMENT(f, i)+18) #define TCP_OPTIONS(f, i) (uint8_t *)(TCP_SEGMENT(f, i)+20) #define UDP_SEGMENT(f, i) (PAYLOAD(f)+i) #define UDP_SRC_PORT(f, i) (uint16_t *)(UDP_SEGMENT(f, i)) #define UDP_DST_PORT(f, i) (uint16_t *)(UDP_SEGMENT(f, i)+2) struct ptcp_header { uint32_t src, dst; uint8_t zero, protocol; uint16_t length; }; static int ipv4_frame(int fd, int n) { uint8_t ipv4_protocol; uint8_t ipv4_ihl; uint16_t src_port, dst_port; int server; struct sockaddr_in dest; DEBUG(2, "IPv4"); ipv4_ihl = ((*IPV4_IHL(buf)) & 0xf)*4; ipv4_protocol = *IPV4_PROTOCOL(buf); DEBUG(2, "IPv4 header size: %d bytes", ipv4_ihl); DEBUG(2, "Protocol: %d / %s", ipv4_protocol, proto2str(ipv4_protocol)); DEBUG(2, "Sender IPv4 address: %s", inet_ntoa(*IPV4_SRC(buf))); DEBUG(2, "Destination IPv4 address: %s", inet_ntoa(*IPV4_DST(buf))); dest.sin_family = AF_INET; dest.sin_addr = *IPV4_DST(buf); if (udp) { DEBUG(3, "Doing udp"); if ((ipv4_protocol == 17) && (*(uint32_t *)IPV4_DST(buf) == (uint32_t)our_ip_addr.s_addr)) { DEBUG(2, "We should forward this."); src_port = htons(*UDP_SRC_PORT(buf, ipv4_ihl)); dst_port = htons(*UDP_DST_PORT(buf, ipv4_ihl)); server = select_server(IPV4_SRC(buf), src_port); if (server == NO_SERVER) { debug("Dropping frame, nowhere to put it"); return -1; } if (!real_hw_known(server)) { DEBUG(2, "Real hw addr unknown"); return -1; } DEBUG(2, "Source port = %d, destination port = %d", src_port, dst_port); if (port == 0 || dst_port == port) { memcpy(MAC_DST(buf), servers[server].hwaddr, 6); DEBUG(2, "Sending %d bytes", n); n = send_packet(fd, buf, n); } } } else { /* not udp, i.e. tcp */ DEBUG(3, "Doing tcp"); if (ipv4_protocol == 6) { if (match_acl(tarpit_acl, (struct sockaddr_storage *)&dest)) { struct ptcp_header ph; int i; unsigned char src_mac[6]; uint32_t seq_nr; uint16_t flags = ntohs(*TCP_FLAGS(buf, ipv4_ihl)); uint32_t checksum; uint16_t *csp; DEBUG(2, "Tarpitting: flags = 0x%x"); if ((flags & 0x0002) == 0) return 0; /* not SYN */ /* fill in the pseudo header fields */ memcpy(&ph.src, IPV4_DST(buf), 4); memcpy(&ph.dst, IPV4_SRC(buf), 4); ph.zero = 0; /* :P */ ph.protocol = 6; /* tcp */ ph.length = htons(40); /* 5 32-bit words */ DEBUG(2, "We should tarpit this"); /* reverse everything to make the syn+ack frame */ /* reverse mac addresses */ memcpy(src_mac, MAC_SRC(buf), 6); memcpy(MAC_SRC(buf), MAC_DST(buf), 6); memcpy(MAC_DST(buf), src_mac, 6); /* reverse ip addresses */ *IPV4_DST(buf) = *IPV4_SRC(buf); *IPV4_SRC(buf) = dest.sin_addr; /* reverse port numbers */ src_port = ntohs(*TCP_SRC_PORT(buf, ipv4_ihl)); *TCP_SRC_PORT(buf, ipv4_ihl) = *TCP_DST_PORT(buf, ipv4_ihl); *TCP_DST_PORT(buf, ipv4_ihl) = htons(src_port); /* reverse sequence numbers */ seq_nr = ntohl(*TCP_SEQ_NR(buf, ipv4_ihl)); *TCP_SEQ_NR(buf, ipv4_ihl) = htonl(42); /* our random number */ *TCP_ACK_NR(buf, ipv4_ihl) = htonl(seq_nr+1); /* 5 words of tcp header and SYN+ACK */ *TCP_FLAGS(buf, ipv4_ihl) = htons((5 << 12) | 0x0012); *TCP_CHECKSUM(buf, ipv4_ihl) = 0; *TCP_URGENT(buf, ipv4_ihl) = 0; checksum = 0; csp = (uint16_t *)&ph; for (i = 0; i < 6; i++) { checksum += ntohs(csp[i]); } csp = (uint16_t *)TCP_SRC_PORT(buf, ipv4_ihl); for (i = 0; i < 10; i++) { checksum += ntohs(csp[i]); } checksum = (checksum & 0xffff) + (checksum >> 16); checksum ^= 0xffff; *TCP_CHECKSUM(buf, ipv4_ihl) = htons(checksum); DEBUG(2, "Checksum = 0x%x", checksum); /* ignore options */ uint8_t offset = (flags >> 12); DEBUG(2, "Offset = %d => %d bytes of options", offset, 4*(offset-5)); uint8_t *options = TCP_OPTIONS(buf, ipv4_ihl); DEBUG(2, "Options start at %p", options); i = 0; for (i = 0; i < 4*(offset-5); i++) { options[i] = 0; } n = send_packet(fd, buf, n); } else if (*(uint32_t *)IPV4_DST(buf) == (uint32_t)our_ip_addr.s_addr) { DEBUG(2, "We should forward this."); src_port = ntohs(*TCP_SRC_PORT(buf, ipv4_ihl)); dst_port = ntohs(*TCP_DST_PORT(buf, ipv4_ihl)); server = select_server(IPV4_SRC(buf), src_port); if (server == NO_SERVER) { debug("Dropping frame, nowhere to put it"); return -1; } if (!real_hw_known(server)) { DEBUG(2, "Real hw addr unknown"); return -1; } DEBUG(2, "Source port = %d, destination port = %d", src_port, dst_port); if (port == 0 || dst_port == port) { memcpy(MAC_DST(buf), servers[server].hwaddr, 6); DEBUG(2, "Sending %d bytes", n); n = send_packet(fd, buf, n); } } } } return 0; } void dsr_arp(int fd) { int server, since; static time_t last_arp = 0; struct sockaddr_in *si; DEBUG(2, "dsr_arp(%d)", fd); since = now-last_arp; DEBUG(2, "%d seconds since last update", since); if (since) { DEBUG(2, "Going through the server list"); for (server = 0; server < nservers; server++) { DEBUG(2, "Checking server %d", server); if (unused_server_slot(server)) { DEBUG(2, "Server slot %d is unused", server); continue; } if (real_hw_known(server) && since < 60) { DEBUG(2, "Server %d hw address is known", server); continue; } si = (struct sockaddr_in *)&servers[server].addr; send_arp_request(fd, &si->sin_addr); last_arp = now; } } } void dsr_frame(int fd) { int i, type, n, limit; static int dirty_bytes = 0; if (dirty_bytes) { DEBUG(1, "Retrying transmission of %d bytes", dirty_bytes); n = send_packet(fd, buf, dirty_bytes); if (n == -1) { DEBUG(2, "Failed again, discarding packet"); } } limit = max_pkts(); for (i = 0; i < limit; i++) { dirty_bytes = recv_packet(fd, buf); if (dirty_bytes == -1) { dirty_bytes = 0; break; } DEBUG(2, "MAC destination: %s", mac2str(MAC_DST(buf))); DEBUG(2, "MAC source: %s", mac2str(MAC_SRC(buf))); type = ntohs(*ETHERTYPE(buf)); DEBUG(2, "EtherType: %s", type2str(type)); switch (type) { case 0x0806: arp_frame(fd, dirty_bytes); break; case 0x0800: if (ipv4_frame(fd, dirty_bytes) == -1) { DEBUG(2, "Couldn't process frame, retry later"); goto End; } break; default: DEBUG(2, "Other (%x)", type); } dirty_bytes = 0; } End: DEBUG(2, "Processed %d frames, %d bytes remaining", i, dirty_bytes); } #else int dsr_init(char *dsr_if, char *dsr_ip) { error("Direct server return is not available"); return -1; } void dsr_arp(int fd) { error("Direct server return is not available"); } void dsr_frame(int fd) { error("Direct server return is not available"); } #endif pen-0.32.0/idlers.c0000644000175000017500000000143312531071327010727 00000000000000#include "config.h" #include "conn.h" #include "diag.h" #include "idlers.h" #include "server.h" int idlers = 0, idlers_wanted = 0; void close_idlers(int n) { int conn; DEBUG(2, "close_idlers(%d)", n); for (conn = 0; n > 0 && conn < connections_max; conn++) { if (idler(conn)) { DEBUG(3, "Closing idling connection %d", conn); close_conn(conn); n--; } } } int add_idler(void) { #ifdef HAVE_LIBSSL int conn = store_conn(-1, NULL, -1); #else int conn = store_conn(-1, -1); #endif if (conn == -1) return 0; conns[conn].initial = server_by_roundrobin(); if (conns[conn].initial == NO_SERVER) { close_conn(conn); return 0; } if (!try_server(conns[conn].initial, conn)) { if (!failover_server(conn)) { close_conn(conn); return 0; } } idlers++; return 1; } pen-0.32.0/ChangeLog0000644000175000017500000006125012624554761011071 00000000000000 151123 Released 0.32.0. 151120 Added tarpit test case to testsuite.sh. 151117 Tarpit functionality to be used with the DSR mode. 151112 pen.1: removed obsolete -S option, updated defaults for -x and -L. 151105 Released 0.31.1. 151103 In failover_server: sanity checks to failover routine. 151102 In add_client: add the initial server to .client as well as .initial. 151029 In failover_server: changed abuse_server to ABUSE_SERVER and emerg_server to EMERG_SERVER, to handle their default NO_SERVER values. See issue #19 on Github. 151012 At the suggestion from Marcos Vinicius Rogowski, the hash algorith will now include the client port number if the -r (roundrobin) option is used. See https://github.com/UlricE/pen/pull/18 Released 0.31.0. 150915 Officially released 0.30.1. 150909 Fixed IP-based client tracking. 150828 Removed unnecessary #include in dlist.c 150818 Released 0.30.0. 150803 Added UDP mode for Direct Server Return. 150803 Updated configure.ac for compatibility with CentOS 6. 150725 Added #ifdef around SSLv3 initialization code in ssl, as suggested by jca@openbsd.org. 150608 Released 0.29.0. 150528 Transparent reverse proxy support for Linux, FreeBSD and OpenBSD. 150527 Allow the client table size to be updated on the fly. Default size still 2048. Allow the connection table size to be updated in the fly. Default still 500. See penctl.1, options clients_max and conn_max. 150526 Introduced the macro NO_SERVER to be used instead of -1 to signify error conditions and such. Removed the fixed server table size along with the -S option. 150525 Fixed cosmetic bug in startup code which required port to be specified on backend servers even if it was the same as the listening port. 150520 Released 0.28.0. 150513 Numerous updates to support the madness that is Windows. 150501 Fix from Vincent Bernat: segfault when not using SSL. 150427 DSR support using Netmap on FreeBSD. Unbroke DSR on Linux. 150424 Replaced all calls to perror with debug(..., strerror(errno); Updated penlog and penlogd to use diag.[ch]. 150422 More refactoring: broke out conn.[ch], client.[ch], server.[ch], idler.[ch]. Made a hash index such that the load balancer may balance load. 150420 Broke out Windows code from pen.c into windows.c. Added windows.h. 150419 Broke out public definitions for dsr into dsr.h. Broke out memory management into memory.[ch]. Broke out dignostic and logging functions into diag.[ch]. Broke out settings into settings.[ch]. Broke out access lists into acl.[ch]. Broke out event initialization into event.[ch]. Added pen_epoll.h, pen_kqueue.h, pen_poll.h, pen_select.h. Broke out pen_aton et al into netconv.[ch]. 150416 Added dsr.c 150408 Bug in copy_down affecting SSL connections fixed. Released 0.27.5. 150408 Updated ocsp stapling to be compatible with server name indication. Added pen-ocsp.sh script. Released 0.27.4. 150407 SSL code broken out into ssl.[ch]. SSL context creation broken out from ssl_init to ssl_create_context. Server Name Indication support. New command to enable: ssl_sni_path PATH where PATH is the name of a directory containing domain.key, domain.crt and domain.ca files for each domain. 150406 OCSP stapling. New command ssl_ocsp_response filename specifies the location of the ocsp response to be stapled. The response must be pre-fetched. The idea was borrowed from Rob Stradling. 150403 New command ssl_client_renegotiation_interval specifies the minimum number of seconds the client must wait between renegotiation requests. Default 3600. 150402 Enabled SSL session resumption. In do_cmd: don't print "ignoring command" for comments starting with '#'. 150330 Added ssl_option no_tlsv1.1 and ssl_option no_tlsv1.2 to disable SSL 1.1 and 1.2 respectively. 150330 Released 0.27.3. 150330 Added autoconf check that the ECDHE is available and not disabled. Bumped default max connections and listen queue to 500. 150326 Support for ECDHE cipher suites. 150325 New commands ssl_option and ssl_ciphers to individually disable insecure protocols and ciphers. 150324 Updated penctl.1 with the new command. 150322 New knob to tweak max number of pending nonblocking connection attempts: pending_max N (default 100). 150305 Released 0.27.2. 150228 Moved dlist prototypes to dlist.h. 150227 Added check to close idle connections after a period of inactivity. Penctl: idle_timeout N (default 0 = never close idle connections). 150225 Moved git repository to GitHub.. 150225 New feature: dummy server. Rather than acting as a proxy, Pen will pretend to be a web server with just barely enough functionality to work as a test target. Penctl: dummy|no dummy. 150224 Yet Another command: abort_on_error|no abort_on_error makes Pen call abort() (or not) when encountering a fatal error. 150224 New feature: "reliable idling". Pen will make and maintain a number of idle connections to the backend servers. When a connection closes, a new one is made (hence "reliable"). Penctl: idlers [N]. 150223 In do_cmd: return diagnostics to penctl so the user can see them, instead of uselessly sending them to syslog. 150223 New penctl commands: socket N (print which connection the socket belongs to) connection N (print info on the specified connection) close N (forcibly close connection N) 150219 In open_listener: check that the requested port is in range. Fixed bug in dlist_insert. Released 0.27.1. 150215 Even load distribution when a server is unavailable. 150212 Let pen save the settings for tcp_nodelay and tcp_fastclose. Make flush_up and flush_down return the correct value on error. 150212 Added config.h.win with reasonable settings for Windows. Released 0.27.0. 150211 Better detection and blacklisting of unavailable servers. 150209 New penctl commands: tcp_nodelay sets TCP_NODELAY on sockets. Turn off with no tcp_nodelay. tcp_fastclose closes both upstream and downstream sockets if one of them closes theirs. Will take the values up, down, both or off (default). 150208 Rather than making a table of pending connections every time through the main loop, keep them in a doubly linked list which is only updated as needed. O(n) -> O(1). 150207 A bug in udp mode: after successful "connect", do not event_add downfd, because it is equal to listenfd and epoll_ctl doesn't like that. 150206 Module kqueue.c updated. Module poll.c: set unused fd:s to -1, or Solaris will say ENOSYS. 150205 Enable diagnostic messages by default in configure.ac. Changed event bookkeeping from stateless to stateful. Made keepalive optional and added "keepalive / no keepalive" penctl command. 150204 Added windows.c and pen.h to the release tarball. Released 0.26.1. 150204 Released 0.26.0. 150203 More sensible autoconfiguration defaults: poll, kqueue, epoll, openssl and geoip are built if found unless explicitly excluded. New event management defaults: kqueue, epoll, poll, select in that order. New penctl commands: kqueue, epoll, poll, select. New command line option: -O cmd where cmd is any penctl command. E.g. -O select to use select instead of the compiled-in default. 150127 New penctl option "listen [address:]port" to allow listening address to be changed on the fly or via a configuration file. New pen options -i and -u to install and uninstall Pen as a Windows service. See pen manpage. Reduced default timeout to 3 seconds. 150126 New autoconf option --enable-debugging to enable debugging code. Lots of fixes for compatibility with Windows. Released 0.26.0beta2. 150123 Fixed bug in mainloop which kept trying to write 0 bytes. MinGW port. Use Makefile.win to compile. 150121 Event management code broken out into select.c, poll.c, kqueue.c and epoll.c. 150113 New command-line option -m to accept multiple incoming connections in a batch. New command-line option -q to set incoming pending connection queue length. 150112 Close upfd when failing over. 150109 Released 0.26.0beta1. Adjusted debug logging levels. 150108 Started on epoll support for Linux. 150107 Rewrote output_net and output_file to take a variable number of arguments. Handle timed out connection attempts in mainloop_kqueue. 150105 Fixed mainloop_kqueue. 150103 A lot of code broken out from mainloop_select into separate functions. Fixed mainloop_poll. 150102 Bugfixes related to the new backend connection logic. 141229 Cleaned up and simplified add_client() and associated circuitry. Connections to back end servers are now nonblocking and parallel. 141217 Removed the -n option and all code explicitly using blocking sockets. Removed the -D option and the "delayed forward" feature. 141213 Renamed server and client fields in the conn, client and server structures to better reflect what they are. Restructured the add_client, store_client, store_conn and try_server functions. 140814 Allow write_cfg to save IPv6 and GeoIP access lists. Released 0.25.1. 140804 Fixed a bug in write_cfg, where Pen would try to write to an unwritable file. Reported by Steven Myint 140804 Released 0.25.0. 140701 Return UDP replies from the server to the client. 140621 UDP load balancing code restructured and bugfixed. Released 0.24.0. 140616 Released 0.23.0. 140417 In mainloop_select: When there is a pending connection, keep accepting up to multi_accept times *or* until EAGAIN *or* connection table is full. This improves performance under load. 140414 Updated GeoIP support for IPv6. 140410 Servers can have ipv6 addresses. It is possible to use a mix of ipv4 and ipv6 servers: ./pen -df -S 2 -r :::2222 [::1]:22 [127.0.0.1]:22 140409 In order to allow server addresses with : in them (i.e. ipv6), it is now possible to use square brackets around the address part of the server specification: [address]:port (e.g. [::1]:8080). 140408 Pen can now listen on ipv6 sockets in addition to ipv4 and unix ones. I.e. things like "pen ::1:2222 127.0.0.1:22" are now possible. 140402 snprintf format errors reported by Christopher Meng fixed in pen.c and penctl.c. Released 0.22.1. 140331 Updated pen manpage to clarify what the control socket does. Resist opening control socket running as root. Remove the default file name for web log. New feature: unix domain listening sockets. Released 0.22.0. 140221 Redesigned server and client structs to allow ipv6 addresses and require less casting (yuck) in the code. 140205 Updated penctl man page with syntax for IPv6 and GeoIP access lists. Fixed cosmetic signedness compiler warnings. 140204 Moved defines for ACE_IPV4 et al outside #ifdef HAVE_SSL clause. Otherwise pen won't compile without ssl. Released 0.21.1. 140204 GeoIP access lists. Released 0.21.0. 140120 Added "special exception" clause for linking with OpenSSL. Released 0.20.2. 131127 Penlog ipv6 compatible. 131126 Modernized automake configuration. Penctl ipv6 compatible. 131123 Updated autoconf to 2.69. Released 0.20.1. 131122 Updated SSL code. Protocol ssl2 removed. Default changed to tls1. Released 0.20.0. 131120 Added UDP patch from Zen. Released 0.19.0. 080517 Added patch from Debian that fixes some issues with penctl.cgi. Released 0.18.0. 080503 Priority based server selection algorithm. 080501 Patch from Stephen P. Schaefer fixes several issues in write_cfg. In the server_by_weight function, multiply current connections by WEIGHT_FACTOR to make the selection mo fine grained when the number of connections is small. Released 0.17.3. 080326 Patch from Dana Contreras: send stdio to /dev/null after forking. Fixed a bunch of cosmetic signedness compiler warnings. 070912 Added sanity check to init() to make sure that servers_max is large enough for the number of servers specified on the command line. Released 0.17.2. 070829 Faster string duplication courtesy of Nigel Horne. 070502 Updated automake links. 070212 Updated INSTALL with instructions for increasing the number of connections on Windows. 061204 Include server weight in response to "penctl servers" command. Set server weight on command line. Server is specified as host:port:maxconn:hard:weight. 060627 Bugfix by Chris Elsworth: server_by_weight would never consider blacklisted servers, which kept them blacklisted indefinitely. Released 0.17.1. 051230 Added code by Chris Elsworth for kqueue support. Configure with --with-kqueue to enable. Released 0.17.0. 051215 Changed the configure option for ssl to --with-experimental-only-ssl. Released 0.16.0. 040709 Added an "abuse server" for naughty clients that have been denied access by an acl. Works similar to the emergency server, use command-line option "-B host:port" to enable. 040706 Servers can be assigned different weights to account for differing capacity. New -W command-line option. New penctl commands: server S weight W (assign weight to server) weight (use weight for server selection) no weight (do not use weight for server selection) Cleaned up the logic in add_client so the weighted server selection can be used without client tracking. Released 0.15.0. 040624 Some performance enhancing changes: New variable connections_used remembers the number of used slots in conns[]. It is incremented by store_conn and decremented by close_conn. This allows the main loop to only accept new connections if there are empty slots in conns[], which is much better than accepting the connection only to immediately close it because we can't handle it. New variable connections_last remembers the last used slot in conns[]. This allows us to scan for empty slots much faster in store_conn when there are many simultaneous connections. Released 0.14.0. 040622 Documented the procedure to change FD_SETSIZE on Linux in INSTALL. 040604 Documented the include command in the penctl manpage. 040527 Fixed SSL so it works in nonblocking mode, except that it doesn't work anyway. Moved listenfd and ctrlfd out of main. 040428 Highly experimental SSL code in pen.c. Updated manpage with the new options. Added https example to HOWTO. Released 0.13.0. 040403 Replaced signal with sigaction so connect() to nonexisting servers can be interrupted and not restarted. Released 0.12.3. 040318 Bugfix by Andreas Wrede: Running pen with -H to generate X-Forwarded-For headers causes POST request data sections to be dropped, if they are in the same packet as the POST header (rather than a continuation packet) and the if the POST data contains binary zeros. This is almost always the case with Internet Explorer 6. Mozilla and friends send the data of a POST request in a separate packet, so the problem does not show up there. 040310 Changed setlinebuf to setvbuf in penlogd.c Released 0.12.2. 040201 Bugfix: rewrite_request would only add the X-Forwarded-For header for the first request. Released 0.12.1. 040104 Removed the reference to mergelogs from the README and added one to penlogd instead. 031023 Released 0.12.0. 031022 Penlogd: sscanf would read 100 bytes + terminating nul into a buffer of size 100. Now reads 99+nul. Spotted by Oezguer Kesim. 031021 Let tracking time be set through penctl.cgi. In do_cmd, "no log": only close the logfile if it is open. New penctl command, "write [FILE]" writes current configuration to a file. If FILE is omitted, overwrite the original configuration file (-F option). 031017 Pen: Time based expiration of tracked clients. Default is 0 seconds = never expire. Added -T option to control expiry time. Also added penctl command "tracking N". Penlogd: zero-terminate results from recvfrom. 031013 In penlogd.c: don't complain if recvfrom is interrupted by signal. 031013 Released 0.11.1. 031011 Use sigaction rather than signal in penlogd. Check for inet_aton in libresolv (needed for Solaris). Install documentation into ${prefix}/doc/pen (can be changed using the --with-doc= configuration option). Added tgz target to Makefile.am for Slackware packaging. 030922 Added an "include" keyword to the command interface, so the configuration can be split into several files. Added access control lists, numbered 0 to 9. The command syntax to define them are: acl N permit|deny ipaddress mask create acl no acl N delete acl client_acl N bind clients to acl control_acl N bind control interface to acl server S acl N who can use server S All access lists start out empty, defaulting to permit anything. 030910 In rewrite_request: don't add an X-Forwarded-For: if there already is one. 030906 Added a configuration file (-F option) with commands in penctl format. It is read after processing all command line arguments and also when a HUP signal is received. 030905 Updated pen manpage to reflect the new -X and -S options. In rewrite_request: look for \n\n if we can't find \r\n\r\n. Some clients do that, according to Steve Hall . Moved everything from CONTROL into penctl.1. Also added the exit command to penctl.1. 030905 Released 0.10.3. 030904 Preallocate slots for servers that can be dynamically added and removed using the control interface, up to a maximum number determined by the -S option (default 16). 030821 A patch from Anders Nordby sets the group as well as user id when running pen with the -u option. 030821 Released 0.10.2. 030820 A patch from Mikko Ruuska (mikko.ruuskaxi at solidtech.com) adds an exit command to pen's control port interface. 030820 Patch for pen.c by Andreas Wrede , fixing the following bugs: The message indicating a failed server is re-issued on every attempt, due to a inverted if-test. The attached patch issues the messages only the first time a server fails and it shows when we will retry the connection. It also suppresses multiple "Using emergency server" messages. 030820 #include in penlog.c. 030820 Patch for penlogd.c by Branson Matheson : - pen sends two lines for every log.. penlogd only needs one to function. - added a -b ... unbuffer to the opts for penlogd so that you can actually see the lines as they come out. - changed one of the dubugs to so post processing of the input data. 030407 Bugs uncovered by Charlie Reitsma : HOWTO incorrectly specified penctl in place of penlog in Apache configuration example, and using penctl to redirect log to penlogd didn't work. Avoid bogus header rewriting in rewrite_request. Released 0.10.1. 030210 New penctl commands "http" and "no http" to toggle -H. 030208 New option -H adds X-Forwarded-For header to http requests. 020717 Patches from Patroklos G. Argyroudis : - check getopt() calls against -1 and not EOF - fix for a possible format string in pen.c 020711 Ported to Darwin/MacOS X. Released 0.9.4. 020705 New penctl command: recent [seconds] displays clients that have connected recently (default five minutes), along with number of connects, transmitted and received data. 020702 Buffer overflow in netlog. See comment in pen.c. Added options -j (for chroot) and -u (for setuid) to pen and penlogd. See manpages. 020627 Fixed an error which could throw penlogd into an endless loop if a udp packet was lost at the crucial moment. 020626 Pedantic checking of memory allocations and buffer sizes. 020618 Penlogd: added option -n to adjust the number of cached log entries from Pen. 020614 Added options -d, -f, -l and -p to penlogd. They do the same as in pen. Also added signal handlers for TERM and HUP; these too do the same as in pen. Updated penlogd manpage. Updated www section in HOWTO to use penlog rather than mergelogs. 020613 Added penlog.c to log over a network using Apaches reliable piped logs. A companion log server, penlogd.c, consolidates logs from Pen and from all web servers into a single file. Added the necessary code to Pen log over the network. 020610 Wrote penctl.cgi, a web wrapper for penctl. 020609 Wrote a new version of the main loop, using poll() instead of select(). Added configuration option --with-poll to enable. Also turned redefinition of FD_SETSIZE into a configuration option --with-fd_setsize=N. Updated installation instructions in INSTALL. 020605 Added optional hard limit to the number of connections to each server. Timestamps in debug log entries. Released 0.8.0. 020604 Added "server of last resort" (-e option) which is only used when all other servers are unavailable. (Andreas Wrede) 020528 Several enhancements and bugfixes by Andreas Wrede: In webstats: changed CLIENTS_MAX to clients_max and CONNECTIONS_MAX to connections_max. Show time in human-readable format rather than seconds since 1970. Changed byte counters from unsigned long to unsigned long long. Fixed file descriptor leak: The connection wasn't closed when the connection table was full. Moved stats generation and log restart out of the signal handlers and into the main loop. If a client went away before receiving all its data (large files), the remaining portion would be sent to the next client occupying the same slot. Added pointers in connection structure to avoid having to memcpy the buffers in flush_up/flush_down. Released 0.7.0. 020507 Updated the penctl manpage to reflect reality. Released 0.6.3. 020417 Added -D switch to make copy_up and copy_down *always* store data in a temporary buffer and wait for the next round through the main loop before passing it on to the receiving end. The penctl command for this is "delayed_forward". When making sockets nonblocking (through fcntl(..., O_NONBLOCK)), make sure that any existing flags are not reset in the process. Important bugfix: each failed connection attempt in try_server would result in one socket leaked because we returned without closing it. 020413 Figured out why nonblocking mode was slower than blocking. Fixed. 020411 Added penctl, a simple user interface to the control protocol. 020324 Cancel timeout if it isn't needed. 020115 Added LDAP info in the HOWTO. Added the flush_up/flush_down bugfix from 0.5.0 again. Released 0.6.1. 020111 Moved #include before #include Replaced the call to setpgrp with setsid. Transformed mergelogs into ultimately portable ANSI C (almost). Thanks to Mike Dugas for help with porting to FreeBSD 4.4-RELEASE. 020110 Rewrote mergelogs completely. It will now never discard a web server log entry, and it tries much harder to locate a good match in the pen log. It deals with log entries that are out of order and servers with unsynchronized clocks and/or different time zones. The -l (lag) option is no more. Removed the -r (rejects) option, since we no longer reject anything. Released 0.6.0 010915 Made the use of daemon() optional. Added the cgi script penstats to update and display statistics. Set current in store_conn. Released 0.5.0. 010914 Statistics in HTML format (Riccard Åkerman). Tested pen on HP-UX 10.20. 010913 Released 0.4.0. 010912 When storing part of the buffer for a renewed attempt, store the *end*, not the beginning. Affects copy_up and copy_down. Autoconf. Use daemon() if available. Make sure that we don't try to close uninitialized file handles in add_client. New option -n to not make sockets nonblocking (mainly useful for debugging). 010911 Make sure that remaining data is stored away when we get EAGAIN in copy_up. Released 0.3.3. 010909 Added -p argument to store process id in a file (Andreas Wrede). Made the sockets nonblocking. Handle EAGAIN in copy_up/down. Released 0.3.2. 010908 Ignore SIGPIPE. Released 0.3.1. 010827 Option -h uses a hash on the client IP address for the initial server selection. Option -s ("stubborn") prevents failover to another server if the initial choice is unavailable. 010824 Use getport for the local port as well. 010820 Append to the logfile rather than overwriting it. Released 0.2.0. 010817 Server selection algorithm rewritten in a cleaner, simpler way. Blacklist nonresponding servers for a selectable period of time. Optional "plain" roundrobin without client tracking. (options -b and -r, see manpage). Log to syslog if we are running in the background. 010814 Installed pen on siag.nu, which now load-balances itself. Apache runs on port 8080, pen on 80. Seems to work (tm). 010813 Added description of options to pen.1 and mergelogs.1. Script to guess libraries. 010812 Fixed typo (webmerge -> mergelogs) in pen.1. 010809 Added mergelogs, a program to match pen logs against web server logs and merge the results into one log file with the correct client addresses. Released 0.1.0. 010808 Print statistics on stderr when sent USR1 signal. Ported to Solaris, i.e. verified that it works ;-). Logging. Reopen log file when sent HUP signal. Exit cleanly when sent TERM signal. 010807 Wrote a manpage. 010803 Completed the conversion to non-forking, selecting mode. Works really well now, with very low CPU utilization even with many simultaneous connections. 010729 Rewrote the program to not fork. 010722 Prettied up the source. 001218 Updated the README. 001022 Rewrote the load balancing algorithm. pen-0.32.0/memory.h0000644000175000017500000000023312514656632010770 00000000000000extern void *pen_malloc(size_t); extern void *pen_calloc(size_t, size_t); extern void *pen_realloc(void *, size_t); extern char *pen_strdup(const char *); pen-0.32.0/pen.h0000644000175000017500000000057012524651724010244 00000000000000#include #ifdef WINDOWS #include #include #include extern void stop_winsock(); #else #include #endif //#ifdef HAVE_LIBSSL //#include //#include //#endif /* HAVE_LIBSSL */ extern int socket_nb(int, int, int); extern int listenfd; extern time_t now; extern void mainloop(void); pen-0.32.0/NEWS0000644000175000017500000000000012507562420007767 00000000000000pen-0.32.0/settings.h0000644000175000017500000000026712531541665011325 00000000000000extern int foreground; extern int abort_on_error; extern int multi_accept; extern int tcp_fastclose; extern int keepalive; extern int protoid; extern int udp; extern int transparent; pen-0.32.0/event.h0000644000175000017500000000057012514670554010604 00000000000000#define EVENT_READ (0x10000) #define EVENT_WRITE (0x20000) #define TIMEOUT 3 /* default timeout for non reachable hosts */ extern int timeout; extern void (*event_init)(void); extern void (*event_add)(int, int); extern void (*event_arm)(int, int); extern void (*event_delete)(int); extern void (*event_wait)(void); extern int (*event_fd)(int *); pen-0.32.0/siag.pem0000644000175000017500000000343312507562420010733 00000000000000-----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQDKcE9kAiLqzJWQAImFRhC1e6wvfTtd1Gcy+eoP+Ngnqroijeon lV2vsNENsr+AMksRREeRFk4WP14MUZAB2p2iEy5J8jU31iUvFHswvWY6IEThwESP bt+3h2buJ6475UgQ3Ww2lJ6jTewBOEEZ/sRuqEmLy33bQEMOwFlSJcFsXwIDAQAB AoGBALxYDaUwT6hAu44E0e3LKFSRQbvVOdysd294EQrXLNSLBS6M9qPpVgbV7Upf Wcg+ApWH/0W/iNsuDaRMZj0zVqAClE9W9mcbIIKxAExj5kBiUSiVJjKiM/N6V/TH a9rqPpUsHkJ2YhN7VWgW8Fkd9l0Poe4eQaQfEYzv/reAHjLxAkEA6bBIB+OztkMv YgKRILwOxIaNUjeo8rYPc5hzQlfHAClr27eTJmKI5vFhjkiFsgZ97kjpBAhCUxv+ tq459txLhQJBAN3EO2vRgNOUp5SzGDE/UOp2D66jEtYeGF6Xwqao4WAuH2peVNTv vb5c8mPUL7XmaOEroTD6M5i2qPunuJI5g5MCQQCpVJLdJKGT8Brlafa/QYVx4g2F Bc/mDwYjPNRHvlL0Sw9cpih6J+wLa9zEvMgjt5CImUw/H7zve9mVhal6tyYBAkEA k0IAqyGcx+JIPSeHgvwmQOpQk4hZs7CcQgPID17I+VLnLXyiHBtuBYA2vC9j1we+ 0PZlvN4HcPqpzyGaIA7s3QJBAIBxJTwBYg/fzNYqeSIuIlVxN+Ao/Qgses7UJvIn qf7PhVAWrpuX1mo2Pi7QH6+F0Cmj8BEIrfIPe+kqnIBOHFQ= -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIICfzCCAeigAwIBAgIBADANBgkqhkiG9w0BAQQFADA6MQswCQYDVQQGEwJTVjEZ MBcGA1UEChMQU2lhZyBPZmZpY2UsIEluYzEQMA4GA1UEAxMHc2lhZy5udTAeFw0w MzAzMTgwODQ4MTRaFw0zMDA4MDMwODQ4MTRaMDoxCzAJBgNVBAYTAlNWMRkwFwYD VQQKExBTaWFnIE9mZmljZSwgSW5jMRAwDgYDVQQDEwdzaWFnLm51MIGfMA0GCSqG SIb3DQEBAQUAA4GNADCBiQKBgQDKcE9kAiLqzJWQAImFRhC1e6wvfTtd1Gcy+eoP +NgnqroijeonlV2vsNENsr+AMksRREeRFk4WP14MUZAB2p2iEy5J8jU31iUvFHsw vWY6IEThwESPbt+3h2buJ6475UgQ3Ww2lJ6jTewBOEEZ/sRuqEmLy33bQEMOwFlS JcFsXwIDAQABo4GUMIGRMB0GA1UdDgQWBBTiAQBmjX5+5ki5ePNiF61jhmF5xDBi BgNVHSMEWzBZgBTiAQBmjX5+5ki5ePNiF61jhmF5xKE+pDwwOjELMAkGA1UEBhMC U1YxGTAXBgNVBAoTEFNpYWcgT2ZmaWNlLCBJbmMxEDAOBgNVBAMTB3NpYWcubnWC AQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQC2nAZn6MdkmX7xQSP0 5Z3NeMx4BKHzfDZ0/gkcpKEfH4A45Nz6cReGy7WY4vkXM8BCN0X46ViKnfcXByrA MPuIEETTffZ1qzFvxolfDqJvsZGw7Tz7GvmbOBEk9itTyJ7h0AFiCr6JyoEUwniQ FD7bVtD5uFKUGksFrzBGdrBNyg== -----END CERTIFICATE----- pen-0.32.0/netconv.h0000644000175000017500000000054112515642340011126 00000000000000extern int getport(char *, char *); extern int pen_setport(struct sockaddr_storage *, int); extern int pen_getport(struct sockaddr_storage *); extern char *pen_ntoa(struct sockaddr_storage *); extern void pen_dumpaddr(struct sockaddr_storage *); extern int pen_ss_size(struct sockaddr_storage *); extern int pen_aton(char *, struct sockaddr_storage *); pen-0.32.0/dsr.h0000644000175000017500000000016212624554430010244 00000000000000extern int dsr_init(char *, char *); extern void dsr_frame(int); extern void dsr_arp(int); extern int tarpit_acl; pen-0.32.0/pen_kqueue.h0000644000175000017500000000003712514666005011616 00000000000000extern void kqueue_init(void); pen-0.32.0/idlers.h0000644000175000017500000000013612515662230010734 00000000000000extern int idlers, idlers_wanted; extern void close_idlers(int); extern int add_idler(void); pen-0.32.0/pen.spec0000644000175000017500000000400012507562420010732 00000000000000# DarContact: Ulric Eriksson Summary: A load balancer for "simple" tcp based protocols. Name: pen Version: 0.11.0 Release: 0 License: GPL Group: Applications/Internet URL: http://siag.nu/pen/ Packager: Dag Wieers Vendor: Dag Apt Repository, http://dag.wieers.com/apt/ Source: ftp://siag.nu/pub/pen/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/root-%{name}-%{version} Prefix: %{_prefix} %description Pen is a load balancer for "simple" tcp based protocols such as http or smtp. It allows several servers to appear as one to the outside and automatically detects servers that are down and distributes clients among the available servers. This gives high availability and scalable performance. %prep %setup ### FIXME: Add a default pen.conf for Apache. (Please fix upstream) %{__cat} <%{name}.conf ScriptAlias /pen/ %{_localstatedir}/www/pen/ DirectoryIndex penctl.cgi Options ExecCGI order deny,allow deny from all allow from 127.0.0.1 EOF %build %configure %{__make} %{?_smp_mflags} %install %{__rm} -rf %{buildroot} %makeinstall %{__install} -d -m0755 %{buildroot}%{_localstatedir}/www/pen/ \ %{buildroot}%{_sysconfdir}/httpd/conf.d/ %{__install} -m0755 penctl.cgi %{buildroot}%{_localstatedir}/www/pen/ %{__install} -m0644 pen.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/ %post if [ -f %{_sysconfdir}/httpd/conf/httpd.conf ]; then if ! grep -q "Include .*/pen.conf" %{_sysconfdir}/httpd/conf/httpd.conf; then echo -e "\n# Include %{_sysconfdir}/httpd/conf.d/pen.conf" >> %{_sysconfdir}/httpd/conf/httpd.conf # /sbin/service httpd restart fi fi %clean %{__rm} -rf %{buildroot} %files %defattr(-, root, root, 0755) %doc AUTHORS ChangeLog COPYING HOWTO NEWS README TODO %doc %{_mandir}/man?/* %config(noreplace) %{_sysconfdir}/httpd/conf.d/*.conf %{_bindir}/* %{_localstatedir}/www/pen/ %changelog * Tue Sep 23 2003 Dag Wieers - 0.11.0-0 - Initial package. (using DAR) pen-0.32.0/conn.h0000644000175000017500000000315412531320303010400 00000000000000#include #ifdef HAVE_LIBSSL #include #include #endif #include #define CONNECTIONS_MAX 500 /* max simultaneous connections */ /* Connection states, as used in struct conn */ #define CS_UNUSED (0) /* not connected, unused slot */ #define CS_IN_PROGRESS (1) /* connection in progress */ #define CS_CONNECTED (2) /* successfully connected */ #define CS_CLOSED_UP (4) /* we read eof from upfd */ #define CS_CLOSED_DOWN (8) /* we read eof from downfd */ #define CS_CLOSED (CS_CLOSED_UP | CS_CLOSED_DOWN) typedef struct { int state; /* as per above */ time_t t; /* time of connection attempt */ int downfd, upfd; unsigned char *downb, *downbptr, *upb, *upbptr; int downn, upn; /* pending bytes */ unsigned long ssx, srx; /* server total sent, received */ unsigned long csx, crx; /* client total sent, received */ int client; /* client index */ int initial; /* first server tried */ int server; /* server index */ int pend; /* node in pending_list */ #ifdef HAVE_LIBSSL SSL *ssl; time_t reneg; /* last time client requested renegotiation */ #endif } connection; extern connection *conns; extern int idle_timeout; extern int pending_list; extern int pending_queue; extern int pending_max; extern int connections_max; extern int connections_used; extern int connections_last; extern int tracking_time; extern void fd2conn_set(int, int); extern int fd2conn_get(int); extern int closing_time(int); #ifdef HAVE_LIBSSL int store_conn(int, SSL *, int); #else int store_conn(int, int); #endif extern int idler(int); extern void close_conn(int); extern void expand_conntable(size_t); pen-0.32.0/TODO0000644000175000017500000000000012507562420007760 00000000000000pen-0.32.0/X64/0000755000175000017500000000000012624555212007744 500000000000000pen-0.32.0/X64/Makefile0000644000175000017500000000010112507562420011313 00000000000000 VPATH=.. CC=x86_64-w64-mingw32-gcc -m64 include ../Makefile.win pen-0.32.0/COPYING0000644000175000017500000004440712507562420010346 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file, and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. If you delete this exception statement from all source files in the program, then also delete it here. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pen-0.32.0/server.h0000644000175000017500000000264412604733030010762 00000000000000#include #ifndef WINDOWS #include #else #include #endif #define ALG_HASH_VALID 1 #define ALG_ROUNDROBIN 2 #define ALG_WEIGHT 4 #define ALG_PRIO 8 #define ALG_HASH 16 #define ALG_STUBBORN 32 #define EMERGENCY_SERVER (-1) #define ABUSE_SERVER (-2) #define NO_SERVER (-3) #define BLACKLIST_TIME 30 /* how long to shun a server that is down */ #define WEIGHT_FACTOR 256 /* to make weight kick in earlier */ typedef struct { int status; /* last failed connection attempt */ int acl; /* which clients can use this server */ struct sockaddr_storage addr; uint8_t hwaddr[6]; int c; /* connections */ int weight; /* default 1 */ int prio; int maxc; /* max connections, soft limit */ int hard; /* max connections, hard limit */ uint64_t sx, rx; /* bytes sent, received */ } server; extern int nservers; /* number of servers */ extern server *servers; extern int current; extern int emerg_server; extern int abuse_server; extern int blacklist_time; extern int server_alg; extern char *e_server; extern char *a_server; extern void setaddress(int, char *, int, char *); extern void blacklist_server(int); extern int unused_server_slot(int); extern int server_is_blacklisted(int); extern int server_is_unavailable(int); extern int server_by_roundrobin(void); extern int initial_server(int); extern int failover_server(int); extern int try_server(int, int); extern void expand_servertable(int); pen-0.32.0/windows.c0000644000175000017500000002227612526327460011155 00000000000000#include "diag.h" #include "pen.h" #include "windows.h" int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { return 0; } uid_t getuid(void) { return 0; } #if 0 static int sigemptyset(sigset_t *set) { return 0; } static int getrlimit(int resource, struct rlimit *rlim) { return 0; } static int setrlimit(int resource, const struct rlimit *rlim) { return 0; } static struct passwd *getpwnam(const char *name) { static struct passwd p; p.pw_uid = 0; p.pw_gid = 0; return &p; } static int chroot(const char *path) { return 0; } static int setgid(gid_t gid) { return 0; } static int setuid(uid_t uid) { return 0; } #endif int inet_aton(const char *cp, struct in_addr *addr) { addr->s_addr = inet_addr(cp); return (addr->s_addr == INADDR_NONE) ? 0 : 1; } #if 0 const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) { struct sockaddr_in sa; memset(&sa, 0, sizeof sa); memcpy(&sa.sin_addr, src, sizeof sa.sin_addr); sa.sin_family = af; if (WSAAddressToString((struct sockaddr *)&sa, sizeof sa, 0, dst, (LPDWORD)&size) != 0) { DWORD rv = WSAGetLastError(); debug("WSAAddressToString returns %d", rv); return NULL; } return dst; } #endif void make_nonblocking(int fd) { int i; u_long mode = 1; if ((i = ioctlsocket(fd, FIONBIO, &mode)) != NO_ERROR) error("Can't ioctlsocket, error = %d", i); } static WSADATA wsaData; static int ws_started = 0; int start_winsock(void) { int n; DEBUG(1, "start_winsock()"); if (!ws_started) { n = WSAStartup(MAKEWORD(2, 2), &wsaData); if (n != NO_ERROR) { error("Error at WSAStartup() [%d]", WSAGetLastError()); } else { DEBUG(2, "Winsock started"); ws_started = 1; } } return ws_started; } void stop_winsock(void) { WSACleanup(); ws_started = 0; } static SERVICE_STATUS ServiceStatus; static SERVICE_STATUS_HANDLE ServiceStatusHandle; static VOID WINAPI ServiceCtrlHandler (DWORD opcode); static VOID WINAPI ServiceStart (DWORD argc, LPTSTR *argv); static DWORD ServiceInitialization (DWORD argc, LPTSTR *argv, DWORD *specificError); static void DeletePenService(SC_HANDLE schSCManager, char *service_name) { SC_HANDLE schService; schService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS); if (schService == NULL) { debug("Can't open service (%d)", (int)GetLastError()); return; } if (!DeleteService(schService)) { debug("Can't delete service (%d)", (int)GetLastError()); } CloseServiceHandle(schService); } int delete_service(char *service_name) { SC_HANDLE schSCManager; debug("delete_service()", 0); // Open a handle to the SC Manager database. schSCManager = OpenSCManager( NULL, // local machine NULL, // ServicesActive database SC_MANAGER_ALL_ACCESS); // full access rights if (NULL == schSCManager) { debug("OpenSCManager failed (%d)", (int)GetLastError()); return 0; } DeletePenService(schSCManager, service_name); return 1; } static BOOL CreatePenService(SC_HANDLE schSCManager, char *service_name, char *display_name) { TCHAR szPath[MAX_PATH]; SC_HANDLE schService; if( !GetModuleFileName( NULL, szPath, MAX_PATH ) ) { debug("GetModuleFileName failed (%d)", (int)GetLastError()); return FALSE; } schService = CreateService( schSCManager, // SCManager database service_name, // name of service display_name, // service name to display SERVICE_ALL_ACCESS, // desired access SERVICE_WIN32_OWN_PROCESS, // service type SERVICE_AUTO_START, // start type SERVICE_ERROR_NORMAL, // error control type szPath, // path to service's binary NULL, // no load ordering group NULL, // no tag identifier NULL, // no dependencies NULL, // LocalSystem account NULL); // no password if (schService == NULL) { debug("CreateService failed (%d)", (int)GetLastError()); return FALSE; } else { CloseServiceHandle(schService); return TRUE; } } int install_service(char *service_name) { SC_HANDLE schSCManager; // Open a handle to the SC Manager database. debug("install_service()", 0); schSCManager = OpenSCManager( NULL, // local machine NULL, // ServicesActive database SC_MANAGER_ALL_ACCESS); // full access rights if (NULL == schSCManager) debug("OpenSCManager failed (%d)", (int)GetLastError()); if (CreatePenService(schSCManager, service_name, service_name)) { debug("Success"); } else { debug("Failure"); } return 0; } int service_main(int argc, char **argv) { SERVICE_TABLE_ENTRY DispatchTable[] = { /* http://msdn.microsoft.com/en-us/library/ms686001(VS.85).aspx If the service is installed with the SERVICE_WIN32_OWN_PROCESS service type, this member is ignored, but cannot be NULL. This member can be an empty string (""). */ { /*SERVICE_NAME*/"", ServiceStart }, { NULL, NULL } }; debug("service_main(%d, %p)", argc, argv); if (!StartServiceCtrlDispatcher( DispatchTable)) { debug(" [PEN] StartServiceCtrlDispatcher (%d)\n", GetLastError()); } return 0; } static void WINAPI ServiceStart (DWORD argc, LPTSTR *argv) { DWORD status; DWORD specificError; debug("ServiceStart()"); ServiceStatus.dwServiceType = SERVICE_WIN32; ServiceStatus.dwCurrentState = SERVICE_START_PENDING; ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_PAUSE_CONTINUE; ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwServiceSpecificExitCode = 0; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; ServiceStatusHandle = RegisterServiceCtrlHandler( /* http://msdn.microsoft.com/en-us/library/ms685054(VS.85).aspx If the service type is SERVICE_WIN32_OWN_PROCESS, the function does not verify that the specified name is valid, because there is only one registered service in the process. */ "", // SERVICE_NAME ServiceCtrlHandler); if (ServiceStatusHandle == (SERVICE_STATUS_HANDLE)0) { debug(" [PEN] RegisterServiceCtrlHandler failed %d\n", GetLastError()); return; } // Initialization code goes here. status = ServiceInitialization(argc,argv, &specificError); // Handle error condition if (status != NO_ERROR) { ServiceStatus.dwCurrentState = SERVICE_STOPPED; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; ServiceStatus.dwWin32ExitCode = status; ServiceStatus.dwServiceSpecificExitCode = specificError; SetServiceStatus (ServiceStatusHandle, &ServiceStatus); return; } // Initialization complete - report running status. ServiceStatus.dwCurrentState = SERVICE_RUNNING; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; if (!SetServiceStatus (ServiceStatusHandle, &ServiceStatus)) { status = GetLastError(); debug(" [PEN] SetServiceStatus error %ld\n",status); } // This is where the service does its work. debug(" [PEN] Returning the Main Thread \n",0); mainloop(); return; } // Stub initialization function. static DWORD ServiceInitialization(DWORD argc, LPTSTR *argv, DWORD *specificError) { return(0); } static VOID WINAPI ServiceCtrlHandler (DWORD Opcode) { DWORD status; switch(Opcode) { case SERVICE_CONTROL_PAUSE: // Do whatever it takes to pause here. ServiceStatus.dwCurrentState = SERVICE_PAUSED; break; case SERVICE_CONTROL_CONTINUE: // Do whatever it takes to continue here. ServiceStatus.dwCurrentState = SERVICE_RUNNING; break; case SERVICE_CONTROL_STOP: // Do whatever it takes to stop here. stop_winsock(); ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwCurrentState = SERVICE_STOPPED; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; if (!SetServiceStatus (ServiceStatusHandle, &ServiceStatus)) { status = GetLastError(); debug(" [PEN] SetServiceStatus error %ld\n", status); } debug(" [PEN] Leaving Service \n",0); return; case SERVICE_CONTROL_INTERROGATE: // Fall through to send current status. break; default: debug(" [PEN] Unrecognized opcode %ld\n", Opcode); } // Send current status. if (!SetServiceStatus (ServiceStatusHandle, &ServiceStatus)) { status = GetLastError(); debug(" [PEN] SetServiceStatus error %ld\n", status); } return; } pen-0.32.0/penctl.10000644000175000017500000002111512622372561010654 00000000000000.TH PENCTL 1 LOCAL .SH NAME penctl - control a running pen load balancer .SH SYNOPSIS .B penctl host:port|/path/to/socket command .SH EXAMPLE penctl lbhost:8888 roundrobin Turns off client tracking on the load balancer running on lbhost. penctl /var/run/pen/tmp/ctrl status Prints status information in html format. .SH DESCRIPTION .I Penctl connects to the optional control socket on a pen load balancer. It reads commands from the command line, performs minimal syntax checking and sends them to pen. Replies, if any, are printed on stdout. The program can also be used through the cgi script penctl.cgi, which allows pen to be controlled from any web browser. .SH OPTIONS .TP \fIhost:port\fR Specifies a control port where the load balancer listens for commands. .SH COMMANDS .TP \fIabort_on_error\fR Call abort() when a fatal error is encountered. This will create a core file which allows further troubleshooting. Disabled by default. .TP \fIno abort_on_error\fR Exit normally on fatal error with an error code which indicates failure. .TP \fIacl N permit|deny sourceip4 [mask]\fR Adds an entry to access list N, where N is a number from 0 to 9. The source and mask addresses are in the usual dotted quad notation. If mask is omitted, it defaults to 255.255.255.255. .TP \fIacl N permit|deny sourceip6[/length]\fR If the source address contains the character ':', the address is interpreted as IPv6. Unlike IPv4 access entries, a length is used to indicate the mask. If length is omitted, it defaults to 128. .TP \fIacl N permit|deny country NN\fR If the source address is the special word "country", a two-letter country code can be used to restrict access to the load balancer. For this to work, pen must be built with geoip support. .TP \fIno acl N\fR Deletes all entries from access list N. The resulting access list permits all traffic. .TP \fIascii\fR Communication dumps in ascii format (cf option -a). .TP \fIno ascii\fR Communication dumps in hex format. .TP \fIblacklist\fR Return current blacklist time in seconds. .TP \fIblacklist T\fR Set the blacklist time in seconds. .TP \fIblock\fR Do not make sockets nonblocking. This is obsolete as of 0.26.0 and does nothing. .TP \fIno block\fR Make sockets nonblocking. .TP \fIclient_acl N\fR Check connecting clients against access list N (default 0). .TP \fIclients_max [N]\fR With argument, increase the maximum number of known clients. Returns max number of clients. .TP \fIclose N\fR Close connection N .TP \fIconnection N\fR Display some basic information about connection N. .TP \fIconn_max [N]\fR With argument, increase the max number of simultaneous connections. Returns max number. .TP \fIcontrol\fR Return address and port where pen listens for control connections. .TP \fIcontrol_acl N\fR Check accesses to the control port against access list N (default 0). .TP \fIdebug\fR Return current debug level. .TP \fIdebug N\fR Set debug level to N. .TP \fIdelayed_forward\fR Always wait for the next round of the main loop before forwarding data. Normally pen tries to do that immediately. This is obsolete as of 0.26.0 and does nothing. .TP \fIno delayed_forward\fR Try to forward data immediately, to avoid the overhead of copying it to a temporary buffer and waiting for the next main loop round. .TP \fIdsr_if IF\fR Use IF as the interface for Direct Server Return. .TP \fIdummy\fR Act as a dummy web server with very limited functionality but high performance. Only useful for testing. Disabled by default. .TP \fIno dummy\fR Do not act as a dummy web server. .TP \fIepoll\fR Use epoll for event management (Linux). This is the default on Linux. .TP \fIexit\fR Exit. Only available if pen was started with the -X option. .TP \fIhash\fR Use a hash on the client IP address for initial server selection. .TP \fIno hash\fR Do not use a hash. .TP \fIhttp\fR Add X-Forwarded-For headers to http requests. .TP \fIno http\fR Do not add X-Forwarded-For headers. .TP \fIidle_timeout N\fR Close connections that have been inactive for N seconds. Default 0 = never close. .TP \fIidlers [N]\fR Create N reliable idle connections to the backend servers. Without argument, display the current/requested number of reliable idlers. .TP \fIinclude FILE\fR Read commands from file. .TP \fIkqueue\fR Use kqueue for event management (FreeBSD, NetBSD, OpenBSD). This is the default on the systems that have it. .TP \fIlisten\fR Return local address and port pen listens to for incoming client connections. .TP \fIlisten [address:]:port Close the listening socket and reopen using specified address (optional) and port. .TP \fIlog\fR Show where pen is logging, if anywhere. .TP \fIlog FILE\fR Log to FILE. .TP \fImode\fR Write a summary of the current mode of operation. The listed modes are block, delayed_forward, hash, roundrobin, stubborn. .TP \fIno log\fR Turn off logging. .TP \fIpending_max N\fR Max allowed number of pending nonblocking connections. Default 100, minimum 1. .TP \fIpid\fR Return the process id of the running daemon. .TP \fIpoll\fR Use poll for event management. .TP \fIprio\fR Use the priority based algorithm. .TP \fIno prio\fR Do not use the priority based algorithm. .TP \fIrecent [N]\fR Shows which clients have connected in the last N seconds (default 300). .TP \fIroundrobin\fR Use round-robin server selection without client tracking .TP \fIno roundrobin\fR .TP \fIselect\fR Use select for event management. .TP \fIserver N [ acl A | address A | port P | max M | hard H | blacklist T | weight W | prio P ]\fR Change acl, address, port, weight, priority and/or max connections for server N, or blacklist it for T seconds. .TP \fIservers\fR List address, port, weight, priority and max number of simultaneous connections for each remote server. .TP \fIsocket N\fR Show to which connection socket N belongs. .TP \fIssl_ciphers CIPHERS\fR Choose list of available SSL ciphers, specified in the format described in https://www.openssl.org/docs/apps/ciphers.html. .TP \fIssl_client_renegotiation_interval S\fR Allowing the client to request renegotiation is a potential denial of service vector. This command specifies the minimum number of seconds the client has to wait between requests for renegotiation requests. Default 3600 = effectively disabled. .TP \fIssl_ocsp_response FILENAME\fR Specifies the location of a file containing a pre-fetched OCSP response. The file must be refreshed regularly by a cron job or similar and the ssl_ocsp_response command repeated to make Pen re-read the file.. .TP \fIssl_option OPTION\fR Manipulate SSL options. The available options are no_sslv2, no_sslv3, no_tlsv1, no_tlsv1.1, no_tlsv1.2, cipher_server_preference. Use the command multiple times to specify multiple options. .TP \fIssl_sni_path PATH\fR This command enables the Server Name Indication TLS extension by specifying a directory where domain.key, domain.crt and domain.ca files can be found. .TP \fIstatus\fR Print status information in html format. .TP \fIstubborn\fR If the initial server selection is unavailable, close the client connection without trying another .TP \fIno stubborn\fR .TP \fItarpit_acl [N]\fR Used in DSR mode. If N is an existing access list, Pen will reply to ARP requests for IP addresses that match the access list, and reply with SYN+ACK to TCP SYN requests to these addresses. The result is that someone trying to scan a network will be slowed down by a large number of false positives. .TP \fItcp_fastclose up|down|both|off\fR Close both sockets to upstream and downstream if one of them closes theirs. Default = off. .TP \fItcp_nodelay\fR Set TCP_NODELAY on sockets, effectively turning off the Nagle algorithm. .TP \fIno tcp_nodelay\fR Do not set TCP_NODELAY on sockets. This is the default. .TP \fItimeout\fR Return current connect timeout in seconds. .TP \fItimeout N\fR Set connect timeout to N seconds. .TP \fItracking N\fR Set tracking time, i.e. how long clients will be remembered. The default 0 will never expire clients based on time. .TP \fItransparent\fR On compatible platforms, use the client's address as source address in the connection to the backend server. .TP \fIno transparent\fR Use Pen's address as source address in the connection to the backend server. .TP \fIweb_stats\fR Return file name of html status reports, if any. .TP \fIweb_stats FILE\fR Set the name of html status reports. .TP \fIno web_stats\fR Do not generate html status reports. .TP \fIweight\fR Use weight for server selection. .TP \fIno weight\fR Do not use weight for server selection. .TP \fIwrite [FILE]\fR Write the current configuration into a file which can be used to start pen. If FILE is omitted, the configuration is written into pen's original configuration file. .SH SEE ALSO pen(1) .SH AUTHOR Copyright (C) 2002-2015 Ulric Eriksson, . pen-0.32.0/penctl.c0000644000175000017500000001060612526564112010737 00000000000000/* Copyright (C) 2000-2015 Ulric Eriksson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" #include #include #include #include #include #include //#include #include #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #include #include #include #include #include #include #include #include #include #include "config.h" static void error(char *fmt, ...) { char b[4096]; va_list ap; va_start(ap, fmt); vsnprintf(b, sizeof b, fmt, ap); fprintf(stderr, "%s\n", b); va_end(ap); exit(EXIT_FAILURE); } static void alarm_handler(int dummy) { ; } static void usage(void) { printf("usage: penctl host:port command\n"); exit(0); } static int open_unix_socket(char *path) { int n, fd; struct sockaddr_un serv_addr; fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) error("error opening socket"); memset(&serv_addr, 0, sizeof serv_addr); serv_addr.sun_family = AF_UNIX; snprintf(serv_addr.sun_path, sizeof serv_addr.sun_path, "%s", path); n = connect(fd, (struct sockaddr *)&serv_addr, sizeof serv_addr); if (n == -1) { error("error connecting to server"); } return fd; } static int open_socket(char *addr, char *port) { int fd = -1; #if 0 struct sockaddr_in serv_addr; struct hostent *h; struct in_addr a; struct servent *s; #else struct addrinfo *ai; struct addrinfo hints; struct addrinfo *runp; #endif int n; #if 0 h = gethostbyname(addr); if (h == NULL) error("unknown or invalid address %s\n", addr); memcpy(&a, h->h_addr, h->h_length); s = getservbyname(port, "tcp"); if (s == NULL) po = atoi(port); else po = ntohs(s->s_port); fd = socket(AF_INET, SOCK_STREAM, 0); #else memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_socktype = SOCK_STREAM; n = getaddrinfo(addr, port, &hints, &ai); if (n != 0) { error("getaddrinfo: %s", gai_strerror(n)); } runp = ai; /* only using first result; should try all */ fd = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol); #endif if (fd < 0) error("error opening socket"); #if 0 serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = a.s_addr; serv_addr.sin_port = htons(po); #endif signal(SIGALRM, alarm_handler); #if 0 n = connect(fd, (struct sockaddr *)&serv_addr, sizeof serv_addr); #else n = connect(fd, runp->ai_addr, runp->ai_addrlen); #endif alarm(0); if (n == -1) { error("error connecting to server"); } return fd; } int main(int argc, char **argv) { int i, fd, n; char b[1024], *p; if (argc < 3) { usage(); } if (strchr(argv[1], '/')) { fd = open_unix_socket(argv[1]); } else { n = 1+strlen(argv[1]); /* one for \0 */ if (n > sizeof b) error("Overlong arg '%s'", argv[1]); snprintf(b, sizeof b, "%s", argv[1]); /* We need the *last* : to allow such arguments as ::1:10080 if pen's control port is ipv6 localhost:10080 */ p = strrchr(b, ':'); if (p == NULL) error("no port given"); *p++ = '\0'; fd = open_socket(b, p); } n = 0; for (i = 2; argv[i]; i++) { for (p = argv[i]; *p; p++) { if (n >= (sizeof b)-1) error("Overlong argument list"); b[n++] = *p; } b[n++] = ' '; } if (n >= (sizeof b)-1) error("Overlong argument list"); b[--n] = '\n'; /* replace last ' ' */ b[++n] = '\0'; /* terminate string */ n = write(fd, b, strlen(b)); if (n == -1) error("error writing to socket"); for (;;) { n = read(fd, b, sizeof b); if (n == 0) break; if (n == -1) error("error reading from socket"); n = write(1, b, n); if (n == -1) error("error writing to stdout"); } close(fd); return 0; } pen-0.32.0/ssl.h0000644000175000017500000000131212510711333010242 00000000000000#ifdef HAVE_LIBSSL #include #include #define SRV_SSL_V23 0 #define SRV_SSL_V2 1 #define SRV_SSL_V3 2 #define SRV_SSL_TLS1 3 #define OCSP_RESP_MAX 10000 extern char ssl_compat; extern char require_peer_cert; extern char ssl_protocol; extern char *certfile; extern char *keyfile; extern char *cacert_dir; extern char *cacert_file; extern char *ssl_sni_path; extern SSL_CTX *ssl_context; extern long ssl_options; extern char *ssl_ciphers; extern int ssl_session_id_context; extern int ssl_client_renegotiation_interval; extern unsigned char ocsp_resp_data[OCSP_RESP_MAX]; extern long ocsp_resp_len; extern char *ocsp_resp_file; extern int ssl_init(void); #endif /* HAVE_LIBSSL */ pen-0.32.0/event.c0000644000175000017500000000103012524651724010566 00000000000000#include "config.h" #include "event.h" #include "pen_epoll.h" #include "pen_kqueue.h" #include "pen_poll.h" #include "pen_select.h" int timeout = TIMEOUT; void (*event_add)(int, int); void (*event_arm)(int, int); void (*event_delete)(int); void (*event_wait)(void); int (*event_fd)(int *); #if defined HAVE_KQUEUE void (*event_init)(void) = kqueue_init; #elif defined HAVE_EPOLL void (*event_init)(void) = epoll_init; #elif defined HAVE_POLL void (*event_init)(void) = poll_init; #else void (*event_init)(void) = select_init; #endif pen-0.32.0/pen_select.h0000644000175000017500000000003712514665746011611 00000000000000extern void select_init(void); pen-0.32.0/mergelogs.10000644000175000017500000000425612527416526011366 00000000000000.TH MERGELOGS 1 LOCAL .SH NAME mergelogs - merge and consolidate web server logs .SH SYNOPSIS .B mergelogs -p penlog [-c] [-d] [-j jitter] [-t seconds] server1:logfile1 [server2:logfile2 ...] .SH EXAMPLES mergelogs -p pen.log 10.0.0.1:access_log.1 10.0.0.2:access_log.2 mergelogs -p pen.log 10.0.18.6:access_log-10.0.18.6 10.0.18.8:access_log-10.0.18.8 .SH DESCRIPTION When pen is used to load balance web servers, the web server log file lists all accesses as coming from the host running pen. This makes it more difficult to analyze the log file. To solve this, pen creates its own log file, which contains the real client address, the time of the access, the target server address and the first few bytes of the requests. Mergelogs reads pen's log file and the log files of all load balanced web servers, compares each entry and creates a combined log file that looks as if the web server cluster were a single physical server. Client addresses are replaced with the real client addresses. In the event that no matching client address can be found in the pen log, the server address is used instead. This should never happen, and is meant as a debugging tool. A large number of these indicates that the server system date needs to be set, or that the jitter value is too small. You probably don't want to use this program. Penlog is a much more elegant and functional solution. .SH OPTIONS .TP -c Do not cache pen log entries. The use of this option is not recommended, as it will make mergelogs search the entire pen log for every line in the web server logs. .TP -d Debugging (repeat for more). .TP -p \fIpenlog\fR Log file from pen. .TP -j \fIjitter\fR Jitter in seconds (default 600). This is the maximum variation in time stamps in the pen and web server log files. A smaller value will result in a smaller pen log cache and faster processing, at the risk of missed entries. .TP -t \fIseconds\fR The difference in seconds between the time on the pen server and UTC. For example, this is 7200 (two hours) in Finland. .TP server:logfile Web server address and name of log file. .SH AUTHOR Copyright (C) 2001-2015 Ulric Eriksson, . .SH SEE ALSO pen(1), webresolve(1), penlog(1), penlogd(1) pen-0.32.0/penstats0000755000175000017500000000045612507562420011076 00000000000000#!/bin/sh PENHOME=/home/ulric/Projekt/pen PIDFILE=$PENHOME/pid WEBFILE=$PENHOME/webstats.html # This will make pen save its stats kill -USR1 `cat $PIDFILE` # We don't know how long it will take; wait a few seconds sleep 2 # And display the results echo "Content-type: text/html" echo cat $WEBFILE pen-0.32.0/Makefile.am0000644000175000017500000000176312526565372011357 00000000000000 bin_PROGRAMS = pen mergelogs penctl penlog penlogd noinst_HEADERS = pen.h dlist.h ssl.h dsr.h memory.h diag.h settings.h acl.h event.h pen_select.h pen_poll.h pen_kqueue.h pen_epoll.h netconv.h windows.h server.h client.h conn.h idlers.h pen_SOURCES = pen.c select.c poll.c kqueue.c epoll.c dlist.c ssl.c dsr.c memory.c diag.c settings.c acl.c event.c netconv.c server.c client.c conn.c idlers.c mergelogs_SOURCES = mergelogs.c memory.c diag.c settings.c penctl_SOURCES = penctl.c penlog_SOURCES = penlog.c diag.c settings.c penlogd_SOURCES = penlogd.c diag.c settings.c doc_DATA = penstats HOWTO AUTHORS README ChangeLog COPYING man_MANS = pen.1 mergelogs.1 penctl.1 penlog.1 penlogd.1 EXTRA_DIST = $(man_MANS) $(doc_DATA) penctl.cgi pen.spec siag.pem \ Makefile.win X86/Makefile X64/Makefile windows.c config.h.win \ pen-ocsp.sh tgz: rm -rf tmpinst mkdir tmpinst make clean ./configure --prefix=/usr make make install-strip prefix=tmpinst/usr (cd tmpinst && makepkg pen.tgz && mv pen.tgz ..) pen-0.32.0/poll.c0000644000175000017500000000526412516404572010426 00000000000000#include "config.h" #include #include #include #include //#include "pen.h" #include "diag.h" #include "event.h" #include "memory.h" #ifdef HAVE_POLL #include static struct pollfd *poll_ufds; static int poll_nfds, poll_count, poll_nfds_max; static int pindex; /* Making a sparse pollfd table, using fd as the index seems most efficient. */ /* Need to make sure to grow the table as necessary. */ static void poll_event_ctl(int fd, int events) { int pollevents = 0; DEBUG(2, "poll_event_ctl(fd=%d, events=%d)", fd, events); if (fd >= poll_nfds_max) { int i, new_max = fd+10000; DEBUG(2, "expanding poll_ufds to %d entries", new_max); poll_ufds = pen_realloc(poll_ufds, new_max * sizeof *poll_ufds); for (i = poll_nfds_max; i < new_max; i++) { poll_ufds[i].fd = -1; poll_ufds[i].events = 0; } poll_nfds_max = new_max; } if (events & EVENT_READ) pollevents |= POLLIN; if (events & EVENT_WRITE) pollevents |= POLLOUT; poll_ufds[fd].fd = fd; poll_ufds[fd].events = pollevents; if (fd >= poll_nfds) poll_nfds = fd+1; } static void poll_event_add(int fd, int events) { DEBUG(2, "poll_event_add(fd=%d, events=%d)", fd, events); poll_event_ctl(fd, events); } static void poll_event_arm(int fd, int events) { DEBUG(2, "poll_event_arm(fd=%d, events=%d)", fd, events); poll_event_ctl(fd, events); } static void poll_event_delete(int fd) { DEBUG(2, "poll_event_delete(fd=%d)", fd); poll_ufds[fd].fd = -1; /* ignore events */ poll_ufds[fd].events = 0; } static void poll_event_wait(void) { DEBUG(2, "poll_event_wait()"); pindex = -1; poll_count = poll(poll_ufds, poll_nfds, 1000*timeout); DEBUG(2, "poll returns %d", poll_count); if (poll_count < 0 && errno != EINTR) { error("Error on poll: %s", strerror(errno)); } } static int poll_event_fd(int *revents) { int events = 0; DEBUG(2, "poll_event_fd(revents=%p)", revents); for (pindex++; pindex < poll_nfds; pindex++) { DEBUG(3, "\tpoll_ufds[%d] = {fd=%d, revents=%d}", pindex, poll_ufds[pindex].fd, poll_ufds[pindex].revents); if (poll_ufds[pindex].revents & POLLIN) events |= EVENT_READ; if (poll_ufds[pindex].revents & POLLOUT) events |= EVENT_WRITE; if (events) { *revents = events; return poll_ufds[pindex].fd; } } return -1; } void poll_init(void) { DEBUG(2, "poll_init()"); poll_nfds = poll_nfds_max = 0; poll_ufds = NULL; event_add = poll_event_add; event_arm = poll_event_arm; event_delete = poll_event_delete; event_wait = poll_event_wait; event_fd = poll_event_fd; } #else void poll_init(void) { debug("You don't have poll"); exit(EXIT_FAILURE); } #endif pen-0.32.0/server.c0000644000175000017500000003052712616170264010765 00000000000000#include "config.h" #include #include #include #include #include #ifndef WINDOWS #include #endif #ifdef HAVE_LIBSSL #include #include #endif #include "acl.h" #include "client.h" #include "conn.h" #include "diag.h" #include "dlist.h" #include "event.h" #include "memory.h" #include "netconv.h" #include "pen.h" #include "server.h" #include "settings.h" #include "windows.h" #ifndef WINDOWS #define CONNECT_IN_PROGRESS (EINPROGRESS) #endif int nservers = 0; server *servers = NULL; int current; /* current server */ int emerg_server = NO_SERVER; /* server of last resort */ static int emergency = 0; /* are we using the emergency server? */ int abuse_server = NO_SERVER; /* server for naughty clients */ int blacklist_time = BLACKLIST_TIME; int server_alg; char *e_server = NULL; char *a_server = NULL; static int pen_hash(struct sockaddr_storage *a) { struct sockaddr_in *si; struct sockaddr_in6 *si6; unsigned char *u; int hash; switch (a->ss_family) { case AF_INET: si = (struct sockaddr_in *)a; if (server_alg & ALG_ROUNDROBIN) { hash = (si->sin_addr.s_addr ^ si->sin_port) % (nservers?nservers:1); } else { hash = si->sin_addr.s_addr % (nservers?nservers:1); } DEBUG(2, "Hash: %d", hash); return hash; case AF_INET6: si6 = (struct sockaddr_in6 *)a; u = (unsigned char *)(&si6->sin6_addr); return u[15] % (nservers?nservers:1); default: return 0; } } /* Introduce the new format "[address]:port:maxc:hard:weight:prio" in addition to the old one. */ void setaddress(int server, char *s, int dp, char *proto) { char address[1024], pno[100]; int n; char *format; int port; if (s[0] == '[') { format = "[%999[^]]]:%99[^:]:%d:%d:%d:%d"; } else { format = "%999[^:]:%99[^:]:%d:%d:%d:%d"; } n = sscanf(s, format, address, pno, &servers[server].maxc, &servers[server].hard, &servers[server].weight, &servers[server].prio); if (n > 1) port = getport(pno, proto); else port = dp; if (n < 3) servers[server].maxc = 0; if (n < 4) servers[server].hard = 0; if (n < 5) servers[server].weight = 0; if (n < 6) servers[server].prio = 0; DEBUG(2, "n = %d, address = %s, pno = %d, maxc1 = %d, hard = %d, weight = %d, prio = %d, proto = %s ", \ n, address, port, servers[server].maxc, \ servers[server].hard, servers[server].weight, \ servers[server].prio, proto); if (pen_aton(address, &servers[server].addr) == 0) { error("unknown or invalid address [%s]", address); } memset(servers[server].hwaddr, 0, 6); pen_setport(&servers[server].addr, port); } void blacklist_server(int server) { servers[server].status = now; } int unused_server_slot(int i) { struct sockaddr_storage *a = &servers[i].addr; if (a->ss_family == AF_INET) { struct sockaddr_in *si = (struct sockaddr_in *)a; if (si->sin_addr.s_addr == 0) return i; } return 0; } int server_is_blacklisted(int i) { return (now-servers[i].status < blacklist_time); } int server_is_unavailable(int i) { return unused_server_slot(i) || server_is_blacklisted(i); } static int server_by_weight(void) { int best_server = NO_SERVER; int best_load = -1; int i, load; DEBUG(2, "server_by_weight()"); for (i = 0; i < nservers; i++) { if (server_is_unavailable(i)) continue; if (servers[i].weight == 0) continue; load = (WEIGHT_FACTOR*servers[i].c)/servers[i].weight; if (best_server == NO_SERVER || load < best_load) { DEBUG(2, "Server %d has load %d", i, load); best_load = load; best_server = i; } } DEBUG(2, "Least loaded server = %d", best_server); return best_server; } static int server_by_prio(void) { int best_server = NO_SERVER; int best_prio = -1; int i, prio; DEBUG(2, "server_by_prio()"); for (i = 0; i < nservers; i++) { if (server_is_unavailable(i)) continue; prio = servers[i].prio; if (best_server == NO_SERVER || prio < best_prio) { DEBUG(2, "Server %d has prio %d", i, prio); best_prio = prio; best_server = i; } } DEBUG(2, "Best prio server = %d", best_server); return best_server; } int server_by_roundrobin(void) { static int last_server = 0; int i = last_server; if (nservers == 0) return NO_SERVER; do { i = (i+1) % (nservers?nservers:1); DEBUG(3, "server_by_roundrobin considering server %d", i); if (!server_is_unavailable(i)) return (last_server = i); DEBUG(3, "server %d is unavailable, try next one", i); } while (i != last_server); return NO_SERVER; } /* Suggest a server for the initial field of the connection. Return NO_SERVER if none available. */ int initial_server(int conn) { int pd = match_acl(client_acl, &clients[conns[conn].client].addr); if (!pd) { DEBUG(1, "initial_server: denied by acl"); return abuse_server; /* returning abuse_server is correct even if it is not set because it defaults to NO_SERVER */ } if (!(server_alg & ALG_ROUNDROBIN)) { // Load balancing with memory == No roundrobin int server = clients[conns[conn].client].server; /* server may be NO_SERVER if this is a new client */ if (server != NO_SERVER && server != emerg_server && server != abuse_server) { DEBUG(2, "Will try previous server %d for client %d", server, conns[conn].client); return server; } } if (server_alg & ALG_PRIO) return server_by_prio(); if (server_alg & ALG_WEIGHT) return server_by_weight(); if (server_alg & ALG_HASH) return pen_hash(&clients[conns[conn].client].addr); return server_by_roundrobin(); } /* Returns 1 if a failover server candidate is available. Close connection and return 0 if none was found. */ int failover_server(int conn) { int server = conns[conn].server; DEBUG(2, "failover_server(%d): server = %d", conn, server); if (server_alg & ALG_STUBBORN) { DEBUG(2, "Won't failover because we are stubborn"); close_conn(conn); return 0; } if (server == ABUSE_SERVER) { DEBUG(2, "Won't failover from abuse server (%d)", abuse_server); close_conn(conn); return 0; } if (server == EMERGENCY_SERVER) { DEBUG(2, "Already using emergency server (%d), won't fail over", emerg_server); close_conn(conn); return 0; } if (conns[conn].upfd != -1) { close(conns[conn].upfd); conns[conn].upfd = -1; } /* there needs to be at least two regular servers in order to fail over to something else */ /* and if we couldn't find a candidate for initial_server, we're not going to find one now */ if (nservers > 1 && server != NO_SERVER) { DEBUG(2, "Trying to find failover server. server = %d, initial = %d, nservers = %d", server, conns[conn].initial, nservers); do { server = (server+1) % nservers; DEBUG(2, "Intend to try server %d", server); if (try_server(server, conn)) return 1; } while (server != conns[conn].initial); } DEBUG(1, "using emergency server, remember to reset flag"); emergency = 1; if (try_server(emerg_server, conn)) return 1; close_conn(conn); return 0; } /* Using os-specific, similar but incompatible techniques, attempt to be transparent by setting our local upstream address to the client's address */ static void spoof_bind(int server, int conn, int upfd) { #if defined(IP_TRANSPARENT) /* Linux */ #define SOL_TRANSPARENCY SOL_IP #define PEN_TRANSPARENCY IP_TRANSPARENT #elif defined(SO_BINDANY) /* OpenBSD */ #define SOL_TRANSPARENCY SOL_SOCKET #define PEN_TRANSPARENCY SO_BINDANY #elif defined(IP_BINDANY) /* FreeBSD */ #define SOL_TRANSPARENCY IPPROTO_IP #define PEN_TRANSPARENCY IP_BINDANY #else #undef PEN_TRANSPARENCY #endif #ifdef PEN_TRANSPARENCY int client = conns[conn].client; int n; int one = 1; struct sockaddr_storage *sss = &servers[server].addr; struct sockaddr_storage *css = &clients[client].addr; struct sockaddr_in *caddr, addr; DEBUG(1, "spoof_bind(server = %d, conn = %d, upfd = %d)", server, conn, upfd); DEBUG(1, "client = %d", client); if (sss->ss_family != AF_INET || css->ss_family != AF_INET) { DEBUG(1, "server family = %d", sss->ss_family); DEBUG(1, "client family = %d", css->ss_family); debug("No transparency for incompatible families"); return; } n = setsockopt(upfd, SOL_TRANSPARENCY, PEN_TRANSPARENCY, &one, sizeof one); if (n == -1) { DEBUG(1, "upfd = %d", upfd); debug("setsockopt: %s", strerror(errno)); return; } caddr = (struct sockaddr_in *)css; addr.sin_family = caddr->sin_family; addr.sin_port = 0; addr.sin_addr.s_addr = caddr->sin_addr.s_addr; n = bind(upfd, (struct sockaddr *)&addr, sizeof addr); if (n == -1) { DEBUG(1, "upfd = %d", upfd); debug("bind: %s", strerror(errno)); return; } #else debug("You are trying to be transparent, but it is not supported"); #endif } /* Initiate connection to server 'index' and populate upfd field in connection */ /* return 1 for (potential) success, 0 for failure */ int try_server(int index, int conn) { int upfd; int client = conns[conn].client; int n = 0, err; int optval = 1; struct sockaddr_storage *addr = &servers[index].addr; /* The idea is that a client should be able to connect again to the same server even if the server is close to its configured connection limit */ int sticky = ((client != -1) && (index == clients[client].server)); if (index == NO_SERVER) { DEBUG(2, "Won't try to connect to NO_SERVER"); return 0; /* out of bounds */ } DEBUG(2, "Trying server %d for connection %d at time %d", index, conn, now); if (pen_getport(addr) == 0) { DEBUG(1, "No port for you!"); return 0; } if (now-servers[index].status < blacklist_time) { DEBUG(1, "Server %d is blacklisted", index); return 0; } if (servers[index].maxc != 0 && (servers[index].c >= servers[index].maxc) && (sticky == 0 || servers[index].c >= servers[index].hard)) { DEBUG(1, "Server %d is overloaded: sticky=%d, maxc=%d, hard=%d", \ index, sticky, servers[index].maxc, servers[index].hard); return 0; } if ((client != -1) && !match_acl(servers[index].acl, &(clients[client].addr))) { DEBUG(1, "try_server: denied by acl"); return 0; } upfd = socket_nb(addr->ss_family, protoid, 0); if (keepalive) { setsockopt(upfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval, sizeof optval); } if (debuglevel > 1) { debug("Connecting to %s", pen_ntoa(addr)); pen_dumpaddr(addr); } conns[conn].t = now; if (transparent) spoof_bind(index, conn, upfd); n = connect(upfd, (struct sockaddr *)addr, pen_ss_size(addr)); err = socket_errno; DEBUG(2, "connect (upfd = %d) returns %d, errno = %d, socket_errno = %d", upfd, n, errno, err); /* A new complication is that we don't know yet if the connect will succeed. */ if (n == 0) { /* connection completed */ conns[conn].state = CS_CONNECTED; if (conns[conn].downfd == -1) { /* idler */ conns[conn].state |= CS_CLOSED_DOWN; } event_add(upfd, EVENT_READ); if (!udp) event_add(conns[conn].downfd, EVENT_READ); servers[index].c++; if (servers[index].status) { servers[index].status = 0; DEBUG(1, "Server %d ok", index); } DEBUG(2, "Successful connect to server %d\n" \ "conns[%d].client = %d\n" \ "conns[%d].server = %d", \ index, conn, conns[conn].client, conn, conns[conn].server); } else if (err == CONNECT_IN_PROGRESS) { /* may potentially succeed */ conns[conn].state = CS_IN_PROGRESS; pending_list = dlist_insert(pending_list, conn); conns[conn].pend = pending_list; pending_queue++; event_add(upfd, EVENT_WRITE); DEBUG(2, "Pending connect to server %d\n" \ "conns[%d].client = %d\n" \ "conns[%d].server = %d", \ index, conn, conns[conn].client, conn, conns[conn].server); } else { /* failed definitely */ if (servers[index].status == 0) { debug("Server %d failed, retry in %d sec: %d", index, blacklist_time, socket_errno); } debug("blacklisting server %d because connect error %d", index, err); blacklist_server(index); close(upfd); return 0; } conns[conn].server = index; DEBUG(2, "Setting server %d for client %d", index, client); clients[client].server = index; current = index; conns[conn].upfd = upfd; fd2conn_set(upfd, conn); return 1; } /* we want size server slots plus two for abuse and emergency */ void expand_servertable(int size) { static server *server_storage = NULL; static int real_size = 0; int new_size = size+2; /* for emergency and abuse servers */ if (new_size <= real_size) return; /* nothing to expand here */ server_storage = pen_realloc(server_storage, new_size*sizeof *server_storage); memset(&server_storage[real_size], 0, (new_size-real_size)*sizeof server_storage[0]); servers = &server_storage[2]; /* making server[0] the first regular server */ real_size = new_size; if (size > nservers) nservers = size; } pen-0.32.0/configure0000755000175000017500000055731612624554543011241 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for pen 0.32.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pen' PACKAGE_TARNAME='pen' PACKAGE_VERSION='0.32.0' PACKAGE_STRING='pen 0.32.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="pen.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS EGREP GREP CPP LN_S am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_profiling enable_debugging with_daemon with_poll with_epoll with_kqueue with_fd_setsize with_ssl with_geoip with_dsr with_docdir ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures pen 0.32.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/pen] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of pen 0.32.0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-profiling enable profiling --enable-debugging enable debugging messages Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-daemon use daemon() if available --with-poll use poll() if available --with-epoll use epoll if available --with-kqueue use kqueue() if available --with-fd_setsize=N set FD_SETSIZE to N (see INSTALL) --with-ssl use SSL (default /usr/local/ssl) --with-geoip use libgeoip --with-dsr enable direct server return --with-docdir=DIR install docs in DIR [PREFIX/doc/pen] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF pen configure 0.32.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by pen $as_me 0.32.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" am__api_version='1.14' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='pen' VERSION='0.32.0' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if ${ac_cv_search_strerror+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char strerror (); int main () { return strerror (); ; return 0; } _ACEOF for ac_lib in '' cposix; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_strerror=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_strerror+:} false; then : break fi done if ${ac_cv_search_strerror+:} false; then : else ac_cv_search_strerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5 $as_echo "$ac_cv_search_strerror" >&6; } ac_res=$ac_cv_search_strerror if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocket" >&5 $as_echo_n "checking for main in -lsocket... " >&6; } if ${ac_cv_lib_socket_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_main=yes else ac_cv_lib_socket_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_main" >&5 $as_echo "$ac_cv_lib_socket_main" >&6; } if test "x$ac_cv_lib_socket_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5 $as_echo_n "checking for main in -lnsl... " >&6; } if ${ac_cv_lib_nsl_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_main=yes else ac_cv_lib_nsl_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_main" >&5 $as_echo "$ac_cv_lib_nsl_main" >&6; } if test "x$ac_cv_lib_nsl_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton in -lresolv" >&5 $as_echo_n "checking for inet_aton in -lresolv... " >&6; } if ${ac_cv_lib_resolv_inet_aton+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lresolv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char inet_aton (); int main () { return inet_aton (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_resolv_inet_aton=yes else ac_cv_lib_resolv_inet_aton=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_inet_aton" >&5 $as_echo "$ac_cv_lib_resolv_inet_aton" >&6; } if test "x$ac_cv_lib_resolv_inet_aton" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRESOLV 1 _ACEOF LIBS="-lresolv $LIBS" fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } if eval \${$as_ac_Header+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_ac_Header=yes" else eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/types.h defines makedev" >&5 $as_echo_n "checking whether sys/types.h defines makedev... " >&6; } if ${ac_cv_header_sys_types_h_makedev+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { return makedev(0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_header_sys_types_h_makedev=yes else ac_cv_header_sys_types_h_makedev=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_types_h_makedev" >&5 $as_echo "$ac_cv_header_sys_types_h_makedev" >&6; } if test $ac_cv_header_sys_types_h_makedev = no; then ac_fn_c_check_header_mongrel "$LINENO" "sys/mkdev.h" "ac_cv_header_sys_mkdev_h" "$ac_includes_default" if test "x$ac_cv_header_sys_mkdev_h" = xyes; then : $as_echo "#define MAJOR_IN_MKDEV 1" >>confdefs.h fi if test $ac_cv_header_sys_mkdev_h = no; then ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default" if test "x$ac_cv_header_sys_sysmacros_h" = xyes; then : $as_echo "#define MAJOR_IN_SYSMACROS 1" >>confdefs.h fi fi fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm tm; int *p = &tm.tm_sec; return !p; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_tm=time.h else ac_cv_struct_tm=sys/time.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi if test "$GCC" = "yes"; then CFLAGS="-Wall $CFLAGS" fi ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" if test "x$ac_cv_func_getaddrinfo" = xyes; then : $as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "accept4" "ac_cv_func_accept4" if test "x$ac_cv_func_accept4" = xyes; then : $as_echo "#define HAVE_ACCEPT4 1" >>confdefs.h fi for ac_header in sys/select.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/select.h" "ac_cv_header_sys_select_h" "$ac_includes_default" if test "x$ac_cv_header_sys_select_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SELECT_H 1 _ACEOF fi done # Check whether --enable-profiling was given. if test "${enable_profiling+set}" = set; then : enableval=$enable_profiling; if test "$withval" != "no"; then CFLAGS="$CFLAGS -pg" fi fi # Check whether --enable-debugging was given. if test "${enable_debugging+set}" = set; then : enableval=$enable_debugging; fi if test "$enable_debugging" != "no"; then : CFLAGS="$CFLAGS -DDEBUGGING" fi # Check whether --with-daemon was given. if test "${with_daemon+set}" = set; then : withval=$with_daemon; if test "$withval" != "no"; then ac_fn_c_check_func "$LINENO" "daemon" "ac_cv_func_daemon" if test "x$ac_cv_func_daemon" = xyes; then : $as_echo "#define HAVE_DAEMON 1" >>confdefs.h fi fi fi # Check whether --with-poll was given. if test "${with_poll+set}" = set; then : withval=$with_poll; fi if test "$with_poll" != "no"; then : ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll" if test "x$ac_cv_func_poll" = xyes; then : $as_echo "#define HAVE_POLL 1" >>confdefs.h fi fi # Check whether --with-epoll was given. if test "${with_epoll+set}" = set; then : withval=$with_epoll; fi if test "$with_epoll" != "no"; then : ac_fn_c_check_func "$LINENO" "epoll_create1" "ac_cv_func_epoll_create1" if test "x$ac_cv_func_epoll_create1" = xyes; then : $as_echo "#define HAVE_EPOLL 1" >>confdefs.h fi fi # Check whether --with-kqueue was given. if test "${with_kqueue+set}" = set; then : withval=$with_kqueue; fi if test "$with_kqueue" != "no"; then : ac_fn_c_check_func "$LINENO" "kqueue" "ac_cv_func_kqueue" if test "x$ac_cv_func_kqueue" = xyes; then : $as_echo "#define HAVE_KQUEUE 1" >>confdefs.h fi fi # Check whether --with-fd_setsize was given. if test "${with_fd_setsize+set}" = set; then : withval=$with_fd_setsize; if test "$withval" != "no"; then cat >>confdefs.h <<_ACEOF #define FD_SETSIZE $withval _ACEOF fi fi # Check whether --with-ssl was given. if test "${with_ssl+set}" = set; then : withval=$with_ssl; fi if test "$with_ssl" != "no"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lcrypto" >&5 $as_echo_n "checking for main in -lcrypto... " >&6; } if ${ac_cv_lib_crypto_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypto_main=yes else ac_cv_lib_crypto_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_main" >&5 $as_echo "$ac_cv_lib_crypto_main" >&6; } if test "x$ac_cv_lib_crypto_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCRYPTO 1 _ACEOF LIBS="-lcrypto $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lssl" >&5 $as_echo_n "checking for main in -lssl... " >&6; } if ${ac_cv_lib_ssl_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lssl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ssl_main=yes else ac_cv_lib_ssl_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_main" >&5 $as_echo "$ac_cv_lib_ssl_main" >&6; } if test "x$ac_cv_lib_ssl_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSSL 1 _ACEOF LIBS="-lssl $LIBS" fi fi ac_fn_c_check_func "$LINENO" "EC_KEY_new_by_curve_name" "ac_cv_func_EC_KEY_new_by_curve_name" if test "x$ac_cv_func_EC_KEY_new_by_curve_name" = xyes; then : $as_echo "#define HAVE_EC_KEY 1" >>confdefs.h fi # Check whether --with-geoip was given. if test "${with_geoip+set}" = set; then : withval=$with_geoip; fi if test "$with_geoip" != "no"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GeoIP_country_code_by_addr in -lGeoIP" >&5 $as_echo_n "checking for GeoIP_country_code_by_addr in -lGeoIP... " >&6; } if ${ac_cv_lib_GeoIP_GeoIP_country_code_by_addr+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lGeoIP $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char GeoIP_country_code_by_addr (); int main () { return GeoIP_country_code_by_addr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_GeoIP_GeoIP_country_code_by_addr=yes else ac_cv_lib_GeoIP_GeoIP_country_code_by_addr=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_GeoIP_GeoIP_country_code_by_addr" >&5 $as_echo "$ac_cv_lib_GeoIP_GeoIP_country_code_by_addr" >&6; } if test "x$ac_cv_lib_GeoIP_GeoIP_country_code_by_addr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGEOIP 1 _ACEOF LIBS="-lGeoIP $LIBS" fi fi # Check whether --with-dsr was given. if test "${with_dsr+set}" = set; then : withval=$with_dsr; fi if test "$with_dsr" != "no"; then : for ac_header in linux/if_packet.h do : ac_fn_c_check_header_mongrel "$LINENO" "linux/if_packet.h" "ac_cv_header_linux_if_packet_h" "$ac_includes_default" if test "x$ac_cv_header_linux_if_packet_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_IF_PACKET_H 1 _ACEOF fi done for ac_header in net/netmap_user.h do : ac_fn_c_check_header_mongrel "$LINENO" "net/netmap_user.h" "ac_cv_header_net_netmap_user_h" "$ac_includes_default" if test "x$ac_cv_header_net_netmap_user_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NET_NETMAP_USER_H 1 _ACEOF fi done fi docdir='${prefix}/doc/pen' # Check whether --with-docdir was given. if test "${with_docdir+set}" = set; then : withval=$with_docdir; if test "$withval" != "yes" && test "$withval" != "no"; then docdir=$withval fi fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by pen $as_me 0.32.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ pen config.status 0.32.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi pen-0.32.0/aclocal.m40000644000175000017500000012166112624554542011157 00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR pen-0.32.0/pen.10000644000175000017500000001660412621052015010144 00000000000000.TH PEN 1 LOCAL .SH NAME pen - Load balancer for udp and tcp based protocols .SH SYNOPSIS .B pen .na [-b sec] [-c N] [-e host:port] [-t sec] [-x N] [-j dir] [-u user] [-F cfgfile] [-l logfile] [-p file ] [-w file] [-C port|/path/to/socket] [-T sec] [-UHWXadfhrs] [-o option] [-E certfile] [-K keyfile] [-G cacertfile] [-A cacertdir] [-Z] [-R] [-L protocol] [host:]port|/path/to/socket h1[:p1[:maxc1[:hard1[:weight1[:prio1]]]]] [h2[:p2[:maxc2[:hard2[:weight2[:prio2]]]]]] ... .ad Windows only: .B pen -i service_name .B pen -u service_name .SH EXAMPLE pen 80 www1:8000:10 www2:80:10 www3 Here three servers cooperate in a web server farm. Host www1 runs its web server on port 8000 and accepts a maximum of 10 simultaneous connections. Host www2 runs on port 80 and accepts 10 connections. Finally, www3 runs its web server on port 80 and allows an unlimited number of simultaneous connections. .SH DESCRIPTION .I Pen is a load balancer for tcp based protocols such as http or smtp. It allows several servers to appear as one to the outside and automatically detects servers that are down and distributes clients among the available servers. This gives high availability and scalable performance. The load balancing algorithm keeps track of clients and will try to send them back to the server they visited the last time. The client table has a number of slots (default 2048, settable through command-line arguments). When the table is full, the least recently used one will be thrown out to make room for the new one. This is superior to a simple round-robin algorithm, which sends a client that connects repeatedly to different servers. Doing so breaks applications that maintain state between connections in the server, including most modern web applications. When pen detects that a server is unavailable, it scans for another starting with the server after the most recently used one. That way we get load balancing and "fair" failover for free. Correctly configured, pen can ensure that a server farm is always available, even when individual servers are brought down for maintenance or reconfiguration. The final single point of failure, pen itself, can be eliminated by running pen on several servers, using vrrp to decide which is active. Sending pen a USR1 signal will make it print some useful statistics on stderr, even if debugging is disabled. If pen is running in the background (i.e. without the -f option), syslog is used rather than stderr. If the -w option is used, the statistics is saved in HTML format in the given file. Sending pen a HUP signal will make it close and reopen the logfile, if logging is enabled, and reload the configuration file. Rotate the log like this (assuming pen.log is the name of the logfile): mv pen.log pen.log.1 kill -HUP `cat ` where is the file containing pen's process id, as written by the -p option. Sending pen a TERM signal will make it exit cleanly, closing the log file and all open sockets. .SH OPTIONS .TP -C \fIport|/path/to/socket\fR Specifies a control port where the load balancer listens for commands. See penctl.1 for a list of the commands available. The protocol is unauthenticated and the administrator is expected to restrict access using an access control list (for connections over a network) or Unix file permissions (for a Unix domain socket). Pen will normally refuse to open the control port if running as root; see -u option. If you still insist that you want to run pen as root with a control port, use "-u root". .TP -F \fIcfgfile\fR Names a configuration file with commands in penctl format (see penctl.1). The file is read after processing all command line arguments, and also after receiving a HUP signal. .TP -H Adds X-Forwarded-For header to http requests. .TP -U Use udp protocol support .TP -O command Allows most penctl commands to be used on the Pen command line. .TP -P Use poll() for event notification. .TP -Q Use kqueue() for event notification (BSD). .TP -W Use weight for server selection. .TP -X Adds an exit command to the control interface. .TP -a Used in conjunction with -dd to get communication dumps in ascii rather than hexadecimal format. .TP -b \fIsec\fR Servers that do not respond are blacklisted, i.e. excluded from the server selection algorithm, for the specified number of seconds (default 30). .TP -T \fIsec\fR Clients are tracked for the specified number of seconds so they can be sent to the same server as the last time (default 0 = never expire clients). .TP -c \fIN\fR Max number of clients (default 2048). .TP -d Debugging (repeat -d for more). The output goes to stderr if we are running in the foreground (see -f) and to syslog (facility user, priority debug) otherwise. .TP -e \fIhost:port\fR host:port specifies the emergency server to contact if all regular servers become unavailable. .TP -f Stay in foreground. .TP -h Use a hash on the client IP address for the initial server selection. This makes it more predictable where clients will be connected. .TP -i \fIservice_name\fR Windows only. Install pen as a service. .TP -j \fIdir\fR Run in a chroot environment. .TP -l \fIfile\fR Turn on logging. .TP -m \fImulti_accept\fR Accept up to \fImulti_accept\fR incoming connections at a time. .TP -p \fIfile\fR Write the pid of the running daemon to \fIfile\fR. .TP -q \fIbacklog\fR Allow the queue of pending incoming connections to grow up to a maximum of \fIbacklog\fR entries. .TP -r Go straight into round-robin server selection without looking up which server a client used the last time. .TP -s Stubborn server selection: if the initial choice is unavailable, the client connection is closed without trying another server. .TP -t \fIsec\fR Connect timeout in seconds (default 5). .TP -u \fIuser\fR Posix only. Run as a different user. .TP -u \fIservice_name\fR Windows only. Uninstall the service. .TP -x \fIN\fR Max number of simultaneous connections (default 500). .TP -w \fIfile\fR File for status reports in HTML format. .TP -o \fIoption\fR Use option in penctl format. .TP -E \fIcertfile\fR Use the given certificate in PEM format. .TP -K \fIkeyfile\fR Use the given key in PEM format (may be contained in cert). .TP -G \fIcacertfile\fR File containing the CA's certificate. .TP -A \fIcacertdir\fR Directory containing CA certificates in hashed format. .TP -Z Use SSL compatibility mode. .TP -R Require valid peer certificate. .TP -L \fIprotocol\fR ssl23 (default), ssl3 or tls1. .TP [host:]port OR /path/to/socket The local address and port pen listens to. By default pen listens to all local addresses. Pen can also use a Unix domain socket as the local listening address. .TP h1:p1:soft:hard:weight:prio The address, port and maximum number of simultaneous connections for a remote server. By default, the port is the same as the local port, and the soft limit on the number of connections is unlimited. The hard limit is used for clients which have accessed the server before. The weight and prio are used for the weight- and priority-based server selection algorithms. .SH LIMITATIONS Pen runs in a single process, and opens two sockets for each connection. Depending on kernel configuration, pen can run out of file descriptors. SSL support is available if pen was built with the --with-ssl option. GeoIP support is available if pen was built with the --with-geoip option. .SH SEE ALSO penctl(1), dwatch(1), mergelogs(1), webresolve(1) .SH AUTHOR Copyright (C) 2001-2015 Ulric Eriksson, . .SH ACKNOWLEDGEMENTS In part inspired by balance by Thomas Obermair. pen-0.32.0/AUTHORS0000644000175000017500000000011412507562420010346 00000000000000Ulric Eriksson UDP support contributed by the Zen project. pen-0.32.0/dlist.h0000644000175000017500000000030212507562420010565 00000000000000/* dlist.c */ extern int dlist_insert(int, int); extern int dlist_remove(int); extern void dlist_free(int); extern int dlist_next(int); extern int dlist_value(int); extern void dlist_init(int); pen-0.32.0/Makefile.win0000644000175000017500000000127012526327460011542 00000000000000CFLAGS=-Wall -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ggdb -DWINDOWS -D_WIN32_WINNT=0x0600 -DDEBUGGING OBJ=pen.o select.o poll.o kqueue.o epoll.o dlist.o ssl.o dsr.o memory.o diag.o settings.o acl.o event.o netconv.o server.o client.o conn.o idlers.o windows.o LIB=-lws2_32 -lpsapi -lole32 -loleaut32 -luuid all: cp config.h.win config.h $(MAKE) -C X86 pen32.exe $(MAKE) -C X64 pen64.exe pen32.exe: $(OBJ) $(CC) -o pen32.exe $(OBJ) $(LIB) pen64.exe: $(OBJ) $(CC) -o pen64.exe $(OBJ) $(LIB) pen.o: pen.c select.o: select.c poll.o: poll.c kqueue.o: kqueue.c epoll.o: epoll.c windows.o: windows.c dlist.o: dlist.c $(OBJ): pen.h config.h clean: rm -f X86/*.o X64/*.o pen-0.32.0/diag.h0000644000175000017500000000114012516364761010363 00000000000000#include #ifdef DEBUGGING #define DEBUG(lvl, ...) \ if (debuglevel >= lvl) { \ debug(__VA_ARGS__); \ } #define DEBUG_ERRNO(lvl, ...) \ if (debuglevel >= lvl) { \ err = socket_errno; \ debug(__VA_ARGS__); \ } #define SPAM \ if (debuglevel >= 2) \ debug("File %s, line %d, function %s", \ __FILE__, __LINE__, __func__); #else #define DEBUG(lvl, ...) #define DEBUG_ERRNO(lvl, ...) #define SPAM #endif #ifdef WINDOWS #define socket_errno WSAGetLastError() #else #define socket_errno errno #endif extern int debuglevel; extern void debug(char *, ...); extern void error(char *, ...); pen-0.32.0/pen_epoll.h0000644000175000017500000000003612514666022011430 00000000000000extern void epoll_init(void); pen-0.32.0/memory.c0000644000175000017500000000110012514661127010750 00000000000000#include #include #include "diag.h" void *pen_malloc(size_t n) { void *q = malloc(n); if (!q) error("Can't malloc %ld bytes", (long)n); return q; } void *pen_calloc(size_t n, size_t s) { void *q = calloc(n, s); if (!q) error("Can't calloc %ld bytes", (long)n*s); return q; } void *pen_realloc(void *p, size_t n) { void *q = realloc(p, n); if (!q) error("Can't realloc %ld bytes", (long)n); return q; } char *pen_strdup(const char *p) { size_t len = strlen(p); char *b = pen_malloc(len+1); memcpy(b, p, len); b[len] = '\0'; return b; } pen-0.32.0/windows.h0000644000175000017500000000274012526327460011154 00000000000000#ifdef WINDOWS #include #include #define SHUT_WR SD_SEND /* for shutdown */ #define LOG_CONS 0 #define LOG_USER 0 #define LOG_ERR 0 #define LOG_DEBUG 0 #define CONNECT_IN_PROGRESS (WSAEWOULDBLOCK) #define WOULD_BLOCK(err) (err == WSAEWOULDBLOCK) #define SIGHUP 0 #define SIGUSR1 0 #define SIGPIPE 0 #define SIGCHLD 0 #ifndef ENOTCONN #define ENOTCONN WSAENOTCONN #endif typedef int sigset_t; typedef int siginfo_t; struct sigaction { void (*sa_handler)(int); void (*sa_sigaction)(int, siginfo_t *, void *); sigset_t sa_mask; int sa_flags; void (*sa_restorer)(void); }; typedef int rlim_t; struct rlimit { rlim_t rlim_cur; rlim_t rlim_max; }; #define RLIMIT_CORE 0 typedef int uid_t; typedef int gid_t; struct passwd { uid_t pw_uid; gid_t pw_gid; }; extern int delete_service(char *); extern int install_service(char *); extern int service_main(int, char **); /* misc kludges */ extern int sigaction(int, const struct sigaction *, struct sigaction *); extern uid_t getuid(void); extern int inet_aton(const char *, struct in_addr *addr); #if 0 extern const char *inet_ntop(int, const void *, char *, socklen_t); #endif extern void make_nonblocking(int); extern int start_winsock(void); #if 0 /* stuff that exists in Windows that MinGW doesn't know about */ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); int inet_pton(int af, const char *src, void *dst); #endif #endif /* WINDOWS */ pen-0.32.0/penlog.10000644000175000017500000000136712527416571010666 00000000000000.TH PENLOG 1 LOCAL .SH NAME penlog - pipe Apache logs to penlogd .SH SYNOPSIS .B penlog server_ip server_port [my_ip] .SH EXAMPLE penlog lbhost:10000 .SH DESCRIPTION .I Penlog reads webserver log entries from stdin and sends them using UDP to penlogd. It is intended for Apache's "reliable piped logs". To use penlog from Apache, add a command like this to the web server's httpd.conf: CustomLog "|/usr/local/bin/penlog somehost 10000" common The optional third argument is used if the server has several addresses. Penlogd uses the source address to identify the server, and it must be identical to the address configured in the command line to Pen. .SH SEE ALSO pen(1), penlogd(1) .SH AUTHOR Copyright (C) 2002-2015 Ulric Eriksson, . pen-0.32.0/INSTALL0000644000175000017500000002642212521654064010343 00000000000000 Installing Pen ============== Option 1. Installing from a source tarball To compile and install using all defaults, type: ./configure make make install See also https://github.com/UlricE/pen/wiki/Building-Pen-from-Source Option 2. Installing from Git ./bootstrap.sh ./configure make make install See also https://github.com/UlricE/pen/wiki/Building-Pen-from-Git Options ------- TL;DR: ./configure without options is usually sufficient to figure out what is available and use the best combination. Most of the "generic" options are verbosely described below. Options that are specific to Pen include: --enable-profiling enable profiling Enable profiling with gprof. Most people have no interest in this. Disabled by default. --enable-debugging enable debugging messages With this enabled, more detailed diagnostics are built into Pen. Most people should have an interest in this, should something go wrong. Enabled by default. --with-geoip use libgeoip Build Pen with support for the GeoIP library. This provides access control lists that use country codes to permit or deny access. Built by default if available. --with-ssl=DIR use SSL (default /usr/local/ssl) Build Pen with SSL support. Built by default if available. --with-daemon use daemon() if available The --with-daemon option specifies how Pen puts itself in the background. Some operating systems have a function called daemon() which does this; with this option, the function will be used. Built by default if available. --with-poll use poll() if available Normally Pen uses the best available function to get notification when a socket is ready for reading or writing. On *BSD that is kqueue; on Linux it is epoll; on other Unix it is poll; on Windows it is select. This option enables using the poll() function. Built by default if available. --with-kqueue use kqueue() if available The kqueue interface for event notification is available on *bsd and offers better performance than either select() or poll(). Used by default if available. --with-epoll use epoll if available The epoll interface serves the same purpose on Linux as kqueue on BSD and is used by default if available. --with-fd_setsize=N set FD_SETSIZE to N (This is only relevant if you use select() as the event notification mechanism. You will probably use something else, except on Windows where only select() is available. If not on Windows, consider this section irrelevant.) To use Pen with a very large number of simultaneous connections, the preprocessing macro FD_SETSIZE must be increased. The default value varies between operating systems, as does the maximum supported. Pen will try to catch attempts to run out of spec. The select() used by Linux is broken in this respect, and doesn't allow FD_SETSIZE to be changed from the default. The solution is to not use Linux, or to change the #defines in the relevant include files: and . Look for lines like this: #define __FD_SETSIZE 1024 and change them to what you really want, such as: #define __FD_SETSIZE 16384 You probably want to change them back afterwards. The resulting max number of simultaneous connections will be: (FD_SETSIZE-10)/2 10 is for stdin, stdout, stderr "and then some". 2 is because each connection uses two file descriptors. The default FD_SETSIZE on Windows is very low, only 64. Fortunately, this value isn't cast in stone like it is on Linux. Just do: ./configure --with-fd_setsize=1024 This will allow 507 simultaneous connections. --------------------------------------------------------------------- Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. pen-0.32.0/X86/0000755000175000017500000000000012624555212007750 500000000000000pen-0.32.0/X86/Makefile0000644000175000017500000000007712507562420011333 00000000000000 VPATH=.. CC=i686-w64-mingw32-gcc -m32 include ../Makefile.win pen-0.32.0/dlist.c0000644000175000017500000000457312570064223010574 00000000000000#include #include "memory.h" /* circular doubly linked lists, used for pending and closing connections */ struct node { int value; /* index into connection table */ int prev; /* back pointer */ int next; /* forward pointer */ }; static struct node *nodes; static int nodes_max; /* This finishes in almost-constant time if there are plenty of free nodes */ static int alloc_node(void) { static int last_node = 0; int start = last_node; do { if (nodes[last_node].value == -1) return last_node; last_node = (last_node+1)%nodes_max; } while (last_node != start); return -1; /* all nodes used */ } /* Insert value into a new node. Return the resulting list. */ int dlist_insert(int list, int value) { int new_node = alloc_node(); if (new_node == -1) return -1; if (list == -1) { /* empty */ nodes[new_node].prev = new_node; nodes[new_node].next = new_node; } else { int prev = nodes[list].prev; nodes[prev].next = new_node; nodes[new_node].prev = prev; nodes[new_node].next = list; nodes[list].prev = new_node; } nodes[new_node].value = value; return new_node; } /* Remove a node from its list. Return the resulting list. */ int dlist_remove(int node) { int prev, next; if (node == -1) return -1; nodes[node].value = -1; /* mark as unused */ if (nodes[node].next == node) { /* last node */ return -1; /* empty list */ } prev = nodes[node].prev; next = nodes[node].next; nodes[prev].next = next; nodes[next].prev = prev; return next; } /* Free an entire list by marking all nodes as unused. */ void dlist_free(int list) { int start = list; if (list == -1) return; do { nodes[list].value = -1; list = (list+1)%nodes_max; } while (list != start); } /* Return next node in the list. Valid even for freed nodes. */ int dlist_next(int node) { return nodes[node].next; } int dlist_value(int node) { return nodes[node].value; } /* Allocate enough nodes for all the doubly linked lists we'll ever need. */ void dlist_init(int size) { int i; nodes_max = size; nodes = pen_malloc(nodes_max * sizeof *nodes); for (i = 0; i < size; i++) { nodes[i].value = -1; /* unused */ } } pen-0.32.0/pen.c0000644000175000017500000020022612622545152010233 00000000000000/* Copyright (C) 2000-2015 Ulric Eriksson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" #include #include #include #include #include #include #ifndef WINDOWS #include #include #include #include #include #include #include #include #include #include #endif #include #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #include #include #include #include #include "ssl.h" #include "pen.h" #include "acl.h" #include "client.h" #include "conn.h" #include "diag.h" #include "dlist.h" #include "dsr.h" #include "event.h" #include "idlers.h" #include "memory.h" #include "netconv.h" #include "pen_epoll.h" #include "pen_kqueue.h" #include "pen_poll.h" #include "pen_select.h" #include "server.h" #include "settings.h" #include "windows.h" #define BUFFER_MAX (32*1024) #define KEEP_MAX 100 /* how much to keep from the URI */ #define DUMMY_MSG "Ulric was here." static int dummy = 0; /* use pen as a test target */ time_t now; static int tcp_nodelay = 0; static int listen_queue = CONNECTIONS_MAX; static int asciidump; static int loopflag; static int exit_enabled = 0; static int hupcounter = 0; #ifndef WINDOWS static int stats_flag = 0; static int restart_log_flag = 0; #endif static int http = 0; static char *cfgfile = NULL; static char *logfile = NULL; static FILE *logfp = NULL; static struct sockaddr_in logserver; static int logsock = -1; static char *pidfile = NULL; static FILE *pidfp = NULL; static char *webfile = NULL; static char listenport[1000]; static int port; static int control_acl; static char *ctrlport = NULL; int listenfd; static int ctrlfd = -1; static char *jail = NULL; static char *user = NULL; static char *proto = "tcp"; static char *dsr_if, *dsr_ip; #ifdef WINDOWS /* because Windows scribbles over errno in an uncalled-for manner */ static int saved_errno; #define SAVE_ERRNO (saved_errno = socket_errno) #define USE_ERRNO (saved_errno) #else /* not windows */ #define WOULD_BLOCK(err) (err == EAGAIN || err == EWOULDBLOCK) #ifndef HAVE_ACCEPT4 static void make_nonblocking(int fd) { int fl; DEBUG(2, "make_nonblocking(%d)", fd); if ((fl = fcntl(fd, F_GETFL, 0)) == -1) error("Can't fcntl, errno = %d", errno); if (fl & O_NONBLOCK) { DEBUG(3, "fd %d is already nonblocking", fd); } else { DEBUG(4, "fd %d is not nonblocking", fd); if (fcntl(fd, F_SETFL, fl | O_NONBLOCK) == -1) { error("Can't fcntl, errno = %d", errno); } } } #endif #define SAVE_ERRNO #define USE_ERRNO (socket_errno) #endif /* enable/disable with "tcp_nodelay/no tcp_nodelay" */ static void tcp_nodelay_on(int s) { #ifdef TCP_NODELAY int one = 1; int n = setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&one, sizeof one); DEBUG(2, "setsockopt(%d, %d, %d, %p, %d) returns %d", s, IPPROTO_TCP, TCP_NODELAY, &one, sizeof one, n); #else debug("You don't have TCP_NODELAY"); #endif } /* save a few syscalls for modern Linux and BSD */ int socket_nb(int domain, int type, int protocol) { #ifdef SOCK_NONBLOCK int s = socket(domain, type|SOCK_NONBLOCK, protocol); SAVE_ERRNO; DEBUG(2, "socket returns %d, socket_errno=%d", s, USE_ERRNO); if (s == -1) error("Error opening socket: %s", strerror(USE_ERRNO)); #else int s = socket(domain, type, protocol); SAVE_ERRNO; DEBUG(2, "socket returns %d, socket_errno=%d", s, USE_ERRNO); if (s == -1) error("Error opening socket: %s", strerror(USE_ERRNO)); make_nonblocking(s); #endif if (tcp_nodelay) tcp_nodelay_on(s); return s; } /* and a few more */ extern int accept4(int, struct sockaddr *, socklen_t *, int); static int accept_nb(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { #ifdef HAVE_ACCEPT4 return accept4(sockfd, addr, addrlen, SOCK_NONBLOCK); #else int s = accept(sockfd, addr, addrlen); if (s != -1) make_nonblocking(sockfd); return s; #endif if (tcp_nodelay) tcp_nodelay_on(sockfd); } #ifndef WINDOWS static struct sigaction alrmaction, hupaction, termaction, usr1action, usr2action; #endif static int pen_strncasecmp(const char *p, const char *q, size_t n) { size_t i = 0; int c = 0; while ((i < n) && !(c = toupper((unsigned char)*p)-toupper((unsigned char)*q)) && *p) { p++; q++; i++; } return c; } static char *pen_strcasestr(const char *haystack, const char *needle) { char *p = (char *)haystack; int n = strlen(needle); while (*p) { if (!pen_strncasecmp(p, needle, n)) return p; p++; } return NULL; } static int webstats(void) { FILE *fp; int i; time_t now; struct tm *nowtm; char nowstr[80]; if (webfile == NULL) { debug("Don't know where to write web stats; see -w option"); return 0; } fp = fopen(webfile, "w"); if (fp == NULL) { debug("Can't write to %s", webfile); return 0; } now=time(NULL); nowtm = localtime(&now); strftime(nowstr, sizeof(nowstr), "%Y-%m-%d %H:%M:%S", nowtm); fprintf(fp, "\n" "\n" "Pen status page\n" "\n" "" "

Pen status page

\n"); fprintf(fp, "Time %s, %d servers, %d current

\n", nowstr, nservers, current); fprintf(fp, "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n"); for (i = 0; i < nservers; i++) { fprintf(fp, "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n", i, pen_ntoa(&servers[i].addr), servers[i].status, pen_getport(&servers[i].addr), servers[i].c, servers[i].maxc, servers[i].hard, servers[i].sx, servers[i].rx, servers[i].weight, servers[i].prio); } fprintf(fp, "
serveraddressstatusportconnectionsmax softmax hardsentreceivedweightprio
%d%s%d%d%d%d%d%" PRIu64 "%" PRIu64 "%d%d
\n"); fprintf(fp, "

Active clients

"); fprintf(fp, "Max number of clients: %d

", clients_max); fprintf(fp, "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n"); for (i = 0; i < clients_max; i++) { if (clients[i].last == 0) continue; fprintf(fp, "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n", i, pen_ntoa(&clients[i].addr), (long)(now-clients[i].last), clients[i].server, clients[i].connects, clients[i].csx, clients[i].crx); } fprintf(fp, "
clientaddressage(secs)last serverconnectssentreceived
%d%s%ld%d%ld%" PRIu64 "%" PRIu64 "
\n"); fprintf(fp, "

Active connections

"); fprintf(fp, "Number of connections: %d max, %d used, %d last

", connections_max, connections_used, connections_last); fprintf(fp, "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n"); for (i = 0; i < connections_max; i++) { if (conns[i].downfd == -1) continue; fprintf(fp, "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n", i, conns[i].downfd, conns[i].upfd, conns[i].downn, conns[i].upn, conns[i].client, conns[i].server); } fprintf(fp, "
connectiondownfdupfdpending data downpending data upclientserver
%d%d%d%d%d%d%d
\n"); fprintf(fp, "\n" "\n"); fclose(fp); return 1; } #ifndef WINDOWS static void textstats(void) { int i; time_t now; struct tm *nowtm; char nowstr[80]; now=time(NULL); nowtm = localtime(&now); strftime(nowstr, sizeof(nowstr), "%Y-%m-%d %H:%M:%S", nowtm); debug("Time %s, %d servers, %d current", nowstr, nservers, current); for (i = 0; i < nservers; i++) { debug("Server %d status:\n" "address %s\n" "%d\n" "port %d\n" "%d connections (%d soft, %d hard)\n" "%llu sent, %llu received\n", i, pen_ntoa(&servers[i].addr), servers[i].status, pen_getport(&servers[i].addr), servers[i].c, servers[i].maxc, servers[i].hard, servers[i].sx, servers[i].rx); } debug("Max number of clients: %d", clients_max); debug("Active clients:"); for (i = 0; i < clients_max; i++) { if (clients[i].last == 0) continue; debug("Client %d status:\n" "address %s\n" "last used %ld\n" "last server %d\n", "connects %ld\n", "sent %llu\n", "received %llu\n", i, pen_ntoa(&clients[i].addr), (long)(now-clients[i].last), clients[i].server, clients[i].connects, clients[i].csx, clients[i].crx); } debug("Max number of connections: %d", connections_max); debug("Active connections:"); for (i = 0; i < connections_max; i++) { if (conns[i].downfd == -1) continue; debug("Connection %d status:\n" "downfd = %d, upfd = %d\n" "pending data %d down, %d up\n" "client %d, server %d\n", i, conns[i].downfd, conns[i].upfd, conns[i].downn, conns[i].upn, conns[i].client, conns[i].server); } } static void stats(int dummy) { DEBUG(1, "Caught USR1, will save stats"); stats_flag=1; sigaction(SIGUSR1, &usr1action, NULL); } static void restart_log(int dummy) { DEBUG(1, "Caught HUP, will read cfg"); restart_log_flag=1; sigaction(SIGHUP, &hupaction, NULL); } #endif static void quit(int dummy) { DEBUG(1, "Quitting\nRead configuration %d times", hupcounter); loopflag = 0; } #ifndef WINDOWS static void die(int dummy) { abort(); } #endif static void dump(unsigned char *p, int n) { int i; fprintf(stderr, "%d: ", n); for (i = 0; i < n; i++) { if (asciidump) { fprintf(stderr, "%c", (isprint(p[i])||isspace(p[i]))?p[i]:'.'); } else { fprintf(stderr, "%02x ", (int)p[i]); } } fprintf(stderr, "\n"); } /* Log format is: + client_ip server_ip request */ static void netlog(int fd, int i, unsigned char *r, int n) { int j, k; char b[1024]; DEBUG(2, "netlog(%d, %d, %p, %d)", fd, i, r, n); strncpy(b, "+ ", sizeof b); k = 2; strncpy(b+k, pen_ntoa(&clients[conns[i].client].addr), (sizeof b)-k); k += strlen(b+k); b[k++] = ' '; strncpy(b+k, pen_ntoa(&servers[conns[i].server].addr), (sizeof b)-k); k += strlen(b+k); b[k++] = ' '; /* We have already used k bytes from b. This means that we want no more than (sizeof b-(k+1)) bytes from r. The +1 is for the trailing newline. */ j = sizeof b-(k+1); if (n > j) n = j; for (j = 0; j < n && r[j] != '\r' && r[j] != '\n'; j++) { b[k++] = r[j]; } b[k++] = '\n'; sendto(fd, b, k, 0, (struct sockaddr *)&logserver, sizeof logserver); } /* Log format is: client_ip timestamp server_ip request */ static void log_request(FILE *fp, int i, unsigned char *b, int n) { int j; if (n > KEEP_MAX) n = KEEP_MAX; fprintf(fp, "%s ", pen_ntoa(&clients[conns[i].client].addr)); fprintf(fp, "%ld ", (long)now); fprintf(fp, "%s ", pen_ntoa(&servers[conns[i].server].addr)); for (j = 0; j < n && b[j] != '\r' && b[j] != '\n'; j++) { fprintf(fp, "%c", isascii(b[j])?b[j]:'.'); } fprintf(fp, "\n"); } static int rewrite_request(int i, int n, char *b) { char *q; char p[BUFFER_MAX]; int pl; b[n] = '\0'; DEBUG(2, "rewrite_request(%d, %d, %s)", i, n, b); if (pen_strncasecmp(b, "GET ", 4) && pen_strncasecmp(b, "POST ", 5) && pen_strncasecmp(b, "HEAD ", 5)) { return n; /* You can't touch this */ } DEBUG(2, "Looking for CRLFCRLF"); q = strstr(b, "\r\n\r\n"); /* Steve Hall tells me that apparently some clients send \n\n instead */ if (!q) { DEBUG(2, "Looking for LFLF"); q = strstr(b, "\n\n"); } if (!q) return n; /* not a header */ #if 0 /* how is that supposed to happen? */ if (q >= b+n) return n; /* outside of buffer */ #endif /* Look for existing X-Forwarded-For */ DEBUG(2, "Looking for X-Forwarded-For"); if (pen_strcasestr(b, "\nX-Forwarded-For:")) return n; DEBUG(2, "Adding X-Forwarded-For"); /* Didn't find one, add our own */ snprintf(p, sizeof p, "\r\nX-Forwarded-For: %s", pen_ntoa(&clients[conns[i].client].addr)); pl=strlen(p); if (n+pl > BUFFER_MAX) return n; memmove(q+pl, q, b+n-q); memmove(q, p, pl); n += pl; return n; } static void change_events(int i) { int up_events = 0, down_events = 0; int state = conns[i].state; if (state & CS_IN_PROGRESS) { DEBUG(2, "waiting for connect() to complete"); up_events |= EVENT_WRITE; } else if (state & CS_CONNECTED) { /* we are never interested in additional udp data from the client */ if (!udp) { if (conns[i].upn == 0) { if (!(state & CS_CLOSED_DOWN)) { DEBUG(2, "interested in reading from downstream socket %d of connection %d", conns[i].downfd, i); down_events |= EVENT_READ; } } else { DEBUG(2, "interested in writing %d bytes to upstream socket %d of connection %d", conns[i].upn, conns[i].upfd, i); up_events |= EVENT_WRITE; } } /* tcp and udp processing upstream is handled the same here */ if (conns[i].downn == 0) { if (!(state & CS_CLOSED_UP)) { DEBUG(2, "interested in reading from upstream socket %d of connection %d", conns[i].upfd, i); up_events |= EVENT_READ; } } else { DEBUG(2, "interested in writing %d bytes to downstream socket %d of connection %d", conns[i].downn, conns[i].downfd, i); down_events |= EVENT_WRITE; } } /* We know that if down_events == up_events == 0, the connection will be closed. Not doing anything here shaves off two syscalls. */ if (down_events || up_events) { if (conns[i].downfd != -1) event_arm(conns[i].downfd, down_events); if (conns[i].upfd != -1) event_arm(conns[i].upfd, up_events); } } static int my_recv(int fd, void *buf, size_t len, int flags) { return recvfrom(fd, buf, len, flags, NULL, 0); } static int my_send(int fd, const void *buf, size_t len, int flags) { if (fd == -1) return len; /* idler */ return sendto(fd, buf, len, flags, NULL, 0); } static void add_dummy_reply(int conn) { char msg[1024]; DEBUG(2, "add_dummy_reply(%d)", conn); snprintf(msg, sizeof msg, "HTTP/1.1 200 OK\r\n" "Content-Length: %d\r\n" "Content-Type: text/html\r\n\r\n%s", (int)strlen(DUMMY_MSG), DUMMY_MSG); conns[conn].downn = strlen(msg); conns[conn].downbptr = conns[conn].downb = pen_malloc(conns[conn].downn); memcpy(conns[conn].downb, msg, conns[conn].downn); change_events(conn); } static int copy_up(int i) { int n, rc, err = 0; int from = conns[i].downfd; int to = conns[i].upfd; int serverindex = conns[i].server; unsigned char b[BUFFER_MAX]; #ifdef HAVE_LIBSSL SSL *ssl = conns[i].ssl; if (ssl) { rc = SSL_read(ssl, b, BUFFER_MAX); DEBUG(2, "SSL_read returns %d\n", rc); if (rc < 0) { err = SSL_get_error(ssl, rc); DEBUG(2, "SSL_read returns %d (SSL error %d)\n", rc, err); if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) { return 0; } } } else { rc = my_recv(from, b, BUFFER_MAX, 0); err = socket_errno; } #else rc = my_recv(from, b, BUFFER_MAX, 0); err = socket_errno; #endif /* HAVE_LIBSSL */ DEBUG(2, "copy_up: recv(%d, %p, %d, 0) returns %d, errno = %d, socket_errno = %d", \ from, b, BUFFER_MAX, rc, errno, socket_errno); if (rc == 0) { /* orderly shutdown */ DEBUG(2, "orderly shutdown of socket downfd=%d", from); conns[i].state |= CS_CLOSED_DOWN; /* no need to bother with any of this if the connection will be closed anyway */ if (closing_time(i)) return -1; change_events(i); /* so we stop reading from downfd */ if (!(conns[i].state & CS_CLOSED_UP)) { /* proceed telling upfd about the close */ n = shutdown(to, SHUT_WR); if (n == -1) { err = socket_errno; DEBUG(2, "shutdown(upfd=%d, SHUT_WR) returns %d, socket_errno=%d", to, n, err); if (err != ENOTCONN) conns[i].state |= CS_CLOSED; /* because of the error */ } } return -1; /* the connection was successfully half-closed, wait for upstream to act */ } else if (rc == -1) { if (WOULD_BLOCK(err)) return 0; conns[i].state |= CS_CLOSED; /* because of the error */ return -1; } else { if (http) { rc = rewrite_request(i, rc, (char *)b); } if (debuglevel > 2) dump(b, rc); if (logfp) { log_request(logfp, i, b, rc); if (debuglevel > 2) log_request(stderr, i, b, rc); } if (logsock != -1) { netlog(logsock, i, b, rc); } n = my_send(to, b, rc, 0); /* no ssl here */ SAVE_ERRNO; DEBUG(2, "copy_up: send(%d, %p, %d, 0) returns %d, socket_errno = %d", to, b, rc, n, USE_ERRNO); if (n == -1) { if (!WOULD_BLOCK(USE_ERRNO)) { conns[i].state |= CS_CLOSED; return -1; } n = 0; } if (n != rc) { DEBUG(2, "copy_up saving %d bytes in up buffer", rc-n); conns[i].upn = rc-n; /* remaining to be copied */ conns[i].upbptr = conns[i].upb = pen_malloc(rc-n); memcpy(conns[i].upb, b+n, rc-n); change_events(i); } #if 0 These could be simplified, no? Just store them in conn and update servers and clients from close_conn. #endif servers[serverindex].sx += rc; /* That's not right? Should be n */ clients[conns[i].client].crx += rc; conns[i].crx += rc; /* rewritten bytes read from client */ conns[i].ssx += n; /* actual bytes written to server */ if (dummy) add_dummy_reply(i); } return 0; } /* this function may have to deal with udp */ static int copy_down(int i) { int n, rc, err = 0; int from = conns[i].upfd; int to = conns[i].downfd; int serverindex = conns[i].server; #ifdef HAVE_LIBSSL SSL *ssl = conns[i].ssl; #endif unsigned char b[BUFFER_MAX]; /* we called connect from add_client, so this works for udp and tcp */ rc = my_recv(from, b, BUFFER_MAX, 0); /* no ssl here */ DEBUG(2, "copy_down: recv(%d, %p, %d, %d) returns %d", from, b, BUFFER_MAX, 0, rc); if (debuglevel > 2) dump(b, rc); if (rc == 0) { DEBUG(2, "orderly shutdown of socket %d", from); conns[i].state |= CS_CLOSED_UP; /* no need to bother with any of this if the connection will be closed anyway */ if (closing_time(i)) return -1; change_events(i); /* so we stop reading from upfd */ if (!(conns[i].state & CS_CLOSED_DOWN)) { n = shutdown(to, SHUT_WR); if (n == -1) { err = socket_errno; DEBUG(2, "shutdown(downfd=%d, SHUT_WR) returns %d, socket_errno=%d", to, n, err); if (err != ENOTCONN) conns[i].state |= CS_CLOSED; /* because of the error */ } } return -1; } else if (rc == -1) { DEBUG(2, "socket_errno = %d", socket_errno); conns[i].state |= CS_CLOSED; /* because of the error */ return -1; } else { int n; if (udp) { struct sockaddr_storage *ss = &clients[conns[i].client].addr; socklen_t sss = pen_ss_size(ss); DEBUG(2, "copy_down sending %d bytes to socket %d", rc, to); n = sendto(to, (void *)b, rc, 0, (struct sockaddr *)ss, sss); close_conn(i); return 0; } #ifdef HAVE_LIBSSL if (ssl) { /* We can't SSL_write here, because the auto buffer we're using now won't be around if we need to retry the write. Therefore don't write anything here but let flush_down do it. */ n = 0; } else { n = my_send(to, b, rc, 0); err = socket_errno; DEBUG(2, "copy_down: send(%d, %p, %d, %d) returns %d", to, b, rc, 0, n); } #else n = my_send(to, b, rc, 0); err = socket_errno; DEBUG(2, "copy_down: send(%d, %p, %d, %d) returns %d", to, b, rc, 0, n); #endif if (n == -1) { DEBUG(2, "errno = %d, socket_errno = %d", errno, socket_errno); if (!WOULD_BLOCK(err)) { conns[i].state |= CS_CLOSED; return -1; } n = 0; } if (n != rc) { DEBUG(2, "copy_down saving %d bytes in down buffer", rc-n); conns[i].downn = rc-n; conns[i].downbptr = conns[i].downb = pen_malloc(rc-n); memcpy(conns[i].downb, b+n, rc-n); change_events(i); } servers[serverindex].rx += rc; clients[conns[i].client].csx += n; conns[i].srx += rc; conns[i].csx += n; } return 0; } #ifndef WINDOWS static void alarm_handler(int dummy) { DEBUG(2, "alarm_handler(%d)", dummy); } #endif static void usage(void) { printf("usage:\n" " pen [-C addr:port] [-X] [-b sec] [-c N] [-e host[:port]] \\\n" " [-t sec] [-x N] [-w dir] [-UHPWadfhrs] \\\n" " [-o option] \\\n" #ifdef HAVE_LIBSSL " [-E certfile] [-K keyfile] \\\n" " [-G cacertfile] [-A cacertdir] \\\n" " [-Z] [-R] [-L protocol] \\\n" #endif " [host:]port h1[:p1[:maxc1[:hard1[:weight1[:prio1]]]]] [h2[:p2[:maxc2[:hard2[:weight2[:prio2]]]]]] ...\n" "\n" " -B host:port abuse server for naughty clients\n" " -C port control port\n" " -T sec tracking time in seconds (0 = forever) [%d]\n" " -H add X-Forwarded-For header in http requests\n" " -U use udp protocol support\n" " -N use hash for initial server selection without save server\n" " -O option use option in penctl format\n" " -P use poll() rather than select()\n" " -Q use kqueue to manage events (BSD)\n" " -W use weight for server selection\n" " -X enable 'exit' command for control port\n" " -a debugging dumps in ascii format\n" " -b sec blacklist time in seconds [%d]\n" " -c N max number of clients [%d]\n" " -d debugging on (repeat -d for more)\n" " -e host:port emergency server of last resort\n" " -f stay in foregound\n" " -h use hash for initial server selection\n" " -j dir run in chroot\n" " -F file name of configuration file\n" " -l file logging on\n" " -r bypass client tracking in server selection\n" " -s stubborn selection, i.e. don't fail over\n" " -t sec connect timeout in seconds [%d]\n" " -u user run as alternative user\n" " -p file write pid to file\n" " -x N max number of simultaneous connections [%d]\n" " -w file save statistics in HTML format in a file\n" " -o option use option in penctl format\n" #ifdef HAVE_LIBSSL " -E certfile use the given certificate in PEM format\n" " -K keyfile use the given key in PEM format (may be contained in cert)\n" " -G cacertfile file containing the CA's certificate\n" " -A cacertdir directory containing CA certificates in hashed format\n" " -Z use SSL compatibility mode\n" " -R require valid peer certificate\n" " -L protocol ssl23 (default), ssl2, ssl3 or tls1\n" #endif "\n" "example:\n" " pen smtp mailhost1:smtp mailhost2:25 mailhost3\n" "\n", TRACKING_TIME, BLACKLIST_TIME, CLIENTS_MAX, TIMEOUT, CONNECTIONS_MAX); exit(0); } #ifndef WINDOWS static void background(void) { #ifdef HAVE_DAEMON daemon(0, 0); #else int childpid; if ((childpid = fork()) < 0) { error("Can't fork"); } else { if (childpid > 0) { exit(0); /* parent */ } } int devnull_fd = open("/dev/null", O_RDWR); dup2(devnull_fd,0); /* stdin */ dup2(devnull_fd,1); /* stdout */ dup2(devnull_fd,2); /* stderr */ setsid(); signal(SIGCHLD, SIG_IGN); #endif } #endif static void init(int argc, char **argv) { int i; int server; DEBUG(2, "init(%d, %p); port = %d", argc, argv, port); #if 0 conns = pen_calloc(connections_max, sizeof *conns); clients = pen_calloc(clients_max, sizeof *clients); #else debug("Before: conns = %p, connections_max = %d, clients = %p, clients_max = %d", conns, connections_max, clients, clients_max); if (connections_max == 0) expand_conntable(CONNECTIONS_MAX); if (clients_max == 0) expand_clienttable(CLIENTS_MAX); debug("After: conns = %p, connections_max = %d, clients = %p, clients_max = %d", conns, connections_max, clients, clients_max); #endif current = 0; server = 0; for (i = 1; i < argc; i++) { DEBUG(2, "server[%d] = %s", server, argv[i]); expand_servertable(server+1); servers[server].status = 0; servers[server].c = 0; /* connections... */ setaddress(server, argv[i], port, proto); servers[server].sx = 0; servers[server].rx = 0; server++; } if (e_server) { DEBUG(2, "Emergency server = %s", e_server); expand_servertable(EMERGENCY_SERVER+1); emerg_server = EMERGENCY_SERVER; servers[EMERGENCY_SERVER].status = 0; servers[EMERGENCY_SERVER].c = 0; /* connections... */ setaddress(EMERGENCY_SERVER, e_server, port, proto); servers[EMERGENCY_SERVER].sx = 0; servers[EMERGENCY_SERVER].rx = 0; server++; } if (a_server) { DEBUG(2, "Abuse server = %s", a_server); expand_servertable(ABUSE_SERVER+1); abuse_server = ABUSE_SERVER; servers[ABUSE_SERVER].status = 0; servers[ABUSE_SERVER].c = 0; /* connections... */ setaddress(ABUSE_SERVER, a_server, port, proto); servers[ABUSE_SERVER].sx = 0; servers[ABUSE_SERVER].rx = 0; server++; } for (i = 0; i < clients_max; i++) { clients[i].last = 0; memset(&clients[i].addr, 0, sizeof(clients[i].addr)); clients[i].server = 0; clients[i].connects = 0; clients[i].csx = 0; clients[i].crx = 0; } #if 0 for (i = 0; i < connections_max; i++) { conns[i].upfd = -1; conns[i].downfd = -1; conns[i].upn = 0; conns[i].downn = 0; } #endif if (debuglevel) { debug("%s starting", PACKAGE_STRING); debug("servers:"); for (i = 0; i < nservers; i++) { debug("%2d %s:%d:%d:%d:%d:%d", i, pen_ntoa(&servers[i].addr), pen_getport(&servers[i].addr), servers[i].maxc, servers[i].hard, servers[i].weight, servers[i].prio); } } } static void open_log(char *logfile) { if (logfp) { fclose(logfp); logfp = NULL; } if (logsock >= 0) { close(logsock); logsock = -1; } if (logfile) { char *p = strchr(logfile, ':'); if (p && logfile[0] != '/') { /* log to net */ struct hostent *hp; DEBUG(2, "net log to %s", logfile); *p++ = '\0'; logsock = socket_nb(PF_INET, SOCK_DGRAM, 0); logserver.sin_family = AF_INET; hp = gethostbyname(logfile); if (hp == NULL) error("Bogus host %s", logfile); memcpy(&logserver.sin_addr.s_addr, hp->h_addr, hp->h_length); logserver.sin_port = htons(atoi(p)); } else { /* log to file */ DEBUG(2, "file log to %s", logfile); logfp = fopen(logfile, "a"); if (!logfp) error("Can't open logfile %s", logfile); } } } #ifndef WINDOWS static int open_unix_listener(char *a) { int n, listenfd; struct sockaddr_un serv_addr; remove(a); memset(&serv_addr, 0, sizeof serv_addr); serv_addr.sun_family = AF_UNIX; snprintf(serv_addr.sun_path, sizeof serv_addr.sun_path, "%s", a); listenfd = socket_nb(AF_UNIX, SOCK_STREAM, 0); if (bind(listenfd, (struct sockaddr *)&serv_addr, sizeof serv_addr) != 0) { error("can't bind local address"); } n = listen(listenfd, listen_queue); if (n == -1) { DEBUG(2, "listen(%d, %d) returns -1, errno = %d, socket_errno = %d", listenfd, listen_queue, errno, socket_errno); } return listenfd; } #endif static int open_listener(char *a) { int listenfd; struct sockaddr_storage ss; char b[1024], *p; int one = 1; int optval = 1; DEBUG(2, "open_listener(%s)", a); #ifndef WINDOWS /* Handle Unix domain sockets separately */ if (strchr(a, '/')) return open_unix_listener(a); #endif memset(&ss, 0, sizeof ss); p = strrchr(a, ':'); /* look for : separating address from port */ if (p) { /* found one, extract parts */ if ((p-a) >= sizeof b) { error("Address %s too long", a); return -1; } strncpy(b, a, p-a); b[p-a] = '\0'; port = getport(p+1, proto); } else { strncpy(b, "0.0.0.0", sizeof b); port = getport(a, proto); } if (port < 1 || port > 65535) { debug("Port %d out of range", port); return -1; } if (!pen_aton(b, &ss)) { debug("Can't convert address '%s'", b); return -1; } pen_setport(&ss, port); listenfd = socket_nb(ss.ss_family, protoid, 0); DEBUG(2, "local address=[%s:%d]", b, port); setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof one); setsockopt(listenfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval, sizeof optval); if (bind(listenfd, (struct sockaddr *)&ss, pen_ss_size(&ss)) < 0) { error("can't bind local address"); } listen(listenfd, listen_queue); return listenfd; } static void read_cfg(char *); static void write_cfg(char *p) { int i; struct tm *nowtm; char nowstr[80]; FILE *fp = fopen(p, "w"); if (!fp) { debug("Can't open file '%s'", p); return; } nowtm = localtime(&now); strftime(nowstr, sizeof(nowstr), "%Y-%m-%d %H:%M:%S", nowtm); fprintf(fp, "# Generated by pen %s\n", nowstr); fprintf(fp, "# pen"); if (udp) fprintf(fp, " -U"); if (foreground) fprintf(fp, " -f"); if (exit_enabled) fprintf(fp, " -X"); if (clients_max != CLIENTS_MAX) fprintf(fp, " -c %d", clients_max); if (e_server) fprintf(fp, " -e %s", e_server); if (a_server) fprintf(fp, " -B %s", a_server); if (jail) fprintf(fp, " -j '%s'", jail); if (pidfile) fprintf(fp, " -p '%s'", pidfile); if (user) fprintf(fp, " -u '%s'", user); if (connections_max != CONNECTIONS_MAX) fprintf(fp, " -x %d", connections_max); fprintf(fp, " -F '%s' -C %s %s\n", p, ctrlport, listenport); save_acls(fp); if (asciidump) fprintf(fp, "ascii\n"); else fprintf(fp, "no ascii\n"); fprintf(fp, "blacklist %d\n", blacklist_time); fprintf(fp, "client_acl %d\n", client_acl); fprintf(fp, "control_acl %d\n", control_acl); fprintf(fp, "debug %d\n", debuglevel); if (server_alg & ALG_HASH) fprintf(fp, "hash\n"); else fprintf(fp, "no hash\n"); if (http) fprintf(fp, "http\n"); else fprintf(fp, "no http\n"); if (logfile) fprintf(fp, "log %s\n", logfile); else fprintf(fp, "no log\n"); if (server_alg & ALG_ROUNDROBIN) fprintf(fp, "roundrobin\n"); else fprintf(fp, "no roundrobin\n"); for (i = 0; i < nservers; i++) { fprintf(fp, "server %d acl %d address %s port %d max %d hard %d", i, servers[i].acl, pen_ntoa(&servers[i].addr), pen_getport(&servers[i].addr), servers[i].maxc, servers[i].hard); if (server_alg & ALG_WEIGHT) fprintf(fp, " weight %d", servers[i].weight); if (server_alg & ALG_PRIO) fprintf(fp, " prio %d", servers[i].prio); fprintf(fp, "\n"); } if (server_alg & ALG_STUBBORN) fprintf(fp, "stubborn\n"); else fprintf(fp, "no stubborn\n"); if (tcp_fastclose == CS_CLOSED) { fprintf(fp, "tcp_fastclose both\n"); } else if (tcp_fastclose == CS_CLOSED_UP) { fprintf(fp, "tcp_fastclose up\n"); } else if (tcp_fastclose == CS_CLOSED_DOWN) { fprintf(fp, "tcp_fastclose down\n"); } else { fprintf(fp, "tcp_fastclose off\n"); } if (tcp_nodelay) { fprintf(fp, "tcp_nodelay\n"); } else { fprintf(fp, "no tcp_nodelay\n"); } fprintf(fp, "timeout %d\n", timeout); fprintf(fp, "tracking %d\n", tracking_time); if (webfile) fprintf(fp, "web_stats %s\n", webfile); else fprintf(fp, "no web_stats\n"); if (server_alg & ALG_WEIGHT) fprintf(fp, "weight\n"); else fprintf(fp, "no weight\n"); if (server_alg & ALG_PRIO) fprintf(fp, "prio\n"); else fprintf(fp, "no prio\n"); fclose(fp); } static void do_cmd(char *b, void (*output)(void *, char *, ...), void *op) { char *p, *q; int n; FILE *fp; DEBUG(2, "do_cmd(%s, %p, %p)", b, output, op); p = strchr(b, '\r'); if (p) *p = '\0'; p = strchr(b, '\n'); if (p) *p = '\0'; p = strtok(b, " "); if (p == NULL) return; if (!strcmp(p, "abort_on_error")) { abort_on_error = 1; } else if (!strcmp(p, "acl")) { char *no, *pd, *ip, *ma; /* acl N permit|deny ipaddr [mask] */ if ((no = strtok(NULL, " ")) && (pd = strtok(NULL, " ")) && (ip = strtok(NULL, " "))) { int a = atoi(no); int permit; if (!strcmp(pd, "permit")) permit = 1; else if (!strcmp(pd, "deny")) permit = 0; else { debug("acl: expected permit|deny"); return; } if (!strcmp(ip, "country")) { char *country = strtok(NULL, " "); if (!country) { debug("acl: expected country"); return; } add_acl_geo(a, country, permit); } else if (strchr(ip, ':')) { unsigned char ipaddr[INET6_ADDRSTRLEN]; ma = strchr(ip, '/'); if (ma) { *ma++ = '\0'; } else { ma = "128"; } #if 0 if (inet_pton(AF_INET6, ip, ipaddr) != 1) { debug("acl: can't convert address %s", ip); return; } #else struct sockaddr_storage ss; struct sockaddr_in6 *si6; if (pen_aton(ip, &ss) != 1) { debug("acl: can't convert address %s", ip); return; } if (ss.ss_family != AF_INET6) { debug("acl: %s is not an ipv6 address", ip); return; } si6 = (struct sockaddr_in6 *)&ss; memcpy(ipaddr, &si6->sin6_addr, sizeof ipaddr); #endif add_acl_ipv6(a, ipaddr, atoi(ma), permit); } else { struct in_addr ipaddr, mask; ma = strtok(NULL, " "); if (!ma) ma = "255.255.255.255"; if (!inet_aton(ip, &ipaddr)) { debug("acl: bogus address '%s'\n", ip); return; } if (!inet_aton(ma, &mask)) { debug("acl: bogus mask '%s'\n", ma); return; } add_acl_ipv4(a, ipaddr.s_addr, mask.s_addr, permit); } } } else if (!strcmp(p, "ascii")) { asciidump = 1; } else if (!strcmp(p, "blacklist")) { p = strtok(NULL, " "); if (p) blacklist_time = atoi(p); output(op, "%d\n", blacklist_time); } else if (!strcmp(p, "client_acl")) { p = strtok(NULL, " "); if (p) client_acl = atoi(p); if (client_acl < 0 || client_acl >= ACLS_MAX) client_acl = 0; output(op, "%d\n", client_acl); } else if (!strcmp(p, "clients_max")) { p = strtok(NULL, " "); if (p) expand_clienttable(atoi(p)); output(op, "%d\n", clients_max); } else if (!strcmp(p, "close")) { p = strtok(NULL, " "); int conn = p ? atoi(p) : 0; if (conn < 0 || conn >= connections_max) { output(op, "Connection %d out of range\n", conn); } else { output(op, "Forcibly closing connection %d\n", conn); close_conn(conn); } } else if (!strcmp(p, "connection")) { p = strtok(NULL, " "); int conn = p ? atoi(p) : 0; if (conn < 0 || conn >= connections_max) { output(op, "Connection %d out of range\n", conn); } else { output(op, "Connection %d:\n", conn); output(op, "state = %d\n", conns[conn].state); output(op, "downfd = %d, upfd = %d\n", conns[conn].downfd, conns[conn].upfd); output(op, "client = %d, server = %d\n", conns[conn].client, conns[conn].server); output(op, "pend = %d\n", conns[conn].pend); } } else if (!strcmp(p, "conn_max")) { p = strtok(NULL, " "); if (p) expand_clienttable(atoi(p)); output(op, "%d\n", connections_max); } else if (!strcmp(p, "control")) { output(op, "%s\n", ctrlport); } else if (!strcmp(p, "control_acl")) { p = strtok(NULL, " "); if (p) control_acl = atoi(p); if (control_acl < 0 || control_acl >= ACLS_MAX) control_acl = 0; output(op, "%d\n", control_acl); } else if (!strcmp(p, "debug")) { p = strtok(NULL, " "); if (p) debuglevel = atoi(p); output(op, "%d\n", debuglevel); } else if (!strcmp(p, "dsr_if")) { p = strtok(NULL, " "); if (p) { free(dsr_if); dsr_if = pen_strdup(p); } } else if (!strcmp(p, "dsr_ip")) { p = strtok(NULL, " "); if (p) { free(dsr_ip); dsr_ip = pen_strdup(p); } } else if (!strcmp(p, "dummy")) { dummy = 1; } else if (!strcmp(p, "epoll")) { event_init = epoll_init; } else if (!strcmp(p, "exit")) { if (exit_enabled) { quit(0); } else { output(op, "Exit is not enabled; restart with -X flag\n"); } } else if (!strcmp(p, "hash")) { server_alg |= ALG_HASH; } else if (!strcmp(p, "http")) { http = 1; } else if (!strcmp(p, "idle_timeout")) { p = strtok(NULL, " "); if (p) idle_timeout = atoi(p); if (idle_timeout < 0) idle_timeout = 0; output(op, "Idle timeout: %d seconds\n", idle_timeout); } else if (!strcmp(p, "idlers")) { p = strtok(NULL, " "); if (p) idlers_wanted = atoi(p); output(op, "Idlers: %d/%d\n", idlers, idlers_wanted); } else if (!strcmp(p, "include")) { p = strtok(NULL, " "); if (p) { read_cfg(p); } else { debug("Usage: include filename"); } } else if (!strcmp(p, "keepalive")) { keepalive = 1; } else if (!strcmp(p, "kqueue")) { event_init = kqueue_init; } else if (!strcmp(p, "listen")) { p = strtok(NULL, " "); if (p) { snprintf(listenport, sizeof listenport, "%s", p); if (listenfd != -1) { n = close(listenfd); DEBUG(2, "close(listenfd=%d) returns %d", listenfd, n); } listenfd = open_listener(p); /* we may need to defer this if we haven't called event_init yet */ if (event_add) event_add(listenfd, EVENT_READ); DEBUG(2, "new listenfd = %d", listenfd); } output(op, "%s\n", listenport); } else if (!strcmp(p, "log")) { p = strtok(NULL, " "); if (p) { free(logfile); logfile = pen_strdup(p); open_log(logfile); } if (logfile) { output(op, "%s\n", logfile); } } else if (!strcmp(p, "mode")) { output(op, "%shash %sroundrobin %sstubborn %sweight %sprio\n", (server_alg & ALG_HASH)?"":"no ", (server_alg & ALG_ROUNDROBIN)?"":"no ", (server_alg & ALG_STUBBORN)?"":"no ", (server_alg & ALG_WEIGHT)?"":"no ", (server_alg & ALG_PRIO)?"":"no "); } else if (!strcmp(p, "no")) { p = strtok(NULL, " "); if (p == NULL) return; if (!strcmp(p, "abort_on_error")) { abort_on_error = 0; } else if (!strcmp(p, "acl")) { int a; p = strtok(NULL, " "); a = atoi(p); del_acl(a); } else if (!strcmp(p, "ascii")) { asciidump = 0; } else if (!strcmp(p, "dummy")) { dummy = 0; } else if (!strcmp(p, "hash")) { server_alg &= ~ALG_HASH; } else if (!strcmp(p, "http")) { http = 0; } else if (!strcmp(p, "keepalive")) { keepalive = 0; } else if (!strcmp(p, "log")) { logfile = NULL; if (logfp) fclose(logfp); logfp = NULL; } else if (!strcmp(p, "prio")) { server_alg &= ~ALG_PRIO; } else if (!strcmp(p, "roundrobin")) { server_alg &= ~ALG_ROUNDROBIN; } else if (!strcmp(p, "stubborn")) { server_alg &= ~ALG_STUBBORN; } else if (!strcmp(p, "tcp_nodelay")) { tcp_nodelay = 0; } else if (!strcmp(p, "transparent")) { transparent = 0; } else if (!strcmp(p, "web_stats")) { webfile = NULL; } else if (!strcmp(p, "weight")) { server_alg &= ~ALG_WEIGHT; } } else if (!strcmp(p, "pending_max")) { p = strtok(NULL, " "); if (p) pending_max = atoi(p); if (pending_max <= 0) pending_max = 1; } else if (!strcmp(p, "pid")) { output(op, "%ld\n", (long)getpid()); } else if (!strcmp(p, "poll")) { event_init = poll_init; } else if (!strcmp(p, "prio")) { server_alg |= ALG_PRIO; } else if (!strcmp(p, "recent")) { time_t when = now; p = strtok(NULL, " "); if (p) when -= atoi(p); else when -= 300; for (n = 0; n < clients_max; n++) { if (clients[n].last < when) continue; output(op, "%s connects %ld sx %lld rx %lld\n", pen_ntoa(&clients[n].addr), clients[n].connects, clients[n].csx, clients[n].crx); } } else if (!strcmp(p, "roundrobin")) { server_alg |= ALG_ROUNDROBIN; } else if (!strcmp(p, "select")) { event_init = select_init; } else if (!strcmp(p, "server")) { p = strtok(NULL, " "); if (p == NULL) return; n = atoi(p); if (n < 0) return; expand_servertable(n+1); while ((p = strtok(NULL, " ")) && (q = strtok(NULL, " "))) { if (!strcmp(p, "acl")) { servers[n].acl = atoi(q); } else if (!strcmp(p, "address")) { int result; debug("do_cmd: server %d address %s", n, q); result = pen_aton(q, &servers[n].addr); DEBUG(1, "pen_aton returns %d\n" \ "address family = %d", \ n, servers[n].addr.ss_family); if (debuglevel > 1) pen_dumpaddr(&servers[n].addr); if (result != 1) return; } else if (!strcmp(p, "port")) { pen_setport(&servers[n].addr, atoi(q)); } else if (!strcmp(p, "max")) { servers[n].maxc = atoi(q); } else if (!strcmp(p, "hard")) { servers[n].hard = atoi(q); } else if (!strcmp(p, "blacklist")) { servers[n].status = now+atoi(q)-blacklist_time; } else if (!strcmp(p, "weight")) { servers[n].weight = atoi(q); } else if (!strcmp(p, "prio")) { servers[n].prio = atoi(q); } } } else if (!strcmp(p, "servers")) { for (n = 0; n < nservers; n++) { output(op, "%d addr %s port %d conn %d max %d hard %d weight %d prio %d sx %llu rx %llu\n", n, pen_ntoa(&servers[n].addr), pen_getport(&servers[n].addr), servers[n].c, servers[n].maxc, servers[n].hard, servers[n].weight, servers[n].prio, servers[n].sx, servers[n].rx); } } else if (!strcmp(p, "socket")) { p = strtok(NULL, " "); int fd = p ? atoi(p) : 0; int conn = fd2conn_get(fd); output(op, "Socket %d belongs to connection %d\n", fd, conn); } else if (!strcmp(p, "status")) { if (webstats()) { fp = fopen(webfile, "r"); if (fp == NULL) { output(op, "Can't read webstats\n"); return; } while (fgets(b, sizeof b, fp)) { output(op, "%s", b); } fclose(fp); } else { output(op, "Unable to create webstats\n"); } #ifdef HAVE_LIBSSL } else if (!strcmp(p, "ssl_ciphers")) { p = strtok(NULL, " "); if (ssl_ciphers) { free(ssl_ciphers); ssl_ciphers = NULL; } if (p) ssl_ciphers = pen_strdup(p); } else if (!strcmp(p, "ssl_client_renegotiation_interval")) { p = strtok(NULL, " "); ssl_client_renegotiation_interval = atoi(p); } else if (!strcmp(p, "ssl_ocsp_response")) { p = strtok(NULL, " "); if (ocsp_resp_file) { free(ocsp_resp_file); } ocsp_resp_file = pen_strdup(p); } else if (!strcmp(p, "ssl_option")) { p = strtok(NULL, " "); if (p == NULL) { debug("Missing option"); } else if (!strcmp(p, "no_sslv2")) { ssl_options |= SSL_OP_NO_SSLv2; } else if (!strcmp(p, "no_sslv3")) { ssl_options |= SSL_OP_NO_SSLv3; } else if (!strcmp(p, "no_tlsv1")) { ssl_options |= SSL_OP_NO_TLSv1; #ifdef SSL_OP_NO_TLSv1_1 } else if (!strcmp(p, "no_tlsv1.1")) { ssl_options |= SSL_OP_NO_TLSv1_1; #endif #ifdef SSL_OP_NO_TLSv1_2 } else if (!strcmp(p, "no_tlsv1.2")) { ssl_options |= SSL_OP_NO_TLSv1_2; #endif } else if (!strcmp(p, "cipher_server_preference")) { ssl_options |= SSL_OP_CIPHER_SERVER_PREFERENCE; } } else if (!strcmp(p, "ssl_sni_path")) { p = strtok(NULL, " "); if (p == NULL) { debug("Missing ssl_sni_path"); } else { if (ssl_sni_path) free(ssl_sni_path); ssl_sni_path = pen_strdup(p); } #endif /* HAVE_SSL */ } else if (!strcmp(p, "stubborn")) { server_alg |= ALG_STUBBORN; } else if (!strcmp(p, "tcp_fastclose")) { p = strtok(NULL, " "); if (!p) { output(op, "do_cmd: ignoring tcp_fastclose without argument\n"); return; } if (!strcmp(p, "both")) { tcp_fastclose = CS_CLOSED; } else if (!strcmp(p, "up")) { tcp_fastclose = CS_CLOSED_UP; } else if (!strcmp(p, "down")) { tcp_fastclose = CS_CLOSED_DOWN; } else { tcp_fastclose = 0; } } else if (!strcmp(p, "tarpit_acl")) { p = strtok(NULL, " "); if (p) tarpit_acl = atoi(p); if (tarpit_acl < -1 || tarpit_acl >= ACLS_MAX) tarpit_acl = 0; output(op, "tarpit_acl = %d", tarpit_acl); } else if (!strcmp(p, "tcp_nodelay")) { tcp_nodelay = 1; } else if (!strcmp(p, "timeout")) { p = strtok(NULL, " "); if (p) timeout = atoi(p); output(op, "%d\n", timeout); } else if (!strcmp(p, "tracking")) { p = strtok(NULL, " "); if (p) tracking_time = atoi(p); output(op, "%d\n", tracking_time); } else if (!strcmp(p, "transparent")) { transparent = 1; } else if (!strcmp(p, "web_stats")) { p = strtok(NULL, " "); if (p) { free(webfile); webfile = pen_strdup(p); } if (webfile) { output(op, "%s\n", webfile); } } else if (!strcmp(p, "weight")) { server_alg |= ALG_WEIGHT; } else if (!strcmp(p, "write")) { p = strtok(NULL, " "); if (!p) p = cfgfile; if (p) { write_cfg(p); } else { debug("write: no file"); } } else { if (p[0] != '#') output(op, "do_cmd: ignoring command starting with '%s'\n", p); } } static void output_net(void *op, char *fmt, ...) { int *fp = op; int n; char b[4096]; va_list ap; va_start(ap, fmt); vsnprintf(b, sizeof b, fmt, ap); n = send(*fp, b, strlen(b), 0); if (n == -1) { debug("output_net: write failed"); } va_end(ap); } static void output_file(void *op, char *fmt, ...) { FILE *fp = op; va_list ap; va_start(ap, fmt); vfprintf(fp, fmt, ap); va_end(ap); } static void do_ctrl(int downfd, struct sockaddr_storage *cli_addr) { char b[4096]; int n, max_b = sizeof b; if (!match_acl(control_acl, cli_addr)) { debug("do_ctrl: not from there"); } else { n = my_recv(downfd, b, max_b-1, 0); if (n != -1) { b[n] = '\0'; do_cmd(b, output_net, &downfd); } } close(downfd); } static void read_cfg(char *cf) { FILE *fp; char b[4096]; DEBUG(1, "read_cfg(%s)", cf); hupcounter++; if (cf == NULL) return; fp = fopen(cf, "r"); if (fp == NULL) { debug("Can't read config file '%s'\n", cf); return; } while (fgets(b, sizeof b, fp)) { do_cmd(b, output_file, stdout); } fclose(fp); } static void add_client(int downfd, struct sockaddr_storage *cli_addr) { int rc = 0; unsigned char b[BUFFER_MAX]; int client = -1; int conn = -1; #ifdef HAVE_LIBSSL SSL *ssl = NULL; /* check the ssl stuff before picking servers */ if (ssl_context) { ssl = SSL_new(ssl_context); if (ssl == NULL) { int err = ERR_get_error(); debug("SSL: error allocating handle: %s", ERR_error_string(err, NULL)); return; } SSL_set_fd(ssl, downfd); SSL_set_accept_state(ssl); } #endif /* we don't know the client address for udp until we read the message */ if (udp) { socklen_t len = sizeof *cli_addr; rc = recvfrom(listenfd, (void *)b, sizeof b, 0, (struct sockaddr *)cli_addr, &len); DEBUG(2, "add_client: received %d bytes from client", rc); if (rc < 0) { if (errno != EINTR) debug("Error receiving data"); return; } } client = store_client(cli_addr); // no server yet DEBUG(2, "store_client returns %d", client); #ifdef HAVE_LIBSSL conn = store_conn(downfd, ssl, client); conns[conn].reneg = 0; /* never */ if (ssl) { SSL_set_app_data(ssl, &conns[conn]); } #else conn = store_conn(downfd, client); #endif DEBUG(2, "store_conn returns %d", conn); if (dummy) { /* don't bother with a server */ conns[conn].initial = -1; conns[conn].upfd = -1; conns[conn].state = CS_CONNECTED|CS_CLOSED_UP; if (!udp) event_add(conns[conn].downfd, EVENT_READ); return; } conns[conn].initial = conns[conn].server = initial_server(conn); if (conns[conn].initial == -1) { DEBUG(1, "No initial server found, giving up"); close_conn(conn); return; } if (!try_server(conns[conn].initial, conn)) { /* try_server rejected the client, try another */ if (!failover_server(conn)) { DEBUG(1, "No failover server found, giving up"); //close_conn(conn); return; } } if (udp && rc > 0) { /* pass on the message */ /* we are "connected" and don't need sendto */ rc = send(conns[conn].upfd, (void *)b, rc, 0); DEBUG(2, "add_client: wrote %d bytes to socket %d", rc, conns[conn].upfd); } } static int flush_down(int i) { int n, err = 0; #ifdef HAVE_LIBSSL SSL *ssl = conns[i].ssl; if (ssl) { int m = conns[i].downn; if (m > 16000) m = 16000; n = SSL_write(ssl, conns[i].downbptr, m); DEBUG(2, "SSL_write returns %d\n", n); if (n < 0) { int err = SSL_get_error(ssl, n); DEBUG(1, "SSL_write returns %d (SSL error %d)", n, err); if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) { return 0; } } } else { n = my_send(conns[i].downfd, conns[i].downbptr, conns[i].downn, 0); err = socket_errno; } #else struct sockaddr name; size_t size = sizeof(struct sockaddr); if (!udp) n = my_send(conns[i].downfd, conns[i].downbptr, conns[i].downn, 0); else n = sendto(conns[i].downfd, (void *)conns[i].downbptr, conns[i].downn, 0, (struct sockaddr *) &name, size); err = socket_errno; #endif /* HAVE_LIBSSL */ DEBUG(2, "flush_down(%d): send(%d, %p, %d, 0) returns %d, errno = %d, socket_errno = %d", \ i, conns[i].downfd, conns[i].downbptr, conns[i].downn, n, errno, socket_errno); if (n == -1) { if (!WOULD_BLOCK(err)) { conns[i].state |= CS_CLOSED; return -1; } n = 0; } if (n > 0) { conns[i].downn -= n; if (conns[i].downn == 0) { free(conns[i].downb); if (dummy) { conns[i].state |= CS_CLOSED; return -1; } else change_events(i); } else { conns[i].downbptr += n; } clients[conns[i].client].csx += n; conns[i].csx += n; } return n; } /* This only talks upstream and does not need ssl */ static int flush_up(int i) { int n, err = 0; struct sockaddr name; size_t size = sizeof(struct sockaddr); if (!udp) n = my_send(conns[i].upfd, conns[i].upbptr, conns[i].upn, 0); else n = sendto(conns[i].upfd, (void *)conns[i].upbptr, conns[i].upn, 0, (struct sockaddr *) &name, size); err = socket_errno; DEBUG(2, "flush_up(%d): send(%d, %p, %d, 0) returns %d, errno = %d, socket_errno = %d", \ i, conns[i].upfd, conns[i].upbptr, conns[i].upn, n, errno, socket_errno); if (n == -1) { if (!WOULD_BLOCK(err)) { conns[i].state |= CS_CLOSED; return -1; } n = 0; } if (n > 0) { conns[i].upn -= n; if (conns[i].upn == 0) { free(conns[i].upb); change_events(i); } else { conns[i].upbptr += n; } conns[i].ssx += n; } return n; } /* For UDP, connection attempts to unreachable servers would sit in the connection table forever unless we remove them by force. This function is pretty brutal, it simply vacates the next slot after the most recently used one. This will always succeed. */ static void recycle_connection(void) { int i; i = connections_last+1; if (i >= connections_max) i = 0; close_conn(i); } #ifndef WINDOWS static void setup_signals(void) { usr1action.sa_handler = stats; sigemptyset(&usr1action.sa_mask); usr1action.sa_flags = 0; sigaction(SIGUSR1, &usr1action, NULL); usr2action.sa_handler = die; sigemptyset(&usr2action.sa_mask); usr2action.sa_flags = 0; sigaction(SIGUSR2, &usr2action, NULL); hupaction.sa_handler = restart_log; sigemptyset(&hupaction.sa_mask); hupaction.sa_flags = 0; sigaction(SIGHUP, &hupaction, NULL); termaction.sa_handler = quit; sigemptyset(&termaction.sa_mask); termaction.sa_flags = 0; sigaction(SIGTERM, &termaction, NULL); alrmaction.sa_handler = alarm_handler; sigemptyset(&alrmaction.sa_mask); alrmaction.sa_flags = 0; signal(SIGPIPE, SIG_IGN); } static void check_signals(void) { if (stats_flag) { if (webfile) webstats(); else textstats(); stats_flag=0; } if (restart_log_flag) { if (logfp) { fclose(logfp); logfp = fopen(logfile, "a"); if (!logfp) error("Can't open logfile %s", logfile); } read_cfg(cfgfile); restart_log_flag=0; } } #else static void setup_signals(void) { ; } static void check_signals(void) { ; } #endif static void check_listen_socket(void) { struct sockaddr_storage cli_addr; socklen_t clilen = sizeof cli_addr; int i, downfd; DEBUG(2, "check_listen_socket()"); if (dsr_if) { /* special case for dsr */ dsr_frame(listenfd); } else if (udp) { /* special case for udp */ downfd = listenfd; add_client(downfd, &cli_addr); } else { /* process tcp connection(s) */ for (i = 0; i < multi_accept; i++) { if (connections_used >= connections_max) break; if (pending_queue >= pending_max) break; downfd = accept_nb(listenfd, (struct sockaddr *)&cli_addr, &clilen); if (downfd < 0) { if (debuglevel && errno != EAGAIN) { debug("accept: %s", strerror(errno)); } break; } if (clilen == 0) { DEBUG(1, "clilen: %s", strerror(errno)); break; } add_client(downfd, &cli_addr); } DEBUG(2, "accepted %d connections", i); } } static void check_control_socket(void) { struct sockaddr_storage cli_addr; socklen_t clilen = sizeof cli_addr; int downfd = accept(ctrlfd, (struct sockaddr *) &cli_addr, &clilen); DEBUG(2, "check_control_socket()"); if (downfd < 0) { DEBUG(1, "accept: %s", strerror(errno)); return; } if (clilen == 0) { DEBUG(1, "clilen: %s", strerror(errno)); return; } do_ctrl(downfd, &cli_addr); } static void check_if_connected(int i) { int result; socklen_t length = sizeof result; DEBUG(2, "Something happened to connection %d", i); if (getsockopt(conns[i].upfd, SOL_SOCKET, SO_ERROR, (void *)&result, &length) < 0) { debug("Can't getsockopt: %s", strerror(errno)); close_conn(i); return; } if (result != 0) { debug("Connect failed: %s", strerror(result)); debug("blacklisting server %d because of connect failure", conns[i].server); blacklist_server(conns[i].server); if (failover_server(i) == 0) { //close_conn(i); } return; } DEBUG(2, "Connection %d completed", i); if (conns[i].state == CS_IN_PROGRESS) { pending_list = dlist_remove(conns[i].pend); pending_queue--; } conns[i].state = CS_CONNECTED; conns[i].t = now; if (conns[i].downfd == -1) { /* idler */ conns[i].state |= CS_CLOSED_DOWN; } else { event_add(conns[i].downfd, EVENT_READ); } event_arm(conns[i].upfd, EVENT_READ); servers[conns[i].server].c++; } static void check_if_timeout(int i) { DEBUG(2, "check_if_timeout(%d, %d)\n" \ "conns[%d].t = %d\n" \ "now-conns[%d].t = %d", \ (int)now, i, i, conns[i].t, i, now-conns[i].t); if (now-conns[i].t >= timeout) { DEBUG(2, "Connection %d timed out", i); debug("blacklisting server %d because of connect timeout", conns[i].server); blacklist_server(conns[i].server); if (failover_server(i) == 0) { //close_conn(i); } } else { DEBUG(2, "Keep waiting..."); } } static int try_copy_up(int i) { DEBUG(2, "want to read from downstream socket %d of connection %d", conns[i].downfd, i); if (copy_up(i) < 0) { //close_conn(i); return 0; } return 1; } static int try_copy_down(int i) { DEBUG(2, "want to read from upstream socket %d of connection %d", conns[i].upfd, i); if (copy_down(i) < 0) { //close_conn(i); return 0; } return 1; } static int try_flush_down(int i) { DEBUG(2, "want to write to downstream socket %d of connection %d", conns[i].downfd, i); if (flush_down(i) < 0) { //close_conn(i); return 0; } return 1; } static int try_flush_up(int i) { DEBUG(2, "want to write to upstream socket %d of connection %d", conns[i].upfd, i); if (flush_up(i) < 0) { //close_conn(i); return 0; } return 1; } static void arm_listenfd(void) { static int can_accept = 0; if (can_accept) { if (connections_used >= connections_max) { event_arm(listenfd, 0); can_accept = 0; } } else { if (connections_used < connections_max) { event_arm(listenfd, EVENT_READ); can_accept = 1; } } } static int handle_events(int *pending_close) { int fd, conn, events; int npc = 0; for (fd = event_fd(&events); fd != -1; fd = event_fd(&events)) { int closing = 0; DEBUG(2, "event_fd returns fd=%d, events=%d", fd, events); if (events == 0) continue; if (fd == listenfd) { if (events & EVENT_READ) { check_listen_socket(); } continue; } if (fd == ctrlfd) { if (events & EVENT_READ) { check_control_socket(); } continue; } conn = fd2conn_get(fd); DEBUG(3, "fd = %d => conn = %d", fd, conn); if (conn == -1) continue; if (conns[conn].state & CS_IN_PROGRESS) { if (fd == conns[conn].upfd && events & EVENT_WRITE) { check_if_connected(conn); } continue; } conns[conn].t = now; if (fd == conns[conn].downfd) { if (!udp && (events & EVENT_READ)) { if (!try_copy_up(conn)) closing = 1; } if (events & EVENT_WRITE) { if (!try_flush_down(conn)) closing = 1; } } else { /* down */ if (events & EVENT_READ) { if (!try_copy_down(conn)) closing = 1; } if (!udp && (events & EVENT_WRITE)) { if (!try_flush_up(conn)) closing = 1; } } if (conns[conn].state == CS_CLOSED) { DEBUG(2, "Connection %d was closed", conn); closing = 1; } if (closing) { pending_close[npc++] = conn; } } return npc; } static void pending_and_closing(int *pending_close, int npc) { int j, p, start; if (pending_list != -1) { p = start = pending_list; do { int conn = dlist_value(p); if (conns[conn].state == CS_IN_PROGRESS) { check_if_timeout(conn); } p = dlist_next(p); } while (p != start); } for (j = 0; j < npc; j++) { int conn = pending_close[j]; if (closing_time(conn)) { close_conn(conn); } } if (idlers > idlers_wanted) { close_idlers(idlers-idlers_wanted); } while (idlers < idlers_wanted) { if (!add_idler()) break; } } static void check_idle_timeout(void) { static int conn = 0; int i, n; if (idle_timeout == 0) return; n = connections_max/idle_timeout; DEBUG(2, "check_idle_timeout(): conn=%d, n=%d", conn, n); for (i = 0; i < n; i++) { if (conns[conn].state == CS_CONNECTED && now-conns[conn].t >= idle_timeout) { DEBUG(2, "Connection %d idle for %d seconds, closing", conn, now-conns[conn].t); close_conn(conn); } conn = (conn+1)%connections_max; } } void mainloop(void) { int npc; int *pending_close; event_init(); event_add(listenfd, EVENT_READ); dlist_init(connections_max); if (ctrlfd != -1) event_add(ctrlfd, EVENT_READ); setup_signals(); loopflag = 1; pending_close = pen_malloc(connections_max * sizeof *pending_close); DEBUG(2, "mainloop()"); while (loopflag) { check_signals(); if (dsr_if) dsr_arp(listenfd); if (udp && (connections_used >= connections_max)) recycle_connection(); arm_listenfd(); event_wait(); now = time(NULL); DEBUG(2, "After event_wait()"); npc = handle_events(pending_close); pending_and_closing(pending_close, npc); check_idle_timeout(); } } static int options(int argc, char **argv) { int c; char b[1024]; #ifdef HAVE_LIBSSL char *opt = "B:C:F:O:S:T:b:c:e:i:j:l:m:o:p:q:t:u:w:x:DHNPQWXUadfhnrsE:K:G:A:ZRL:"; #else char *opt = "B:C:F:O:S:T:b:c:e:i:j:l:m:o:p:q:t:u:w:x:DHNPQWXUadfhnrs"; #endif while ((c = getopt(argc, argv, opt)) != -1) { switch (c) { case 'B': a_server = optarg; break; case 'C': ctrlport = optarg; break; case 'D': fprintf(stderr, "Pen 0.26.0 removed the delayed forward feature,\n" "making the -D option obsolete\n"); break; case 'F': cfgfile = optarg; break; case 'H': http = 1; break; case 'O': do_cmd(optarg, output_file, stdout); break; case 'Q': event_init = kqueue_init; break; case 'P': event_init = poll_init; break; case 'S': fprintf(stderr, "As of 0.28.1 the server table is expanded dynamically,\n" "making the -S option obsolete\n"); break; case 'T': tracking_time = atoi(optarg); break; case 'U': udp = 1; break; case 'W': server_alg |= ALG_WEIGHT; break; case 'X': exit_enabled = 1; break; case 'a': asciidump = 1; break; case 'b': blacklist_time = atoi(optarg); break; case 'c': expand_clienttable(atoi(optarg)); break; case 'd': debuglevel++; break; case 'e': e_server = optarg; break; case 'f': foreground = 1; break; case 'h': server_alg |= ALG_HASH; break; case 'i': #ifdef WINDOWS install_service(optarg); #else fprintf(stderr, "Windows only\n"); #endif exit(0); case 'j': jail = optarg; break; case 'l': logfile = pen_strdup(optarg); break; case 'm': multi_accept = atoi(optarg); if (multi_accept < 1) { fprintf(stderr, "multi_accept bumped to 1\n"); multi_accept = 1; } break; case 'n': fprintf(stderr, "Pen 0.26.0 and up uses only nonblocking sockets,\n" "making the -n option obsolete\n"); break; case 'o': snprintf(b, sizeof b, "%s", optarg); do_cmd(optarg, output_file, stdout); break; case 'p': pidfile = optarg; break; case 'q': listen_queue = atoi(optarg); if (listen_queue < 50) { fprintf(stderr, "listen_queue bumped to 50\n"); listen_queue = 50; } break; case 'r': server_alg |= ALG_ROUNDROBIN; break; case 's': server_alg |= ALG_STUBBORN; break; case 't': timeout = atoi(optarg); if (timeout < 1) { usage(); } break; case 'u': #ifdef WINDOWS delete_service(optarg); exit(0); #else user = optarg; #endif break; case 'x': expand_conntable(atoi(optarg)); break; case 'w': webfile = pen_strdup(optarg); break; #ifdef HAVE_LIBSSL case 'E': certfile = optarg; break; case 'K': keyfile = optarg; break; case 'G': cacert_file = optarg; break; case 'A': cacert_dir = optarg; break; case 'Z': ssl_compat = 1; break; case 'R': require_peer_cert = 1; break; case 'L': if (strcmp(optarg, "ssl23") == 0) ssl_protocol = SRV_SSL_V23; else if (strcmp(optarg, "ssl2") == 0) ssl_protocol = SRV_SSL_V2; else if (strcmp(optarg, "ssl3") == 0) ssl_protocol = SRV_SSL_V3; else if (strcmp(optarg, "tls1") == 0) ssl_protocol = SRV_SSL_TLS1; else { fprintf(stderr, "protocol version %s not known\n", optarg); exit(1); } break; #endif /* HAVE_LIBSSL */ case '?': default: usage(); } } return optind; } int main(int argc, char **argv) { int i, n; acl_init(); n = options(argc, argv); argc -= n; argv += n; #ifndef WINDOWS if (argc < 1) { usage(); } #endif now = time(NULL); #ifdef WINDOWS start_winsock(); #endif read_cfg(cfgfile); #ifndef WINDOWS struct rlimit r; getrlimit(RLIMIT_CORE, &r); r.rlim_cur = r.rlim_max; setrlimit(RLIMIT_CORE, &r); signal(SIGCHLD, SIG_IGN); if (!foreground) { background(); } #endif /* we must open listeners before dropping privileges */ /* Control port */ if (ctrlport) { if (getuid() == 0 && user == NULL) { debug("Won't open control port running as root; use -u to run as different user"); } else { ctrlfd = open_listener(ctrlport); } } /* Balancing port */ if (udp) { protoid = SOCK_DGRAM; proto = "udp"; } snprintf(listenport, sizeof listenport, "%s", argv[0]); /* Direct server return */ if (dsr_if) { listenfd = dsr_init(dsr_if, listenport); if (listenfd == -1) { error("Can't initialize direct server return"); } } else { listenfd = open_listener(listenport); } init(argc, argv); #ifdef HAVE_LIBSSL if (certfile) { ssl_init(); } #endif #ifndef WINDOWS /* we must look up user id before chrooting */ struct passwd *pwd = NULL; if (user) { DEBUG(1, "Run as user %s", user); pwd = getpwnam(user); if (pwd == NULL) error("Can't getpwnam(%s)", user); } /* we must chroot before dropping privileges */ if (jail) { DEBUG(1, "Run in %s", jail); if (chroot(jail) == -1) error("Can't chroot(%s)", jail); } /* ready to defang ourselves */ if (pwd) { if (setgid(pwd->pw_gid) == -1) error("Can't setgid(%d)", (int)pwd->pw_gid); if (setuid(pwd->pw_uid) == -1) error("Can't setuid(%d)", (int)pwd->pw_uid); } #endif open_log(logfile); if (pidfile) { pidfp = fopen(pidfile, "w"); if (!pidfp) { error("Can't create pidfile %s", pidfile); exit(1); } fprintf(pidfp, "%d", (int)getpid()); fclose(pidfp); } #ifdef WINDOWS if (!foreground) { char cfgdir[1024], *p, dirsep = '\\'; GetModuleFileName(NULL, cfgdir, sizeof cfgdir); cfgdir[sizeof cfgdir - 1] = '\0'; p = strrchr(cfgdir, dirsep); if (p) *p = '\0'; chdir(cfgdir); read_cfg("pen.cfg"); service_main(0, NULL); } else { mainloop(); } #else mainloop(); #endif DEBUG(1, "Exiting, cleaning up..."); if (logfp) fclose(logfp); for (i = 0; i < connections_max; i++) { if (conns[i].downfd != -1) close_conn(i); } close(listenfd); if (pidfile) { unlink(pidfile); } return 0; } pen-0.32.0/acl.c0000644000175000017500000001666212622643701010220 00000000000000#include "config.h" #include #include #include #ifdef WINDOWS #include #else #include #include #include #endif #ifdef HAVE_LIBGEOIP #include GeoIP *geoip4, *geoip6; #endif #include "acl.h" #include "diag.h" #include "memory.h" #include "netconv.h" #include "windows.h" #define ACE_IPV4 (1) #define ACE_IPV6 (2) #define ACE_GEO (3) static int nacls[ACLS_MAX]; static acl *acls[ACLS_MAX]; static unsigned char mask_ipv6[129][16]; static void init_mask(void) { unsigned char m6[16]; int i, j; memset(m6, 0, sizeof m6); for (i = 0; i < 129; i++) { for (j = 15; j >= 0; j--) { mask_ipv6[i][j] = m6[j]; m6[j] >>= 1; if (j > 0) { m6[j] |= (m6[j-1] << 7); } else { m6[j] |= (1 << 7); } } } } /* allocate ace and fill in the generics */ static int add_acl(int a, unsigned char permit) { int i; if (a < 0 || a >= ACLS_MAX) { debug("add_acl: %d outside (0,%d)", a, ACLS_MAX); return -1; } i = nacls[a]++; acls[a] = pen_realloc(acls[a], nacls[a]*sizeof(acl)); acls[a][i].permit = permit; return i; } void add_acl_ipv4(int a, unsigned int ip, unsigned int mask, unsigned char permit) { int i = add_acl(a, permit); if (i == -1) return; DEBUG(2, "add_acl_ipv4(%d, %x, %x, %d)", a, ip, mask, permit); acls[a][i].class = ACE_IPV4; acls[a][i].ace.ipv4.ip = ip; acls[a][i].ace.ipv4.mask = mask; } void add_acl_ipv6(int a, unsigned char *ipaddr, unsigned char len, unsigned char permit) { int i = add_acl(a, permit); if (i == -1) return; DEBUG(2, "add_acl_ipv6(%d, %x, %d, %d)\n" \ "%x:%x:%x:%x:%x:%x:%x:%x/%d", \ a, ipaddr, len, permit, \ 256*ipaddr[0]+ipaddr[1], 256*ipaddr[2]+ipaddr[3], 256*ipaddr[4]+ipaddr[5], 256*ipaddr[6]+ipaddr[7], \ 256*ipaddr[8]+ipaddr[9], 256*ipaddr[10]+ipaddr[11], 256*ipaddr[12]+ipaddr[13], 256*ipaddr[14]+ipaddr[15], len); acls[a][i].class = ACE_IPV6; memcpy(acls[a][i].ace.ipv6.ip.s6_addr, ipaddr, 16); acls[a][i].ace.ipv6.len = len; } void add_acl_geo(int a, char *country, unsigned char permit) { int i = add_acl(a, permit); if (i == -1) return; DEBUG(2, "add_acl_geo(%d, %s, %d", a, country, permit); acls[a][i].class = ACE_GEO; strncpy(acls[a][i].ace.geo.country, country, 2); } void del_acl(int a) { DEBUG(2, "del_acl(%d)", a); if (a < 0 || a >= ACLS_MAX) { debug("del_acl: %d outside (0,%d)", a, ACLS_MAX); return; } free(acls[a]); acls[a] = NULL; nacls[a] = 0; } #ifndef WINDOWS static int match_acl_unix(int a, struct sockaddr_un *cli_addr) { DEBUG(2, "Unix acl:s not implemented"); return 1; } #endif static int match_acl_ipv4(int a, struct sockaddr_in *cli_addr) { unsigned int client = cli_addr->sin_addr.s_addr; int i; int permit = 0; acl *ap = acls[a]; #ifdef HAVE_LIBGEOIP const char *country = NULL; int geo_done = 0; #endif DEBUG(2, "match_acl_ipv4(%d, %u)", a, client); for (i = 0; i < nacls[a]; i++) { permit = ap[i].permit; switch (ap[i].class) { case ACE_IPV4: if ((client & ap[i].ace.ipv4.mask) == ap[i].ace.ipv4.ip) { return permit; } break; case ACE_GEO: #ifdef HAVE_LIBGEOIP if (geoip4 == NULL) break; if (!geo_done) { country = GeoIP_country_code_by_addr(geoip4, pen_ntoa((struct sockaddr_storage *)cli_addr)); DEBUG(2, "Country = %s", country?country:"unknown"); geo_done = 1; } if (country && !strncmp(country, ap[i].ace.geo.country, 2)) { return permit; } #else debug("ACE_GEO: Not implemented"); #endif break; default: /* ignore other ACE classes (ipv6 et al) */ break; } } return !permit; } /* The most straightforward way to get at the bytes of an ipv6 address is to take the pointer to the in6_addr and cast it to a pointer to unsigned char. */ static int match_acl_ipv6(int a, struct sockaddr_in6 *cli_addr) { unsigned char *client = (unsigned char *)&(cli_addr->sin6_addr); unsigned char *ip; unsigned char *mask; int len; int i, j; int permit = 0; acl *ap = acls[a]; #ifdef HAVE_LIBGEOIP const char *country = NULL; int geo_done = 0; #endif DEBUG(2, "match_acl_ipv6(%d, %u)", a, client); for (i = 0; i < nacls[a]; i++) { permit = ap[i].permit; switch (ap[i].class) { case ACE_IPV6: len = ap[i].ace.ipv6.len; ip = (unsigned char *)&(ap[i].ace.ipv6.ip); mask = mask_ipv6[len]; DEBUG(2, "Matching %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x against %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x / %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", \ client[0], client[1], client[2], client[3], \ client[4], client[5], client[6], client[7], \ client[8], client[9], client[10], client[11], \ client[12], client[13], client[14], client[15], \ ip[0], ip[1], ip[2], ip[3], \ ip[4], ip[5], ip[6], ip[7], \ ip[8], ip[9], ip[10], ip[11], \ ip[12], ip[13], ip[14], ip[15], \ mask[0], mask[1], mask[2], mask[3], \ mask[4], mask[5], mask[6], mask[7], \ mask[8], mask[9], mask[10], mask[11], \ mask[12], mask[13], mask[14], mask[15]); for (j = 0; j < 16; j++) { if ((client[j] & mask[j]) != ip[j]) break; } if (j == 16) return permit; break; case ACE_GEO: #ifdef HAVE_LIBGEOIP if (geoip6 == NULL) break; if (!geo_done) { country = GeoIP_country_code_by_addr_v6(geoip6, pen_ntoa((struct sockaddr_storage *)cli_addr)); DEBUG(2, "Country = %s", country?country:"unknown"); geo_done = 1; } if (country && !strncmp(country, ap[i].ace.geo.country, 2)) { return permit; } #else debug("ACE_GEO: Not implemented"); #endif break; default: /* ignore other ACE classes (ipv4 et al) */ break; } } return !permit; } /* returns nonzero if the acl is matched, zero otherwise */ int match_acl(int a, struct sockaddr_storage *cli_addr) { if (a < 0 || a > ACLS_MAX) return 0; /* acl out of bounds */ switch (cli_addr->ss_family) { #ifndef WINDOWS case AF_UNIX: return match_acl_unix(a, (struct sockaddr_un *)cli_addr); #endif case AF_INET: return match_acl_ipv4(a, (struct sockaddr_in *)cli_addr); case AF_INET6: return match_acl_ipv6(a, (struct sockaddr_in6 *)cli_addr); default: debug("match_acl: unknown address family %d", cli_addr->ss_family); } return 0; } void save_acls(FILE *fp) { int i, j; struct in_addr ip; char ip_str[INET6_ADDRSTRLEN]; for (i = 0; i < ACLS_MAX; i++) { fprintf(fp, "no acl %d\n", i); for (j = 0; j < nacls[i]; j++) { fprintf(fp, "acl %d %s ", i, acls[i][j].permit?"permit":"deny"); switch (acls[i][j].class) { case ACE_IPV4: memcpy(&ip, &acls[i][j].ace.ipv4.ip, 4); fprintf(fp, "%s ", inet_ntoa(ip)); memcpy(&ip, &acls[i][j].ace.ipv4.mask, 4); fprintf(fp, "%s\n", inet_ntoa(ip)); break; case ACE_IPV6: fprintf(fp, "%s/%d\n", inet_ntop(AF_INET6, &acls[i][j].ace.ipv6.ip, ip_str, sizeof ip_str), acls[i][j].ace.ipv6.len); break; case ACE_GEO: fprintf(fp, "country %c%c\n", acls[i][j].ace.geo.country[0], acls[i][j].ace.geo.country[1]); break; default: debug("Unknown ACE class %d (this is probably a bug)", acls[i][j].class); } } } } void acl_init(void) { init_mask(); #ifdef HAVE_LIBGEOIP geoip4 = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_MEMORY_CACHE); if (geoip4 == NULL) debug("Could not initialize GeoIP for IPv4"); geoip6 = GeoIP_open_type(GEOIP_COUNTRY_EDITION_V6, GEOIP_MEMORY_CACHE); if (geoip6 == NULL) debug("Could not initialize GeoIP for IPv6"); #endif } pen-0.32.0/Makefile.in0000644000175000017500000007604512624554542011371 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : bin_PROGRAMS = pen$(EXEEXT) mergelogs$(EXEEXT) penctl$(EXEEXT) \ penlog$(EXEEXT) penlogd$(EXEEXT) subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in depcomp $(noinst_HEADERS) COPYING TODO \ compile install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \ "$(DESTDIR)$(docdir)" PROGRAMS = $(bin_PROGRAMS) am_mergelogs_OBJECTS = mergelogs.$(OBJEXT) memory.$(OBJEXT) \ diag.$(OBJEXT) settings.$(OBJEXT) mergelogs_OBJECTS = $(am_mergelogs_OBJECTS) mergelogs_LDADD = $(LDADD) am_pen_OBJECTS = pen.$(OBJEXT) select.$(OBJEXT) poll.$(OBJEXT) \ kqueue.$(OBJEXT) epoll.$(OBJEXT) dlist.$(OBJEXT) ssl.$(OBJEXT) \ dsr.$(OBJEXT) memory.$(OBJEXT) diag.$(OBJEXT) \ settings.$(OBJEXT) acl.$(OBJEXT) event.$(OBJEXT) \ netconv.$(OBJEXT) server.$(OBJEXT) client.$(OBJEXT) \ conn.$(OBJEXT) idlers.$(OBJEXT) pen_OBJECTS = $(am_pen_OBJECTS) pen_LDADD = $(LDADD) am_penctl_OBJECTS = penctl.$(OBJEXT) penctl_OBJECTS = $(am_penctl_OBJECTS) penctl_LDADD = $(LDADD) am_penlog_OBJECTS = penlog.$(OBJEXT) diag.$(OBJEXT) settings.$(OBJEXT) penlog_OBJECTS = $(am_penlog_OBJECTS) penlog_LDADD = $(LDADD) am_penlogd_OBJECTS = penlogd.$(OBJEXT) diag.$(OBJEXT) \ settings.$(OBJEXT) penlogd_OBJECTS = $(am_penlogd_OBJECTS) penlogd_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(mergelogs_SOURCES) $(pen_SOURCES) $(penctl_SOURCES) \ $(penlog_SOURCES) $(penlogd_SOURCES) DIST_SOURCES = $(mergelogs_SOURCES) $(pen_SOURCES) $(penctl_SOURCES) \ $(penlog_SOURCES) $(penlogd_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 NROFF = nroff MANS = $(man_MANS) DATA = $(doc_DATA) HEADERS = $(noinst_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope AM_RECURSIVE_TARGETS = cscope DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_HEADERS = pen.h dlist.h ssl.h dsr.h memory.h diag.h settings.h acl.h event.h pen_select.h pen_poll.h pen_kqueue.h pen_epoll.h netconv.h windows.h server.h client.h conn.h idlers.h pen_SOURCES = pen.c select.c poll.c kqueue.c epoll.c dlist.c ssl.c dsr.c memory.c diag.c settings.c acl.c event.c netconv.c server.c client.c conn.c idlers.c mergelogs_SOURCES = mergelogs.c memory.c diag.c settings.c penctl_SOURCES = penctl.c penlog_SOURCES = penlog.c diag.c settings.c penlogd_SOURCES = penlogd.c diag.c settings.c doc_DATA = penstats HOWTO AUTHORS README ChangeLog COPYING man_MANS = pen.1 mergelogs.1 penctl.1 penlog.1 penlogd.1 EXTRA_DIST = $(man_MANS) $(doc_DATA) penctl.cgi pen.spec siag.pem \ Makefile.win X86/Makefile X64/Makefile windows.c config.h.win \ pen-ocsp.sh all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) mergelogs$(EXEEXT): $(mergelogs_OBJECTS) $(mergelogs_DEPENDENCIES) $(EXTRA_mergelogs_DEPENDENCIES) @rm -f mergelogs$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mergelogs_OBJECTS) $(mergelogs_LDADD) $(LIBS) pen$(EXEEXT): $(pen_OBJECTS) $(pen_DEPENDENCIES) $(EXTRA_pen_DEPENDENCIES) @rm -f pen$(EXEEXT) $(AM_V_CCLD)$(LINK) $(pen_OBJECTS) $(pen_LDADD) $(LIBS) penctl$(EXEEXT): $(penctl_OBJECTS) $(penctl_DEPENDENCIES) $(EXTRA_penctl_DEPENDENCIES) @rm -f penctl$(EXEEXT) $(AM_V_CCLD)$(LINK) $(penctl_OBJECTS) $(penctl_LDADD) $(LIBS) penlog$(EXEEXT): $(penlog_OBJECTS) $(penlog_DEPENDENCIES) $(EXTRA_penlog_DEPENDENCIES) @rm -f penlog$(EXEEXT) $(AM_V_CCLD)$(LINK) $(penlog_OBJECTS) $(penlog_LDADD) $(LIBS) penlogd$(EXEEXT): $(penlogd_OBJECTS) $(penlogd_DEPENDENCIES) $(EXTRA_penlogd_DEPENDENCIES) @rm -f penlogd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(penlogd_OBJECTS) $(penlogd_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dsr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epoll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idlers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kqueue.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mergelogs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netconv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/penctl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/penlog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/penlogd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/select.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settings.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` install-man1: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-docDATA: $(doc_DATA) @$(NORMAL_INSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ done uninstall-docDATA: @$(NORMAL_UNINSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) $(HEADERS) config.h installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(docdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-docDATA install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-docDATA uninstall-man uninstall-man: uninstall-man1 .MAKE: all install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \ clean-binPROGRAMS clean-cscope clean-generic cscope \ cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-compile distclean-generic \ distclean-hdr distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-binPROGRAMS install-data \ install-data-am install-docDATA install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-man1 \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-docDATA uninstall-man uninstall-man1 tgz: rm -rf tmpinst mkdir tmpinst make clean ./configure --prefix=/usr make make install-strip prefix=tmpinst/usr (cd tmpinst && makepkg pen.tgz && mv pen.tgz ..) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pen-0.32.0/HOWTO0000644000175000017500000002554612507562420010141 00000000000000HTTP ---- pen -l pen.log -p pen.pid lbhost:80 host1:80 host2:80 If pen is running on one of the web servers, it might seem like a good idea to simply use an alternative port for the web server process, reusing the IP address. Unfortunately, that doesn't work very well. Look at this (simplified) example: sh-2.05# pen lbhost:80 lbhost:8080 sh-2.05# telnet lbhost 80 Trying 127.0.0.1... Connected to lbhost. Escape character is '^]'. GET /bb 301 Moved Permanently

Moved Permanently

The document has moved here.


Apache/1.3.14 Server at lbhost Port 8080
Connection closed by foreign host. This will cause the client to attempt to contact the web server directly, which may not be possible depending on firewall configuration and is certainly not desirable since it defeats any load balancing attempts from pen. The solution is to bind two addresses to the server running pen, and use one address for pen and the other for the web server. Like this: pen address1:80 address2:80 server2:80 Here, address1 and address2 refer to the same server, while server2 refers to another server. The programs penlog and penlogd are used to combine the web server logs into a single file which can be used to calculate statistics. Penlog runs on each of the web servers. It reads log entries from stdin and sends them over the network to the host running penlogd. For Apache, this is accomplished by adding a line similar to this to httpd.conf: CustomLog "|/usr/local/bin/penlog loghost 10000" common For other web servers, the procedure is different. If the server cannot write its logs to a pipe, this kludge may actually work: tail -f /path/to/logfile | penlogd loghost 10000 The command line to pen must also be altered to indicate that the logs should go to the penlogd server rather than a file. This is accomplished using the -l loghost:10000 option. The log file pen.log is used to combine the web server logs into a single file which can be used to calculate statistics. Example: mergelogs -p pen.log \ 10.0.0.1:access_log.host1 10.0.0.2:access_log.host2 \ > access_log The program mergelogs is distributed with pen. Use matching versions of pen and mergelogs to ensure that the log file format is compatible. 10.0.0.1 and 10.0.0.2 are the IP addresses of host1 and host2. The log files access_log.host1 and access_log.host2 are Apache access log files in combined or common format. The resulting access_log is in the same format as the input files. If the log file will be used to calculate visitor statistics, you probably want host names rather than IP addresses. This can be accomplished by forcing the web server to do hostname lookups on the clients. This harms performance since the lookups are slow. A better solution is to use a separate program to process the log file. One such program is webresolve, which is usually run from the splitwr script to perform many lookups in parallel. Example: splitwr access_log > access_log.resolved Webresolve is available from http://siag.nu/webresolve/. HTTPS ----- pen -l pen.log -p pen.pid lbhost:443 host1:443 host2:443 Otherwise identical to http (for our purposes), https uses port 443. Using pen for the ssl encapsulation: pen -l pen.log -p pen.pid -E mycert.pem lbhost:443 host1:80 host2:80 HTTP + HTTPS ------------ pen -l pen80.log -p pen80.pid -h lbhost:80 host1:80 host2:80 pen -l pen443.log -p pen443.pid -h lbhost:443 host1:443 host2:443 If we are using http and https in parallel for a single site and need to make sure that requests go to the same server for both protocols, we use the -h (hash) option. Note that it is still possible for a client to end up with a split connection if e.g. http is down on host1 and https is down on host2. The server selection can be made completely deterministic by adding the -s option. Pen will then stubbornly refuse to fail over to another server if the first choice is unavailable. Obviously, this means the site will fail for some clients if either http or https is down on any server, which is unsatisfactory. A better solution is to use a single protocol for all communication, or design the application such that split connections do not matter. For example, serve static content such as images over http. SMTP ---- pen -l pen.log -p pen.pid -r lbhost:25 host1:25 host2:25 This is straightforward enough, with the added twist that all connections to host1 and host2 appear to come from lbhost. It is therefore important that care be taken so that the setup can't be used as an open relay for spam. An example use for load balancing with smtp is for large sites with a high volume of outgoing mail. FTP --- pen -l pen.log -p pen.pid lbhost:21 host1:21 host2:21 The ftp protocol has quirks that makes load balancing more difficult than many other protocols. Details in RFC959, but here is an example from a pen debug session: copy_up(0) 23: PORT 127,0,0,1,12,212 copy_down(0) 30: 200 PORT command successful. copy_up(0) 18: RETR loadlin.exe copy_down(0) 72: 150 Opening BINARY mode data connection for loadlin.exe (32177 bytes). copy_down(0) 24: 226 Transfer complete. Notice how the last two entries claim that the transfer is first "opening", and then "complete" with no intermediary step. In other words, the initial connection is just a command telnet stream. For the data transfer, the client opens a port of its own and the server connects directly there, bypassing the load balancer. There isn't necessarily anything particularly wrong about that, except that the server will connect from an address that the client doesn't expect, and it will have to connect *to* an address that is different from the peer in the command stream. In addition, it may not work if the server is behind a firewall and it most certainly won't work if pen is acting as the firewall. A solution would be to intercept the PORT command, open a connection there, listen to a socket of our own and send a new PORT command to the server instead of the one the client sent. We would also need to track the command stream during the data transfer, and check for things like ABOR and STAT. And we'd have to implements all kinds of workarounds for buggy clients and servers. Messy indeed, and pen doesn't even try. Browse through an ftp client some time; it's entertaining to see what programmers think of the protocol. Here is a recipe for ftp load balancing that is portable, works and is easy to implement. First a snippet from /etc/hosts. The IP addresses are supposed to be public addresses. It is possible to play tricks with NAT to remove that requirement, but that is beyond the scope of this document. 123.123.123.1 lbhost 123.123.123.2 host1 123.123.123.3 host2 ftp servers are running on host1 and host2. Use this command to start pen on lbhost: pen -l pen.log -p pen.pid lbhost:21 host1:21 host2:21 Incoming connections from clients are distributed to host1 and host2, transparently to the user. Outgoing connections from host1 and host2 bypass lbhost. If there is a firewall between the servers and the Internet, it must permit incoming traffic to lbhost on port 21 and outgoing traffic from host1 and host2. This can be prevented from working if the client is behind a firewall that does its own stateful session tracking (for example, setting up temporary rules that let the server access the client on the port given in the PORT command), but there's little or nothing we can do about that. Such schemes break anyway if the server has multiple IP addresses, load balancing or not. Picky servers that refuse to set up data streams that bypass the load balancer won't work either, but then we at least have the option to replace the server. The stock Solaris ftpd is fine; wu-ftpd 2.6.0 is not. POP3 ---- The pop3 service normally runs from inetd. In that case, it is not possible to use multiple IP addresses to allow pen and the pop3 server to run on the same host. However, there's nothing to stop us from using multiple ports. Add this to /etc/services: pop3-pen 1110/tcp And change /etc/inetd.conf like this: # pop3 stream tcp nowait root /usr/sbin/tcpd in.pop3d pop3-pen stream tcp nowait root /usr/sbin/tcpd in.pop3d Note how the old entry for pop3 is commented out. Restart inetd and run pen -p pen.pid pop3 localhost:1110 otherhost:pop3 Pen will listen to the pop3 port and distribute incoming requests to the local pop3 server running on port 1110 and to the pop3 server running on "otherhost" on the standard port. LDAP ---- (This was sent as a reply to a question is pen could handle load balancing and failover for a group of ldap servers.) As far as I know, LDAP is a simple tcp based protocol. The following experiment on my laptop was successful: 1. Install OpenLDAP 2. Run slapd like this: /usr/local/libexec/slapd -d 255 3. Run pen like this: pen -d -d -f 3890 localhost:389 4. Run ldapsearch like this: ldapsearch -H ldap://localhost:3890 \ -x -b '' -s base '(objectclass=*)' namingContexts Slapd and pen spewed lots of debugging info and ldapsearch returned: 8<--- # # filter: (objectclass=*) # requesting: namingContexts # # dn: namingContexts: o=Qbranch,c=SE # search result search: 2 result: 0 Success # numResponses: 2 # numEntries: 1 8<--- which was what I expected. Inspired by this success, I repeated the test: 8<--- /usr/local/libexec/slapd -d 255 -h ldap://localhost:389/ /usr/local/libexec/slapd -d 255 -h ldap://localhost:390/ pen -d -d -f 3890 localhost:389 localhost:390 ldapsearch -H ldap://localhost:3890 \ -x -b '' -s base '(objectclass=*)' namingContexts 8<--- Got a reply. Repeated a few times, then pressed Ctrl-C on the slapd that was serving the replies. Did another ldapsearch and got a reply from the other slapd. As far as I can see, pen handles LDAP load balancing and failover just fine. VRRP ---- It is possible to install pen on two load balancers and use vrrp to get failover in case one of them goes down. To do this, you need two servers (obviously), pen and Jerome Etienne's vrrpd for Linux. Install pen and vrrpd on both servers. Start pen on both servers, using all the same parameters and listening on all addresses. Finally start vrrpd, again using the same parameters on both hosts. Example, using debugging output to show what is going on: pen -df 2323 192.168.1.240:23 vrrpd -i eth0 -v 1 192.168.1.199 Now try telnetting to 192.168.1.199 on port 2323. You should get connected through pen on one of the servers. Log out and stop vrrpd on the active server. Again telnet to 192.168.1.199 port 2323. You should get connected again, this time through pen on the other server. Note that this doesn't provide perfect fault tolerance. Vrrpd only checks if the other server is alive, but it doesn't care if pen is responding. Also note that the legal status of vrrp is unclear, as both Cisco and IBM claim to hold patents on the technology. pen-0.32.0/acl.h0000644000175000017500000000163412624554430010220 00000000000000#ifndef WINDOWS #include #include /* for sockaddr_storage */ #else #include #include #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 46 #endif #endif #define ACLS_MAX 10 /* max acls */ typedef struct { unsigned int ip, mask; } ace_ipv4; typedef struct { struct in6_addr ip; unsigned char len; } ace_ipv6; typedef struct { char country[2]; } ace_geo; typedef struct { unsigned char class; unsigned char permit; union { ace_ipv4 ipv4; ace_ipv6 ipv6; ace_geo geo; } ace; } acl; extern int client_acl; extern void add_acl_ipv4(int, unsigned int, unsigned int, unsigned char); extern void add_acl_ipv6(int, unsigned char *, unsigned char, unsigned char); extern void add_acl_geo(int, char *, unsigned char); extern void del_acl(int); extern int match_acl(int, struct sockaddr_storage *); extern void save_acls(FILE *fp); extern void acl_init(void); pen-0.32.0/compile0000755000175000017500000001624512423346767010703 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pen-0.32.0/epoll.c0000644000175000017500000000524612567007062010572 00000000000000#include "config.h" #include #include #include #include //#include "pen.h" #include "conn.h" #include "diag.h" #include "event.h" #include "memory.h" #ifdef HAVE_EPOLL #include static int efd; static struct epoll_event *epoll_ev; static int epoll_count, maxevents; static int pindex; static void epoll_event_ctl(int fd, int events, int op) { int n, epevents = 0; struct epoll_event ev; memset(&ev, 0, sizeof(struct epoll_event)); DEBUG(2, "epoll_event_ctl(fd=%d, events=%d, op=%d)", fd, events, op); if (events & EVENT_READ) epevents |= EPOLLIN; if (events & EVENT_WRITE) epevents |= EPOLLOUT; ev.events = epevents; ev.data.fd = fd; n = epoll_ctl(efd, op, fd, &ev); if (n == -1) { error("epoll_ctl: %s", strerror(errno)); } } static void epoll_event_add(int fd, int events) { DEBUG(2, "epoll_event_add(fd=%d, events=%d)", fd, events); epoll_event_ctl(fd, events, EPOLL_CTL_ADD); } static void epoll_event_arm(int fd, int events) { DEBUG(2, "epoll_event_arm(fd=%d, events=%d)", fd, events); epoll_event_ctl(fd, events, EPOLL_CTL_MOD); } /* We don't need to do anything here, because this function is only called when we are about to close the socket. */ static void epoll_event_delete(int fd) { DEBUG(2, "epoll_event_delete(fd=%d)", fd); #if 0 epoll_ctl(efd, EPOLL_CTL_DEL, fd, NULL); #endif } static void epoll_event_wait(void) { DEBUG(2, "epoll_event_wait()"); pindex = -1; epoll_count = epoll_wait(efd, epoll_ev, maxevents, 1000*timeout); DEBUG(2, "epoll_wait returns %d", epoll_count); if (epoll_count == -1 && errno != EINTR) { error("Error on epoll_wait: %s", strerror(errno)); } } static int epoll_event_fd(int *revents) { int events = 0; DEBUG(2, "epoll_event_fd(revents=%p)", revents); pindex++; if (pindex >= epoll_count) return -1; DEBUG(3, "\tepoll_ev[%d] = {revents=%d, data.fd=%d}", pindex, epoll_ev[pindex].events, epoll_ev[pindex].data.fd); if (epoll_ev[pindex].events & EPOLLIN) events |= EVENT_READ; if (epoll_ev[pindex].events & EPOLLOUT) events |= EVENT_WRITE; *revents = events; return epoll_ev[pindex].data.fd; } void epoll_init(void) { efd = epoll_create1(0); DEBUG(2, "epoll_create1 returns %d", efd); if (efd == -1) { debug("epoll_create1: %s", strerror(errno)); error("Error creating epoll fd"); } maxevents = connections_max*2+2; epoll_ev = pen_malloc(maxevents*sizeof *epoll_ev); event_add = epoll_event_add; event_arm = epoll_event_arm; event_delete = epoll_event_delete; event_wait = epoll_event_wait; event_fd = epoll_event_fd; } #else void epoll_init(void) { debug("You don't have epoll"); exit(EXIT_FAILURE); } #endif pen-0.32.0/config.h.in0000644000175000017500000000663612624554544011350 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* #undef FD_SETSIZE */ #undef FD_SETSIZE /* #undef HAVE_ACCEPT4 */ #undef HAVE_ACCEPT4 /* #undef HAVE_DAEMON */ #undef HAVE_DAEMON /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* #undef HAVE_EC_KEY */ #undef HAVE_EC_KEY /* #undef HAVE_EPOLL */ #undef HAVE_EPOLL /* #undef HAVE_GETADDRINFO */ #undef HAVE_GETADDRINFO /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* #undef HAVE_KQUEUE */ #undef HAVE_KQUEUE /* Define to 1 if you have the `crypto' library (-lcrypto). */ #undef HAVE_LIBCRYPTO /* Define to 1 if you have the `GeoIP' library (-lGeoIP). */ #undef HAVE_LIBGEOIP /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `resolv' library (-lresolv). */ #undef HAVE_LIBRESOLV /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the `ssl' library (-lssl). */ #undef HAVE_LIBSSL /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_IF_PACKET_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_NETMAP_USER_H /* #undef HAVE_POLL */ #undef HAVE_POLL /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if `major', `minor', and `makedev' are declared in . */ #undef MAJOR_IN_MKDEV /* Define to 1 if `major', `minor', and `makedev' are declared in . */ #undef MAJOR_IN_SYSMACROS /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Version number of package */ #undef VERSION /* Define to `unsigned int' if does not define. */ #undef size_t pen-0.32.0/config.h.win0000644000175000017500000000671512526327460011531 00000000000000/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* #undef FD_SETSIZE */ /* #undef FD_SETSIZE */ #define FD_SETSIZE 1024 /* #undef HAVE_ACCEPT4 */ //#define HAVE_ACCEPT4 1 /* #undef HAVE_DAEMON */ /* #undef HAVE_DAEMON */ /* Define to 1 if you have the header file, and it defines `DIR'. */ #define HAVE_DIRENT_H 1 /* #undef HAVE_EPOLL */ //#define HAVE_EPOLL 1 /* #undef HAVE_GETADDRINFO */ #define HAVE_GETADDRINFO 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* #undef HAVE_KQUEUE */ /* #undef HAVE_KQUEUE */ /* Define to 1 if you have the `crypto' library (-lcrypto). */ #define HAVE_LIBCRYPTO 1 /* Define to 1 if you have the `GeoIP' library (-lGeoIP). */ //#define HAVE_LIBGEOIP 1 /* Define to 1 if you have the `nsl' library (-lnsl). */ #define HAVE_LIBNSL 1 /* Define to 1 if you have the `resolv' library (-lresolv). */ #define HAVE_LIBRESOLV 1 /* Define to 1 if you have the `socket' library (-lsocket). */ /* #undef HAVE_LIBSOCKET */ /* Define to 1 if you have the `ssl' library (-lssl). */ //#define HAVE_LIBSSL 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ /* #undef HAVE_NDIR_H */ /* #undef HAVE_POLL */ //#define HAVE_POLL 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ /* #undef HAVE_SYS_DIR_H */ /* Define to 1 if you have the header file, and it defines `DIR'. */ /* #undef HAVE_SYS_NDIR_H */ /* Define to 1 if you have the header file. */ #define HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if `major', `minor', and `makedev' are declared in . */ /* #undef MAJOR_IN_MKDEV */ /* Define to 1 if `major', `minor', and `makedev' are declared in . */ /* #undef MAJOR_IN_SYSMACROS */ /* Name of package */ #define PACKAGE "pen" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define PACKAGE_NAME "pen" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "pen 0.27.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "pen" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "0.27.0" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 /* Define to 1 if your declares `struct tm'. */ /* #undef TM_IN_SYS_TIME */ /* Version number of package */ #define VERSION "0.28.0" /* Define to `unsigned int' if does not define. */ /* #undef size_t */ pen-0.32.0/install-sh0000755000175000017500000003325512423346767011331 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pen-0.32.0/pen-ocsp.sh0000755000175000017500000000341612514211005011355 00000000000000#!/bin/sh # Run from cron like so: # 0 * * * * /usr/local/bin/pen-ocsp.sh >> /var/log/pen-ocsp.log 2>&1 # Suggested file hierarchy: # /etc/pen # General configuration files # /etc/pen/sni # Private keys, certificates et al, including default certificate # /etc/pen/sni/example.com.key # Private key for example.com # /etc/pen/sni/example.com.crt # Certificate for example.com # /etc/pen/sni/example.com.ca # CA's certificate for example.com # /etc/pen/sni/example.com.ocsp # OCSP response file, auto-loaded by this script # /etc/pen/sni/example.net.key # Private key for example.net # /etc/pen/sni/example.net.crt # Certificate for example.net # /etc/pen/sni/example.net.ca # CA's certificate for example.net # /etc/pen/sni/example.net.ocsp # OCSP response file, auto-loaded by this script # Pen *requires* a default certificate in order to enable SSL. It is suggested that # this certificate is placed in /etc/pen/sni with the other certificates. CFG=/etc/pen SNI=$CFG/sni CTL=/var/run/pen/https.ctl # Sample domains, default domain first: DOMAINS="example.com example.net" # No changes should be necessary below this line. # get_ocsp cert cacert outfile get_ocsp() { uri=`openssl x509 -noout -ocsp_uri -in $1` if test -z "$uri"; then echo "No OCSP URI found in cert" else host=`echo "$uri"|cut -f 3 -d /` openssl ocsp -noverify -issuer "$2" -cert "$1" -url "$uri" -header Host "$host" -respout "$3.tmp" if test -s "$3.tmp"; then mv "$3.tmp" "$3" else echo "No response for $1" fi fi } for d in $DOMAINS; do get_ocsp $SNI/$d.crt $SNI/$d.ca $SNI/$d.ocsp done # Tell Pen to reload the ocsp response for the default ssl context. set $DOMAINS if test -s "$SNI/$1.ocsp"; then penctl "$CTL" "ssl_ocsp_response" "$SNI/$1.ocsp" else echo "No response for default domain $1" fi pen-0.32.0/conn.c0000644000175000017500000001201112531547321010376 00000000000000#include "config.h" #include #include #ifndef WINDOWS #include #endif #include #include "conn.h" #include "client.h" #include "diag.h" #include "dlist.h" #include "event.h" #include "idlers.h" #include "memory.h" #include "pen.h" #include "server.h" #include "settings.h" int idle_timeout = 0; /* never time out */ int pending_list = -1; /* pending connections */ int pending_queue = 0; /* number of pending connections */ int pending_max = 100; /* max number of pending connections */ connection *conns; int connections_max = 0; int connections_used = 0; int connections_last = 0; int tracking_time = TRACKING_TIME; static int fd2conn_max = 0; static int *fd2conn; /* store_conn does fd2conn_set(fd, conn) */ /* close_conn does fd2conn_set(fd, -1) */ void fd2conn_set(int fd, int conn) { DEBUG(3, "fd2conn_set(fd=%d, conn=%d)", fd, conn); if (fd < 0) error("fd2conn_set(fd = %d, conn = %d)", fd, conn); if (fd >= fd2conn_max) { int i, new_max = fd+10000; DEBUG(2, "expanding fd2conn to %d bytes", new_max); fd2conn = pen_realloc(fd2conn, new_max * sizeof *fd2conn); for (i = fd2conn_max; i < new_max; i++) fd2conn[i] = -1; fd2conn_max = new_max; } fd2conn[fd] = conn; } int fd2conn_get(int fd) { if (fd < 0 || fd >= fd2conn_max) return -1; return fd2conn[fd]; } int closing_time(int conn) { int closed = conns[conn].state & CS_CLOSED; if (closed == CS_CLOSED) return 1; if (conns[conn].downn + conns[conn].upn == 0) { return closed & tcp_fastclose; } return 0; } #ifdef HAVE_LIBSSL int store_conn(int downfd, SSL *ssl, int client) #else int store_conn(int downfd, int client) #endif { int i; i = connections_last; do { if (conns[i].state == CS_UNUSED) break; i++; if (i >= connections_max) i = 0; } while (i != connections_last); if (conns[i].state == CS_UNUSED) { connections_last = i; connections_used++; DEBUG(2, "incrementing connections_used to %d for connection %d", connections_used, i); conns[i].upfd = -1; conns[i].downfd = downfd; if (downfd != -1) fd2conn_set(downfd, i); #ifdef HAVE_LIBSSL conns[i].ssl = ssl; #endif conns[i].client = client; conns[i].initial = NO_SERVER; conns[i].server = NO_SERVER; conns[i].srx = conns[i].ssx = 0; conns[i].crx = conns[i].csx = 0; } else { i = -1; if (debuglevel) debug("Connection table full (%d slots), can't store connection.\n" "Try restarting with -x %d", connections_max, 2*connections_max); if (downfd != -1) close(downfd); } DEBUG(2, "store_conn: conn = %d, downfd = %d, connections_used = %d", \ i, downfd, connections_used); return i; } int idler(int conn) { return (conns[conn].state & CS_CONNECTED) && (conns[conn].client == -1); } void close_conn(int i) { int index = conns[i].server; /* unfinished connections have server == NO_SERVER */ if (index != NO_SERVER) { servers[index].c -= 1; if (servers[index].c < 0) servers[index].c = 0; } if (conns[i].upfd != -1 && conns[i].upfd != listenfd) { event_delete(conns[i].upfd); close(conns[i].upfd); fd2conn_set(conns[i].upfd, -1); } #ifdef HAVE_LIBSSL if (conns[i].ssl) { int n = SSL_shutdown(conns[i].ssl); DEBUG(3, "First SSL_shutdown(%d) returns %d", conns[i].ssl, n); if (n == 0) { n = SSL_shutdown(conns[i].ssl); DEBUG(3, "Second SSL_shutdown(%d) returns %d", conns[i].ssl, n); } if (n == -1) { n = SSL_get_error(conns[i].ssl, n); DEBUG(3, "%s", ERR_error_string(SSL_get_error(conns[i].ssl, n), NULL)); ERR_print_errors_fp(stderr); } SSL_free(conns[i].ssl); conns[i].ssl = 0; } #endif if (conns[i].downfd != -1 && conns[i].downfd != listenfd) { event_delete(conns[i].downfd); close(conns[i].downfd); fd2conn_set(conns[i].downfd, -1); } if (idler(i)) idlers--; conns[i].upfd = conns[i].downfd = -1; if (conns[i].downn) { free(conns[i].downb); conns[i].downn=0; } if (conns[i].upn) { free(conns[i].upb); conns[i].upn=0; } connections_used--; DEBUG(2, "decrementing connections_used to %d for connection %d", connections_used, i); if (connections_used < 0) { debug("connections_used = %d. Resetting.", connections_used); connections_used = 0; } if (conns[i].state == CS_IN_PROGRESS) { pending_list = dlist_remove(conns[i].pend); pending_queue--; } conns[i].state = CS_UNUSED; DEBUG(2, "close_conn: Closing connection %d to server %d; connections_used = %d\n" \ "\tRead %ld from client, wrote %ld to server\n" \ "\tRead %ld from server, wrote %ld to client", \ i, index, connections_used, \ conns[i].crx, conns[i].ssx, \ conns[i].srx, conns[i].csx); DEBUG(3, "Aggregate for server %d: sx=%d, rx=%d", conns[i].server, servers[conns[i].server].sx, servers[conns[i].server].rx); } void expand_conntable(size_t size) { int i; DEBUG(1, "expand_conntable(%d)", size); if (size < connections_max) return; /* nothing to do */ conns = pen_realloc(conns, size*sizeof *conns); memset(&conns[connections_max], 0, (size-connections_max)*sizeof *conns); for (i = connections_max; i < size; i++) { conns[i].upfd = conns[i].downfd = -1; } connections_max = size; } pen-0.32.0/diag.c0000644000175000017500000000244412524651724010363 00000000000000#include #include #include #include #ifndef WINDOWS #include #else #include "windows.h" #endif #include "settings.h" int debuglevel; #ifdef WINDOWS static FILE *syslogfp; static void openlog(const char *ident, int option, int facility) { syslogfp = fopen("syslog.txt", "a"); } static void syslog(int priority, const char *format, ...) { va_list ap; va_start(ap, format); if (syslogfp) { vfprintf(syslogfp, format, ap); } va_end(ap); } static void closelog(void) { fclose(syslogfp); } #endif void debug(char *fmt, ...) { time_t now; struct tm *nowtm; char nowstr[80]; char b[4096]; va_list ap; va_start(ap, fmt); vsnprintf(b, sizeof b, fmt, ap); now=time(NULL); nowtm = localtime(&now); strftime(nowstr, sizeof(nowstr), "%Y-%m-%d %H:%M:%S", nowtm); if (foreground) { fprintf(stderr, "%s: %s\n", nowstr, b); } else { openlog("pen", LOG_CONS, LOG_USER); syslog(LOG_DEBUG, "%s\n", b); closelog(); } va_end(ap); } void error(char *fmt, ...) { char b[4096]; va_list ap; va_start(ap, fmt); vsnprintf(b, sizeof b, fmt, ap); fprintf(stderr, "%s\n", b); if (!foreground) { openlog("pen", LOG_CONS, LOG_USER); syslog(LOG_ERR, "%s\n", b); closelog(); } va_end(ap); if (abort_on_error) abort(); else exit(EXIT_FAILURE); } pen-0.32.0/netconv.c0000644000175000017500000001242512524651724011133 00000000000000#include "config.h" #include #include #include #include #ifdef WINDOWS #include #include #include #else #include #include #include #include #include #endif #include "diag.h" #include "windows.h" /* return port number in host byte order */ int getport(char *p, char *proto) { struct servent *s = getservbyname(p, proto); if (s == NULL) { return atoi(p); } else { return ntohs(s->s_port); } } /* Takes a struct sockaddr_storage and returns the port number in host order. For a Unix socket, the port number is 1. */ int pen_getport(struct sockaddr_storage *a) { struct sockaddr_in *si; struct sockaddr_in6 *si6; switch (a->ss_family) { case AF_UNIX: return 1; case AF_INET: si = (struct sockaddr_in *)a; return ntohs(si->sin_port); case AF_INET6: si6 = (struct sockaddr_in6 *)a; return ntohs(si6->sin6_port); default: debug("pen_getport: Unknown address family %d", a->ss_family); } return 0; } int pen_setport(struct sockaddr_storage *a, int port) { struct sockaddr_in *si; struct sockaddr_in6 *si6; switch (a->ss_family) { case AF_UNIX: /* No port for Unix domain sockets */ return 1; case AF_INET: si = (struct sockaddr_in *)a; si->sin_port = htons(port); return 1; case AF_INET6: si6 = (struct sockaddr_in6 *)a; si6->sin6_port = htons(port); return 1; default: debug("pen_setport: Unknown address family %d", a->ss_family); } return 0; } /* Takes a struct sockaddr_storage and returns the name in a static buffer. The address can be a unix socket path or an ipv4 or ipv6 address. */ char *pen_ntoa(struct sockaddr_storage *a) { static char b[1024]; struct sockaddr_in *si; struct sockaddr_in6 *si6; #ifndef WINDOWS struct sockaddr_un *su; #endif switch (a->ss_family) { case AF_INET: si = (struct sockaddr_in *)a; snprintf(b, sizeof b, "%s", inet_ntoa(si->sin_addr)); break; case AF_INET6: si6 = (struct sockaddr_in6 *)a; if (inet_ntop(AF_INET6, &si6->sin6_addr, b, sizeof b) == NULL) { debug("pen_ntoa: can't convert address"); strncpy(b, "(cannot convert address)", sizeof b); } break; #ifndef WINDOWS case AF_UNIX: su = (struct sockaddr_un *)a; snprintf(b, sizeof b, "%s", su->sun_path); break; #endif default: debug("pen_ntoa: unknown address family %d", a->ss_family); snprintf(b, sizeof b, "(unknown address family %d", a->ss_family); } return b; } void pen_dumpaddr(struct sockaddr_storage *a) { switch (a->ss_family) { case AF_INET: debug("Family: AF_INET"); debug("Port: %d", pen_getport(a)); debug("Address: %s", pen_ntoa(a)); break; case AF_INET6: debug("Family: AF_INET6"); debug("Port: %d", pen_getport(a)); debug("Address: %s", pen_ntoa(a)); break; #ifndef WINDOWS case AF_UNIX: debug("Family: AF_UNIX"); debug("Path: %s", pen_ntoa(a)); break; #endif default: debug("pen_dumpaddr: Unknown address family %d", a->ss_family); } } int pen_ss_size(struct sockaddr_storage *ss) { switch (ss->ss_family) { #ifndef WINDOWS case AF_UNIX: return sizeof(struct sockaddr_un); #endif case AF_INET: return sizeof(struct sockaddr_in); case AF_INET6: return sizeof(struct sockaddr_in6); default: debug("pen_ss_size: unknown address family %d", ss->ss_family); return sizeof(struct sockaddr_storage); } } /* Takes a name and fills in a struct sockaddr_storage. The port is left alone. The address can be a unix socket path, a host name, an ipv4 address or an ipv6 address. Returns 0 for failure and 1 for success. */ int pen_aton(char *name, struct sockaddr_storage *addr) { struct sockaddr_in *si; struct sockaddr_in6 *si6; #ifndef WINDOWS struct sockaddr_un *su; #endif struct addrinfo *ai; struct addrinfo hints; int n, result; DEBUG(2, "pen_aton(%s, %p)", name, addr); #ifndef WINDOWS /* Deal with Unix domain sockets first */ if (strchr(name, '/')) { addr->ss_family = AF_UNIX; su = (struct sockaddr_un *)addr; snprintf(su->sun_path, sizeof su->sun_path, "%s", name); return 1; } #endif memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_socktype = SOCK_STREAM; n = getaddrinfo(name, NULL, &hints, &ai); if (n != 0) { debug("getaddrinfo: %s", gai_strerror(n)); return 0; } DEBUG(2, "family = %d\nsocktype = %d\nprotocol = %d\n" \ "addrlen = %d\nsockaddr = %d\ncanonname = %s", \ ai->ai_family, ai->ai_socktype, ai->ai_protocol, \ (int)ai->ai_addrlen, ai->ai_addr, ai->ai_canonname); addr->ss_family = ai->ai_family; switch (ai->ai_family) { case AF_INET: si = (struct sockaddr_in *)addr; /* ai->ai_addr is a struct sockaddr * */ /* (struct sockaddr_in *)ai->ai_addr is a struct sockaddr_in * */ /* ((struct sockaddr_in *)ai->ai_addr)->sin_addr is a struct in_addr */ si->sin_addr = ((struct sockaddr_in *)ai->ai_addr)->sin_addr; result = 1; break; case AF_INET6: si6 = (struct sockaddr_in6 *)addr; /* ai->ai_addr is a struct sockaddr * */ /* (struct sockaddr_in6 *)ai->ai_addr is a struct sockaddr_in6 * */ /* ((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr is a struct in6_addr */ si6->sin6_addr = ((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; result = 1; break; default: debug("Unknown family %d", ai->ai_family); result = 0; break; } freeaddrinfo(ai); return result; }