bld-0.3.4.1/0000755000175000017500000000000011033016030010163 5ustar obobbld-0.3.4.1/daemon.h0000644000175000017500000000266510417723244011631 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _DAEMON_H #define _DAEMON_H extern void daemon_init(void); #endif /* _DAEMON_H */ bld-0.3.4.1/utils.h0000644000175000017500000000417010417723250011514 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _UTILS_H #define _UTILS_H #include #define savebufpos(svc, svl, buf, len) \ do { \ svc = buf[len]; \ svl = len; \ buf[len] = '\0'; \ } while (0) #define restorebuf(svc, svl, buf) buf[svl] = svc; #define xsigaction(sa, signal, function) \ do { \ sa.sa_flags = 0; \ sigemptyset(&sa.sa_mask); \ sigaddset(&sa.sa_mask, signal); \ sa.sa_handler = function; \ sigaction(signal, &sa, NULL); \ } while(0) /* Return a string converted to a long, -1 on failure */ long int xstrtol(const char *nptr); /* Return a copy of the first n bytes of a string */ extern char *xstrndup(const char *s, const size_t size); #endif /* _UTILS_H */ bld-0.3.4.1/options.c0000644000175000017500000001446610421660261012050 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include "options.h" /* Defaults to put in options when initializing */ #define DEFAULT_PORT "2905" #define DEFAULT_LIST_SIZE (2000) #define DEFAULT_INTERVAL (30) #define DEFAULT_MAX_REQ (10) #define DEFAULT_BLACKLIST_SIZE (1000) #define DEFAULT_BLACKLIST_EXPIRATION (900) #define DEFAULT_DUMP_DELAY (60) #define DEFAULT_LOG_LEVEL (1) #define DEFAULT_WORKING_DIR VARRUN #define DEFAULT_WL_FILENAME DEFAULT_WORKING_DIR"/"PROGNAME"_iplist.dump" #define DEFAULT_BL_FILENAME DEFAULT_WORKING_DIR"/"PROGNAME"_blacklist.dump" #define DEFAULT_PID_FILENAME VARRUN"/"PROGNAME".pid" #define DEFAULT_ACL_FILENAME ETC_LOCATION"/"PROGNAME"_acl.conf" #define DEFAULT_WHITELIST_FILENAME ETC_LOCATION"/"PROGNAME"_whitelist.conf" #define DEFAULT_LISTENING_IP "127.0.0.1" #define DEFAULT_DAEMON_MODE (1) #define DEFAULT_CLIENT_TIMEOUT (60) #define DEFAULT_UID NULL #define DEFAULT_GID NULL #define DEFAULT_CONFIG_FILE ETC_LOCATION"/bld.conf" #define DEFAULT_NOTIFY_HOST NULL #define DEFAULT_NOTIFY_TIMEOUT (10) #define DEFAULT_CONNECT_TIMEOUT (10) extern struct options opt; /* > 0 */ #define GTZERO 0 /* >= 0 */ #define GEZERO 1 /* > 1 */ #define GEONE 2 /* 0 or 1 */ #define ZEROONE 3 static unsigned int checktab[] = { ZEROONE, /* daemon */ GEZERO, /* log_level */ GTZERO, /* interval */ GTZERO, /* max_req */ GTZERO, /* list_size */ GTZERO, /* blacklist_size */ GTZERO, /* blacklist_expiration */ GTZERO /* client_timeout */ }; /* Initialize options/parameters */ extern void options_init(char *progname) { opt.port = DEFAULT_PORT; opt.list_size = DEFAULT_LIST_SIZE; opt.interval = DEFAULT_INTERVAL; opt.max_req = DEFAULT_MAX_REQ; opt.blacklist_size = DEFAULT_BLACKLIST_SIZE; opt.blacklist_expiration = DEFAULT_BLACKLIST_EXPIRATION; opt.dump_delay = DEFAULT_DUMP_DELAY; opt.last_dump = time(NULL); opt.log_level = DEFAULT_LOG_LEVEL; opt.wl_filename = DEFAULT_WL_FILENAME; opt.bl_filename = DEFAULT_BL_FILENAME; opt.pid_filename = DEFAULT_PID_FILENAME; opt.daemon = DEFAULT_DAEMON_MODE; opt.start_time = time(NULL); opt.progname = progname; opt.working_dir = DEFAULT_WORKING_DIR; opt.listening_ip = DEFAULT_LISTENING_IP; opt.acl_filename = DEFAULT_ACL_FILENAME; opt.acl_mtime = 0; opt.acl = netlist_init(); opt.whitelist_filename = DEFAULT_WHITELIST_FILENAME; opt.whitelist_mtime = 0; opt.whitelist = netlist_init(); opt.client_timeout = DEFAULT_CLIENT_TIMEOUT; opt.submissions = 0; opt.blqueries = 0; opt.positive_blqueries = 0; opt.insertqueries = 0; opt.bad_requests = 0; opt.denied_requests = 0; opt.config_file = DEFAULT_CONFIG_FILE; opt.config_mtime = 0; opt.notify_hosts = DEFAULT_NOTIFY_HOST; opt.notify_timeout = DEFAULT_NOTIFY_TIMEOUT; opt.connect_timeout = DEFAULT_CONNECT_TIMEOUT; opt.notifies = 0; opt.syslog = 0; } /* Show runtime options/parameters */ extern void options_log(void) { int i; syslog(LOG_INFO, "starting with following parameters:"); syslog(LOG_INFO, "start time: %lu", (unsigned long)opt.start_time); syslog(LOG_INFO, "Listening IP:port: %s:%s", opt.listening_ip, opt.port); syslog(LOG_INFO, "IP list size: %d", opt.list_size); syslog(LOG_INFO, "Max submissions / time interval : %d / %lu secs", (int)opt.max_req, (unsigned long)opt.interval); syslog(LOG_INFO, "Blacklist size: %d", opt.blacklist_size); syslog(LOG_INFO, "Blacklist expiration: %lu", (unsigned long)opt.blacklist_expiration); syslog(LOG_INFO, "Stats dump delay: %lu", (unsigned long)opt.dump_delay); syslog(LOG_INFO, "Log level: %d", opt.log_level); syslog(LOG_INFO, "IP list filename: %s", opt.wl_filename); syslog(LOG_INFO, "Blacklist filename: %s", opt.bl_filename); syslog(LOG_INFO, "Configuration filename: %s", opt.config_file); syslog(LOG_INFO, "PID filename = %s", opt.pid_filename); syslog(LOG_INFO, "Daemon mode: %d", opt.daemon); syslog(LOG_INFO, "Working dir: %s", opt.working_dir); syslog(LOG_INFO, "ACL file: %s (mtime: %lu)", opt.acl_filename, (unsigned long)opt.acl_mtime); syslog(LOG_INFO, "Whitelist file: %s (mtime: %lu)", opt.whitelist_filename, (unsigned long)opt.whitelist_mtime); syslog(LOG_INFO, "Client timeout: %lu secs", (unsigned long)opt.client_timeout); syslog(LOG_INFO, "Dump delay: %lu secs", (unsigned long)opt.dump_delay); syslog(LOG_INFO, "uid / gid : %s / %s", opt.uid ? opt.uid : "(not specified)", opt.gid ? opt.gid : "(not specified)"); if (opt.notify_hosts) for (i = 0; opt.notify_hosts[i]; i += 2) syslog(LOG_INFO, "Notify host: %s:%s\n", opt.notify_hosts[i], opt.notify_hosts[i+1]); } /* Check an option value and return 1 if correct */ extern int options_check(const int option, const int value) { if (checktab[option] == GTZERO && value > 0) return 1; if (checktab[option] == GEZERO && value >= 0) return 1; if (checktab[option] == GEONE && value >= 1) return 1; if (checktab[option] == ZEROONE && (value == 0 || value == 1)) return 1; return 0; } bld-0.3.4.1/parse_args.c0000644000175000017500000001234210417723250012475 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include "options.h" #include "utils.h" #include "parse_args.h" extern struct options opt; /* Search if we have a particular config file to use */ extern void parse_args_for_config_file(int argc, char **argv) { int i; for (i = 1; i < argc - 1; i++) if (!strcmp(argv[i], "-f")) { opt.config_file = argv[i+1]; return; } } /* Parse arguments and fill global options */ /* Return: - -1 if error and must exit with code 1, - 0 if success and must exit with usage printing and code 0, - 1 if success and must continue. Exits with -v option */ /* FIXME: use getopt(3)? */ extern int parse_args(int argc, char **argv) { int i; for (i = 1; i < argc; i++) if (!strcmp(argv[i], "-n")) opt.daemon = 0; else if (i < argc - 1 && !strcmp(argv[i], "-a")) { printf("Warning, -a option might be insecure, depending on your environment!\n"); printf("Use at your own risk! Please see the README file or bld(8).\n"); opt.listening_ip = argv[++i]; } else if (i < argc - 1 && !strcmp(argv[i], "-p")) opt.port = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-I")) opt.wl_filename = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-B")) opt.bl_filename = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-P")) opt.pid_filename = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-A")) opt.acl_filename = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-W")) opt.whitelist_filename = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-u")) opt.uid = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-g")) opt.gid = argv[++i]; else if (i < argc - 1 && !strcmp(argv[i], "-l")) { if ((opt.log_level = xstrtol(argv[++i])) < 0) { fprintf(stderr, "%s: Invalid log level: %s\n", opt.progname, argv[i]); return -1; } } else if (i < argc - 1 && !strcmp(argv[i], "-t")) { opt.interval = xstrtol(argv[++i]); if (!options_check(INTERVAL_CHK, opt.interval)) { fprintf(stderr, "%s: Invalid interval: %s\n", opt.progname, argv[i]); return -1; } } else if (i < argc - 1 && !strcmp(argv[i], "-m")) { opt.max_req = xstrtol(argv[++i]); if (!options_check(MAX_REQ_CHK, opt.max_req)) { fprintf(stderr, "%s: Invalid value for max requests: %s\n", opt.progname, argv[i]); return -1; } } else if (i < argc - 1 && !strcmp(argv[i], "-i")) { opt.list_size = xstrtol(argv[++i]); if (!options_check(LIST_SIZE_CHK, opt.list_size)) { fprintf(stderr, "%s: Invalid IP list size: %s\n", opt.progname, argv[i]); return -1; } } else if (i < argc - 1 && !strcmp(argv[i], "-b")) { opt.blacklist_size = xstrtol(argv[++i]); if (!options_check(BLACKLIST_SIZE_CHK, opt.blacklist_size)) { fprintf(stderr, "%s: Invalid blacklist size: %s\n", opt.progname, argv[i]); return -1; } } else if (i < argc - 1 && !strcmp(argv[i], "-e")) { opt.blacklist_expiration = xstrtol(argv[++i]); if (!options_check(BLACKLIST_EXPIRATION_CHK, opt.blacklist_expiration)) { fprintf(stderr, "%s: Invalid blacklist expiration: %s\n", opt.progname, argv[i]); return -1; } } else if (i < argc - 1 && !strcmp(argv[i], "-T")) { opt.client_timeout = xstrtol(argv[++i]); if (!options_check(CLIENT_TIMEOUT_CHK, opt.client_timeout)) { fprintf(stderr, "%s: Invalid client timeout: %s\n", opt.progname, argv[i]); return -1; } } else if (!strcmp(argv[i], "-h")) { return 0; } else if (!strcmp(argv[i], "-v")){ printf("%s %s\n", PROGNAME, PROGRAM_VERSION); exit(EXIT_SUCCESS); } else if (!strcmp(argv[i], "-f")) { i++; } else { fprintf(stderr, "%s: Invalid option: %s\n", opt.progname, argv[i]); return -1; } return 1; } bld-0.3.4.1/options.h0000644000175000017500000001101611033003117012030 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _OPTIONS_H #define _OPTIONS_H #include /* time_t */ #include "netlist.h" /* General information */ #define PROGRAM_VERSION "v0.3.4.1" #define MAX_CMD_LEN (32) /* Global options */ struct options { char *port; /* port to listen to */ unsigned int list_size; /* IP list max size */ time_t interval; /* time to wait before blacklisting */ unsigned int max_req; /* max reqs in interval before blacklisting */ unsigned int blacklist_size; /* blacklist max size */ time_t blacklist_expiration; /* time to keep an IP in the blacklist */ time_t last_dump; /* last data dump */ time_t dump_delay; /* interval between data dumps */ int log_level; /* logs verbosity */ char *wl_filename; /* where to dump IP list */ char *bl_filename; /* where to dump blacklist */ char *pid_filename; /* where to write PID */ int daemon; /* detach from terminal */ time_t start_time; /* birthdate */ char *progname; /* argv[0] */ char *working_dir; /* where to chdir() at startup */ char *listening_ip; /* IP address to listen to */ char *acl_filename; /* where to find access list */ time_t acl_mtime; /* mtime of ACL filename */ netlist acl; /* access list */ char *whitelist_filename; /* where to find access list */ time_t whitelist_mtime; /* mtime of whitelist filename */ netlist whitelist; /* access list */ time_t client_timeout; /* max idle time for a client */ char *uid; /* user to run as */ char *gid; /* group to run as */ unsigned long submissions; /* total submissions */ unsigned long blqueries; /* total BL queries */ unsigned long positive_blqueries; /* total positive BL queries */ unsigned long insertqueries; /* total submissions to BL */ unsigned long bad_requests; /* total invalid requests */ unsigned long denied_requests; /* total denied requests */ char *config_file; /* configuration file */ time_t config_mtime; /* mtime of config file */ char **notify_hosts; /* host(s) to send notifications to */ unsigned int notify_timeout; /* timeout when notifying other hosts */ unsigned int connect_timeout;/* connect(2) timeout */ unsigned long notifies; /* total notifications to other hosts */ int syslog; /* either log to syslog or stderr */ unsigned long decrqueries; /* total decrements */ }; /* Values to use as parameter to options_check */ #define DAEMON_CHK (0) #define LOG_LEVEL_CHK (1) #define INTERVAL_CHK (2) #define MAX_REQ_CHK (3) #define LIST_SIZE_CHK (4) #define BLACKLIST_SIZE_CHK (5) #define BLACKLIST_EXPIRATION_CHK (6) #define CLIENT_TIMEOUT_CHK (7) /* Initialize options/parameters */ extern void options_init(char *progname); /* Show runtime options/parameters */ extern void options_log(void); /* Check an option value and return 1 if correct */ extern int options_check(const int option, const int value); #endif /* _OPTIONS_H */ bld-0.3.4.1/ChangeLog0000644000175000017500000000675711033002745011764 0ustar obob2008-07-03: v0.3.4.1 release * minor updates (typos, website URL, removed obsolete references) 2006-04-24: v0.3.4 released * updated bld.8 manual page with all bld options * better error reporting about failures during notifies * fixed a bug in timeout handling during notifies * added safety tests in postfix_policy.c (submitted by Oleg Milaenko) * fixed a bug submitted by David Cary Hart in Makefile.in (manual pages directory were not created correctly) 2005-07-25: v0.3.3 released * better code against fd_set structure bitmap array index overflow * updated configure and config.h.in * put a logcheck configuration file in misc/ directory. ``Omniflux'' did the initial contribution * code cleanups submitted by Samuel Tardieu: - Use real package name and version - Do not copy IP address, work directly on object - Wakeup at least every 60 seconds to perform some cleanups 2004-11-17: v0.3.2 released * various code cleanups and portability fixes. Code compiles on Linux, FreeBSD 4.x, FreeBSD 5.x, NetBSD 1.6, Mac OS X and Cygwin * code cleanups submitted by Bertrand Demiddelaer 2004-10-27: v0.3.1 released * added README.postfix that explains how to use BLD with Postfix * added Policy server for Postfix: bld-pf_policy(8) * added two scripts: bld-pf_policy.pl and bld-pf_log.pl, allowing Postfix interaction * added a query to decrement an IP counter and the associated tool: blddecr(8) * cleaned autoconf output to generated manual pages * fixed some typos in bld.conf.sample thanks to Oleg Milaenko * fixed some bugs (in Postfix log reader and bld.conf.sample) thanks to Tim Bynum 2004-10-19: v0.3.0 released * added notifies between multiple bld hosts * added support for configuration file. See bld.conf(5) * added the ipbl query, to force an insertion in the blacklist and the associated command line client: bldinsert * changed behaviour of bldsubmit and bldquery to be backward-compatible but more intuitive and easy to use (ie use localhost:2905 by default if not specified) * added some tests to be more NULL-malloc-returns proof * standardized error messages * fixed a bug in configuration files reloading * added a MRTG script in utils/ directory * fixed a typo in this ChangeLog: v0.2.4 was released in 2004 not 2003 :) 2004-09-29: v0.2.4 released * bugfixes (IP address redemption in blacklist, ACL file parsing) and suggestions (detailed statistics on requests) from Oleg Milaenko 2004-08-27: v0.2.3 released * suggestions and fixes from Cyril Bouthors: - fixed bug with return code at startup (1 when daemonizing), - return 500 instead of 000 if command not recognized (WARNING: check your client before upgrading!), - add a string after the return code to be more human readable, - manpages updates (mostly bldread(8) output format), - be more lintian friendly 2004-08-19: v0.2.2 released * added options to chose various filenames (-I, -B, -A and -W options) * added options to change uid/gid to run as (-u and -g options) * added timeout on client connections (-T option) * specify filename to save PID to (-P option) * added white lists * added access lists 2004-08-15: v0.2.1 released * code cleanups by Samuel Tardieu * fixed bad signal handling while in read()/write() * portability fixes by Pierre Beyssac 2004-08-12: v0.2 released * moved to autoconf * code cleanups, small design changes, non-blocking sockets 2004-08-09: v0.1 * initial release bld-0.3.4.1/README.postfix0000644000175000017500000000615511033003010012537 0ustar obobBLD and Postfix As of version 0.3.1, BLD comes with tools allowing its interaction with Postfix. Feeding BLD To submit IP addresses to BLD, you have to read your mail logs with a small script named bld-pf_log.pl. Basically, it takes any line logging a "User unknown" reject and sends the IP address of the SMTP client to BLD. On FreeBSD, you can do it with something like this: tail -c0 -F /var/log/maillog | bld-pf_log.pl If you use Linux or more generally GNU tail, this would be: tail -c0 --follow=name /var/log/mail.log | bld-pf_log.pl Of course, you'll have to replace /var/log/mail.log with the file that keeps logs of "user unkown" errors. You may want to test that everything works fine by reading the logs BLD sends to syslog. A submission looks like this: Feb 24 06:50:01 mx bld[1975]: 192.168.0.1 submitted by 127.0.0.1 And an insertion in the blacklist: Feb 24 06:50:02 mx bld[1975]: 192.168.0.1 put in bl: 19 reqs / 30 secs Using BLD from Postfix This is easy if you have Postfix 2.1 or a later version thanks to the policy server. If you don't, you can have a look at the bld2zone.pl script that generates a RBL zone file from BLD dumps. The problem with this method is that potential dictionary-spammers won't be rejected until the RBL zone is reloaded. If you run Postfix 2.1, though, BLD is really simple to use as a policy server. It works just like the greylist mechanism implemented by the greylist.pl distributed with Postfix source code (more precisely, the following script is written from greylist.pl). You'll only have to put these lines in your master.cf file: bld-policy unix - n n - - spawn user=nobody argv=/usr/bin/perl /usr/local/sbin/bld-pf_policy.pl Alternative: If you prefer using a binary compiled for your platform, you can try using bld-postfix_policy (a C program that comes with BLD): bld-policy unix - n n - - spawn user=nobody argv=/usr/bin/perl /usr/local/sbin/bld-pf_policy And add the following to smtpd_recipient restrictions after reject_unauth_destination: check_policy_service unix:private/bld-policy The best way to test this is to temporarily insert your own IP with the command "bldinsert 127.0.0.1". This should generate a log line like this one: Feb 24 06:50:03 mx bld[1975]: 127.0.0.1 inserted by 127.0.0.1 Then try to connect to Postfix and see if you are rejected: --> % telnet localhost 25 Trying 127.0.0.1... Connected to localhost.redhate.org. Escape character is '^]'. 220 r14.redhate.org ESMTP Postfix --> HELO localhost 250 r14.redhate.org --> MAIL FROM: me 250 Ok --> RCPT TO: me 554 : Recipient address rejected: Too many Users unknown from this IP --> QUIT 221 Bye Connection closed by foreign host. If you dislike the idea of not getting local mail any more, you may wish to remove yourself from the blacklist. This can be done by stopping BLD and deleting all files in /var/run/bld/. bld-0.3.4.1/config.h.in0000644000175000017500000001167210417723247012241 0ustar obob/* config.h.in. Generated from configure.ac by autoheader. */ /* Configuration directory */ #undef ETC_LOCATION /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the `gethostbyname' function. */ #undef HAVE_GETHOSTBYNAME /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* 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 your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG /* 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 `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* 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 `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_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_SOCKET_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_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* 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 version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to the type of arg 1 for `select'. */ #undef SELECT_TYPE_ARG1 /* Define to the type of args 2, 3 and 4 for `select'. */ #undef SELECT_TYPE_ARG234 /* Define to the type of arg 5 for `select'. */ #undef SELECT_TYPE_ARG5 /* 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 /* Directory for runtime data */ #undef VAR_LOCATION /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `int' if does not define. */ #undef pid_t /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned' if does not define. */ #undef size_t /* Define as `fork' if `vfork' does not work. */ #undef vfork bld-0.3.4.1/parse_config.c0000644000175000017500000001647210422133536013014 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include "utils.h" #include "options.h" #define CONFIG_BUFSIZE (1024) extern struct options opt; /* Append a host to the notify_hosts list */ static int notify_hosts_append(int index, char *value) { char *c, svc; size_t svl, len; len = sizeof(char *) * ((index + 1) * 2 + 1); if ((opt.notify_hosts = realloc(opt.notify_hosts, len)) == NULL) { if (opt.syslog) syslog(LOG_ERR, "%s: unable to calloc %d bytes to split host\n", opt.progname, sizeof(char *) * 3); else fprintf(stderr, "%s: unable to calloc %d bytes to split host\n", opt.progname, sizeof(char *) * 3); return 0; } opt.notify_hosts[index * 2 + 2] = NULL; if ((c = strchr(value, ':')) == NULL) { opt.notify_hosts[index*2] = value; opt.notify_hosts[index*2+1] = "2905"; } else { savebufpos(svc, svl, value, strlen(value) - strlen(c)); if ((opt.notify_hosts[index*2] = strdup(value)) == NULL) { if (opt.syslog) syslog(LOG_ERR, "%s: strdup failed\n", opt.progname); else fprintf(stderr, "%s: strdup failed\n", opt.progname); return 0; } restorebuf(svc, svl, value); if ((opt.notify_hosts[index*2+1] = strdup(c + 1)) == NULL) { if (opt.syslog) syslog(LOG_ERR, "%s: strdup failed\n", opt.progname); else fprintf(stderr, "%s: strdup failed\n", opt.progname); return 0; } } return 1; } /* Read comma separated hosts list and fill relevant structure */ static int read_hosts_list(char *value) { char *c, *p; int i = 0; p = c = value; while ((c = strchr(c, ','))) { *c = '\0'; for (c++; *c == ',' || *c == ' ' || *c == '\t'; c++) notify_hosts_append(i++, p); p = c; } notify_hosts_append(i++, p); return 1; } /* Set option structure given variable name and its value */ static int set_option(const char *variable, char *value) { if (!strcmp(variable, "daemon")) { opt.daemon = xstrtol(value); return options_check(DAEMON_CHK, opt.daemon); } if (!strcmp(variable, "max_submissions")) { opt.max_req = xstrtol(value); return options_check(MAX_REQ_CHK, opt.max_req); } if (!strcmp(variable, "min_interval")) { opt.interval = xstrtol(value); return options_check(INTERVAL_CHK, opt.interval); } if (!strcmp(variable, "ip_list_size")) { opt.list_size = xstrtol(value); return options_check(LIST_SIZE_CHK, opt.list_size); } if (!strcmp(variable, "blacklist_size")) { opt.blacklist_size = xstrtol(value); return options_check(BLACKLIST_SIZE_CHK, opt.blacklist_size); } if (!strcmp(variable, "blacklist_expiration")) { opt.blacklist_expiration = xstrtol(value); return options_check(BLACKLIST_EXPIRATION_CHK, opt.blacklist_expiration); } if (!strcmp(variable, "client_timeout")) { opt.client_timeout = xstrtol(value); return options_check(CLIENT_TIMEOUT_CHK, opt.client_timeout); } if (!strcmp(variable, "address")) opt.listening_ip = value; else if (!strcmp(variable, "port")) opt.port = value; else if (!strcmp(variable, "log_level")) opt.log_level = xstrtol(value); else if (!strcmp(variable, "user")) opt.uid = value; else if (!strcmp(variable, "group")) opt.gid = value; else if (!strcmp(variable, "iplist_dump")) opt.wl_filename = value; else if (!strcmp(variable, "blacklist_dump")) opt.bl_filename = value; else if (!strcmp(variable, "pid_filename")) opt.pid_filename = value; else if (!strcmp(variable, "acl_filename")) opt.acl_filename = value; else if (!strcmp(variable, "whitelist_filename")) opt.whitelist_filename = value; else if (!strcmp(variable, "notifies_to")) return read_hosts_list(value); else return 0; return 1; } /* Open the config file and parse it. Return 0 on error */ extern int parse_config(void) { FILE *fd; char buf[CONFIG_BUFSIZE]; char *variable; char *value; size_t i, end, len; int lineno = 0; char svc; int svl; if ((fd = fopen(opt.config_file, "r")) == NULL) { if (errno == ENOENT) return 1; if (opt.syslog) syslog(LOG_ERR, "%s: error while opening %s\n", opt.progname, opt.config_file); else fprintf(stderr, "%s: error while opening %s\n", opt.progname, opt.config_file); perror("fopen"); return 0; } while (fgets(buf, CONFIG_BUFSIZE, fd)) { lineno++; len = strlen(buf); if (buf[0] == '#' || buf[0] == '\n') continue; variable = NULL; value = NULL; /* Search for '=' */ for (i = 1; i < len && buf[i] != '='; i++); if (i >= len - 2) { if (opt.syslog) syslog(LOG_ERR, "%s:%s:%i: invalid line: %s", opt.progname, opt.config_file, lineno, buf); else fprintf(stderr, "%s:%s:%i: invalid line: %s", opt.progname, opt.config_file, lineno, buf); return 0; } /* Go back to the real end of the variable and copy it */ end = i - 1; while (buf[end] == ' ' || buf[end] == '\t') end--; variable = buf; savebufpos(svc, svl, buf, end + 1); buf[end+1] = '\0'; /* Get the value now */ for (i++; i < len && (buf[i] == ' ' || buf[i] == '\t'); i++); for (end = len - 1; end > i && (buf[end] == ' ' || buf[end] == '\t' || buf[end] == '\n' || buf[end] == '\r'); end--); if ((value = xstrndup(buf + i, end - i + 1)) == NULL) { if (opt.syslog) syslog(LOG_ERR, "%s: parse_config failed to alloc %d bytes", opt.progname, end - i); else fprintf(stderr, "%s: parse_config failed to alloc %d bytes", opt.progname, end - i); return 0; } if (!set_option(variable, value)) { restorebuf(svc, svl, buf); if (opt.syslog) syslog(LOG_ERR, "%s: invalid line in config file %s:%d\n%s", opt.progname, opt.config_file, lineno, buf); else fprintf(stderr, "%s: invalid line in config file %s:%d\n%s", opt.progname, opt.config_file, lineno, buf); return 0; } } fclose(fd); return 1; } bld-0.3.4.1/bld-pf_policy.80000644000175000017500000000127510417723251013023 0ustar obob.TH BLD-POSTFIX_POLICY "8" "October 2004" .SH NAME bld-postfix_policy - BLD policy server for Postfix .SH SYNOPSIS .br .B bld-postfix_policy [-v] [host [port]] .SH OPTIONS .TP \fB\-v\fR Log information to syslog .TP \fBhost\fR and \fBport\fR Connect to a BLD running on a different host and port (default localhost:2905) .SH DESCRIPTION \fBbld-postfix_policy\fR implements a policy server for \fBPostfix\fR. It is a safe interface to \fBBLD\fR: any error (eg unable to connect to the daemon) returns a "dunno" action instead of a reject code. .PP Please read Postfix documentation on how to install a policy server. .SH SEE ALSO .PP bld(8) postfix(1) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/client.c0000644000175000017500000001021110422161577011622 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include "options.h" #include "client.h" #include "utils.h" #include "net.h" #define timeout_read(sd,buf,rd,errorcode) \ do { \ struct timeval tv; \ fd_set rset; \ \ /* Handle timeout */ \ tv.tv_sec = opt.notify_timeout; \ tv.tv_usec = 0; \ FD_ZERO(&rset); \ FD_SET(sd, &rset); \ net_socket_set_nb(sd); \ if ((select(sd + 1, &rset, NULL, NULL, &tv)) <= 0) { \ close(sd); \ return errorcode; \ } \ \ if ((rd = read(sd, &buf, sizeof(buf))) <= 0) { \ close(sd); \ return errorcode; \ } \ } while (0) extern struct options opt; /* Connect to host:port and return a socket descriptor if success, -1 otherwise */ extern int client_connect(const char *host, const char *port) { int sd; char buf[MAX_CMD_LEN]; ssize_t rd; if ((sd = net_client_sock_create(host, port)) == -1) return -1; /* Read banner and return -1 if error/timeout */ timeout_read(sd, buf, rd, -1); return sd; } /* Send a command and return the result code or -1 */ extern int client_send_cmdi(const int sd, const int cmd, const char *value) { char *buf; if ((buf = client_send_cmdc(sd, cmd, value)) == NULL) return -1; if (!isdigit(buf[0]) || !isdigit(buf[1]) || !isdigit(buf[2])) return -1; return (buf[0] - '0') * 100 + (buf[1] - '0') * 10 + buf[2] - '0'; } /* Send a command and return the resulting message line or NULL */ extern char *client_send_cmdc(const int sd, const int cmd, const char *value) { static char buf[MAX_CMD_LEN]; ssize_t rd; switch (cmd) { case CMD_SUBMIT: sprintf(buf, "ip=%s\r\n", value); break; case CMD_INSERT: sprintf(buf, "ipbl=%s\r\n", value); break; case CMD_DECR: sprintf(buf, "ipdecr=%s\r\n", value); break; case CMD_QUERY: default: sprintf(buf, "ip?=%s\r\n", value); } write(sd, buf, strlen(buf)); /* Read and return NULL if timeout/error */ timeout_read(sd, buf, rd, NULL); if (rd < 2) { return NULL; } buf[rd-2] = '\0'; return buf; } bld-0.3.4.1/submit.c0000644000175000017500000000547210421661333011656 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include "options.h" #include "net.h" #include "client.h" struct options opt; int main(int argc, char **argv) { int sd, cmd; char *reply, *basename; char *host = "localhost"; char *port = "2905"; if (argc >= 3) host = argv[1]; if (argc == 4) port = argv[2]; if (argc == 1 || argc > 4) { fprintf(stderr, "Usage: %s [host [port]] ip\n", argv[0]); exit(EXIT_FAILURE); } if (strlen(argv[argc-1]) > MAX_CMD_LEN - 6) { fprintf(stderr, "%s: can't submit data: too long\n", argv[0]); exit(EXIT_FAILURE); } if ((basename = strrchr(argv[0], '/')) != NULL) basename++; else basename = argv[0]; if (strcmp(basename, PROGNAME"submit") == 0) cmd = CMD_SUBMIT; else if (strcmp(basename, PROGNAME"query") == 0) cmd = CMD_QUERY; else if (strcmp(basename, PROGNAME"insert") == 0) cmd = CMD_INSERT; else if (strcmp(basename, PROGNAME"decr") == 0) cmd = CMD_DECR; else { fprintf(stderr, "%s: sorry, I don't know what to do\n", argv[0]); exit(EXIT_FAILURE); } options_init(argv[0]); opt.log_level = 0; if ((sd = client_connect(host, port)) == -1) fprintf(stderr, "%s: unable to connect to %s:%s\n", argv[0], host, port); else if ((reply = client_send_cmdc(sd, cmd, argv[argc-1])) == NULL) fprintf(stderr, "%s: error getting server answer\n", argv[0]); else puts(reply); close(sd); exit(EXIT_SUCCESS); } bld-0.3.4.1/iptree.c0000644000175000017500000003613310417723242011644 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include #include "ipinfo.h" #include "iptree.h" #include "options.h" #define get_pos(x, y) (x + y * 256) extern struct options opt; #define IPTREE_M_IPLIST (0) #define IPTREE_M_BLACKLIST (1) /* dlist is a common double linked list made of dl_nodes */ typedef struct dlist *dlist; struct dl_node { struct ipinfo *p; struct dl_node *prev; struct dl_node *next; }; struct dlist { struct dl_node *first; struct dl_node *last; size_t count; }; /* iptree stores IP addresses IP x.y.z.t is in the tree at position iptree->[x + 256 * y]->c[z]->d[t] */ struct ipt_leaf { size_t count; struct ipinfo *d[256]; }; struct ipt_node { size_t count; struct ipt_leaf *c[256]; }; struct iptree { struct ipt_node *ab[256 * 256]; dlist ipl; /* Whole IPs list */ dlist bl; /* Blacklisted IPs */ }; static void iptree_free(const iptree ipt, struct ipinfo *val); static void *xcalloc(size_t nmemb, size_t size) { void *tmp; if ((tmp = calloc(nmemb, size)) == NULL) syslog(LOG_ERR, "unable to calloc()"); return tmp; } /* Dump dlist to file */ static void dlist_dump2file(const dlist dl, FILE *f) { struct dl_node *p; for (p = dl->first; p; p = p->next) fwrite(p->p, sizeof(struct ipinfo), 1, f); } /* Remove the first element of dlist and return its address */ static struct dl_node *dlist_clean(const iptree ipt, const int mode) { dlist l; struct dl_node *p; if (mode == IPTREE_M_IPLIST) { l = ipt->ipl; l->first->p->iplp = NULL; } else { l = ipt->bl; l->first->p->blp = NULL; } if (l->first == NULL) return NULL; p = l->first; /* Free only if - we are in the IP list and entry is not blacklisted, - we want to explicitly delete from blacklist and entry is not in IP list */ if ((mode == IPTREE_M_IPLIST && !p->p->blp) || (mode == IPTREE_M_BLACKLIST && !p->p->iplp)) { if (opt.log_level >= 3) syslog(LOG_INFO, "Going to free %p (last=%lu - mode=%d)", (void *)p->p, (unsigned long)p->p->last, mode); iptree_free(ipt, p->p); } l->first = p->next; if (l->first) l->first->prev = NULL; l->count--; p->prev = NULL; p->next = NULL; return p; } /* Return a newly allocated dlist */ static dlist dlist_init(void) { dlist tmp; tmp = xcalloc(sizeof(struct dlist), 1); return tmp; } /* Add an ipinfo record at the end of the wanted dlist (mode is IPTREE_M_IPLIST or M_BLACKLIST) Return 1 if success, 0 if allocation failed */ static int dlist_add(const iptree ipt, struct ipinfo *val, const int mode, const time_t req_time) { dlist l; unsigned int list_size; struct dl_node *p; time_t delta; if (val->blp) { if (opt.log_level >= 3) syslog(LOG_INFO, "%u.%u.%u.%u already in bl", val->iptbl[3], val->iptbl[2], val->iptbl[1], val->iptbl[0]); return 1; } if (mode == IPTREE_M_IPLIST) { l = ipt->ipl; p = val->iplp; list_size = opt.list_size; } else { l = ipt->bl; p = val->blp; list_size = opt.blacklist_size; } if (p == NULL) { /* Add entry to list */ l->count++; /* See if we can get an expirable, already allocated node, otherwise alloc a brand new one */ if (l->count >= list_size + 1) p = dlist_clean(ipt, mode); else if ((p = xcalloc(sizeof(struct dl_node), 1)) == NULL) { syslog(LOG_ERR, "dlist_add failed to allocate %d bytes", sizeof(struct dl_node)); return 0; } if (mode == IPTREE_M_IPLIST) val->iplp = p; else val->blp = p; p->p = val; if (opt.log_level >= 3) syslog(LOG_INFO, "%s list size: %u/%u", mode == IPTREE_M_IPLIST?"IP":"black", l->count, list_size); if (l->first == NULL) { l->first = p; l->last = p; return 1; } } else { /* Already existing entry, see if we have to blacklist */ delta = val->last - val->start; if (mode == IPTREE_M_IPLIST && !val->blp && delta >= opt.interval && val->count * opt.interval / delta >= opt.max_req) { /* Blacklist We will not remove the entry from the IP list and just wait until the entry expires (no more updates once it's blacklisted) */ dlist_add(ipt, val, IPTREE_M_BLACKLIST, req_time); if (opt.log_level >= 1) syslog(LOG_INFO, "%u.%u.%u.%u put in bl: %u reqs / %lu secs", val->iptbl[3], val->iptbl[2], val->iptbl[1], val->iptbl[0], val->count, (unsigned long)delta); } if (l->last == p) return 1; if (l->first == p) l->first = p->next; } /* Do the generic moving stuff */ l->last->next = p; if (p->prev) p->prev->next = p->next; if (p->next) p->next->prev = p->prev; p->next = NULL; p->prev = l->last; l->last = p; l->first->prev = NULL; return 1; } #if 0 /* Call for debugging purposes only: brute force dump */ static void iptree_dump(const iptree ipt) { size_t i, j, k; for (i = 0; i < 256 * 256; i++) if (ipt->ab[i]) for (j = 0; j < 256; j++) if (ipt->ab[i]->c[j]) for (k = 0; k < 256; k++) if (ipt->ab[i]->c[j]->d[k]) syslog(LOG_INFO, "iptree: %u.%u.%u.%u: %u %lu %lu", i%256, i/256, j, k, ipt->ab[i]->c[j]->d[k]->count, ipt->ab[i]->c[j]->d[k]->start, ipt->ab[i]->c[j]->d[k]->last); } #endif /* Read dlist from file */ static void iptree_getfromfile(const iptree ipt, FILE *f) { struct ipinfo ipi; int svlog_level; unsigned int val; svlog_level = opt.log_level; opt.log_level = 0; while (fread(&ipi, sizeof(struct ipinfo), 1, f)) { val = (ipi.iptbl[3]<<24) + (ipi.iptbl[2]<<16) + (ipi.iptbl[1]<<8) + ipi.iptbl[0]; iptree_add(ipt, val, ipi.start, ipi.last, ipi.count, 0); } opt.log_level = svlog_level; } /* Return a newly allocated iptree */ extern iptree iptree_init(void) { iptree tmp; struct stat sb; FILE *f; /* FIXME: should add a test */ tmp = malloc(sizeof(struct iptree)); memset(tmp->ab, 0, 256 * 256); tmp->ipl = dlist_init(); tmp->bl = dlist_init(); if (stat(opt.wl_filename, &sb) == 0 && S_ISREG(sb.st_mode)) { double records = (double)sb.st_size / (double)sizeof(struct ipinfo); int check = sb.st_size / sizeof(struct ipinfo); /* Sanity check */ if ((double)check != records) return tmp; if ((f = fopen(opt.wl_filename, "r")) != NULL) { syslog(LOG_INFO, "loading information from previous dump"); iptree_getfromfile(tmp, f); fclose(f); } } return tmp; } /* Add an IP address to a tree */ extern int iptree_add(const iptree ipt, const unsigned int val, const time_t cr_time, const time_t req_time, const int count, const int options) { union { long l; unsigned char c[sizeof(val)]; } u; unsigned char *iptbl; unsigned long pos; size_t i; u.l = val; iptbl = u.c; pos = get_pos(iptbl[3], iptbl[2]); if (!ipt->ab[pos]) { ipt->ab[pos] = xcalloc(sizeof(struct ipt_node), 1); if (ipt->ab[pos] == NULL) { syslog(LOG_ERR, "iptree_add failed to alloc %d bytes for %u.%u.%u.%u 1", sizeof(struct ipt_node), iptbl[3], iptbl[2], iptbl[1], iptbl[0]); return 0; } } if (!ipt->ab[pos]->c[iptbl[1]]) { ipt->ab[pos]->c[iptbl[1]] = xcalloc(sizeof(struct ipt_leaf), 1); if (ipt->ab[pos]->c[iptbl[1]] == NULL) { syslog(LOG_ERR, "iptree_add failed to alloc %d bytes for %u.%u.%u.%u 2", sizeof(struct ipt_node), iptbl[3], iptbl[2], iptbl[1], iptbl[0]); if (!ipt->ab[pos]->count) { syslog(LOG_ERR, "iptree_add freed block %u.%u.", iptbl[3], iptbl[2]); free(ipt->ab[pos]); ipt->ab[pos] = NULL; } return 0; } } if (!ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]) { ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]] = xcalloc(sizeof(struct ipinfo), 1); if (ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]] == NULL) { syslog(LOG_ERR, "iptree_add failed to alloc %d bytes for %u.%u.%u.%u 3", sizeof(struct ipt_node), iptbl[3], iptbl[2], iptbl[1], iptbl[0]); if (!ipt->ab[pos]->c[iptbl[1]]->count) { syslog(LOG_ERR, "freed block %u.%u.%u", iptbl[3], iptbl[2], iptbl[1]); free(ipt->ab[pos]->c[iptbl[1]]); ipt->ab[pos]->c[iptbl[1]] = NULL; } if (!ipt->ab[pos]->count) { syslog(LOG_ERR, "freed block %u.", iptbl[3]); free(ipt->ab[pos]); ipt->ab[pos] = NULL; } return 0; } ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->start = cr_time; ipt->ab[pos]->c[iptbl[1]]->count++; ipt->ab[pos]->count++; } for (i = 0; i < sizeof(long); i++) ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->iptbl[i] = iptbl[i]; ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->options |= options; /* Decrement only if IP count is greater than zero */ if (count > 0 || ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->count > 0) ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->count += count; ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->last = req_time; if ((options & IPINFO_OPT_FORCED)) { if (dlist_add(ipt, ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]], IPTREE_M_BLACKLIST, req_time) == 0) { syslog(LOG_INFO, "iptree_add cleaning last added bl entry %u.%u.%u.%u (%p)", iptbl[3], iptbl[2], iptbl[1], iptbl[0], (void *)ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]); iptree_free(ipt, ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]); return 0; } else return 1; } if (dlist_add(ipt, ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]], IPTREE_M_IPLIST, req_time) == 0 && ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->count == 1 && ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->blp == NULL) { syslog(LOG_INFO, "iptree_add cleaning last added entry %u.%u.%u.%u (%p)", iptbl[3], iptbl[2], iptbl[1], iptbl[0], (void *)ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]); iptree_free(ipt, ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]); return 0; } return 1; } /* Remove an ipinfo record from the tree and any unused node above */ static void iptree_free(const iptree ipt, struct ipinfo *val) { unsigned long pos; unsigned char *iptbl; /* Shortcut */ iptbl = val->iptbl; pos = get_pos(iptbl[3], iptbl[2]); if (opt.log_level >= 3) syslog(LOG_INFO, "free IP %u.%u.%u.%u (%p)", iptbl[3], iptbl[2], iptbl[1], iptbl[0], (void *)val); free(val); ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]] = NULL; ipt->ab[pos]->c[iptbl[1]]->count--; if (!ipt->ab[pos]->c[iptbl[1]]->count) { free(ipt->ab[pos]->c[iptbl[1]]); ipt->ab[pos]->c[iptbl[1]] = NULL; if (opt.log_level >= 3) syslog(LOG_INFO, "freed block %u.%u.%u.", iptbl[3], iptbl[2], iptbl[1]); } ipt->ab[pos]->count--; if (!ipt->ab[pos]->count) { free(ipt->ab[pos]); ipt->ab[pos] = NULL; if (opt.log_level >= 3) syslog(LOG_INFO, "freed block %u.%u.", iptbl[3], iptbl[2]); } return; } /* Dump all iptree lists to files */ extern void iptree_dump2files(const iptree ipt) { FILE *f; if ((f = fopen(opt.wl_filename, "w+")) == NULL) { syslog(LOG_ERR, "fopen: %s", strerror(errno)); return; } dlist_dump2file(ipt->ipl, f); if (opt.log_level >= 3) syslog(LOG_INFO, "IP list dumped to %s", opt.wl_filename); fclose(f); if ((f = fopen(opt.bl_filename, "w+")) == NULL) { syslog(LOG_ERR, "fopen: %s", strerror(errno)); return; } dlist_dump2file(ipt->bl, f); if (opt.log_level >= 3) syslog(LOG_INFO, "black list dumped to %s", opt.bl_filename); fclose(f); } /* Return 1 if entry is blacklisted, 0 otherwise */ extern int iptree_get_bl(const iptree ipt, const unsigned long val, const time_t req_time) { unsigned char *iptbl; unsigned long pos; time_t t, delta; iptbl = (unsigned char *)&val; pos = get_pos(iptbl[3], iptbl[2]); if (ipt->ab[pos] && ipt->ab[pos]->c[iptbl[1]] && ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]] && ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->blp) { t = req_time - ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->last; if (t <= opt.blacklist_expiration) { delta = ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->last - ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->start; if (ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->options & IPINFO_OPT_FORCED || (delta >= opt.interval && (ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->count * opt.interval / delta >= opt.max_req))) { if (opt.log_level >= 3) syslog(LOG_INFO, "request for a blacklisted IP: %u.%u.%u.%u", iptbl[3], iptbl[2], iptbl[1], iptbl[0]); return 1; } } else { /* Redemption */ ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->count = 0; ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->options = 0; ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->start = req_time; ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->last = req_time; /* if entry is still in IP list, update it */ if (ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]->iplp) { if (opt.log_level >= 3) syslog(LOG_INFO, "re-adding %u.%u.%u.%u (%p)", iptbl[3], iptbl[2], iptbl[1], iptbl[0], (void *)ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]]); dlist_add(ipt, ipt->ab[pos]->c[iptbl[1]]->d[iptbl[0]], IPTREE_M_IPLIST, req_time); } } } return 0; } /* Show some stats via syslog */ extern void iptree_show_stats(const iptree ipt, const time_t t) { if (ipt->ipl->first == NULL) syslog(LOG_INFO, "IP list: %u/%u", ipt->ipl->count, opt.list_size); else syslog(LOG_INFO, "IP list: %u/%u (oldest: %lu secs)", ipt->ipl->count, opt.list_size, (unsigned long)t - ipt->ipl->first->p->last); if (ipt->bl->first == NULL) syslog(LOG_INFO, "Blacklist: %u/%u", ipt->bl->count, opt.blacklist_size); else syslog(LOG_INFO, "Blacklist: %u/%u (oldest: %lu secs)", ipt->bl->count, opt.blacklist_size, (unsigned long)t - ipt->bl->first->p->last); } bld-0.3.4.1/parse_args.h0000644000175000017500000000316610417723251012507 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _PARSE_ARGS_H #define _PARSE_ARGS_H /* Search if we have a particular config file to use */ extern void parse_args_for_config_file(int argc, char **argv); /* Parse arguments and fill global options */ extern int parse_args(int argc, char **argv); #endif /* _PARSE_ARGS_H */ bld-0.3.4.1/cmd.c0000644000175000017500000001544010422163574011117 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "options.h" #include "cmd.h" #include "iptree.h" #include "ipinfo.h" #include "utils.h" #include "netlist.h" #include "client.h" #define MSG_BL (421) #define MSG_NOBL (200) #define MSG_AUTHF (600) #define exiterror(ident, svc, svl, buf) \ do { \ syslog(LOG_ERR, "invalid request from %s: %s", ident, buf); \ restorebuf(svc, svl, buf); \ return 500; \ } while(0) extern struct options opt; /* Send notifications */ static void send_notifies(const char *ip) { int i; pid_t pid; struct sigaction sa; if (!opt.notify_hosts) return; if ((pid = fork()) == -1) { syslog(LOG_ERR, "fork() error: %s", strerror(errno)); return; } if (pid != 0) return; /* Detach from previous sigactions */ xsigaction(sa, SIGTERM, SIG_DFL); xsigaction(sa, SIGINT, SIG_DFL); xsigaction(sa, SIGUSR1, SIG_IGN); xsigaction(sa, SIGUSR2, SIG_IGN); xsigaction(sa, SIGCHLD, SIG_IGN); for (i = 0; opt.notify_hosts[i]; i += 2) { int sd, reply; char *host = opt.notify_hosts[i]; char *port = opt.notify_hosts[i+1]; opt.notifies++; if ((sd = client_connect(host, port)) == -1) { syslog(LOG_ERR, "error (connect) while notifying %s to %s:%s", ip, host, port); } else { if ((reply = client_send_cmdi(sd, CMD_INSERT, ip)) != 200 && reply != 421) syslog(LOG_ERR, "error (reply=%d) while notifying %s to %s:%s", reply, ip, host, port); else syslog(LOG_INFO, "notified %s:%s about %s", host, port, ip); close(sd); } } exit(EXIT_SUCCESS); } /* Do the real stuff after command has been interpreted by read_cmd */ static int cmd_commit(const iptree ipt, const int cmd, const char *val, const char *ident) { struct in_addr inp; unsigned long ip; time_t t; int options = 0; int bl = 0; int notify = 0; int code = 200; int wl = 0; int count = 1; t = time(NULL); if (!inet_aton(val, &inp)) { syslog(LOG_ERR, "invalid IP address submitted by %s: %s", ident, val); return 500; } ip = ntohl(inp.s_addr); if (iptree_get_bl(ipt, ip, t)) { bl = 1; code = MSG_BL; } /* Check against whitelist */ wl = (netlist_getmode(opt.whitelist, ip) == 1); if (cmd == CMD_DECR) { opt.decrqueries++; if (wl) { syslog(LOG_INFO, "%s (wl) decremented by %s", val, ident); return code; } count = -1; } else if (cmd == CMD_INSERT) { opt.insertqueries++; options |= IPINFO_OPT_FORCED; if (wl) { syslog(LOG_INFO, "%s (wl) inserted by %s", val, ident); return code; } } else if (cmd == CMD_SUBMIT) { opt.submissions++; if (wl) { syslog(LOG_INFO, "%s (wl) submitted by %s", val, ident); return code; } } switch (cmd) { case CMD_DECR: /* Decrement IP count */ case CMD_INSERT: /* IP insertion */ case CMD_SUBMIT: /* IP submission */ if (iptree_add(ipt, ip, t, t, count, options)) { if (cmd == CMD_SUBMIT) { syslog(LOG_INFO, "%s submitted by %s", val, ident); if (iptree_get_bl(ipt, ip, t)) { notify = 1; } } else if (cmd == CMD_DECR) { syslog(LOG_INFO, "%s decremented by %s", val, ident); } else if (cmd == CMD_INSERT && !bl) { syslog(LOG_INFO, "%s inserted by %s", val, ident); notify = 1; } /* If the IP has just been put in the blacklist, send notifies */ if (!bl && notify) { send_notifies(val); code = MSG_BL; } } else syslog(LOG_ERR, "error in iptree_add IP %s", val); break; case CMD_QUERY: /* Check if an IP is blacklisted or not */ opt.blqueries++; if (bl) { opt.positive_blqueries++; return MSG_BL; } else return MSG_NOBL; break; } return code; } /* Read the command pointed to by cmd and update iptree Return the code to show to client */ extern int read_cmd(char *buf, const ssize_t len, const char *ident, const iptree ipt, const int mode) { char *p; char svc, svctmp; ssize_t svl; int cmd = CMD_NO; int code; if (buf[len-1] == '\n' && buf[len-2] == '\r') savebufpos(svc, svl, buf, len-2); else { savebufpos(svc, svl, buf, len); exiterror(ident, svc, svl, buf); } if ((p = strchr(buf, '=')) == NULL) exiterror(ident, svc, svl, buf); svctmp = *p; *p = '\0'; if (strcmp(buf, "ip") == 0) cmd = CMD_SUBMIT; else if (strcmp(buf, "ip?") == 0) cmd = CMD_QUERY; else if (strcmp(buf, "ipbl") == 0) cmd = CMD_INSERT; else if (strcmp(buf, "ipdecr") == 0) cmd = CMD_DECR; else { opt.bad_requests++; } *p++ = svctmp; /* Check client request against ACL */ if ((cmd == CMD_SUBMIT && !(mode & ACL_M_SUBMIT)) || (cmd == CMD_QUERY && !(mode & ACL_M_QUERY)) || (cmd == CMD_INSERT && !(mode & ACL_M_INSERT)) || (cmd == CMD_DECR && !(mode & ACL_M_DECR))) { syslog(LOG_INFO, "denied request from %s", ident); opt.denied_requests++; restorebuf(svc, svl, buf); return MSG_AUTHF; } if (cmd == CMD_NO || (code = cmd_commit(ipt, cmd, p, ident)) == 0) exiterror(ident, svc, svl, buf); restorebuf(svc, svl, buf); return code; } bld-0.3.4.1/postfix_policy.c0000644000175000017500000000766010417723376013442 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include #include #include "client.h" #define DEFAULT_HOST "localhost" #define DEFAULT_PORT "2905" #define BUF_SIZE (1024) #define exit_error() \ do { \ syslog(LOG_ERR, "Invalid options, usage: %s [-v] [host [port]]", argv[0]); \ exit(EXIT_FAILURE); \ } while (0) /* Asks the BLD listening on host:port if ip is blacklisted */ extern char *bld_query(const char *host, const char *port, const char *ip) { int sd, reply; static char *dunno = "dunno"; static char *reject = "defer_if_permit Too many Users unknown from this IP"; if ((sd = client_connect(host, port)) == -1) return dunno; else if ((reply = client_send_cmdi(sd, CMD_QUERY, ip)) == 421) { close(sd); return reject; } close(sd); return dunno; } int main(int argc, char **argv) { FILE *in; struct in_addr inp; char *c, *basename, buf[BUF_SIZE]; char *ip = NULL; char *host = DEFAULT_HOST; char *port = DEFAULT_PORT; int verbose = 0; if ((basename = strrchr(argv[0], '/')) != NULL) basename++; else basename = argv[0]; openlog(basename, LOG_PID, LOG_MAIL); if (argc >= 2 && argc <= 4) { if (strcmp(argv[1], "-v") == 0) { verbose = 1; if (argc == 4) { host = argv[argc-2]; port = argv[argc-1]; } else if (argc == 3) { host = argv[argc-1]; } } else { if (argc >= 2 && argc <= 3) { host = argv[1]; if (argc == 3) port = argv[2]; } else exit_error(); } } else if (argc != 1) exit_error(); if ((in = fdopen(STDIN_FILENO, "r")) == NULL) { syslog(LOG_ERR, "Error while opening stdin: %s", strerror(errno)); exit(EXIT_FAILURE); } while (fgets(buf, BUF_SIZE, in)) { if (!strncmp(buf, "client_address=", strlen("client_address=")) && (c = strchr(buf, '='))) { c++; c[strlen(c)-1] = '\0'; ip = strdup(c); } else if (buf[0] == '\n') { char *action = "dunno"; if (!ip || !inet_aton(ip, &inp)) syslog(LOG_ERR, "invalid IP address: %s", ip); else action = bld_query(host, port, ip); printf("action=%s\n\n", action); fflush(stdout); if (verbose) syslog(LOG_INFO, "%s: %s", ip, action); if (ip) free(ip); break; } } fclose(in); exit(EXIT_SUCCESS); } bld-0.3.4.1/README0000644000175000017500000000613211033003720011047 0ustar obobWhat is it? BLD stands for "blacklist daemon" and is intended to serve a blacklist. The blacklist is built by simply inserting IP addresses or by using submission rate limits based on a maximum number of submissions of the same IP address within a minimum time interval. You can build a BLD cluster by configuring the daemon to notify other similar daemon(s) every time an IP address is added to the blacklist. BLD was primarily designed to fight against dictionary-based spams (by making the MTA report to BLD any host that tries to send a mail to an unknown user) but can be used by any program. As of now, it is highly recommended to USE IT IN A SAFE ENVIRONMENT: access control is based on clients IP addresses. This is why, by default, BLD binds to localhost and should not accept requests from a machine where non-trusted users can be logged in or establish network connections to via other means (PHP for example). How does it work? BLD requests can be insertions (to add an address to the list), submissions (to add an address if its submission rate is too high), queries (to ask if an address is blacklisted) or decrements (to decrease the internal counter of submissions for an IP). BLD uses a very simple algorithm to decide whether to add submitted IP addresses to the blacklist or not. The first time an IP address is submitted, it is added to an internal list with a timestamp and all further requests increment a counter for this IP. As soon as the minimum time interval is elapsed (default: 30 seconds), and if a maximum requests ratio is reached (default: 10 submissions in the 30 seconds interval), the IP is put in the blacklist. It is then blacklisted for a configurable time (default: 900 seconds). Can I use it with Postfix? Yes. BLD v0.3.1 and later versions come with a README.postfix file and tools allowing BLD to be used as a policy server for Postfix. You will need at least Postfix 2.1. How can I configure a BLD cluster? Since v0.3.0, a BLD daemon is able to notify other BLD daemons about new addresses insertions in its blacklist. You can do this with the "notifies_to" parameter in bld.conf(5). There is a simple mechanism preventing against loops, allowing you to put a "notifies_to=B" on host A and a "notifies_to=A" on host B. You should then configure your ACL correctly (see the `insert' action in bld_acl.conf(5)) to give the right permissions to each host. Who did it? BLD has been written by Olivier Beyssac and is released under the BSD license. Its home page is at http://sites.google.com/a/r14.freenix.org/bld/ Many thanks to: Pierre Beyssac for his fixes Jean-Marc Drouaud for his advices. And also to the following contributors: Samuel Tardieu Cyril Bouthors Oleg Milaenko Tim Bynum Bertrand Demiddelaer Omniflux David Cary Hart bld-0.3.4.1/mktest/0000755000175000017500000000000011033013640011476 5ustar obobbld-0.3.4.1/mktest/mktest.sh0000644000175000017500000000311410417723252013354 0ustar obob#!/bin/sh distclean=0 CFLAGS="-W -Wall -pedantic -O2" export CFLAGS rm bld_iplist.dump rm bld_blacklist.dump date > mktest.log (cd .. if [ ! -f Makefile ] then distclean=1 echo Configuring... ./configure >> mktest/mktest.log 2>&1 fi for i in Makefile config.h do cp $i mktest done echo "=-=" >> mktest/mktest.log echo Compiling... make >> mktest/mktest.log 2>&1 echo "=-=" >> mktest/mktest.log for i in bldquery bldinsert blddecr do ln -sf bldsubmit $i done echo Running... ./bld -l 0 -a 127.0.0.1 -p 2906 -P mktest/bld.pid -B `pwd`/mktest/bld_blacklist.dump -I `pwd`/mktest/bld_iplist.dump -t 1 -m 3 >> mktest/mktest.log 2>&1 echo Testing... sleep 1 ./bldsubmit 127.0.0.1 2906 192.168.75.1 >> mktest/mktest.log 2>&1 ./bldquery 127.0.0.1 2906 192.168.75.1 >> mktest/mktest.log 2>&1 ./bldsubmit 127.0.0.1 2906 192.168.75.1 >> mktest/mktest.log 2>&1 sleep 1 ./bldsubmit 127.0.0.1 2906 192.168.75.1 >> mktest/mktest.log 2>&1 ./bldquery 127.0.0.1 2906 192.168.75.1 >> mktest/mktest.log 2>&1 ./bldinsert 127.0.0.1 2906 192.168.75.2 >> mktest/mktest.log 2>&1 ./bldquery 127.0.0.1 2906 192.168.75.2 >> mktest/mktest.log 2>&1 echo Killing... kill `cat mktest/bld.pid` rm -f mktest/bld.pid sleep 1 ./bldread mktest/bld_iplist.dump > mktest/bld_iplist.txt 2>&1 ./bldread mktest/bld_blacklist.dump > mktest/bld_blacklist.txt 2>&1 echo "=-=" >> mktest/mktest.log if [ $distclean -eq 1 ] then make distclean >> mktest/mktest.log 2>&1 echo "=-=" >> mktest/mktest.log fi date >> mktest/mktest.log ) echo Tests are over, thank you! You can send the content of this directory to: echo " " bld-0.3.4.1/configure0000755000175000017500000055466411033003127012121 0ustar obob#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for bld 0.3.4.1. # # Report bugs to >. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 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=: # Zsh 3.x and 4.x performs 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 # PATH needs CR # 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 # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false 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.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. 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 echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. 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 # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs 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 : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs 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_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell autoconf@gnu.org about your system, echo including any error possibly output before this echo message } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. 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" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # 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 } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi 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 fi echo >conf$$.file 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 -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' 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=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # 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 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, 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= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='bld' PACKAGE_TARNAME='bld' PACKAGE_VERSION='0.3.4.1' PACKAGE_STRING='bld 0.3.4.1' PACKAGE_BUGREPORT='Olivier Beyssac ' ac_unique_file="cmd.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='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT LN_S SET_MAKE CPP GREP EGREP LIBOBJS LTLIBOBJS' ac_subst_files='' 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 # 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=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_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=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_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=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 ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && 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'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. 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 case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } 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 echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 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 .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # 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 -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | 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 .." { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } 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 bld 0.3.4.1 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/bld] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of bld 0.3.4.1:";; esac cat <<\_ACEOF 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 C/C++/Objective 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 >. _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" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`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 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 bld configure 0.3.4.1 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 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 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 bld $as_me 0.3.4.1, which was generated by GNU Autoconf 2.61. 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=. 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=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$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 ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export 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 cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX 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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_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 cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" 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'; { (exit 1); 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 # 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 # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" 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. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 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,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 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 { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`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. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } 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_config_headers="$ac_config_headers config.h" # Checks for programs. 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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$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 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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" echo "$as_me:$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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$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 { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$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 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}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:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out 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. { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; 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 | *.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 { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; 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 | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; 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 ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 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 { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 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 { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$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 { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* 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" 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 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) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac 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 { echo "$as_me:$LINENO: checking whether ln -s works" >&5 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no, using $LN_S" >&5 echo "${ECHO_T}no, using $LN_S" >&6; } fi { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&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 { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } SET_MAKE= else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi # Global constants cat >>confdefs.h <<_ACEOF #define VAR_LOCATION "$localstatedir" _ACEOF cat >>confdefs.h <<_ACEOF #define ETC_LOCATION "$sysconfdir" _ACEOF # Checks for libraries. # FIXME: Replace `main' with a function in `-lnsl': { echo "$as_me:$LINENO: checking for main in -lnsl" >&5 echo $ECHO_N "checking for main in -lnsl... $ECHO_C" >&6; } if test "${ac_cv_lib_nsl_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_nsl_main=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_nsl_main=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_main" >&5 echo "${ECHO_T}$ac_cv_lib_nsl_main" >&6; } if test $ac_cv_lib_nsl_main = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi # FIXME: Replace `main' with a function in `-lresolv': { echo "$as_me:$LINENO: checking for main in -lresolv" >&5 echo $ECHO_N "checking for main in -lresolv... $ECHO_C" >&6; } if test "${ac_cv_lib_resolv_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lresolv $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_resolv_main=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_resolv_main=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_main" >&5 echo "${ECHO_T}$ac_cv_lib_resolv_main" >&6; } if test $ac_cv_lib_resolv_main = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBRESOLV 1 _ACEOF LIBS="-lresolv $LIBS" fi { echo "$as_me:$LINENO: checking for socket in -lsocket" >&5 echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6; } if test "${ac_cv_lib_socket_socket+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* 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 socket (); int main () { return socket (); ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_socket_socket=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_socket_socket=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5 echo "${ECHO_T}$ac_cv_lib_socket_socket" >&6; } if test $ac_cv_lib_socket_socket = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi # Checks for header files. 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 { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f 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 { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$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 >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } 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 { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else 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" { test -f "$ac_path_GREP" && $as_test_x "$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 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" 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 ac_count=`expr $ac_count + 1` 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 fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else 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" { test -f "$ac_path_EGREP" && $as_test_x "$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 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" 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 ac_count=`expr $ac_count + 1` 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 fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 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 >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* 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 >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* 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 >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* 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 rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi { echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6; } if test "${ac_cv_header_sys_wait_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_sys_wait_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_WAIT_H 1 _ACEOF 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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ----------------------------------------------------- ## ## Report this to Olivier Beyssac ## ## ----------------------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi { echo "$as_me:$LINENO: checking for pid_t" >&5 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } if test "${ac_cv_type_pid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef pid_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_pid_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_pid_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 echo "${ECHO_T}$ac_cv_type_pid_t" >&6; } if test $ac_cv_type_pid_t = yes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi { echo "$as_me:$LINENO: checking for size_t" >&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef size_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_size_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6; } if test $ac_cv_type_size_t = yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi { echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi # Checks for library functions. for ac_header in vfork.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ----------------------------------------------------- ## ## Report this to Olivier Beyssac ## ## ----------------------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in fork vfork do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* 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 $ac_func (); /* 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_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_func_fork" = xyes; then { echo "$as_me:$LINENO: checking for working fork" >&5 echo $ECHO_N "checking for working fork... $ECHO_C" >&6; } if test "${ac_cv_func_fork_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_fork_works=cross else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { /* By Ruediger Kuhlmann. */ return fork () < 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_fork_works=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_fork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5 echo "${ECHO_T}$ac_cv_func_fork_works" >&6; } else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { echo "$as_me:$LINENO: checking for working vfork" >&5 echo $ECHO_N "checking for working vfork... $ECHO_C" >&6; } if test "${ac_cv_func_vfork_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_vfork_works=cross else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ $ac_includes_default #include #ifdef HAVE_VFORK_H # include #endif /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void #ifdef __cplusplus sparc_address_test (int arg) # else sparc_address_test (arg) int arg; #endif { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main () { pid_t parent = getpid (); pid_t child; sparc_address_test (0); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; return ( /* Was there some problem with vforking? */ child < 0 /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_vfork_works=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_vfork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5 echo "${ECHO_T}$ac_cv_func_vfork_works" >&6; } fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then cat >>confdefs.h <<\_ACEOF #define HAVE_WORKING_VFORK 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define vfork fork _ACEOF fi if test "x$ac_cv_func_fork_works" = xyes; then cat >>confdefs.h <<\_ACEOF #define HAVE_WORKING_FORK 1 _ACEOF fi for ac_header in stdlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ----------------------------------------------------- ## ## Report this to Olivier Beyssac ## ## ----------------------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6; } if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_malloc_0_nonnull=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_malloc_0_nonnull=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 0 _ACEOF case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac cat >>confdefs.h <<\_ACEOF #define malloc rpl_malloc _ACEOF fi for ac_header in stdlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ----------------------------------------------------- ## ## Report this to Olivier Beyssac ## ## ----------------------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5 echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6; } if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_realloc_0_nonnull=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *realloc (); #endif int main () { return ! realloc (0, 0); ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_realloc_0_nonnull=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_realloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5 echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6; } if test $ac_cv_func_realloc_0_nonnull = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_REALLOC 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define HAVE_REALLOC 0 _ACEOF case " $LIBOBJS " in *" realloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; esac cat >>confdefs.h <<\_ACEOF #define realloc rpl_realloc _ACEOF fi for ac_header in sys/select.h sys/socket.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ----------------------------------------------------- ## ## Report this to Olivier Beyssac ## ## ----------------------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking types of arguments for select" >&5 echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; } if test "${ac_cv_func_select_args+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else for ac_arg234 in 'fd_set *' 'int *' 'void *'; do for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_SYS_SELECT_H # include #endif #ifdef HAVE_SYS_SOCKET_H # include #endif int main () { extern int select ($ac_arg1, $ac_arg234, $ac_arg234, $ac_arg234, $ac_arg5); ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done done done # Provide a safe default value. : ${ac_cv_func_select_args='int,int *,struct timeval *'} fi { echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 echo "${ECHO_T}$ac_cv_func_select_args" >&6; } ac_save_IFS=$IFS; IFS=',' set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` IFS=$ac_save_IFS shift cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG1 $1 _ACEOF cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG234 ($2) _ACEOF cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG5 ($3) _ACEOF rm -f conftest* { echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_signal=int else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF { echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; } if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -f conftest.sym conftest.file echo >conftest.file if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then if test "$cross_compiling" = yes; then ac_cv_func_lstat_dereferences_slashed_symlink=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { struct stat sbuf; /* Linux will dereference the symlink and fail. That is better in the sense that it means we will not have to compile and use the lstat wrapper. */ return lstat ("conftest.sym/", &sbuf) == 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_lstat_dereferences_slashed_symlink=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi else # If the `ln -s' command failed, then we probably don't even # have an lstat function. ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f conftest.sym conftest.file fi { echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && cat >>confdefs.h <<_ACEOF #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 _ACEOF if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then case " $LIBOBJS " in *" lstat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;; esac fi { echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_stat_empty_string_bug=yes else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { struct stat sbuf; return stat ("", &sbuf) == 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_stat_empty_string_bug=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_stat_empty_string_bug=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } if test $ac_cv_func_stat_empty_string_bug = yes; then case " $LIBOBJS " in *" stat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS stat.$ac_objext" ;; esac cat >>confdefs.h <<_ACEOF #define HAVE_STAT_EMPTY_STRING_BUG 1 _ACEOF fi for ac_func in alarm gethostbyname inet_ntoa memset select socket strchr strdup strerror strrchr strtol do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* 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 $ac_func (); /* 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_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$prefix" = "xNONE"; then prefix=$ac_default_prefix fi sysconfdir=`eval echo ${sysconfdir}` ac_config_files="$ac_config_files Makefile bld.8 bld_acl.conf.5 bld_whitelist.conf.5 bld.conf.5" 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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_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 test "x$cache_file" != "x/dev/null" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 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= 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=`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. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $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} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## 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=: # Zsh 3.x and 4.x performs 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 # PATH needs CR # 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 # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false 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.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. 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 echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. 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 # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. 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" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # 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 } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi 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 fi echo >conf$$.file 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 -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' 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=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # 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 # 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 bld $as_me 0.3.4.1, which was generated by GNU Autoconf 2.61. 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 cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet 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 Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ bld config.status 0.3.4.1 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 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' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. 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=$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 ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) 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. -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$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 if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # 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" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "bld.8") CONFIG_FILES="$CONFIG_FILES bld.8" ;; "bld_acl.conf.5") CONFIG_FILES="$CONFIG_FILES bld_acl.conf.5" ;; "bld_whitelist.conf.5") CONFIG_FILES="$CONFIG_FILES bld_whitelist.conf.5" ;; "bld.conf.5") CONFIG_FILES="$CONFIG_FILES bld.conf.5" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; 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 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= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # # Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF SHELL!$SHELL$ac_delim PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim PACKAGE_NAME!$PACKAGE_NAME$ac_delim PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim PACKAGE_STRING!$PACKAGE_STRING$ac_delim PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim exec_prefix!$exec_prefix$ac_delim prefix!$prefix$ac_delim program_transform_name!$program_transform_name$ac_delim bindir!$bindir$ac_delim sbindir!$sbindir$ac_delim libexecdir!$libexecdir$ac_delim datarootdir!$datarootdir$ac_delim datadir!$datadir$ac_delim sysconfdir!$sysconfdir$ac_delim sharedstatedir!$sharedstatedir$ac_delim localstatedir!$localstatedir$ac_delim includedir!$includedir$ac_delim oldincludedir!$oldincludedir$ac_delim docdir!$docdir$ac_delim infodir!$infodir$ac_delim htmldir!$htmldir$ac_delim dvidir!$dvidir$ac_delim pdfdir!$pdfdir$ac_delim psdir!$psdir$ac_delim libdir!$libdir$ac_delim localedir!$localedir$ac_delim mandir!$mandir$ac_delim DEFS!$DEFS$ac_delim ECHO_C!$ECHO_C$ac_delim ECHO_N!$ECHO_N$ac_delim ECHO_T!$ECHO_T$ac_delim LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim CC!$CC$ac_delim CFLAGS!$CFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim ac_ct_CC!$ac_ct_CC$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim LN_S!$LN_S$ac_delim SET_MAKE!$SET_MAKE$ac_delim CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 51; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF :end s/|#_!!_#|//g CEOF$ac_eof _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ 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[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF fi # test -n "$CONFIG_FILES" for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[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="$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 || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac ac_file_inputs="$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 "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; 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 || 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" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`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 || 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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`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 # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # 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= case `sed -n '/datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF 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 sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s&@configure_input@&$configure_input&;t t s&@top_builddir@&$ac_top_builddir_sub&;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 $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 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 "$tmp/stdin" case $ac_file in -) cat "$tmp/out"; rm -f "$tmp/out";; *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac ;; :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then 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. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # 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 || { (exit 1); exit 1; } fi bld-0.3.4.1/blddecr.80000644000175000017500000000063010417723252011672 0ustar obob.TH BLDSUBMIT "8" "August 2004" .SH NAME blddecr - decrement the counter of an IP address on a bld host .SH SYNOPSIS .br .B blddecr [host [port]] ip .SH DESCRIPTION .PP \fBblddecr\fR asks the \fBbld\fR daemon listening on host:port (default localhost:2905) to decrement the counter for ip. .SH SEE ALSO bld(8) bldread(8) bldquery(8) bldinsert(8) blddecr(8) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/bldinsert.80000644000175000017500000000057610417723252012272 0ustar obob.TH BLDINSERT "8" "August 2004" .SH NAME bldsubmit - submit an IP address to a bld host .SH SYNOPSIS .br .B bldinsert [host [port]] ip .SH DESCRIPTION .PP \fBbldinsert\fR adds ip to blacklist of the \fBbld\fR daemon listening on host:port (default localhost:2905). .SH SEE ALSO bld(8) bldread(8) bldquery(8) bldsubmit(8) blddecr(8) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/bldsubmit.80000644000175000017500000000056410417723247012272 0ustar obob.TH BLDSUBMIT "8" "August 2004" .SH NAME bldsubmit - submit an IP address to a bld host .SH SYNOPSIS .br .B bldsubmit [host [port]] ip .SH DESCRIPTION .PP \fBbldsubmit\fR submits ip to the \fBbld\fR daemon listening on host:port (default localhost:2905). .SH SEE ALSO bld(8) bldread(8) bldquery(8) bldinsert(8) blddecr(8) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/bldread.80000644000175000017500000000166110417723247011701 0ustar obob.TH BLDREAD "8" "August 2004" .SH NAME bldread - read bld dumps .SH SYNOPSIS .br .B bld -h | filename .SH OPTIONS \fB\-h\fR display usage .SH DESCRIPTION .PP \fBbldread\fR is the utility designed to read \fBbld\fR dump files. It outputs semicolon separated values in the following order: .IP \(bu IP address (`a.b.c.d') .IP \(bu Insertion time (timestamp in seconds) .IP \(bu Last update (timestamp in seconds) .IP \(bu Number of submissions during the interval .IP \(bu Second submissions counter .IP \(bu options bitfield (`1' if forced insertion, no other options yet) .IP \(bu Blacklist flag (`1' if blacklisted, `0' otherwise) .IP \(bu Internal pointer value for debugging purposes .IP \(bu Another internal pointer value for debugging purposes .SH FILES .PP /var/run/bld/bld_iplist.dump /var/run/bld/bld_blacklist.dump .SH SEE ALSO bld(8) bldquery(8) bldsubmit(8) bldinsert(8) blddecr(8) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/ipinfo.h0000644000175000017500000000374010417723245011646 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _IPINFO_H #define _IPINFO_H #include struct ipinfo { size_t count; /* counter */ size_t count2; /* the well-named other counter */ unsigned char iptbl[sizeof(long)]; /* IP 1.2.3.4 -> { 4, 3, 2, 1 } */ time_t start; /* insertion time */ time_t last; /* last update */ int options; /* options bitfield */ struct dl_node *iplp; /* pointer to position in ip list */ struct dl_node *blp; /* pointer to position in black list */ }; #define IPINFO_OPT_FORCED 1 #endif /* _IPINFO_H */ bld-0.3.4.1/daemon.c0000644000175000017500000000477410417723243011626 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include #include "options.h" #include "daemon.h" #define MAXFD (16) extern struct options opt; static void write_pid(void) { FILE *f; if ((f = fopen(opt.pid_filename, "w")) == NULL) { syslog(LOG_ERR, "fopen %s: %s", opt.pid_filename, strerror(errno)); exit(EXIT_FAILURE); } else { fprintf(f, "%i\n", getpid()); fclose(f); } } /* Mostly from Unix Network Programming */ extern void daemon_init(void) { int i; pid_t pid; if ((pid = fork()) != 0) exit(EXIT_SUCCESS); /* parent terminates */ /* 1st child continues */ setsid(); /* become session leader */ signal(SIGHUP, SIG_IGN); if ((pid = fork()) != 0) exit(EXIT_FAILURE); /* 1st child terminates */ write_pid(); /* 2nd child continues */ chdir(opt.working_dir); /* change working directory */ umask(0); /* clear our file mode creation mask */ for (i = 0; i < MAXFD; i++) close(i); } bld-0.3.4.1/client.h0000644000175000017500000000352510417723251011636 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _CLIENT_H #define _CLIENT_H #include "cmd.h" /* Connect to host:port and return a socket descriptor if success, -1 otherwise */ extern int client_connect(const char *host, const char *port); /* Send a command and return the result code or -1 */ extern int client_send_cmdi(const int sd, const int cmd, const char *value); /* Send a command and return the resulting message line or NULL */ extern char *client_send_cmdc(const int sd, const int cmd, const char *value); #endif /* _CLIENT_H */ bld-0.3.4.1/net.h0000644000175000017500000000352010421661465011144 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _NET_H #define _NET_H /* Set a socket non-blocking. Return 1 if successful, 0 if not */ extern int net_socket_set_nb(const int sd); /* Return a TCP socket listening on port port Return -1 on error */ extern int net_server_sock_create(const char *ip, const char *port); /* Return a TCP socket connected to server:port, Return -1 on error NOTE: SIGALRM used to handle connect(2) timeout */ extern int net_client_sock_create(const char *server, const char *port); #endif /* _NET_H */ bld-0.3.4.1/bldquery.80000644000175000017500000000056210417723245012130 0ustar obob.TH BLDQUERY "8" "August 2004" .SH NAME bldquery - query a bld host .SH SYNOPSIS .br .B bldquery [host [port]] ip .SH DESCRIPTION .PP \fBbldquery\fR asks the \fBbld\fR daemon listening on host:port (default localhost:2905) if ip is blacklisted or not. .SH SEE ALSO bld(8) bldread(8) bldsubmit(8) bldinsert(8) blddecr(8) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/iptree.h0000644000175000017500000000406710417723243011653 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _IPTREE_H #define _IPTREE_H #include #include typedef struct iptree *iptree; /* Return a newly allocated iptree */ extern iptree iptree_init(void); /* Add an IP address to a tree */ extern int iptree_add(const iptree lt, const unsigned int val, const time_t cr_time, const time_t req_time, const int count, const int force); /* Dump all iptree lists to files */ extern void iptree_dump2files(const iptree lt); /* Return 1 if entry is blacklisted, 0 otherwise */ extern int iptree_get_bl(const iptree lt, const unsigned long val, const time_t req_time); /* Show some stats via syslog */ extern void iptree_show_stats(const iptree ipt, const time_t t); #endif /* _IPTREE_H */ bld-0.3.4.1/parse_config.h0000644000175000017500000000277710417723251013027 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _PARSE_CONFIG_H #define _PARSE_CONFIG_H /* Open the config file and parse it. Exit on error */ extern int parse_config(void); #endif /* _PARSE_CONFIG_H */ bld-0.3.4.1/COPYRIGHT0000644000175000017500000000252710417723245011506 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ bld-0.3.4.1/Makefile.in0000644000175000017500000001005611033002653012240 0ustar obobprefix=@prefix@ exec_prefix=@exec_prefix@ sbindir=@sbindir@ mandir=@mandir@ sysconfdir=@sysconfdir@ varrun=/var/run/bld CC= @CC@ PROGNAME= bld READERNAME= $(PROGNAME)read SUBMITNAME= $(PROGNAME)submit QUERYNAME= $(PROGNAME)query INSERTNAME= $(PROGNAME)insert DECRNAME= $(PROGNAME)decr POLICYNAME= $(PROGNAME)-pf_policy UTILS=utils/bld-mrtg.pl utils/bld-pf_log.pl utils/bld-pf_policy.pl CFLAGS= @CFLAGS@ -DPROGNAME=\"$(PROGNAME)\" -DVARRUN=\"$(varrun)\" -DETC_LOCATION=\"$(sysconfdir)\" OBJS= main.o net.o cmd.o iptree.o daemon.o netlist.o utils.o parse_args.o \ parse_config.o options.o client.o LDFLAGS= @LDFLAGS@ LIBS= @LIBS@ GZIP= gzip -c -9 all: $(PROGNAME) $(READERNAME) $(SUBMITNAME) $(POLICYNAME) $(PROGNAME): $(OBJS) $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) $(READERNAME): dumpread.o $(CC) -o $@ dumpread.o $(SUBMITNAME): submit.o net.o client.o utils.o options.o netlist.o $(CC) -o $@ $(LDFLAGS) submit.o net.o client.o utils.o options.o \ netlist.o $(LIBS) $(POLICYNAME): postfix_policy.o net.o client.o $(CC) -o $@ $(LDFLAGS) postfix_policy.o net.o client.o $(LIBS) links: $(SUBMITNAME) -ln -sf $(SUBMITNAME) $(QUERYNAME) -ln -sf $(SUBMITNAME) $(INSERTNAME) -ln -sf $(SUBMITNAME) $(DECRNAME) submit.o: submit.c net.h install: all [ -d $(DESTDIR)$(sbindir) ] || mkdir -p $(DESTDIR)$(sbindir) cp $(PROGNAME) $(READERNAME) $(POLICYNAME) $(UTILS) $(DESTDIR)$(sbindir) strip $(DESTDIR)$(sbindir)/$(PROGNAME) strip $(DESTDIR)$(sbindir)/$(READERNAME) strip $(DESTDIR)$(sbindir)/$(POLICYNAME) cp $(SUBMITNAME) $(DESTDIR)$(sbindir) \ && (cd $(DESTDIR)$(sbindir) && ln -s $(SUBMITNAME) $(QUERYNAME)) \ && (cd $(DESTDIR)$(sbindir) && ln -s $(SUBMITNAME) $(INSERTNAME)) \ && (cd $(DESTDIR)$(sbindir) && ln -s $(SUBMITNAME) $(DECRNAME)) strip $(DESTDIR)$(sbindir)/$(SUBMITNAME) [ -d $(DESTDIR)$(mandir)/man8 ] || mkdir -p $(DESTDIR)$(mandir)/man8 $(GZIP) -c bld.8 > $(DESTDIR)$(mandir)/man8/bld.8.gz $(GZIP) -c bldread.8 > $(DESTDIR)$(mandir)/man8/bldread.8.gz $(GZIP) -c bldquery.8 > $(DESTDIR)$(mandir)/man8/bldquery.8.gz $(GZIP) -c bldsubmit.8 > $(DESTDIR)$(mandir)/man8/bldsubmit.8.gz $(GZIP) -c bldinsert.8 > $(DESTDIR)$(mandir)/man8/bldinsert.8.gz $(GZIP) -c blddecr.8 > $(DESTDIR)$(mandir)/man8/blddecr.8.gz $(GZIP) -c bld-pf_policy.8 > $(DESTDIR)$(mandir)/man8/bld-pf_policy.8.gz [ -d $(DESTDIR)$(mandir)/man5 ] || mkdir -p $(DESTDIR)$(mandir)/man5 $(GZIP) -c bld.conf.5 > $(DESTDIR)$(mandir)/man5/bld.conf.5.gz $(GZIP) -c bld_acl.conf.5 > $(DESTDIR)$(mandir)/man5/bld_acl.conf.5.gz $(GZIP) -c bld_whitelist.conf.5 > $(DESTDIR)$(mandir)/man5/bld_whitelist.conf.5.gz $(GZIP) -c utils/bld-pf_log.pl.8 > $(DESTDIR)$(mandir)/man8/bld-pf_log.pl.8.gz $(GZIP) -c utils/bld-mrtg.pl.8 > $(DESTDIR)$(mandir)/man8/bld-mrtg.pl.8.gz client.o: client.c options.h netlist.h client.h cmd.h iptree.h utils.h \ net.h cmd.o: cmd.c options.h netlist.h cmd.h iptree.h ipinfo.h utils.h \ client.h daemon.o: daemon.c options.h netlist.h daemon.h dumpread.o: dumpread.c ipinfo.h iptree.o: iptree.c ipinfo.h iptree.h options.h netlist.h main.o: main.c options.h netlist.h parse_args.h parse_config.h net.h \ cmd.h iptree.h daemon.h utils.h net.o: net.c net.h netlist.o: netlist.c netlist.h utils.h options.o: options.c options.h netlist.h parse_args.o: parse_args.c options.h netlist.h utils.h parse_args.h parse_config.o: parse_config.c utils.h options.h netlist.h postfix_policy.o: postfix_policy.c client.h cmd.h iptree.h options.h \ netlist.h submit.o: submit.c options.h netlist.h net.h client.h cmd.h iptree.h utils.o: utils.c utils.h clean: -rm -f $(PROGNAME) $(READERNAME) $(SUBMITNAME) $(DECRNAME) \ $(POLICYNAME) $(OBJS) dumpread.o submit.o postfix_policy.o core distclean: clean -rm -f *~ Makefile config.status config.log config.cache config.h \ $(READERNAME) $(SUBMITNAME) $(QUERYNAME) $(INSERTNAME) $(DECRNAME) \ $(POLICYNAME) bld.8 bld_acl.conf.5 bld_whitelist.conf.5 bld.conf.5 -rm -rf autom4te.cache bld.8.html -rm -rf mktest/Makefile mktest/config.h mktest/mktest.log \ mktest/bld_iplist.txt mktest/bld_blacklist.txt \ mktest/bld_iplist.dump mktest/bld_blacklist.dump bld-0.3.4.1/netlist.h0000644000175000017500000000463310417723250012042 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _NETLIST_H #define _NETLIST_H #include #include #include /* in_addr_t */ #define ACL_M_QUERY (1) #define ACL_M_SUBMIT (2) #define ACL_M_INSERT (4) #define ACL_M_DECR (8) #define ACL_M_ALL (ACL_M_QUERY | ACL_M_SUBMIT | ACL_M_INSERT | ACL_M_DECR) typedef struct netlist *netlist; /* Return a newly allocated netlist */ extern netlist netlist_init(void); /* Free a netlist */ extern void netlist_free(netlist nl); /* Load ACL from file. Return 1 on success, 0 if file was not found, -1 for all other errors */ extern int netlist_acl_getfromfile(const netlist nl, const char *filename); /* Load whitelist from file. Return 1 on success, 0 if file was not found, -1 for all other errors */ extern int netlist_whitelist_getfromfile(const netlist nl, const char *filename); /* Return allowed actions for IP If list is an ACL: bitmask between none (0) and ACL_M_* above If list is a whitelist: whitelisted (1) */ extern int netlist_getmode(const netlist nl, const in_addr_t ip); #endif /* _NETLIST_H */ bld-0.3.4.1/bld.conf.sample0000644000175000017500000000170010417723251013070 0ustar obob## Fork as a daemon #daemon=0 ## Address to bind to #address=127.0.0.1 ## Port to listen to #port=2905 ## Minimum time interval before blacklisting (seconds) #min_interval=30 ## Maximum submissions in time interval #max_submissions=10 ## IP list size #ip_list_size=2000 ## Blacklist size #blacklist_size=1000 ## Blacklist expiration (seconds) #blacklist_expiration=900 ## Log level (0-3) #log_level=1 ## User to run as #user= ## Group to run as #group= ## Client timeout #client_timeout=60 ## File to dump IP list to #iplist_dump=/var/run/bld/bld_iplist.dump ## File to dump blacklist to #blacklist_dump=/var/run/bld/bld_blacklist.dump ## PID filename #pid_filename=/var/run/bld/bld.pid ## ACL filename #acl_filename=/usr/local/etc/bld/bld_acl.conf ## Whitelist filename #whitelist_filename=/usr/local/etc/bld/bld_whitelist.conf ## Host to notify when a new address is inserted into the blacklist #notifies_to=my.host.tld, other.host.tld:2906 bld-0.3.4.1/configure.ac0000644000175000017500000000261711033003053012460 0ustar obob# Process this file with autoconf to produce a configure script. AC_INIT([bld],[0.3.4.1],[Olivier Beyssac ]) AC_CONFIG_SRCDIR([cmd.c]) AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC AC_PROG_LN_S AC_PROG_MAKE_SET # Global constants AC_DEFINE_UNQUOTED(VAR_LOCATION, "$localstatedir", [Directory for runtime data]) AC_DEFINE_UNQUOTED(ETC_LOCATION, "$sysconfdir", [Configuration directory]) # Checks for libraries. # FIXME: Replace `main' with a function in `-lnsl': AC_CHECK_LIB([nsl], [main]) # FIXME: Replace `main' with a function in `-lresolv': AC_CHECK_LIB([resolv], [main]) AC_CHECK_LIB([socket], [socket]) # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME # Checks for library functions. AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_TYPE_SIGNAL AC_FUNC_STAT AC_CHECK_FUNCS([alarm gethostbyname inet_ntoa memset select socket strchr strdup strerror strrchr strtol]) if test "x$prefix" = "xNONE"; then prefix=$ac_default_prefix fi sysconfdir=`eval echo ${sysconfdir}` AC_CONFIG_FILES([Makefile bld.8 bld_acl.conf.5 bld_whitelist.conf.5 bld.conf.5]) AC_OUTPUT bld-0.3.4.1/bld.conf.5.in0000644000175000017500000000332710417723251012367 0ustar obob.TH BLD.CONF "5" "October 2004" .SH NAME bld.conf - Configuration file for BLD .SH DESCRIPTION \fIbld.conf\fR consists of lines used to set various configuration options for \fBbld\fR. The lines are processed in order of appearance. Options set via \fBbld.conf\fR are overriden by \fBbld\fR command line options. If two lines assign different values to the same variables, the last is used. Blank lines and lines beginning with a `#' are ignored. .PP \fIbld.conf\fR lines have the following format: .sp .ti +3 variable = value .PP \fIvariable\fR can be on of the following: .IP \(bu daemon: (0 or 1) fork to background or not. .IP \(bu address: IP address to bind to. .IP \(bu port: port to listen to. .IP \(bu min_interval: minimum time interval before blacklisting. .IP \(bu max_submissions: maximum submissions in time interval. .IP \(bu ip_list_size: IP list size. .IP \(bu blacklist_size: blacklist size. .IP \(bu blacklist_expiration: blacklist expiration (seconds). .IP \(bu log_level: log level. .IP \(bu user: user to run as. .IP \(bu group: group to run as. .IP \(bu client_timeout: client idle timeout before closing connection (seconds). .IP \(bu iplist_dump: file to dump IP list to. .IP \(bu blacklist_dump: file to dump blacklist to. .IP \(bu pid_filename: PID filename. .IP \(bu acl_filename: ACL filename. .IP \(bu whitelist_filename: whitelist filename. .IP \(bu notifies_to: comma separated hosts (`hostname' or `hostname:port') to notify when a new address is inserted into the blacklist .SH NOTES .PP You need to completely restart \fBbld\fR after any modification of this file. .SH FILES .PP @sysconfdir@/bld.conf .SH SEE ALSO .PP bld(8) bld_acl.conf(5) bld_whitelist.conf(5) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/netlist.c0000644000175000017500000002112710417723250012032 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include #include "netlist.h" #include "utils.h" #define ACL_MAX_LINE 80 #define WHITELIST_MAX_LINE 80 #define trim_buffer(buf) \ do { \ size_t i; \ for (i = strlen(buf) - 1; \ i > 0 && (buf[i] == '\n' || buf[i] == '\r' \ || buf[i] == '\t' || buf[i] == ' '); i--) \ buf[i] = '\0'; \ } while(0) static unsigned int bitmasks[] = { 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff }; struct netlist { size_t size; /* netlist size */ in_addr_t *net; /* Networks list */ in_addr_t *mask; /* Masks list */ int *mode; /* Permissions list */ }; /* Return a newly allocated acl */ extern netlist netlist_init(void) { netlist tmp; tmp = calloc(sizeof(struct netlist), 1); return tmp; } /* Free a netlist */ extern void netlist_free(const netlist nl) { nl->size = 0; free(nl->net); free(nl->mask); free(nl->mode); } /* Search for an IP in the netlist. Return the mode if found, -1 otherwise. If not NULL, parameter index is modified to get position in the list */ static int netlist_search(const netlist nl, const in_addr_t ip, int *index) { int i, j; if (nl->size == 0) return -1; for (i = 0, j = nl->size - 1; i < j && nl->net[i] != ip && nl->net[j] != ip; i++, j--); if (nl->net[i] == ip) { if (index != NULL) *index = i; return nl->mode[i]; } if (nl->net[j] == ip) { if (index != NULL) *index = j; return nl->mode[j]; } return -1; } /* Add or update IP/mask in the netlist */ static int netlist_add(const netlist nl, const in_addr_t ip, const in_addr_t mask, const int mode) { int index; if (netlist_search(nl, ip, &index) != -1) { nl->mode[index] = mode; return 1; } nl->size++; nl->net = realloc(nl->net, sizeof(in_addr_t) * nl->size); nl->mask = realloc(nl->mask, sizeof(int) * nl->size); nl->mode = realloc(nl->mode, sizeof(int) * nl->size); nl->net[nl->size - 1] = ip; nl->mask[nl->size - 1] = mask; nl->mode[nl->size - 1] = mode; return 1; } /* Convert the string-mode to an int-mode (ignoring whitespaces and tabs) */ static int acl_mode_str2int(char *str_mode) { int mode; char *p, *q; char svc; size_t i, len, svl; /* Trim the beginning */ for (p = str_mode; *p && (*p == ' ' || *p == '\t'); p++); /* Trim the end */ q = p; len = strlen(q); for (i = len - 1; i > 0 && (q[i] == ' ' || q[i] == '\t'); i--); /* Remember how to restore the buffer to its initial state */ savebufpos(svc, svl, q, i+1); if (strcmp(p, "submit") == 0) mode = ACL_M_SUBMIT; else if (strcmp(p, "query") == 0) mode = ACL_M_QUERY; else if (strcmp(p, "insert") == 0) mode = ACL_M_INSERT; else if (strcmp(p, "decrement") == 0) mode = ACL_M_DECR; else if (strcmp(p, "all") == 0) mode = ACL_M_ALL; else { restorebuf(svc, svl, q); syslog(LOG_ERR, "invalid mode in ACL file: %s", str_mode); return -1; } restorebuf(svc, svl, q); return mode; } /* Parse buf and fill IP/Mask. Return 1 if successful, 0 otherwise */ static int netlist_fill_ip_mask(char *buf, in_addr_t *ip, in_addr_t *mask) { char *b, *p; char svc; size_t svl; struct in_addr inp; int tmpmask; *ip = 0; *mask = 0; /* Ignore leading whitespaces and tabs */ for (b = buf; *b != '\0' && (*b == ' ' || *b == '\t'); b++); if ((p = strchr(b, '/')) == NULL) { *mask = bitmasks[32]; if (inet_aton(b, &inp) == 0) { syslog(LOG_ERR, "invalid IP address %s", buf); return 0; } *ip = ntohl(inp.s_addr); return 1; } /* Remember how to unbreak the buffer */ savebufpos(svc, svl, b, strlen(buf) - strlen(p)); p++; if (!inet_aton(b, &inp)) { syslog(LOG_ERR, "invalid IP address %s", buf); return 0; } *ip = ntohl(inp.s_addr); if ((tmpmask = xstrtol(p)) == -1) { if (!inet_aton(p, &inp)) { syslog(LOG_ERR, "invalid netmask %s", b); return 0; } else { *mask = ntohl(inp.s_addr); } } else *mask = bitmasks[tmpmask]; *ip &= *mask; restorebuf(svc, svl, b); return 1; } /* Load ACL from file. Return 1 on success, 0 if file was not found, -1 for all other errors */ extern int netlist_acl_getfromfile(const netlist nl, const char *filename) { FILE *f; char buf[ACL_MAX_LINE]; char *str_mode, *cur_mode; int mode, tmp_mode; in_addr_t ip, mask; if ((f = fopen(filename, "r")) == NULL) { if (errno == ENOENT) return 0; syslog(LOG_ERR, "fopen %s: %s", filename, strerror(errno)); return -1; } while (fgets(buf, sizeof(buf), f)) { size_t len; len = strlen(buf); if ((len >= 1 && (buf[0] == '#' || buf[0] == '\n')) || (len >= 2 && buf[0] == '\r' && buf[1] == '\n')) continue; trim_buffer(buf); if ((str_mode = strchr(buf, ':')) == NULL) return -1; *str_mode = '\0'; if (!netlist_fill_ip_mask(buf, &ip, &mask)) { fclose(f); return -1; } str_mode++; mode = 0; /* Parse mode list */ while ((cur_mode = strchr(str_mode, ','))) { *cur_mode = '\0'; cur_mode++; if ((tmp_mode = acl_mode_str2int(str_mode)) == -1) { fclose(f); return -1; } else mode |= tmp_mode; str_mode = cur_mode; } if ((tmp_mode = acl_mode_str2int(str_mode)) == -1) { fclose(f); return -1; } else mode |= tmp_mode; netlist_add(nl, ip, mask, mode); } fclose(f); return 1; } /* Load whitelist from file. Return 1 on success, 0 if file was not found, -1 for all other errors */ extern int netlist_whitelist_getfromfile(const netlist nl, const char *filename) { FILE *f; char buf[WHITELIST_MAX_LINE]; in_addr_t ip, mask; if ((f = fopen(filename, "r")) == NULL) { if (errno == ENOENT) return 0; syslog(LOG_ERR, "fopen %s: %s", filename, strerror(errno)); return -1; } while (fgets(buf, sizeof(buf), f)) { size_t len; len = strlen(buf); if ((len >= 1 && (buf[0] == '#' || buf[0] == '\n')) || (len >= 2 && buf[0] == '\r' && buf[1] == '\n')) continue; trim_buffer(buf); if (!netlist_fill_ip_mask(buf, &ip, &mask)) { fclose(f); return -1; } netlist_add(nl, ip, mask, 1); } fclose(f); return 1; } /* Return allowed actions for IP */ extern int netlist_getmode(const netlist nl, const in_addr_t ip) { size_t i; if (nl->size == 0) return ACL_M_ALL; for (i = 0; i < nl->size; i++) if ((ip & nl->mask[i]) == nl->net[i]) return nl->mode[i]; return 0; } bld-0.3.4.1/utils.c0000644000175000017500000000360110417723250011505 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include "utils.h" /* Return a string converted to a long, -1 on failure */ long int xstrtol(const char *nptr) { char *endptr; long tmp; tmp = strtol(nptr, &endptr, 10); if (*endptr == '\0') return tmp; return -1; } /* Return a copy of the first n bytes of a string */ extern char *xstrndup(const char *s, const size_t size) { char *tmp; if ((tmp = (char *)malloc(size + 1)) == NULL) return NULL; memcpy(tmp, s, size); tmp[size] = '\0'; return tmp; } bld-0.3.4.1/main.c0000644000175000017500000004426310417723243011304 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "options.h" #include "parse_args.h" #include "parse_config.h" #include "net.h" #include "cmd.h" #include "iptree.h" #include "daemon.h" #include "netlist.h" #include "utils.h" #define BANNER "220 "PROGNAME" "PROGRAM_VERSION"\r\n" #ifdef FD_SETSIZE #define MAX_CLIENTS (FD_SETSIZE >= 160 ? 150 : FD_SETSIZE - 10) #else #define MAX_CLIENTS (150) #endif /* FD_SETSIZE */ struct options opt; /* global runtime options/parameters */ iptree ipt; /* global iptree */ int ncli = 0; /* clients connected */ int listen_sd; /* listening socket */ /* Information about clients */ struct { int sd; struct sockaddr_in addr; int reply; int mode; time_t last; } client[MAX_CLIENTS]; #define close_client(i) \ do { \ close(client[i].sd); \ client[i].sd = -1; \ client[i].last = 0; \ ncli--; \ } while(0) static void dump_data(void) { iptree_dump2files(ipt); opt.last_dump = time(NULL); } /* Exit cleanly */ static void exit_signal_handler(const int signo) { int i; syslog(LOG_INFO, "terminated by signal %d, closing all connections", signo); close(listen_sd); for (i = 0; i < MAX_CLIENTS; i++) if (client[i].sd != -1) { if (opt.log_level >= 3) syslog(LOG_INFO, "closing slot %d", i); close(client[i].sd); } /* Dump data to disk before exiting */ dump_data(); if (opt.daemon && unlink(opt.pid_filename) < 0) syslog(LOG_ERR, "unlink: %s", strerror(errno)); exit(EXIT_SUCCESS); } /* Show some stats when we catch USR1 */ static void usr1_signal_handler(const int signo) { struct rusage u; time_t t = time(NULL); syslog(LOG_INFO, "caught signal %d", signo); syslog(LOG_INFO, "start time: %lu (age: %lu secs)", (unsigned long)opt.start_time, (unsigned long)t - opt.start_time); syslog(LOG_INFO, "submissions: %lu", opt.submissions); syslog(LOG_INFO, "insertions in BL: %lu", opt.insertqueries); syslog(LOG_INFO, "notifies: %lu", opt.notifies); syslog(LOG_INFO, "decrements: %lu", opt.decrqueries); syslog(LOG_INFO, "positive BL queries: %lu", opt.positive_blqueries); syslog(LOG_INFO, "total BL queries: %lu", opt.blqueries); syslog(LOG_INFO, "bad requests: %lu", opt.bad_requests); syslog(LOG_INFO, "denied requests: %lu", opt.denied_requests); syslog(LOG_INFO, "clients: %d/%d", ncli, MAX_CLIENTS); iptree_show_stats(ipt, t); if (getrusage(RUSAGE_SELF, &u) == -1) { syslog(LOG_ERR, "getrusage(): %s", strerror(errno)); return; } syslog(LOG_INFO, "utime=%li.%lis - stime=%li.%lis", u.ru_utime.tv_sec, u.ru_utime.tv_usec, u.ru_stime.tv_sec, u.ru_stime.tv_usec); syslog(LOG_INFO, "maxrss=%li", u.ru_maxrss); syslog(LOG_INFO, "ixrss=%li - idrss=%li", u.ru_ixrss, u.ru_idrss); syslog(LOG_INFO, "minflt=%li - majflt=%li", u.ru_minflt, u.ru_majflt); syslog(LOG_INFO, "nswap=%li", u.ru_nswap); syslog(LOG_INFO, "inblock=%li - oublock=%li", u.ru_inblock, u.ru_oublock); syslog(LOG_INFO, "msgsnd=%li - msgrcv=%li", u.ru_msgsnd, u.ru_msgrcv); syslog(LOG_INFO, "nsignals=%li", u.ru_nsignals); syslog(LOG_INFO, "nvcsw=%lu - nivcsw=%lu", u.ru_nvcsw, u.ru_nivcsw); #ifdef SHOW_PROC_STATUS sprintf(filename, "/proc/%d/status", getpid()); if ((f = fopen(filename, "r")) == NULL) { syslog(LOG_ERR, "fopen: %s", strerror(errno)); return; } while (fgets(buf, sizeof(buf), f)) syslog(LOG_INFO, buf); fclose(f); #endif /* PROC_STATUS_EXISTS */ } /* Dump data to disk when catching USR2 */ static void usr2_signal_handler(const int signo) { syslog(LOG_INFO, "caught signal %d", signo); dump_data(); } /* Catch terminated childs */ static void chld_signal_handler(const int signo) { pid_t pid; int status; status = signo; /* don't like gcc warnings :) */ while ((pid = waitpid(-1, &status, WNOHANG)) > 0) if (opt.log_level >= 3) syslog(LOG_INFO, "child %d terminated", pid); } static void usage(void) { printf("Usage: %s [-v] [-p port] [-n] [-l loglevel]\n", opt.progname); printf("\nOptions:\n"); printf(" -h this help\n"); printf(" -v output version information and exit\n"); printf(" -f file use a specific configuration file\n"); printf(" (default: %s)\n", opt.config_file); printf(" -n do not fork as a daemon\n"); printf(" -a ip address to bind to (default: %s)\n", opt.listening_ip ? opt.listening_ip : "any"); printf(" -p port port to listen to (default: %s)\n", opt.port); printf(" -t number min. time interval before blacklisting (default: %lu secs)\n", (unsigned long)opt.interval); printf(" -m number maximum submissions in time interval (default %d)\n", opt.max_req); printf(" -i number IP list size (default: %d)\n", opt.list_size); printf(" -b number blacklist size (default: %d)\n", opt.blacklist_size); printf(" -e number blacklist expiration (default: %lu secs)\n", (unsigned long)opt.blacklist_expiration); printf(" -l number log level (0-3, default: %d)\n", opt.log_level); printf(" -u user user to run as\n"); printf(" -g group group to run as\n"); printf(" -T number client timeout (default %lu secs)\n", (unsigned long)opt.client_timeout); printf(" -I file which file to dump IP list do\n"); printf(" (default: `%s')\n", opt.wl_filename); printf(" -B file which file to dump blacklist to\n"); printf(" (default: `%s')\n", opt.bl_filename); printf(" -P file PID filename (default: `%s')\n", opt.pid_filename); printf(" -A file ACL filename (default: `%s')\n", opt.acl_filename); printf(" -W file whitelist filename (default: `%s')\n", opt.whitelist_filename); } /* Return a free slot for a client. FIXME: should be linear and keep maxsd more optimal for select() below */ static int get_client_slot(const int max) { int i, j; if (max == MAX_CLIENTS) return -1; for (i = 0, j = MAX_CLIENTS - 1; i < MAX_CLIENTS && j != i && client[i].sd != -1 && client[j].sd != -1; i++, j--); if (i < MAX_CLIENTS && client[i].sd == -1) return i; if (j > 0 && client[j].sd == -1) return j; return -1; } /* Reload ACL and whitelist files if they changed and if they contain valid information */ static void reload_files(void) { struct stat sb; netlist nl; #if 0 struct options sv_opt; /* Untested code. */ /* Config */ if (stat(opt.config_file, &sb) == 0) { if (S_ISREG(sb.st_mode) && sb.st_mtime > opt.config_mtime) { /* File modified */ opt.config_mtime = sb.st_mtime; if (opt.log_level >= 2) syslog(LOG_INFO, "%s changed on disk, reloading", opt.config_file); memcpy(&sv_opt, &opt, sizeof(struct options)); if (!parse_config()) { syslog(LOG_ERR, "error while parsing %s, restoring old configuration", opt.config_file); memcpy(&opt, &sv_opt, sizeof(struct options)); } } } else if (errno == ENOENT && opt.config_mtime) { /* File removed */ if (opt.log_level >= 2) syslog(LOG_INFO, "%s disappeared", opt.config_file); opt.config_mtime = 0; } #endif /* ACL */ if (stat(opt.acl_filename, &sb) == 0) { if (S_ISREG(sb.st_mode) && sb.st_mtime > opt.acl_mtime) { /* File modified */ opt.acl_mtime = sb.st_mtime; if (opt.log_level >= 2) syslog(LOG_INFO, "%s changed on disk, reloading", opt.acl_filename); if ((nl = netlist_init()) == NULL) { syslog(LOG_ERR, "netlist_init() failed for ACL, keeping old configuration"); } else if (netlist_acl_getfromfile(nl, opt.acl_filename) == -1) { syslog(LOG_ERR, "error while parsing %s, keeping old configuration", opt.acl_filename); free(nl); } else { netlist_free(opt.acl); opt.acl = nl; } } } else if (errno == ENOENT && opt.acl_mtime) { /* File removed */ if (opt.log_level >= 2) syslog(LOG_INFO, "%s disappeared, cleaning list", opt.acl_filename); netlist_free(opt.acl); opt.acl = netlist_init(); opt.acl_mtime = 0; } /* Whitelist */ if (stat(opt.whitelist_filename, &sb) == 0) { if (S_ISREG(sb.st_mode) && sb.st_mtime > opt.whitelist_mtime) { /* File modified */ opt.whitelist_mtime = sb.st_mtime; if (opt.log_level >= 2) syslog(LOG_INFO, "%s changed on disk, reloading", opt.whitelist_filename); if ((nl = netlist_init()) == NULL) { syslog(LOG_ERR, "netlist_init() failed for whitelist, keeping old configuration"); } else if (netlist_whitelist_getfromfile(nl, opt.whitelist_filename) == -1) { syslog(LOG_ERR, "error while parsing %s, keeping old configuration", opt.whitelist_filename); free(nl); } else { netlist_free(opt.whitelist); opt.whitelist = nl; } } } else if (errno == ENOENT && opt.whitelist_mtime) { /* File removed */ if (opt.log_level >= 2) syslog(LOG_INFO, "%s disappeared, cleaning list", opt.whitelist_filename); netlist_free(opt.whitelist); opt.whitelist = netlist_init(); opt.whitelist_mtime = 0; } } /* Set effective user and group. Exit with 1 on error */ static void set_eugid(void) { int id; struct passwd *pw; struct group *gr; if (opt.gid != NULL) { if ((gr = getgrnam(opt.gid)) == NULL && ((id = xstrtol(opt.gid)) < 0 || (gr = getgrgid(id)) == NULL)) { fprintf(stderr, "%s: Invalid group: %s\n", opt.progname, opt.gid); exit(EXIT_FAILURE); } if (setegid(gr->gr_gid) == -1) { perror("setegid"); exit(EXIT_FAILURE); } if (setgroups(1, &gr->gr_gid) == -1) { perror("setgroups"); exit(EXIT_FAILURE); } } if (opt.uid != NULL) { if ((pw = getpwnam(opt.uid)) == NULL && ((id = xstrtol(opt.uid)) < 0 || (pw = getpwuid(id)) == NULL)) { fprintf(stderr, "%s: Invalid user: %s\n", opt.progname, opt.uid); exit(EXIT_FAILURE); } if (seteuid(pw->pw_uid) == -1) { perror("seteuid"); exit(EXIT_FAILURE); } } } /* Fill the buffer with the reply code and human understandable string */ static void buildreply(const int code, char *buffer, const size_t maxsize) { size_t len; switch (code) { case 200: snprintf(buffer, maxsize, "%d OK", code); break; case 421: snprintf(buffer, maxsize, "%d Blacklisted", code); break; case 500: snprintf(buffer, maxsize, "%d Syntax error", code); break; case 600: snprintf(buffer, maxsize, "%d Authorization failed", code); break; default: snprintf(buffer, maxsize, "%d", code); } len = strlen(buffer); if (len >= maxsize - 2) sprintf(buffer + len - 2, "\r\n"); else sprintf(buffer + len, "\r\n"); return; } extern int main(int argc, char **argv) { int i, client_sd, maxsd, ret; struct sockaddr_in cliaddr; size_t csize = sizeof(cliaddr); ssize_t rd, wd; char buf[MAX_CMD_LEN+1]; fd_set rset, svrset, wset, svwset; int slot, errors; struct sigaction sa; struct stat sb; struct timeval tv; openlog(PROGNAME, LOG_PID, LOG_DAEMON); xsigaction(sa, SIGINT, exit_signal_handler); xsigaction(sa, SIGTERM, exit_signal_handler); xsigaction(sa, SIGUSR1, usr1_signal_handler); xsigaction(sa, SIGUSR2, usr2_signal_handler); xsigaction(sa, SIGCHLD, chld_signal_handler); options_init(argv[0]); parse_args_for_config_file(argc, argv); if (!parse_config()) exit(EXIT_FAILURE); if ((ret = parse_args(argc, argv)) == -1) { usage(); exit(EXIT_FAILURE); } else if (ret == 0) { usage(); exit(EXIT_SUCCESS); } if (netlist_acl_getfromfile(opt.acl, opt.acl_filename) == -1) { fprintf(stderr, "%s: Error while parsing %s\n", opt.progname, opt.acl_filename); exit(EXIT_FAILURE); } if (netlist_whitelist_getfromfile(opt.whitelist, opt.whitelist_filename) == -1) { fprintf(stderr, "%s: Error while parsing %s\n", opt.progname, opt.whitelist_filename); exit(EXIT_FAILURE); } if (stat(opt.config_file, &sb) == 0 && S_ISREG(sb.st_mode)) opt.config_mtime = sb.st_mtime; if (stat(opt.acl_filename, &sb) == 0 && S_ISREG(sb.st_mode)) opt.acl_mtime = sb.st_mtime; if (stat(opt.whitelist_filename, &sb) == 0 && S_ISREG(sb.st_mode)) opt.whitelist_mtime = sb.st_mtime; set_eugid(); if (opt.log_level >= 3) options_log(); opt.syslog = 1; if (opt.daemon) daemon_init(); umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if ((listen_sd = net_server_sock_create(opt.listening_ip, opt.port)) == -1) exit(EXIT_FAILURE); net_socket_set_nb(listen_sd); ipt = iptree_init(); /* Initialize all client slots */ for (i = 0; i < MAX_CLIENTS; i++) { client[i].sd = -1; client[i].reply = -1; client[i].last = 0; } FD_ZERO(&svrset); FD_SET(listen_sd, &svrset); FD_ZERO(&svwset); /* FIXME: should optimize maxsd count for select() */ maxsd = MAX_CLIENTS; syslog(LOG_INFO, "listening on port %s", opt.port); errors = 0; for (;;) { int nsel; time_t t = time(NULL); if (t - opt.last_dump > opt.dump_delay) dump_data(); /* Close idle connections */ if (ncli) for (i = 0; i < MAX_CLIENTS; i++) if (client[i].sd != -1 && client[i].last && t - client[i].last >= opt.client_timeout) { if (opt.log_level >= 2) syslog(LOG_INFO, "connection with %s closed (timeout)", inet_ntoa(client[i].addr.sin_addr)); if (FD_ISSET(client[i].sd, &svrset)) FD_CLR(client[i].sd, &svrset); if (FD_ISSET(client[i].sd, &svwset)) FD_CLR(client[i].sd, &svwset); close_client(i); } /* Reload ACL and whitelist files if needed */ reload_files(); rset = svrset; wset = svwset; /* Wake up at least every 60 seconds to perform some cleanup */ tv.tv_sec = 60; tv.tv_usec = 0; if ((nsel = select(maxsd + 1, &rset, &wset, NULL, &tv)) == -1 && errno != EINTR) { syslog(LOG_ERR, "error in select(): %s", strerror(errno)); if (++errors >= 3) { syslog(LOG_ERR, "too many errors, aborting"); close(listen_sd); exit(EXIT_FAILURE); } continue; } if (FD_ISSET(listen_sd, &rset)) { /* First look for incoming connections */ nsel--; client_sd = accept(listen_sd, (struct sockaddr *)&cliaddr, &csize); if (client_sd < 0) { if (errno != EINTR && errno != EWOULDBLOCK) syslog(LOG_ERR, "accept: %s (errno=%d)", strerror(errno), errno); } else { slot = get_client_slot(ncli); if (slot == -1) close(client_sd); else { int mode = netlist_getmode(opt.acl, ntohl(cliaddr.sin_addr.s_addr)); if (!mode) { close(client_sd); syslog(LOG_INFO, "closed unauthorized connection from %s", inet_ntoa(cliaddr.sin_addr)); } else { ncli++; net_socket_set_nb(client_sd); client[slot].sd = client_sd; client[slot].addr.sin_addr = cliaddr.sin_addr; client[slot].mode = mode; client[slot].last = time(NULL); if (opt.log_level == 2) syslog(LOG_INFO, "connect from %s (%d/%d) [%d]", inet_ntoa(cliaddr.sin_addr), ncli, MAX_CLIENTS, mode); write(client_sd, BANNER, strlen(BANNER)); FD_SET(client_sd, &svrset); } /* if (!mode) [...] else */ } /* if (slot == -1) [...] else */ } /* if (client_sd < 0) [...] else */ } /* if (FD_ISSET(listen_sd, &rset) */ /* Then have a look at open connections */ for (i = 0; nsel > 0 && i < maxsd; i++) { if (client[i].sd != -1) { if (FD_ISSET(client[i].sd, &rset)) { /* Something to read */ nsel--; if ((rd = read(client[i].sd, &buf, MAX_CMD_LEN)) <= 0) { if (rd < 0 && (errno == EINTR || errno == EWOULDBLOCK)) continue; if (rd < 0) syslog(LOG_ERR, "read: %s", strerror(errno)); FD_CLR(client[i].sd, &svrset); close_client(i); } else { client[i].reply = read_cmd(buf, rd, inet_ntoa(cliaddr.sin_addr), ipt, client[i].mode); client[i].last = time(NULL); FD_CLR(client[i].sd, &svrset); FD_SET(client[i].sd, &svwset); } } else if (FD_ISSET(client[i].sd, &wset)) { /* Something to write */ nsel--; buildreply(client[i].reply, buf, MAX_CMD_LEN + 1); wd = write(client[i].sd, &buf, strlen(buf)); if (wd < 0 && (errno == EINTR || errno == EWOULDBLOCK)) continue; if (wd < 0) syslog(LOG_ERR, "write: %s", strerror(errno)); FD_CLR(client[i].sd, &svwset); close_client(i); if (opt.log_level == 2) syslog(LOG_INFO, "connection with %s closed (%d/%d)", inet_ntoa(client[i].addr.sin_addr), ncli, MAX_CLIENTS); } /* if (FD_ISSET(client[i].sd, &rset)) [...] else [...] */ } /* if (client[i].sd != -1) */ } /* for (i = 0; i < MAX_CLIENTS; i++) */ } /* for (;;) */ /* Can never be called but exit with a polite code */ exit(EXIT_SUCCESS); } bld-0.3.4.1/bld_whitelist.conf.5.in0000644000175000017500000000150310417723250014454 0ustar obob.TH BLD_WHITELIST.CONF "5" "August 2004" .SH NAME bld_whitelist.conf - White lists for BLD .SH DESCRIPTION \fIbld_whitelist.conf\fR consists of lines used by \fBbld\fR to configure its white lists. The lines are processed in order of appearance. If two lines contain different information about the same IP address, the last is used. Blank lines and lines beginning with a `#' are ignored. .PP Lines have the following format: .sp .ti +3 .IP \(bu `n.n.n.n' (IP address), .IP \(bu `n.n.n.n/m.m.m.m' (network with netmask) .IP \(bu or `n.n.n.n/b' (network with bitmask). .SH NOTES .PP There is no need to restart or send any signal to \fBbld\fR after modifying (or deleting) this file. .SH FILES .PP @sysconfdir@/bld_whitelist.conf .SH SEE ALSO .PP bld(8) bld.conf(5) bld_acl.conf(5) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/bld_acl.conf.5.in0000644000175000017500000000202110417723250013173 0ustar obob.TH BLD_ACL.CONF "5" "August 2004" .SH NAME bld_acl.conf - Access lists for BLD .SH DESCRIPTION \fIbld_acl.conf\fR consists of lines used by \fBbld\fR to control clients access. The lines are processed in order of appearance. If two lines contain different information about the same IP address, the last is used. Blank lines and lines beginning with a `#' are ignored. .PP Access control lines have the following format: .sp .ti +3 address: action[, action] .PP \fIaddress\fR can be of the following forms: .IP \(bu `n.n.n.n' (IP address), .IP \(bu `n.n.n.n/m.m.m.m' (network with netmask) .IP \(bu or `n.n.n.n/b' (network with bitmask). .PP \fIaction\fR is one of the following: .IP \(bu `submit', .IP \(bu `query' .IP \(bu `insert' .IP \(bu `decrement' .IP \(bu or `all'. .SH NOTES .PP There is no need to restart or send any signal to \fBbld\fR after modifying (or deleting) this file. .SH FILES .PP @sysconfdir@/bld_acl.conf .SH SEE ALSO .PP bld(8) bld.conf(5) bld_whitelist.conf(5) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/misc/0000755000175000017500000000000011033013641011123 5ustar obobbld-0.3.4.1/misc/bld-logcheck_ignore.d0000644000175000017500000000041210417723252015161 0ustar obobbld\[[0-9]+\]: ([0-9]+\.){3}[0-9]+ (\(wl\) ){0,1}(decremen|submit|inser)ted by ([0-9]+\.){3}[0-9]+ bld\[[0-9]+\]: ([0-9]+\.){3}[0-9]+ put in bl: bld\[[0-9]+\]: notified .+:.+ about ([0-9]+\.){3}[0-9]+ bld\[[0-9]+\]: request for a blacklisted IP: ([0-9]+\.){3}[0-9]+ bld-0.3.4.1/misc/README0000644000175000017500000000043710417723252012022 0ustar obobbld-logcheck_ignore.d: logcheck configuration file matching all `normal' bld logs. It should be put in the logcheck ignore.d configuration directory (depends on your site's configuration) with the name `bld'. bld-0.3.4.1/dumpread.c0000644000175000017500000000410710417723245012154 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include "ipinfo.h" int main(int argc, char **argv) { struct ipinfo ipi; FILE *f; if ((argc >= 2 && !strcmp(argv[1], "-h")) || argc != 2) { fprintf(stderr, "Usage: %s -h|filename\n", argv[0]); exit(EXIT_FAILURE); } if ((f = fopen(argv[1], "r")) == NULL) { perror("fopen"); exit(EXIT_FAILURE); } while (fread(&ipi, sizeof(struct ipinfo), 1, f)) printf("%u.%u.%u.%u;%lu;%lu;%u;%u;%d;%d;%p;%p\n", ipi.iptbl[3], ipi.iptbl[2], ipi.iptbl[1], ipi.iptbl[0], (unsigned long)ipi.start, (unsigned long)ipi.last, ipi.count, ipi.count2, ipi.options, ipi.blp ? 1 : 0, (void *)ipi.iplp, (void *)ipi.blp); fclose(f); exit(EXIT_SUCCESS); } bld-0.3.4.1/bld.8.in0000644000175000017500000000720210420127124011431 0ustar obob.TH BLD "8" "August 2004" .SH NAME bld - A black list daemon .SH SYNOPSIS .br .B bld -h | [option] .SH OPTIONS .TP \fB\-v\fR Output version information and exit .TP \fB-n\fR Do not fork to become a daemon .TP \fB-a\fR \fIaddress\fR Address to bind to .TP \fB-p\fR \fIport\fR Port to listen to .TP \fB-l\fR \fInumber\fR Log verbosity (between 0 and 3) .TP \fB-t\fR \fInumber\fR Minimum time interval before blacklisting .TP \fB-m\fR \fInumber\fR Maximum submissions in time interval .TP \fB-i\fR \fInumber\fR IP list size .TP \fB-b\fR \fInumber\fR Blacklist size .TP \fB-e\fR \fInumber\fR Blacklist expiration .TP \fB-P\fR \fIfilename\fR Filename where to save PID .TP \fB-T\fR \fInumber\fR Timeout for client connections .TP \fB-u\fR \fIuser\fR User to run as .TP \fB-g\fR \fIgroup\fR Group to run as .TP \fB-f\fR \fIfilename\fR Use a specific configuration file .TP \fB-A\fR \fIfilename\fR Filename where to find ACLs .TP \fB-W\fR \fIfilename\fR Filename where to find whitelist .TP \fB-B\fR \fIfilename\fR Filename where to store blacklist .TP \fB-I\fR \fIfilename\fR Filename where to store whole IP list .TP .SH DESCRIPTION .PP By default, the \fBbld\fR daemon listens to requests on port 2905. Requests are either IP addresses submissions or checks against the black list. .PP \fBbld\fR uses a very simple algorithm to decide whether to add IP addresses to the blacklist or not. The first time an IP address is submitted, it is added to an internal list with a timestamp and all further requests increment a counter for this IP. As soon as the minimum time interval is elapsed (default: 30 seconds), and if a maximum requests ratio is reached (default: 10 submissions in the 30 seconds interval), the IP is put in the blacklist. It is then blacklisted for a configurable time (default: 900 seconds). .SH PROTOCOL .PP Requests sent to \fBbld\fR are rather simple. Each request or reply is followed by a linefeed and a carriage return. A client may only send one request per TCP session. As of now, two commands may be used: \fBip\fR (address submission) and \fBip?\fR (ask if address is blacklisted). .PP \fBip=a.b.c.d\fR submits an IP address. The server acknowledges either with a \fB200\fR code if the address is not blacklisted or a \fB421\fR if it is. .PP \fBipdecr=a.b.c.d\fR decrements the internal counter for an IP address. The lowest value for the counter is zero. The server always acknowledges with a \fB200\fR code. .PP \fBip?=a.b.c.d\fR asks if address is blacklisted. The server reply may be \fB421\fR if it is or \fB200\fR if it's not. .PP \fBipbl=a.b.c.d\fR forces the insertion in the blacklist. The server acknowledges with a \fB200\fR code. .PP If using IP based restrictions, the server reply may be \fB600\fR if the client is not in the correct ACL to perform a request. Any other error will generate a reply with a \fB500\fR error code. .SH NOTES .PP \fBbld\fR binds to localhost by default and accepts any local request, so please make sure that only trusted users can establish a connection to the daemon. Please check that all authorized hosts meet the minimal security requirements before changing this parameter even if using an access control list (see \fIbld_acl.conf\fR(5)). .PP \fBbld\fR will log some statistics if it receives the SIGUSR1 signal. SIGUSR2 is used to force a dump of both lists in \fBbld\fR working directory. .SH FILES .PP @sysconfdir@/bld.conf @sysconfdir@/bld_acl.conf @sysconfdir@/bld_whitelist.conf /var/run/bld/bld.pid /var/run/bld/bld_iplist.dump /var/run/bld/bld_blacklist.dump .SH SEE ALSO .PP bld.conf(5) bld_acl.conf(5) bld_whitelist.conf(5) bldread(8) bldquery(8) bldsubmit(8) blddecr(8) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/TODO0000644000175000017500000000060410420126537010670 0ustar obobApache mod_bld Support for permanent blacklists Reload blacklist (not only IP list) from disk too Replace tests with opt.syslog with real variable arguments function Allow persistent connections? Use ipinfo->count2 to compute percentages Blacklist auto-resize option Give user the choice between pre-allocation (better for big sites) and current on-demand-mallocs Become a newsreader bld-0.3.4.1/net.c0000644000175000017500000001133010422172346011131 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "net.h" #include "utils.h" #include "options.h" #define LISTENQ 5 struct options opt; /* Set a socket non-blocking. Return 1 if successful, 0 if not */ extern int net_socket_set_nb(const int sd) { int flags; if ((flags = fcntl(sd, F_GETFL, 0)) == -1) { syslog(LOG_ERR, "fcntl: %s", strerror(errno)); return 0; } if ((fcntl(sd, F_SETFL, flags | O_NONBLOCK)) == -1) { syslog(LOG_ERR, "fcntl: %s", strerror(errno)); return 0; } return 1; } /* Return a TCP socket listening on ip:port Return -1 on error */ extern int net_server_sock_create(const char *ip, const char *port) { struct sockaddr_in servaddr; struct servent *sv; struct hostent *h; int listen_port; int optval = 1; int sd; if ((listen_port = atoi(port)) == 0) { if ((sv = getservbyname(port, "tcp")) == NULL) { syslog(LOG_ERR, "getservbyname() error on %s", port); return -1; } else { listen_port = ntohs(sv->s_port); } } if ((h = gethostbyname(ip)) == NULL) { syslog(LOG_ERR, "gethostbyname() error on %s\n", ip); return -1; } memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = h->h_addrtype; memcpy((char *)&servaddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length); servaddr.sin_port = htons(listen_port); if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { syslog(LOG_ERR, "socket(): %s", strerror(errno)); return -1; } setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); if (bind(sd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) { syslog(LOG_ERR, "bind() to port %s: %s", port, strerror(errno)); return -1; } if (listen(sd, LISTENQ) == -1) { syslog(LOG_ERR, "listen() on port %s: %s", port, strerror(errno)); return -1; } return sd; } static void alrm_signal_handler(const int signum) { if (opt.log_level >= 3) syslog(LOG_INFO, "caught signal %d", signum); } /* Return a TCP socket connected to server:port Return -1 on error NOTE: SIGALRM used to handle connect(2) timeout */ extern int net_client_sock_create(const char *server, const char *server_port) { int sd, port; struct sockaddr_in local_addr, serv_addr; struct hostent *h; struct servent *sv; struct sigaction sa; if ((h = gethostbyname(server)) == NULL) return -1; if ((port = atoi(server_port)) == 0) { if ((sv = getservbyname(server_port, "tcp")) == NULL) return -1; else port = sv->s_port; } serv_addr.sin_family = h->h_addrtype; memcpy((char *)&serv_addr.sin_addr.s_addr, h->h_addr_list[0], h->h_length); serv_addr.sin_port = htons(port); if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return -1; local_addr.sin_family = AF_INET; local_addr.sin_addr.s_addr = htonl(INADDR_ANY); local_addr.sin_port = htons(0); if (bind(sd, (struct sockaddr *)&local_addr, sizeof(local_addr)) < 0) return -1; xsigaction(sa, SIGALRM, alrm_signal_handler); alarm(opt.connect_timeout); if (connect(sd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) return -1; alarm(0); xsigaction(sa, SIGALRM, SIG_IGN); return sd; } bld-0.3.4.1/cmd.h0000644000175000017500000000340210417723243011116 0ustar obob/*- * Copyright (c) 2004 Free (Olivier Beyssac) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _CMD_H #define _CMD_H #include "iptree.h" #define CMD_NO (0) #define CMD_SUBMIT (1) #define CMD_TO (2) #define CMD_QUERY (3) #define CMD_INSERT (4) #define CMD_DECR (5) /* Read the command pointed to by cmd and update iptree Return the code to show to client */ extern int read_cmd(char *cmd, const ssize_t len, const char *ident, const iptree ipt, const int mode); #endif /* _CMD_H */ bld-0.3.4.1/utils/0000755000175000017500000000000011033013641011330 5ustar obobbld-0.3.4.1/utils/bld-pf_log.pl.80000644000175000017500000000121110417723244014047 0ustar obob.TH BLD-PF_LOG.PL "8" "December 2004" .SH NAME bld-pf_log.pl - feed BLD with Postifx log files .SH SYNOPSIS .br .B bld-pf_log.pl .SH DESCRIPTION .PP \fBbld-pf_log.pl\fR reads mail logs and submits to a \fBbld\fR daemon anything that looks like a "user unknown" Postfix log line. This script gets its information from stdin, so the easiest way to use it is like this: .sp .ti +3 tail -f /path/to/postfix/logfile | bld-pf_log.pl .PP You may have to provide various options to the \fBtail\fR program in order to support file modifications such as log rotations. .SH SEE ALSO bld(8) bldread(8) tail(1) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/utils/bld-pf_log.pl0000755000175000017500000000173210417723244013714 0ustar obob#!/usr/bin/perl # # This Perl script reads mail logs and submits to a BLD daemon anything # that looks like a "user unknown" Postfix log line # # Olivier Beyssac # # Contributors: # Tim Bynum # use IO::Socket; use strict; my $bld_host = "localhost"; my $bld_port = "2905"; sub bld_submit($$$$) { my ($host, $port, $ip, $debug) = @_; my $sd = IO::Socket::INET->new(PeerHost => $host, PeerPort => $port) || return undef; my $buf; return if (sysread($sd, $buf, 1024) <= 0); print "BLD: $buf" if ($debug); syswrite($sd, "ip=$ip\r\n"); print "YOU: ip=$ip\r\n" if ($debug); return if (sysread($sd, $buf, 1024) <= 0); print "BLD: $buf" if ($debug); close($sd); } my $debug; if ($#ARGV == 0 && $ARGV[0] eq "-d") { $debug = 1; } while () { if (/postfix\/smtp[^:]+:[^:]+: reject: RCPT from [^\[]+\[([^\]]+)\]: .* User unknown/) { bld_submit($bld_host, $bld_port, $1, $debug); } } bld-0.3.4.1/utils/bldsubmit.py0000755000175000017500000000077210417723244013714 0ustar obob#!/usr/bin/python # # Usage: bldsubmit.py host port ip # # Connect to bld on host:port to submit ip # import sys, socket MAX_CMD_LEN = 80 if len(sys.argv) < 4: print "Usage: "+sys.argv[0]+" host port ip" sys.exit(1) host = sys.argv[1] port = int(sys.argv[2]) ip = sys.argv[3] s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) data = s.recv(MAX_CMD_LEN) if not data: s.close() s.send("ip="+ip+"\r\n") data = s.recv(MAX_CMD_LEN) s.close() data.rstrip() print data, bld-0.3.4.1/utils/bldcheck.py0000755000175000017500000000101310417723244013453 0ustar obob#!/usr/bin/python # # Usage: bldcheck.py host port ip # # Connect to bld on host:port to check if ip is blacklisted # import sys, socket MAX_CMD_LEN = 80 if len(sys.argv) < 4: print "Usage: "+sys.argv[0]+" host port ip" sys.exit(1) host = sys.argv[1] port = int(sys.argv[2]) ip = sys.argv[3] s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) data = s.recv(MAX_CMD_LEN) if not data: s.close() s.send("ip?="+ip+"\r\n") data = s.recv(MAX_CMD_LEN) s.close() data.rstrip() print data, bld-0.3.4.1/utils/bld-pf_policy.pl0000755000175000017500000001015710417723244014433 0ustar obob#!/usr/bin/perl use IO::Socket::INET; use Sys::Syslog qw(:DEFAULT setlogsock); # Modify these variables if needed to point to your BLD daemon my $bld_host = "localhost"; my $bld_port = "2905"; # # Usage: bld-postfix_policy.pl [-v] # # Demo delegated Postfix SMTPD policy server. This server implements # interaction with BLD and is heavily based on example greylist.pl from # Postfix 2.1. Logging is sent to syslogd. # # How it works: each time a Postfix SMTP server process is started # it connects to the policy service socket, and Postfix runs one # instance of this PERL script. By default, a Postfix SMTP server # process terminates after 100 seconds of idle time, or after serving # 100 clients. Thus, the cost of starting this PERL script is smoothed # out over time. # # To run this from /etc/postfix/master.cf: # # bld-policy unix - n n - - spawn # user=nobody argv=/usr/bin/perl /usr/libexec/postfix/bld-postfix_policy.pl # # To use this from Postfix SMTPD, use in /etc/postfix/main.cf: # # smtpd_recipient_restrictions = # ... # reject_unauth_destination # check_policy_service unix:private/bld-policy # ... # # NOTE: specify check_policy_service AFTER reject_unauth_destination # or else your system can become an open relay. # # To test this script by hand, execute: # # % perl bld-postfix_policy.pl # # Each query is a bunch of attributes. Order does not matter, and # the demo script uses only a few of all the attributes shown below: # # request=smtpd_access_policy # protocol_state=RCPT # protocol_name=SMTP # helo_name=some.domain.tld # queue_id=8045F2AB23 # sender=foo@bar.tld # recipient=bar@foo.tld # client_address=1.2.3.4 # client_name=another.domain.tld # instance=123.456.7 # sasl_method=plain # sasl_username=you # sasl_sender= # size=12345 # [empty line] # # The policy server script will answer in the same style, with an # attribute list followed by a empty line: # # action=dunno # [empty line] # # # Syslogging options for verbose mode and for fatal errors. # NOTE: comment out the $syslog_socktype line if syslogging does not # work on your system. # $syslog_socktype = 'unix'; # inet, unix, stream, console $syslog_facility="mail"; $syslog_options="pid"; $syslog_priority="info"; # # BLD query submission routine. Return the action to take for the given # IP # sub bld_query($$$) { my ($host, $port, $ip) = @_; my $sd = IO::Socket::INET->new(PeerHost => $host, PeerPort => $port) || return undef; my $action = "dunno"; # Default action my $buf; return $action if (sysread($sd, $buf, 1024) <= 0); syswrite($sd, "ip?=$ip\r\n"); return $action if (sysread($sd, $buf, 1024) <= 0); close($sd); return "defer_if_permit Too many Users unknown from this IP" if ($buf =~ /^421 /); return $action; } # # Log an error and abort. # sub fatal_exit { my($first) = shift(@_); syslog "err", "fatal: $first", @_; exit 1; } # # This process runs as a daemon, so it can't log to a terminal. Use # syslog so that people can actually see our messages. # setlogsock $syslog_socktype; openlog $0, $syslog_options, $syslog_facility; # # We don't need getopt() for now. # while ($option = shift(@ARGV)) { if ($option eq "-v") { $verbose = 1; } else { syslog $syslog_priority, "Invalid option: %s. Usage: %s [-v]", $option, $0; exit 1; } } # # Unbuffer standard output. # select((select(STDOUT), $| = 1)[0]); # # Receive a bunch of attributes, evaluate the policy, send the result. # while () { if (/([^=]+)=(.*)\n/) { $attr{substr($1, 0, 512)} = substr($2, 0, 512); } elsif ($_ eq "\n") { if ($verbose) { for (keys %attr) { syslog $syslog_priority, "Attribute: %s=%s", $_, $attr{$_}; } } fatal_exit "unrecognized request type: '%s'", $attr{request} unless $attr{"request"} eq "smtpd_access_policy"; $action = bld_query($bld_host, $bld_port, $attr{client_address}); syslog $syslog_priority, "Action: %s", $action if $verbose; print STDOUT "action=$action\n\n"; %attr = (); } else { chop; syslog $syslog_priority, "warning: ignoring garbage: %.100s", $_; } } bld-0.3.4.1/utils/bld-mrtg.pl.80000644000175000017500000000071410417723244013561 0ustar obob.TH BLD-MRTG.PL "8" "December 2004" .SH NAME bld-mrtg.pl - return MRTG-friendly statistics about local BLD status .SH SYNOPSIS .br .B bld-mrtg.pl .SH DESCRIPTION .PP \fBbld-mrtg.pl\fR reads \fBbld\fR daemon dump files and prints statistics about the number of currently blacklisted IPs and the number of IPs added within the last 5 minutes. The default output is MRTG-friendly. .SH SEE ALSO bld(8) bldread(8) .SH AUTHOR Olivier Beyssac bld-0.3.4.1/utils/bld-mrtg.pl0000755000175000017500000000200510417723244013411 0ustar obob#!/usr/bin/perl # # This script reads BLD dump files and prints statistics about the number # of currently blacklisted IPs and the number of IPs added in the last 5 # minutes. The default output is MRTG-friendly. # # Olivier Beyssac # use strict; # If you don't use BLD default value for blacklist expiration (-e option # or blacklist_expiration parameter in bld.conf(5)), change this my $expiration = 900; # If you don't run MRTG every 5 minutes, change this my $rate = 300; my $dump = "/var/run/bld/bld_blacklist.dump"; my $state = "/var/run/bld-mrtg.state"; my $current_time = time(); my $count = 0; my $total = 0; open(BLD, "bldread $dump |"); while () { if (/^(\d+\.\d+\.\d+\.\d+;\d+;(\d+);/) { my $ip = $1; my $time = $2; $total++ if ($time > $current_time - $expiration); if ($time > $current_time - $rate) { $count++; } } } close(BLD); print "$count\n$total\n\n\n"; bld-0.3.4.1/utils/bld2zone.pl0000755000175000017500000000121510417723244013422 0ustar obob#!/usr/bin/perl # # Converts a bld dump printed by bldread to a zone file. # # Olivier Beyssac # use Date::Format; use strict; my $domain = "FILLME"; my $ns0 = "FILLME"; my $ip0 = "FILLME"; my $ns1 = "FILLME"; my $ip1 = "FILLME"; my $date = time2str("%Y%m%d%H", time()); print <) { if (/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+);/) { print "$4.$3.$2.$1 IN A 127.0.0.1\n\t\tTXT \"Blacklisted by postmaster\@$domain\"\n"; } }