gld-1.7/0040755000005300000010000000000010425472146010251 5ustar xfsbingld-1.7/HISTORY0100644000000000000000000000726510425472077011734 0ustar rootroot01/05/2006 : V 1.7 - Removed the KEEPDBOPEN option as it could lead to multiple instance of gld running when mail traffic is low and thus father process MYSQL connection timeout . Furthermore, after tests, efficency is the same . KEEPDBOPEN option is now silently ignored to forced to NO . 16/09/2005 : V 1.6 - Removed the algorithm lightgreydomain as the new mxgrey does better and simpler - Removed the UPDATE option, now gld always update triplets . - Fixed a minor flaw in the MXGREY algorithm. - Now you can configure MXGREY to consider an ip as a safe MX after X succesful greylists instead of only 1 . (read gld.conf for details) - Now gld updates the counters only when mail is not greylisted - Added Training mode, read gld.conf for details - Now gld verify that if you supply a custom smtp code, it's a 4XX code otherwise gld discard it and use 450 . - If gld cannot connect to MySQL server on startup it will not refuse to run anymore, but will set keepdbopen to 0 and accept to run . - The sample config file provided now only listen to loopback only accept connection from localhost and runs as nobody/ nobody. WARNING: if you were using lightgreydomain algorithm, it has been discontinued use MXGREY in place, please read gld.conf for details. 21/04/2005 : V 1.5.2 - Fixed a bug in MXGREY algorithm 13/04/2005 : V 1.5 - Fixed several possible buffer overflow by removing all sprintf() calls and replacing them by snprintf() - Added pgsql support, use configure --with-pgsql to compile gld with pgsql support - Added the MXGREY parameter, please read gld.conf for details. - Added KEEPDBOPEN parameter, please read gld.conf for details. - Added Configurable SMTP return code - Updated the white list to the lastest known. 19/08/2004 : V 1.4 - Added the USER and GROUP parameters to allow running gld as a specific user/group instead of root. - Added the LIGHTGREYDOMAIN parameter for greylisting on domains please read gld.conf for details. - Added CLIENTS parameter, to restrict clients allowed to connect to gld. 15/08/2004 : V 1.3.1 - Parameters are now checked to avoid a possible buffer overflow - Parameters are now checked to avoid a possible SQL injection - Fixed the bug which makes gld crash when displaying infos for an empty database 19/07/2004 : V 1.3 - Now, when LIGHTGREY is active, full ip+network is checked in whitlists instead of the network only. - Added the LOOPBACKONLY parameter, to make gld listen only to loopback (127.0.0.1) . - Added the DNSW parameter for DNS whitelist support (cf DNSWL in gld.conf) - Added the FACILITY parameter to define the syslog facility we want to use - Added the -C switch to simulate what -c would do - Added the -k and -K switchs to clean the one hits entries in the database - Added the -i switch to display some database informations - Added the -d switch to enable debug mode - Added in the documentation a mini howto to setup postfix to greylist only some emails/domains. 25/06/2004 : V 1.2 - Improved child management to avoid zombies on some BSD. Thanks to Michael Rasmussen that solved the bug that caused gld to leave spawned children as zombies on BSD. - Added the light greylisting algorithm (cf LIGHTGREY parameter in gld.conf). - Added the -c option to gld to clean up the database (try gld -h). - All options have now a default value and are no more mandatory. - gld now use a configure script and should be easier to compile on some unixes. - Improved documentation and given a postfix configuration example. 20/06/2004 : V 1.1 - Some tries, this version has never been released. 10/05/2004 : V 1.0 - Initial release. gld-1.7/LICENCE0100644000000000000000000004257110070071370011617 0ustar rootrootHello, gld software is placed under the GNU General Public License (GPL) As a courtsy, here follow the original GPL: ------------------------------------------------------------------- The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. one line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. gld-1.7/Makefile.in0100644000000000000000000000136510132750415012676 0ustar rootrootall: gld gld: cnf.o server.o sql.o sockets.o greylist.o gld.h @CC@ -O2 @DEFS@ -Wall server.o sql.o sockets.o cnf.o greylist.o @LIBS@ @SQL_LIBS@ -o gld strip gld sockets.o: sockets.c sockets.h @CC@ -O2 @DEFS@ -Wall -c sockets.c cnf.o: cnf.c gld.h @CC@ -O2 @DEFS@ -Wall -c cnf.c greylist.o: greylist.c gld.h @CC@ -O2 @DEFS@ -Wall -c greylist.c server.o: server.c gld.h @CC@ -O2 @DEFS@ -Wall -c server.c sql.o: sql.c @CC@ -O2 @DEFS@ @SQL_CFLAGS@ -Wall -c sql.c clean: rm -f gld *.o install: gld gld.conf mkdir -p /usr/local/bin cp gld /usr/local/bin chmod 700 /usr/local/bin/gld cp gld.conf /etc/gld.conf.sample chmod 600 /etc/gld.conf.sample distclean: clean rm -f Makefile config.status config.log config.cache rm -rf autom4te.cache gld-1.7/README0100644000000000000000000001073310312513766011516 0ustar rootrootWhat is gld ? gld stands for GreyList Daemon. gld is a standalone policy delegation server for postfix that implements the greylist algorithm as defined at http://www.greylisting.org What are the requirements ? gld needs the following software: - a postfix 2.1 or higher server - a mysql server or a pgsql server How to build gld ? This should be easy, just run ./configure and then make and wait ... Of course you need to have include files and libraries for MySQL support. If the compilation fails with mysql related errors, try to run ./configure --with-mysql=DIR . How to install gld ? Just run make install The install copy only 2 files into your system. The files are installed as follow: /etc/gld.conf.sample : the sample config file /usr/local/bin/gld : the gld executable file Afterward, edit /etc/gld.conf.sample file and modify it to suit your needs. Then rename it to gld.conf . Please, PLEASE read the README-SECURITY file before choosing your options. Then, create the tables whitelist and greylist on your mysql server I have provided the script tables.sql that helps you to do this task. Then start gld and see if it run or if an error message is displayed If you are here, you are done, now just configure postfix to use your brand new greylist server . To configure postfix just add the following line: check_policy_service inet:127.0.0.1:2525 to the end of your smtpd_recipient_restrictions statement of your main.cf file. You don't have to edit or modify your master.cf file . How to start gld ? just run gld without any parameters. How to stop gld ? Just kill the process with the TERM signal (SIGTERM is the default signal sent by the kill command) How to reload the configuration of the server ? Just send the HUP signal to the server ie: kill -HUP or killall -HUP gld How to know the version of gld ? Just try: gld -v What happens if the mysql server goes down ? Depending on the configuration of gld, the server can refuse to answer or send a 'dunno' response, which will likely accept the mails. Please read gld.conf for more informations. What happens if gld goes down ? Well, gld *MUST* be running while postfix is running. make sure you start gld before you start postfix . If gld should die (this has never occured here) postfix will not be able to connect to the policy server and will return a '450 server configuration' . Thus, you won't be able to receive any greylisted mail ..... What king of replies this server send to postfix ? gld sends only 2 replies to postfix. if the email is to be refused, then gld reply: action=defer_if_permit MESSAGE otherwise gld reply: action=dunno I want to greylist only some emails and only some domains, How to do ? postfix has a cool feature for that named policy maps. Let say you want to greylist only the email grey@foo.bar and the whole domain bar.com here follow hos to set up postfix for that. First, define a policy map named greylist_policy in main.cf to do this just add the following lines in main.cf : smtpd_restriction_classes = greylist_policy greylist_policy = check_policy_service inet:127.0.0.1:2525 Then in the end of smtpd_recipient_restrictions add the following line: check_recipient_access hash:/etc/postfix/A_FILE_OF_YOUR_CHOICE instead of the standard line: check_policy_service inet:127.0.0.1:2525 Finally create a text file named /etc/postfix/A_FILE_OF_YOUR_CHOICE which contains domain and emails to be greylisted the format is: email greylist_policy domain greylist_policy thus in our example, the file would contain grey@foo.bar greylist_policy bar.com greylist_policy Finally make this text file a hash database with the command: postmap /etc/postfix/A_FILE_OF_YOUR_CHOICE and you are done ! . Where do I report bugs,suggestions,insults ? Just send a mail to salim@gasmi.net (of course this email is greylisted ..) But please, include the version of gld you use and the OS you are running. Note from the author: I want to thanks all people who mailed me with suggestions, patches and especially the following guys: - Lefteris Tsintjelis for his help and support for testing 1.6. - Dietmar Braun for his idea of the training mode. - Wayne Smith for his support and suggestions. - Santiago Vila for maintaining the Debian package. - Blaz Zupan for maintaining the FreeBSD port. - Volker Tanger for the nice howto. - Brian Truelsen for his help and suggestions on MXGREY. - Wietse Venema for postfix. gld-1.7/cnf.c0100644000000000000000000001107210425466142011545 0ustar rootroot#include "gld.h" #ifdef HAVE_SYSLOG_H #include #define FACSIZE 10 typedef struct facs { char *name; int fac; }facs; facs facys[] = { { "daemon", LOG_DAEMON }, { "mail", LOG_MAIL }, { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 } }; #endif int ReadConfig(char *file,config *conf) { char *p; char buffer[1024]; FILE *fic; int i; fic=fopen(file,"r"); if(fic==(FILE *)NULL) return(-1); // We set the default values strcpy(conf->sqlhost,"localhost"); strcpy(conf->sqluser,"myuser"); strcpy(conf->sqldb,"mydb"); strcpy(conf->sqlpasswd,"mypasswd"); strcpy(conf->message,"Greylisted"); conf->training=0; conf->port=2525; conf->maxcon=100; conf->mini=60; conf->syslog=1; conf->accept=1; conf->whitelist=1; conf->light=0; conf->dnswl[0]=0; conf->loopback=1; conf->debug=0; conf->user[0]=0; conf->grp[0]=0; conf->nbnet=0; conf->mxgrey=0; #ifdef HAVE_SYSLOG_H conf->facility=LOG_MAIL; #endif // Now we read while(fgets(buffer,1024,fic)!=NULL) { p=(char *)strstr(buffer,"="); if(p!=NULL) { buffer[strlen(buffer)-1]=0; *p=0; if(strcmp(buffer,"CLIENTS")==0) ReadClients(conf,p+1); if(strcmp(buffer,"USER")==0) strcpy(conf->user,p+1); if(strcmp(buffer,"GROUP")==0) strcpy(conf->grp,p+1); if(strcmp(buffer,"DNSWL")==0) strcpy(conf->dnswl,p+1); if(strcmp(buffer,"SQLHOST")==0) strcpy(conf->sqlhost,p+1); if(strcmp(buffer,"SQLUSER")==0) strcpy(conf->sqluser,p+1); if(strcmp(buffer,"SQLDB")==0) strcpy(conf->sqldb,p+1); if(strcmp(buffer,"SQLPASSWD")==0) strcpy(conf->sqlpasswd,p+1); if(strcmp(buffer,"MESSAGE")==0) strcpy(conf->message,p+1); if(strcmp(buffer,"PORT")==0) conf->port=atoi(p+1); if(strcmp(buffer,"MAXCON")==0) conf->maxcon=atoi(p+1); if(strcmp(buffer,"TRAINING")==0) conf->training=atoi(p+1); if(strcmp(buffer,"MINTIME")==0) conf->mini=atol(p+1); if(strcmp(buffer,"MXGREY")==0) conf->mxgrey=atoi(p+1); if(strcmp(buffer,"SYSLOG")==0) conf->syslog=atoi(p+1); if(strcmp(buffer,"ERRACCEPT")==0) conf->accept=atoi(p+1); if(strcmp(buffer,"WHITELIST")==0) conf->whitelist=atoi(p+1); if(strcmp(buffer,"LIGHTGREY")==0) conf->light=atoi(p+1); if(strcmp(buffer,"LOOPBACKONLY")==0) conf->loopback=atoi(p+1); #ifdef HAVE_SYSLOG_H if(strcmp(buffer,"FACILITY")==0) for(i=0;ifacility=facys[i].fac; #endif } } fclose(fic); return(0); } void Log(config *conf,char *recipient,char *sender,char *ip,int white) { #ifdef HAVE_SYSLOG_H openlog("gld",0,conf->facility); if(white==MSGGREYLIST) syslog(LOG_NOTICE,"Greylist activated for recipient=<%s> sender=<%s> ip=<%s>",recipient,sender,ip); if(white==MSGLOCALWL) syslog(LOG_NOTICE,"Local whitelist hit for recipient=<%s> sender=<%s> ip=<%s>",recipient,sender,ip); if(white==MSGDNSWL) syslog(LOG_NOTICE,"DNS whitelist hit for recipient=<%s> sender=<%s> ip=<%s>",recipient,sender,ip); closelog(); #endif } void ErrorLog(config *conf,char *msg) { #ifdef HAVE_SYSLOG_H openlog("gld",0,conf->facility); syslog(LOG_ALERT,"%s",msg); closelog(); #endif } int ReadClients(config *conf,char *str) { char *ptr,*x,*y; ptr=str; conf->nbnet=0; while(*ptr!=0) { x=strstr(ptr," "); if(x!=NULL) *x=0; y=strstr(ptr,"/"); if(y!=NULL) { *y=0; conf->nets[conf->nbnet].netw=Hash(ptr); conf->nets[conf->nbnet].mask=CidrMsk(atoi(y+1)); conf->nbnet++; if(conf->nbnet==NLEN || x==NULL) break; } ptr=x+1; } return(0); } unsigned long Hash(char *ip) { struct in_addr x; int r; r=inet_aton(ip,&x); if(r==0) return(0); return(x.s_addr); } int CheckIP(config *conf,char *ip) { unsigned long h,netw,mask; int i; if(conf->nbnet==0) return(1); h=Hash(ip); for(i=0;inbnet;i++) { netw=conf->nets[i].netw; mask=conf->nets[i].mask; if((h&mask)==(netw&mask)) return(1); } return(0); } unsigned long CidrMsk(int msk) { int i; unsigned long x=0; for(i=0;i>1; x+=0x80000000; } x=htonl(x); return(x); } gld-1.7/configure0100755000000000000000000022636610134671135012555 0ustar rootroot#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --with-mysql=DIR Set root of MySQL distribution. Should contain include/mysql/mysql.h and lib/mysql/libmysqlclient.so [default=/usr]. Cannot be used at the same time as --with-pgsql. --with-mysql is the default." ac_help="$ac_help --with-pgsql=DIR Set root of PostgreSQL distribution. Should contain include/postgresql/libpq-fe.h and lib/libpq.so [default=/usr/local]. Cannot be used at the same time as --with-mysql." # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= 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=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -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 ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$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" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac 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) # 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 << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$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" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) 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) 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" ;; -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 ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi 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 "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=cnf.c # 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 its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. 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 if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi # Check whether --with-mysql or --without-mysql was given. if test "${with_mysql+set}" = set; then withval="$with_mysql" MYSQL_SET=1; MYSQL_PREFIX=$with_mysql else MYSQL_SET=0; MYSQL_PREFIX="/usr" fi # Check whether --with-pgsql or --without-pgsql was given. if test "${with_pgsql+set}" = set; then withval="$with_pgsql" PGSQL_SET=1; PGSQL_PREFIX=$with_pgsql else PGSQL_SET=0; PGSQL_PREFIX="/usr/local" fi if [ "${PGSQL_PREFIX}" = "yes" ]; then PGSQL_PREFIX=/usr/local fi if [ "${MYSQL_PREFIX}" = "yes" ]; then MYSQL_PREFIX=/usr fi if [ ${MYSQL_SET} -eq 1 -a ${PGSQL_SET} -eq 1 ]; then echo echo "Error: --with-pgsql and --with-mysql are mutually exclusive!" echo exit 1 fi if [ ${MYSQL_SET} -eq 1 ]; then SQL_LIBS="-L /usr/lib -L /lib -L${MYSQL_PREFIX}/lib/mysql -lmysqlclient" SQL_CFLAGS="-I${MYSQL_PREFIX}/include -D_DB_MYSQL_" fi if [ ${PGSQL_SET} -eq 1 ]; then SQL_LIBS="-L${PGSQL_PREFIX}/lib -lpq" SQL_CFLAGS="-g -Wall -I${PGSQL_PREFIX}/include -I${PGSQL_PREFIX}/include/postgresql -D_DB_PGSQL_" fi if [ ${MYSQL_SET} -eq 0 -a ${PGSQL_SET} -eq 0 ]; then SQL_LIBS="-L /usr/lib -L /lib -L${MYSQL_PREFIX}/lib/mysql -lmysqlclient" SQL_CFLAGS="-I${MYSQL_PREFIX}/include -D_DB_MYSQL_" fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:596: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:626: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_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 $# -gt 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 set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:677: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:709: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 720 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:725: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:751: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:756: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:784: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&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 $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:817: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:855: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:872: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 for ac_hdr in sys/time.h syslog.h netdb.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:900: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for working const""... $ac_c" 1>&6 echo "configure:938: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } ; return 0; } EOF if { (eval echo configure:992: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_c_const=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_c_const" 1>&6 if test $ac_cv_c_const = no; then cat >> confdefs.h <<\EOF #define const EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 echo "configure:1013: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include int main() { struct tm *tp; ; return 0; } EOF if { (eval echo configure:1027: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_time=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_header_time" 1>&6 if test $ac_cv_header_time = yes; then cat >> confdefs.h <<\EOF #define TIME_WITH_SYS_TIME 1 EOF fi for ac_func in select do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1051: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1079: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: select not found." 1>&2; exit 1; } fi done echo $ac_n "checking for socket""... $ac_c" 1>&6 echo "configure:1105: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { /* 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_socket) || defined (__stub___socket) choke me #else socket(); #endif ; return 0; } EOF if { (eval echo configure:1133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_socket=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 echo "configure:1152: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lsocket" else echo "$ac_t""no" 1>&6 fi fi echo $ac_n "checking for inet_addr""... $ac_c" 1>&6 echo "configure:1197: checking for inet_addr" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_addr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char inet_addr(); int main() { /* 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_inet_addr) || defined (__stub___inet_addr) choke me #else inet_addr(); #endif ; return 0; } EOF if { (eval echo configure:1225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_inet_addr=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_inet_addr=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'inet_addr`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6 echo "configure:1244: checking for inet_addr in -lnsl" >&5 ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lnsl" else echo "$ac_t""no" 1>&6 fi fi for ac_func in strstr do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1291: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: strstr not found." 1>&2; exit 1; } fi done #AC_CHECK_FUNCS(daemon,,AC_MSG_ERROR(daemon not found.)) for ac_func in fork do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1348: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1376: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: fork not found." 1>&2; exit 1; } fi done for ac_func in accept do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1404: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: accept not found." 1>&2; exit 1; } fi done for ac_func in wait do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1460: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: wait not found." 1>&2; exit 1; } fi done for ac_func in shutdown do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1516: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: shutdown not found." 1>&2; exit 1; } fi done for ac_func in gethostbyname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1572: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: gethostbyname not found." 1>&2; exit 1; } fi done for ac_func in bzero do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1628: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1656: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: bzero not found." 1>&2; exit 1; } fi done for ac_func in bcopy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1684: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: bcopy not found." 1>&2; exit 1; } fi done for ac_func in connect do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1740: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: connect not found." 1>&2; exit 1; } fi done for ac_func in bind do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1796: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: bind not found." 1>&2; exit 1; } fi done for ac_func in sendto do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1852: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: sendto not found." 1>&2; exit 1; } fi done for ac_func in gethostbyaddr do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1908: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: gethostbyaddr not found." 1>&2; exit 1; } fi done for ac_func in getpeername do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1964: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: getpeername not found." 1>&2; exit 1; } fi done for ac_func in setsockopt do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2020: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2048: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: setsockopt not found." 1>&2; exit 1; } fi done for ac_func in waitpid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2076: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: waitpid not found." 1>&2; exit 1; } fi done for ac_func in sscanf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2132: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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 #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 { echo "configure: error: sscanf not found." 1>&2; exit 1; } fi done echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 echo "configure:2186: checking for inet_aton" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char inet_aton(); int main() { /* 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_inet_aton) || defined (__stub___inet_aton) choke me #else inet_aton(); #endif ; return 0; } EOF if { (eval echo configure:2214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_inet_aton=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_inet_aton=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'inet_aton`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 echo $ac_n "checking for inet_aton in -lresolv""... $ac_c" 1>&6 echo "configure:2233: checking for inet_aton in -lresolv" >&5 ac_lib_var=`echo resolv'_'inet_aton | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lresolv $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lresolv" else echo "$ac_t""no" 1>&6 fi fi trap '' 1 2 15 cat > confcache <<\EOF # 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. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # 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. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. cat > conftest.defs <<\EOF s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g s%\[%\\&%g s%\]%\\&%g s%\$%$$%g EOF DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` rm -f conftest.defs # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@MYSQL_PREFIX@%$MYSQL_PREFIX%g s%@PGSQL_PREFIX@%$PGSQL_PREFIX%g s%@MYSQL_SET@%$MYSQL_SET%g s%@PGSQL_SET@%$PGSQL_SET%g s%@SQL_LIBS@%$SQL_LIBS%g s%@SQL_CFLAGS@%$SQL_CFLAGS%g s%@CC@%$CC%g s%@CPP@%$CPP%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 gld-1.7/configure.in0100644000000000000000000000632110134671131013136 0ustar rootrootdnl Process this file with autoconf to produce a configure script. AC_INIT(cnf.c) AC_ARG_WITH(mysql, [ --with-mysql=DIR Set root of MySQL distribution. Should contain include/mysql/mysql.h and lib/mysql/libmysqlclient.so [default=/usr]. Cannot be used at the same time as --with-pgsql. --with-mysql is the default.], [MYSQL_SET=1; MYSQL_PREFIX=$with_mysql], [MYSQL_SET=0; MYSQL_PREFIX="/usr"]) AC_ARG_WITH(pgsql, [ --with-pgsql=DIR Set root of PostgreSQL distribution. Should contain include/postgresql/libpq-fe.h and lib/libpq.so [default=/usr/local]. Cannot be used at the same time as --with-mysql.], [PGSQL_SET=1; PGSQL_PREFIX=$with_pgsql], [PGSQL_SET=0; PGSQL_PREFIX="/usr/local"]) AC_SUBST(MYSQL_PREFIX) AC_SUBST(PGSQL_PREFIX) AC_SUBST(MYSQL_SET) AC_SUBST(PGSQL_SET) if [[ "${PGSQL_PREFIX}" = "yes" ]]; then PGSQL_PREFIX=/usr/local fi if [[ "${MYSQL_PREFIX}" = "yes" ]]; then MYSQL_PREFIX=/usr fi if [[ ${MYSQL_SET} -eq 1 -a ${PGSQL_SET} -eq 1 ]]; then echo echo "Error: --with-pgsql and --with-mysql are mutually exclusive!" echo exit 1 fi if [[ ${MYSQL_SET} -eq 1 ]]; then SQL_LIBS="-L /usr/lib -L /lib -L${MYSQL_PREFIX}/lib/mysql -lmysqlclient" SQL_CFLAGS="-I${MYSQL_PREFIX}/include -D_DB_MYSQL_" fi if [[ ${PGSQL_SET} -eq 1 ]]; then SQL_LIBS="-L${PGSQL_PREFIX}/lib -lpq" SQL_CFLAGS="-g -Wall -I${PGSQL_PREFIX}/include -I${PGSQL_PREFIX}/include/postgresql -D_DB_PGSQL_" fi if [[ ${MYSQL_SET} -eq 0 -a ${PGSQL_SET} -eq 0 ]]; then SQL_LIBS="-L /usr/lib -L /lib -L${MYSQL_PREFIX}/lib/mysql -lmysqlclient" SQL_CFLAGS="-I${MYSQL_PREFIX}/include -D_DB_MYSQL_" fi AC_SUBST(SQL_LIBS) AC_SUBST(SQL_CFLAGS) dnl Checks for programs. AC_PROG_CC dnl Checks for header files. AC_CHECK_HEADERS(sys/time.h syslog.h netdb.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_HEADER_TIME dnl Checks for library functions. AC_CHECK_FUNCS(select,,AC_MSG_ERROR(select not found.)) AC_CHECK_FUNC(socket, [], [ AC_CHECK_LIB(socket, socket, [ LIBS="$LIBS -lsocket" ]) ]) AC_CHECK_FUNC(inet_addr, [], [ AC_CHECK_LIB(nsl, inet_addr, [ LIBS="$LIBS -lnsl" ]) ]) AC_CHECK_FUNCS(strstr,,AC_MSG_ERROR(strstr not found.)) #AC_CHECK_FUNCS(daemon,,AC_MSG_ERROR(daemon not found.)) AC_CHECK_FUNCS(fork,,AC_MSG_ERROR(fork not found.)) AC_CHECK_FUNCS(accept,,AC_MSG_ERROR(accept not found.)) AC_CHECK_FUNCS(wait,,AC_MSG_ERROR(wait not found.)) AC_CHECK_FUNCS(shutdown,,AC_MSG_ERROR(shutdown not found.)) AC_CHECK_FUNCS(gethostbyname,,AC_MSG_ERROR(gethostbyname not found.)) AC_CHECK_FUNCS(bzero,,AC_MSG_ERROR(bzero not found.)) AC_CHECK_FUNCS(bcopy,,AC_MSG_ERROR(bcopy not found.)) AC_CHECK_FUNCS(connect,,AC_MSG_ERROR(connect not found.)) AC_CHECK_FUNCS(bind,,AC_MSG_ERROR(bind not found.)) AC_CHECK_FUNCS(sendto,,AC_MSG_ERROR(sendto not found.)) AC_CHECK_FUNCS(gethostbyaddr,,AC_MSG_ERROR(gethostbyaddr not found.)) AC_CHECK_FUNCS(getpeername,,AC_MSG_ERROR(getpeername not found.)) AC_CHECK_FUNCS(setsockopt,,AC_MSG_ERROR(setsockopt not found.)) AC_CHECK_FUNCS(waitpid,,AC_MSG_ERROR(waitpid not found.)) AC_CHECK_FUNCS(sscanf,,AC_MSG_ERROR(sscanf not found.)) AC_CHECK_FUNC(inet_aton, [], [ AC_CHECK_LIB(resolv, inet_aton, [ LIBS="$LIBS -lresolv" ]) ]) AC_SUBST(LIBS) AC_OUTPUT(Makefile) gld-1.7/gld.conf0100644000000000000000000001116610425466170012255 0ustar rootroot# # Config file for gld # # # TCP Port gld should listen to (default is 2525) # PORT=2525 # # Shall we bind only to loopback ? (0=No,1=Yes) (default is 1) # LOOPBACKONLY=1 # # The list of networks allowed to connect to us (default is everybody) # The format is network/cidrmask,.... # # comment the line to deactivate it. # CLIENTS=127.0.0.1/32 # # The user used to run gld (default value is no user change) # comment the line to deactivate it. # USER=nobody # # The group used to run gld (default value is no group change) # comment the line to deactivate it. # GROUP=nobody # # Maximum simultaneous connexions (default is 100) # MAXCON=100 # # How many seconds we should wait before accepting # a mail that is in the greylist. (default is 60) # MINTIME=60 # # Shall we use lightgrey option ? (0=No,1=Yes) (default is 0) # # The lightgrey option, mask the last octet of IP addresses # and thus we greylist only C classes (/24) instead of individual IPs. # LIGHTGREY=0 # # Shall we use the mxgrey algorithm ? (0=No,>0=Yes) (default is 0) # # the mxgrey algorithm is a variation of the greylist algorithm. # When this is enabled, we allow all incoming mails from an IP address # whatever source/destination email as long as this IP has been greylisted # at least X time and succeded the mail resend . # # Example: # The IP 1.2.3.4 sends an email from src@domain.com to user@yourdomain.com # We greylist this mail as this IP is not yet in database and send a 450 SMTP code # After some time, the IP re-send the mail from src@domain.com to user@yourdomain.com # We update the db. # Some time after the ip 1.2.3.4 sends an email from john@domain.com to fred@yourdomain.com # We will accept this mail without any greylisting, as this ip already succeded a greylist test # and thus seems to be a valid smtp server and not a spammer . # # The advantage of this method, is that it reduce the re-send time due to greylisting to # x mail per server instead of one mail per destination . # # The value you provide in MXGREY is the minimum number of succesful greylists # before accepting all mails from this MX. higher the number is, harder is to get in. # # This algortihm replace the old LIGHTGREYDOMAIN which was available prior version 1.6 # MXGREY=0 # # Shall we use the whitelist table ? (0=No,1=Yes) (default is 1) # # If set to yes, then the table 'whitelist' is looked up # each time postfix request the server # if the email/domain/ip is in the whitelist, then the response # will be 'dunno' . # # In the whitelist table, you can set the following values: # an email: ie john@foo.tld # a domain: ie @bar.tld # an IP : ie 1.2.3.4 # a subnet: ie 1.2.3 # WHITELIST=1 # # Shall we use a DNS based whitelist ? (default is no) # # To activate it, the line must be uncommented # and the value set to the domain of the DNS whitelist. # for example, if DNSWL is set to toto.com and we get a mail from ip a.b.c.d # then gld will DNS lookup d.c.b.a.toto.com # and if found allow the ip without greylisting it. # #DNSWL=toto.com # # Shall we send a 'dunno' in case of error (mysql down,....) (0=No,1=Yes) (default is 1) # # Normaly, if an error occur, the server is supposed to close the connection # and thus postfix will return a 450 Server configuration error # if this parameter is set to 1, then the server will return 'dunno' # and thus let postfix decide the fate of the mail. # ERRACCEPT=1 # # Shall we log to the syslog (0=No,1=Yes) (default is 1) # SYSLOG=1 # # If we use syslog, which facility shall we use (default is mail) # it can only be one of the following facilities: # daemon mail local0 local1 local2 local3 local4 local5 local6 local7 # FACILITY=mail # # The Message that We display in case of reject (default is "Greylisted") # # If you want another SMTP return code than the default 450, just put it in # the beginning of the message, ie: 451 You have been greylisted by gld ... # If you don't provide any SMTP code, the default 450 will be used by postfix # # WARNING: if you set a custom smtp code make sure it's a 4XX code. # if you don't provide a 4XX code, gld will ignore it and send the default 450. # Be also warned that if you set a custom code, gld will no use defer_if_permit anymore # but direct supplied code to postfix . # MESSAGE=Greylisting in action, please try later # # Training mode activated ? (0=No,1=Yes) (default is 0) # # If activated, gld will do all the work but will always reply dunno to postfix # and thus, will never greylist any mail. # This feature is useful for testing gld performances without greylisting any mail # TRAINING=0 # # SQL INFOS (defaults are localhost,myuser,mypasswd,mydb) # SQLHOST=XXXXXXXXX SQLUSER=XXXXXXXX SQLPASSWD=XXXXXXX SQLDB=XXXXXXXX gld-1.7/gld.h0100644000000000000000000000511110425467504011552 0ustar rootroot#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_SYS_TIME_H #ifdef TIME_WITH_SYS_TIME #include #endif #endif #define TOUT 10 // Network timeout in seconds #define BLEN 2048 // Our buffer size #define QLEN 20480 // Our Query Size must be > than 6*BLEN #define NLEN 32 // Max # of networks in our table. #define REQ "smtpd_access_policy" // The string to be matched #define CONF "/etc/gld.conf" // The default config file #define MSGGREYLIST 0 #define MSGLOCALWL 1 #define MSGDNSWL 2 #define VERSION "1.7" typedef struct network { unsigned long netw; unsigned long mask; }network; typedef struct config { int port; // Port to listen to int maxcon; // max # of connections long mini; // Minimum time for greylist int syslog; // Shall we write to the syslog int accept; // Shall we return OK in case of error int whitelist; // Shall we lookup the whitelist table int light; // Shall we use light greylisting ? int facility; // Syslog facility to use int loopback; // Shall we bind only to loopback int mxgrey; // Shall we use the mexgrey algorithm ? int debug; // Shall we display debug informations int training; // Shall we activate training mode char dnswl[512]; // The domain to use if we do DNSWL char message[512]; // The text we display char sqlhost[128]; // SQL server char sqluser[128]; // SQL User char sqlpasswd[128]; // SQL password char sqldb[128]; // SQL Database name char user[128]; // The user we setuid to char grp[128]; // The group we setgid to network nets[NLEN]; // The networks allowed to connect int nbnet; // # of networks in nets }config; // // Prototypes // int ReadConfig(char *file,config *conf); int HandleChild(int s,config *cnf); void TheEnd(int s); int SQLConnect(char *host,char *user,char *passwd,char *db); void SQLClose(void); long SQLQuery(char *q); int GreyList(char *ip,char *sender,char *recipient,config *conf); void Log(config *conf,char * recipient,char *sender,char *ip,int white); void ErrorLog(config *conf,char *msg); void Reload(int s); void ShowBaseInfo(void); void Quote(char *str); int ReadClients(config *conf,char *str); unsigned long Hash(char *ip); int CheckIP(config *conf,char *ip); unsigned long CidrMsk(int msk); int MyDaemon(int nochdir, int noclose); gld-1.7/gld.init0100755000000000000000000000162210107750210012256 0ustar rootroot#!/bin/sh # # gld : Postfix greylist server # # chkconfig: 2345 78 31 # description: Postfix greylist server # # processname: gld # config: /etc/gld.conf # # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 0 PROG=/usr/local/bin/gld # See how we were called. case "$1" in start) # Start daemons. echo -n "Starting gld: " $PROG echo exit 0 ;; stop) # Stop daemons. echo -n "Stopping gld: " killall $PROG exit 0 ;; restart) # Stop/Start $0 stop sleep 1 $0 start ;; reload) # Reload the configuration killall -HUP $PROG exit 0 ;; *) echo "Usage: gld {start|stop|restart|reload}" exit 1 esac exit 0 gld-1.7/greylist.c0100644000000000000000000000736210312512751012641 0ustar rootroot#include "gld.h" #include "sockets.h" int GreyList(char *ip,char *sender,char *recipient,config *conf) { char query[QLEN]; long n,x; int ts; char *domain; char netw[32]; int i,l; char oip[32]; int a,b,c,d; int pid; char osender[BLEN]; char orecipient[BLEN]; pid=getpid(); ts=time(0); strncpy(oip,ip,sizeof(oip)-1); strncpy(osender,sender,sizeof(osender)-1); strncpy(orecipient,recipient,sizeof(orecipient)-1); if(conf->debug==1) printf("%d: Starting the greylist algo\n",pid); // // If we do lightgreylisting, then we just keep the network part of ip // if(conf->light==1) { if(conf->debug==1) printf("%d: lightgrey is on, let's remove the last octet of ip\n",pid); l=strlen(ip); for(i=l-1;i>=0;i--) { if(ip[i]=='.') { ip[i+1]='0'; ip[i+2]=0; break; } } } // // Do we have this entry in our database? // snprintf(query,sizeof(query)-1,"select first from greylist where ip='%s' and sender='%s' and recipient='%s'",ip,sender,recipient); n=SQLQuery(query); if(conf->debug==1) printf("%d: Query=(%s) result=%ld\n",pid,query,n); // // If request failed, return the error // if(n<0) { return(-1); } // // If the triplet is in our db // if(n>0) { // and mintime+, always update last timestamp (cleanup needs this) and accept it if(ts-n>conf->mini) { snprintf(query,sizeof(query)-1,"update greylist set last=%d,n=n+1 where ip='%s' and sender='%s' and recipient='%s'",ts,ip,sender,recipient); SQLQuery(query); if(conf->debug==1) printf("%d: Query=(%s)\n",pid,query); return(1); } // any other case (mintime-), refuse it else { if(conf->debug==1) printf("%d: MINTIME has not been reached yet\n",pid); return(0); } } // ######################################################### // From this point to the end, the triplet WAS NOT in the db // ######################################################### // // Now we do some whitelist checks before inserting it // // // First we check our local whitelist // if(conf->whitelist==1) { if(conf->debug==1) printf("%d: whitelist is on\n",pid); domain=(char *)strstr(osender,"@"); if(domain==NULL) domain=osender; strncpy(netw,oip,sizeof(netw)-1); l=strlen(netw); for(i=l-1;i>=0;i--) { if(netw[i]=='.') { netw[i]=0; break; } } snprintf(query,sizeof(query)-1,"select count(mail) from whitelist where mail in ('%s','%s','%s','%s')",osender,domain,oip,netw); n=SQLQuery(query); if(conf->debug==1) printf("%d: Query=(%s) result=%ld\n",pid,query,n); if(n>0) { if(conf->syslog==1) Log(conf,orecipient,osender,oip,MSGLOCALWL); return(1); } } // // then we check the DNS whitelist // if(conf->dnswl[0]!=0) { if(conf->debug==1) printf("%d: DNS whitelist is on\n",pid); x=sscanf(oip,"%d.%d.%d.%d",&a,&b,&c,&d); if(x==4) { snprintf(query,sizeof(query)-1,"%d.%d.%d.%d.%s",d,c,b,a,conf->dnswl); n=DnsIp(query,NULL); if(conf->debug==1) printf("%d: DNSQuery=(%s) result=%ld\n",pid,query,n); if(n==0) { if(conf->syslog==1) Log(conf,orecipient,osender,oip,MSGDNSWL); return(1); } } } // // If we are here, The mail was not in our database // was not whitelisted and thus we have to insert it // snprintf(query,sizeof(query)-1,"insert into greylist values('%s','%s','%s',%d,%d,1)",ip,sender,recipient,ts,ts); SQLQuery(query); if(conf->debug==1) printf("%d: Query=(%s)\n",pid,query); // // If we have activated the mxgrey // Let's accept the mail if this ip already succeded the required number of greylists // if(conf->mxgrey>0) { // check for unique triplets already graylisted from the IP snprintf(query,sizeof(query)-1,"select count(first) from greylist where ip='%s' and n>1",ip); n=SQLQuery(query); if(conf->debug==1) printf("%d: Mxgrey Query=(%s) result=%ld (minimum needed is %d)\n",pid,query,n,conf->mxgrey); // if found, accept it if(n>=conf->mxgrey) { return(1); } } return(0); } gld-1.7/server.c0100644000000000000000000002072110425471336012307 0ustar rootroot#include "gld.h" #include "sockets.h" TcpServer srv; config conf; int main(int argc,char **argv) { int s; int cid; int c; char clean=0; char query[QLEN]; int status; struct group *grp; struct passwd *user; if(argc==2 && strcmp(argv[1],"-v")==0) { printf("gld %s \n",VERSION); exit(0); } if(argc==3 && strcmp(argv[1],"-c")==0) clean=1; if(argc==3 && strcmp(argv[1],"-C")==0) clean=2; if(argc==3 && strcmp(argv[1],"-k")==0) clean=3; if(argc==3 && strcmp(argv[1],"-K")==0) clean=4; if(argc==2 && strcmp(argv[1],"-i")==0) clean=5; if(argc!=1 && clean==0 && strcmp(argv[1],"-d")!=0) { printf("Usage: gld [-c |-C |-k |-K |-h|-v]\n"); printf(" gld -c : clean the database for ALL entries not updated since days\n"); printf(" gld -C : show what the -c option would do, without doing it\n"); printf(" gld -k : clean the database for entries not updated since days with only one hit \n"); printf(" gld -K : show what the -k option would do, without doing it\n"); printf(" gld -i : show some database informations\n"); printf(" gld -d : enable debug mode\n"); printf(" gld -v : display version\n"); printf(" gld -h : display Usage\n"); exit(1); } if(ReadConfig(CONF,&conf)!=0) { printf("Invalid config file %s\n",CONF); exit(2); } if(argc==2 && strcmp(argv[1],"-d")==0) conf.debug=1; signal(SIGTERM,TheEnd); signal(SIGHUP,Reload); signal(SIGCHLD,NoZombies); // // Here we drop privileges and setuid/setgid if needed // if(conf.grp[0]!=0) { grp=getgrnam(conf.grp); if(grp==(struct group *)NULL) { printf("Group %s not found, please check the GROUP variable in gld.conf\n",conf.grp); exit(10); } if(setgid(grp->gr_gid)!=0) { printf("Unable to setgid to %s\n",conf.grp); exit(11); } if(conf.debug==1) printf("setgid to %s OK\n",conf.grp); } if(conf.user[0]!=0) { user=getpwnam(conf.user); if(user==(struct passwd *)NULL) { printf("User %s not found, please check the USER variable in gld.conf\n",conf.user); exit(10); } if(setuid(user->pw_uid)!=0) { printf("Unable to setuid to %s\n",conf.user); exit(12); } if(conf.debug==1) printf("setuid to %s OK\n",conf.user); } // // Now we do what we have to do // if(clean!=0) { if(SQLConnect(conf.sqlhost,conf.sqluser,conf.sqlpasswd,conf.sqldb)<0) { printf("Unable to connect to MYSQL\n"); exit(1); } if(clean==5) { ShowBaseInfo(); SQLClose(); exit(0); } if(clean==1 || clean==2) snprintf(query,sizeof(query)-1,"select count(last) from greylist where last < UNIX_TIMESTAMP()-86400*%d",atoi(argv[2])); if(clean==3 || clean==4) snprintf(query,sizeof(query)-1,"select count(last) from greylist where last < UNIX_TIMESTAMP()-86400*%d AND n=1",atoi(argv[2])); c=SQLQuery(query); if(clean==2 || clean==4) { printf("I would clean %d entries older than %d days\n",c,atoi(argv[2])); SQLClose(); exit(0); } if(clean==1) snprintf(query,sizeof(query)-1,"delete from greylist where last < UNIX_TIMESTAMP()-86400*%d",atoi(argv[2])); if(clean==3) snprintf(query,sizeof(query)-1,"delete from greylist where last < UNIX_TIMESTAMP()-86400*%d and n=1",atoi(argv[2])); SQLQuery(query); SQLClose(); printf("Cleaned %d entries older than %d days\n",c,atoi(argv[2])); exit(0); } // // Ok, here we start the server // srv=OpenTcpServer(conf.port,conf.maxcon,conf.loopback); if(srv.sd==-1) { printf("Unable to bind to port %d\n",conf.port); perror("Error was: "); exit(1); } if(conf.debug==1) printf("bind to port %d succesful\n",conf.port); if(conf.syslog==1) ErrorLog(&conf,"gld started, up and running"); if(conf.debug==0) MyDaemon(0,0); if(conf.debug==1) printf("Waiting for incoming connexions\n"); // // The main loop // while(1==1) { s=WaitTcpServer(srv); if(s>=0) { cid=fork(); if(cid < 0 && conf.syslog==1) ErrorLog(&conf,"Fork returned error code, no child"); if(cid==0) { c=HandleChild(s,&conf); if(c!=0 && conf.accept==1) WriteSocket(s,"action=dunno\n\n",14,TOUT); close(s); waitpid(-1, &status, WNOHANG); exit(0); } close(s); } } CloseTcpServer(srv); exit(0); } int HandleChild(int s,config *cnf) { char buff[BLEN]; char request[BLEN]; char sender[BLEN]; char recipient[BLEN]; char ip[BLEN]; int n; long ts; int pid; pid=getpid(); if(SQLConnect(cnf->sqlhost,cnf->sqluser,cnf->sqlpasswd,cnf->sqldb)<0) { if(cnf->debug==1) printf("%d: Unable to connect to MYSQL\n",pid); if(cnf->syslog==1) { snprintf(buff,sizeof(buff)-1,"Unable to connect to MYSQL\n"); ErrorLog(cnf,buff); } return(-1); } GetPeerIp(s,ip,buff); // // We check if this IP is authorized to connect to us // if(CheckIP(cnf,ip)!=1) { if(cnf->debug==1) printf("%d: Rejected New incoming connexion from %s (%s)\n",pid,buff,ip); if(cnf->syslog==1) { snprintf(buff,sizeof(buff)-1,"Rejected New incoming connexion from %s (%s)\n",buff,ip); ErrorLog(cnf,buff); } SQLClose(); return(0); } // // Ok, The IP is accepted // if(cnf->debug==1) printf("%d: New incoming connexion from %s (%s)\n",pid,buff,ip); ts=time(0); request[0]=sender[0]=recipient[0]=ip[0]=0; CloseTcpServer(srv); while(1==1) { // // This functions does not read more than BLEN-1 bytes // from the network and thus no buffer overflow is possible // if(ReadLSocket(s,buff,BLEN-1,TOUT)<0) { if(cnf->syslog==1) ErrorLog(cnf,"Read Network error"); if(cnf->debug==1) printf("%d: Read Network error\n",pid); SQLClose(); return(-1); } // // To be sure that our buffer is null terminated to avoid // a buffer overflow, we manually set a null to the end of the buffer. // buff[BLEN-1]=0; // // Now, we are sure our buffer string length is no more than BLEN // as all parameters are defined also as buffers with a BLEN size // no buffer overflow is possible using strcpy . // if(strcmp(buff,"")==0) break; if(strncmp(buff,"request=",8)==0) strcpy(request,buff+8); if(strncmp(buff,"sender=",7)==0) strcpy(sender,buff+7); if(strncmp(buff,"recipient=",10)==0) strcpy(recipient,buff+10); if(strncmp(buff,"client_address=",15)==0) strcpy(ip,buff+15); } // // To be sure that our parameters are null terminated to avoid // a buffer overflow, we manually set a null to the end of the parameters. // ip[BLEN-1]=0; recipient[BLEN-1]=0; sender[BLEN-1]=0; // // Then we remove nasty chars to avoid a possible SQL injection // Quote(ip); Quote(recipient); Quote(sender); // // Now, we can safely use, str** functions // if(sender[0]==0) strcpy(sender,"void@void"); if(strcmp(request,REQ)!=0 || recipient[0]==0 || ip[0]==0) { snprintf(buff,sizeof(buff)-1,"Received invalid data req=(%s) sender=(%s) recipient=(%s) ip=(%s)",request,sender,recipient,ip); if(cnf->syslog==1) ErrorLog(cnf,buff); if(cnf->debug==1) printf("%d: %s\n",pid,buff); SQLClose(); return(-2); } if(cnf->debug==1) printf("%d: Got the following valid data req=(%s) sender=(%s) recipient=(%s) ip=(%s)\n",pid,request,sender,recipient,ip); n=GreyList(ip,sender,recipient,cnf); if(cnf->debug==1) printf("%d: End of the greylist algo\n",pid); if(n<0) { if(cnf->syslog==1) ErrorLog(cnf,"MySQL error"); if(cnf->debug==1) printf("%d: MySQL error\n",pid); SQLClose(); return(-3); } if(n==0) { if(cnf->syslog==1) Log(cnf,recipient,sender,ip,MSGGREYLIST); if(cnf->debug==1) printf("%d: Decision is to greylist\n",pid); if(cnf->training==0) { if(atoi(cnf->message)<400 || atoi(cnf->message)>499) snprintf(buff,sizeof(buff)-1,"action=defer_if_permit %s\n\n",cnf->message); else snprintf(buff,sizeof(buff)-1,"action=%s\n\n",cnf->message); } else { if(cnf->debug==1) printf("%d: Training mode, sending dunno\n",pid); strcpy(buff,"action=dunno\n\n"); } WriteSocket(s,buff,strlen(buff),TOUT); } else { WriteSocket(s,"action=dunno\n\n",14,TOUT); if(cnf->debug==1) printf("%d: Decision is to not greylist\n",pid); } SQLClose(); return(0); } void TheEnd(int s) { int status; while(wait(&status) > 0); shutdown(srv.sd,2); CloseTcpServer(srv); exit(0); } void Reload(int s) { ReadConfig(CONF,&conf); } int MyDaemon(int nochdir, int noclose) { int fd; switch (fork()) { case -1: return(-1); case 0: break; default: _exit(0); } if(setsid() == -1) return(-1); if(!nochdir) (void)chdir("/"); if(!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { (void)dup2(fd, STDIN_FILENO); (void)dup2(fd, STDOUT_FILENO); (void)dup2(fd, STDERR_FILENO); if(fd>2) (void)close(fd); } return(0); } gld-1.7/sockets.c0100644000000000000000000005670510132750206012456 0ustar rootroot/************************************************/ /* */ /* TCP/UDP sockets */ /* */ /************************************************/ /* */ /* Version : 2.4 (02/01/01) */ /* */ /************************************************/ /* */ /* Author: Salim Gasmi (salim@gasmi.net) */ /* */ /************************************************/ /* */ /* Suppported OS : */ /* */ /* Standard Unix : -D UNIX (Linux,HPUX,OSF...) */ /* AIX Unix : -D AIX */ /* SunOs/Solaris : -D SUN (link -lnsl -lsockets)*/ /* BeOs : -D BEOS */ /* AmigaOs : -D AMIGAOS */ /* */ /************************************************/ #include #include #include #include #include #include #include "sockets.h" #ifdef AMIGAOS /************************************************/ /* */ /* Open & CloseSocketLib (Amiga Only) */ /* */ /************************************************/ /* */ /* 0 : Okay */ /* S_LIB_ERR : Impossible d'ouvrir la lib */ /* */ /************************************************/ struct Library * SocketBase; int OpenSocketLib() { if ((SocketBase=(struct Library *)OpenLibrary(SOCKLIB,SOCKVER))==NULL) return(S_SLIB_ERR); else return(0); } void CloseSocketLib() { CloseLibrary(SocketBase); } #endif /************************************************/ /* */ /* OpenTcpSocket : Se connecte sur un port TCP */ /* */ /************************************************/ /* */ /* host : Host name du Server */ /* port : Port TCP a se connecter */ /* */ /************************************************/ /* */ /* >=0 : Socket de connexion */ /* S_HOST_ERR : le serveur n'existe pas */ /* S_PORT_ERR : le port ne reponds pas */ /* S_SOCK_ERR : Erreur creation socket */ /* */ /************************************************/ int OpenTcpSocket(char *host, int port) { struct sockaddr_in sock_addr; struct hostent *host_struct; int s; #ifdef AMIGAOS if(SocketBase==NULL) OpenSocketLib(); #endif if ((host_struct=(struct hostent *)gethostbyname(host))==NULL) return(S_HOST_ERR); if ((s=socket(AF_INET, SOCK_STREAM, 0)) < 0) return(S_SOCK_ERR); bzero(&sock_addr, sizeof(sock_addr)); bcopy(host_struct->h_addr, (char *)&sock_addr.sin_addr, host_struct->h_length); sock_addr.sin_port = htons((u_short)port); sock_addr.sin_family = host_struct->h_addrtype; if (connect(s, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0) return(S_PORT_ERR); return(s); } /************************************************/ /* */ /* ReadSocket : lit n octets sur un socket TCP */ /* */ /************************************************/ /* */ /* s : le socket */ /* buffer : le buffer a remplir */ /* bufsize : le nb d'octets a lire */ /* tout : le timeout reseau en s */ /* */ /************************************************/ /* */ /* >=0 : le nb d'octets lus */ /* S_WAIT_ERR : Erreur de Wait */ /* S_RECV_ERR : Erreur de recv */ /* S_TIME_ERR : Erreur de timeout */ /* S_SOCK_ERR : Socket passe en arg invalide */ /* */ /************************************************/ int ReadSocket(int s, char *buffer, int bufsize,int tout) { int nbytes=0, nfds=0; fd_set readfds; fd_set excepfds; struct timeval timeout; if(s<0) return(S_SOCK_ERR); timeout.tv_sec=tout; timeout.tv_usec=0; FD_ZERO( &readfds ); FD_SET(s, &readfds ); FD_ZERO( &excepfds ); if( (nfds = select(s + 1, &readfds, NULL, NULL, &timeout )) < 0) return(S_WAIT_ERR); if (nfds > 0) { if ((nbytes=recv(s,buffer,bufsize,0)) < 0) return(S_RECV_ERR); else return(nbytes); } else return(S_TIME_ERR); } /************************************************/ /* */ /* WriteSocket:ecrit n octets sur un socket TCP */ /* */ /************************************************/ /* */ /* s : le socket */ /* buffer : le buffer a utiliser */ /* bufsize : le nb d'octets a ecrire */ /* tout : le timeout reseau en s */ /* */ /************************************************/ /* */ /* 0 : OK */ /* S_WAIT_ERR : Erreur de Wait */ /* S_SEND_ERR : Erreur de send */ /* S_TIME_ERR : Erreur de timeout */ /* S_SOCK_ERR : Socket passe en arg invalide */ /* */ /************************************************/ int WriteSocket(int s, char *buffer, int bufsize, int tout) { int nbytes=0, nfds=0; fd_set writefds; struct timeval timeout ; if(s<0) return(S_SOCK_ERR); timeout.tv_sec=tout; timeout.tv_usec=0; while (1) { FD_ZERO( &writefds ); FD_SET(s, &writefds ); if( (nfds = select(s + 1, NULL, &writefds, NULL, &timeout )) < 0) return(S_WAIT_ERR); if (nfds > 0) { if ((nbytes=send(s,buffer,bufsize,0)) < 0) return(S_SEND_ERR); buffer+=nbytes; bufsize-=nbytes; if (bufsize==0) return(0); } else return(S_WAIT_ERR); } } /************************************************/ /* */ /* ReadLSocket: lit une ligne sur un socket TCP */ /* */ /************************************************/ /* */ /* s : le socket */ /* buf : le buffer a remplir */ /* len : le nb d'octets Maxi a lire */ /* tout : le timeout reseau en s */ /* */ /************************************************/ /* */ /* 0 : Ligne lue OK */ /* S_WAIT_ERR : Erreur de Wait */ /* S_RECV_ERR : Erreur de recv */ /* S_TIME_ERR : Erreur de timeout */ /* S_SOCK_ERR : Socket passe en arg invalide */ /* */ /************************************************/ int ReadLSocket(int s, char *buf,int len,int tout) { int nfds=0; fd_set readfds; int ret=0; struct timeval timeout ; if(s<0) return(S_SOCK_ERR); timeout.tv_sec=tout; timeout.tv_usec=0; while (--len) { FD_ZERO( &readfds ); FD_SET(s, &readfds ); ret=0; if((nfds = select(s + 1, &readfds, NULL, NULL, &timeout )) < 0) { ret=S_WAIT_ERR; break; } if(nfds==0) { ret=S_TIME_ERR; break; } if (recv(s, buf, 1,0) != 1) { ret=S_RECV_ERR; break; } if (*buf == '\n') { ret=0; break; } if (*buf != '\r' && *buf!=0) buf++; } *buf = 0; return(ret); } /************************************************/ /* */ /* WriteLSocket: ecrit une ligne sur socket TCP */ /* */ /************************************************/ /* */ /* s : le socket */ /* lin : la ligne a ecrire */ /* tout : le timeout reseau en s */ /* */ /************************************************/ /* */ /* >=0 : le nb d'octets ecrits */ /* S_WAIT_ERR : Erreur de Wait */ /* S_SEND_ERR : Erreur de recv */ /* S_TIME_ERR : Erreur de timeout */ /* S_SOCK_ERR : Socket passe en arg invalide */ /* */ /************************************************/ int WriteLSocket(int s, char *line,int tout) { int nbytes=0, ntot=0, ntottemp=0, nfds=0; fd_set writefds; struct timeval timeout ; if(s<0) return(S_SOCK_ERR); timeout.tv_sec=tout; timeout.tv_usec=0; if ((ntot=strlen(line))==0) return(-4); ntottemp=ntot; while (1) { FD_ZERO( &writefds ); FD_SET(s, &writefds ); if( (nfds = select(s + 1, NULL, &writefds, NULL, &timeout )) < 0) return(S_WAIT_ERR); if (nfds > 0) { if ((nbytes=send(s,line,strlen(line),0)) < 0) return(S_SEND_ERR); line+=nbytes; ntot-=nbytes; if (ntot==0) { if(send(s,"\r\n",2,0) !=2) return(S_SEND_ERR); return(ntottemp); } } else return(S_TIME_ERR); } } /************************************************/ /* */ /* OpenUdpSocket : Se connecte sur un port UDP */ /* */ /************************************************/ /* */ /* host : Host name du Server */ /* port : Port UDP a se connecter */ /* addr : struct Udp a conserver pour ecrire */ /* */ /************************************************/ /* */ /* >=0 : Socket de connexion */ /* S_HOST_ERR : le serveur n'existe pas */ /* S_PORT_ERR : le port ne reponds pas */ /* S_SOCK_ERR : Erreur creation socket */ /* S_BIND_ERR : Erreur bind local */ /* */ /************************************************/ int OpenUdpSocket(char *host, int port,Udp *addr) { struct sockaddr_in local_addr; struct hostent *host_struct; int s; #ifdef AMIGAOS if(SocketBase==NULL) OpenSocketLib(); #endif if ((host_struct=(struct hostent *)gethostbyname(host))==NULL) return(S_HOST_ERR); if ((s=socket(AF_INET, SOCK_DGRAM, 0)) < 0) return(S_SOCK_ERR); bzero(addr, sizeof(Udp)); bcopy(host_struct->h_addr, (char *)&addr->sin_addr, host_struct->h_length); addr->sin_port = htons((ushort)port); addr->sin_family = host_struct->h_addrtype; /* Now we bind a local port since it is a connectionless protocol */ /* bind is done on localhost + dynamic free port for response port */ /* Some systems does this by default and binding is not needed */ /* Anyway I *ALWAYS* do it, in case of an old system .... */ bzero(&local_addr,sizeof(local_addr)); local_addr.sin_family = AF_INET; local_addr.sin_addr.s_addr= htonl(INADDR_ANY); local_addr.sin_port = htons(0); if(bind(s,(struct sockaddr *)&local_addr,sizeof(local_addr))<0) { close(s); return(S_BIND_ERR); } return(s); } /************************************************/ /* */ /* SendUdpData:ecrit n octets sur un socket UDP */ /* */ /************************************************/ /* */ /* s : le socket */ /* addr : structure Udp destination */ /* buffer : le buffer a remplir */ /* size : le nb d'octets a ecrire */ /* */ /************************************************/ /* */ /* 0 : OK */ /* S_SEND_ERR : Erreur de sendto */ /* S_SOCK_ERR : Socket passe en arg invalide */ /* */ /************************************************/ int SendUdpData(int s,Udp *addr,char *buffer,int size) { if(s<0) return(S_SOCK_ERR); #ifdef SUN if(sendto(s,buffer,size,0,(struct sockaddr *)addr,sizeof(struct sockaddr_in))!=size) #else if(sendto(s,buffer,size,0,(const struct sockaddr *)addr,sizeof(struct sockaddr_in))!=size) #endif return(S_SEND_ERR); return(0); } /************************************************/ /* */ /* ReadUdpData: lit n octets sur un socket UDP */ /* */ /************************************************/ /* */ /* s : le socket */ /* buffer : le buffer a remplir */ /* maxsize : le nb d'octets max a lire */ /* tout : timeout en secondes */ /* */ /************************************************/ /* */ /* >=0 : le nb d'octets lus */ /* S_RECV_ERR : Erreur de recv */ /* S_SOCK_ERR : Socket passe en arg invalide */ /* S_WAIT_ERR : Erreur de wait */ /* S_TIME_ERR : Erreur de timeout */ /* */ /************************************************/ int ReadUdpData(int s,char *buffer,int maxsize,int tout) { int nbytes=0, nfds=0; fd_set readfds; fd_set excepfds; struct timeval timeout; if(s<0) return(S_SOCK_ERR); timeout.tv_sec=tout; timeout.tv_usec=0; FD_ZERO( &readfds ); FD_SET(s, &readfds ); FD_ZERO( &excepfds ); if( (nfds = select(s + 1, &readfds, NULL, NULL, &timeout )) < 0) return(S_WAIT_ERR); if (nfds > 0) { nbytes=recvfrom(s,buffer,maxsize,0,(struct sockaddr *)0,(int *)0); if(nbytes<0) return(S_RECV_ERR); else return(nbytes); } else return(S_TIME_ERR); } /************************************************/ /* */ /* CloseSocket : ferme un socket */ /* */ /************************************************/ /* */ /* s : le socket */ /* */ /************************************************/ /* */ /* 0 : OK */ /* S_CLOS_ERR : Erreur de close */ /* S_SHUT_ERR : Erreur de shutdown */ /* */ /************************************************/ int CloseSocket(int s) { if ( (s && close(s)) < 0 ) return(S_CLOS_ERR); /* if ((s && shutdown(s,2)) < 0) return(S_SHUT_ERR); */ return(0); } /************************************************/ /* */ /* DnsIp : recupere la 1ere IP d'un hostname */ /* */ /************************************************/ /* */ /* host : le nom du host */ /* ip : le buffer a remplir avec l'IP */ /* */ /************************************************/ /* */ /* 0 : OK */ /* S_HOST_ERR : Le host n'existe pas */ /* S_INET_ERR : Host non de la famille INET */ /* */ /************************************************/ int DnsIp(char *host,char *ip) { struct hostent *hostptr; struct in_addr *ptr; if((hostptr=(struct hostent *)gethostbyname(host))==NULL) return(S_HOST_ERR); if(hostptr->h_addrtype != AF_INET) return(S_INET_ERR); ptr=(struct in_addr *) *hostptr->h_addr_list; if(ip!=NULL) strcpy(ip,(char *)inet_ntoa(*ptr)); return(0); } /************************************************/ /* */ /* DnsFQDN : recupere le FQDN d'un hostname */ /* */ /************************************************/ /* */ /* host : le nom du host */ /* fqdn : le buffer a remplir avec FQDN */ /* */ /************************************************/ /* */ /* 0 : OK */ /* S_HOST_ERR : Le host n'existe pas */ /* */ /************************************************/ int DnsFQDN(char *host,char *fqdn) { struct hostent *hostptr; if((hostptr=(struct hostent *)gethostbyname(host))==NULL) return(S_HOST_ERR); strcpy(fqdn,hostptr->h_name); return(0); } /************************************************/ /* */ /* DnsName : recupere le FQDN d'une IP dotted */ /* */ /************************************************/ /* */ /* host : dotted ip */ /* fqdn : le buffer a remplir avec FQDN */ /* */ /************************************************/ /* */ /* 0 : OK */ /* S_HOST_ERR : L'IP n'existe pas */ /* */ /************************************************/ int DnsName(char *ip,char *fqdn) { struct hostent *hostptr; struct in_addr addr; addr.s_addr=inet_addr(ip); if((hostptr=(struct hostent *)gethostbyaddr((char *)&addr,sizeof(struct in_addr),AF_INET))==NULL) return(S_HOST_ERR); strcpy(fqdn,hostptr->h_name); return(0); } /************************************************/ /* */ /* GetPeerIp : recupere le FQDN+Dotted IP */ /* du peer connecte au socket sock */ /* */ /************************************************/ /* */ /* sock : socket */ /* ipfrom : le buffer a remplir avec l'IP */ /* hostfrom : le buffer a remplir avec FQDN */ /* */ /************************************************/ /* */ /* AUCUNE */ /* */ /************************************************/ void GetPeerIp(int sock,char *ipfrom,char *hostfrom) { struct sockaddr_in from; size_t foo=sizeof(struct sockaddr_in); struct hostent *hostptr; strcpy(ipfrom,"???.???.???.???"); strcpy(hostfrom,"?????"); if (getpeername(sock,(struct sockaddr *)&from, &foo) == 0) { strcpy(ipfrom,(char *)inet_ntoa(from.sin_addr)); hostptr=(struct hostent *)gethostbyaddr((char *)&from.sin_addr,sizeof(struct in_addr),AF_INET); if(hostptr!=NULL) strcpy(hostfrom,hostptr->h_name); } } /************************************************/ /* */ /* TcpServer: Cree un serveur Tcp */ /* */ /************************************************/ /* */ /* port : port TCP a ecouter */ /* mxcon : nb maxi de connections */ /* loopback : 0 ou 1 (1=loopback bind) */ /* */ /************************************************/ /* */ /* serv.sd >=0 : descripteur du serveur */ /* serv.sd= -1 : Impossible de creer le serveur */ /* */ /************************************************/ TcpServer OpenTcpServer(int port,int mxcon,int loopback) { TcpServer serv; int one=1; serv.sd=-1; bzero(&(serv.sin), sizeof(serv.sin)); serv.sin.sin_family = AF_INET; serv.sin.sin_port = htons((u_short)port); if(loopback==1) serv.sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); else serv.sin.sin_addr.s_addr = htonl(INADDR_ANY); if ((serv.sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return(serv); setsockopt(serv.sd,SOL_SOCKET,SO_REUSEADDR,(void *)&one,sizeof(int)); /* we bind it to the host */ if (bind(serv.sd, (struct sockaddr *)&(serv.sin),sizeof(serv.sin)) < 0) { close(serv.sd); serv.sd=-1; return(serv); } /* our socket can handle mxcon connections at a time */ if(listen(serv.sd,mxcon)<0) { close(serv.sd); serv.sd=-1; return(serv); } return(serv); } /************************************************/ /* */ /* WaitTcpServer : attend connexion sur serveur */ /* */ /************************************************/ /* */ /* serv : Descripteur de serveur */ /* */ /************************************************/ /* */ /* >=0 : descripteur du nouveau socket */ /* -1 : Erreur */ /* */ /************************************************/ int WaitTcpServer(TcpServer serv) { size_t foo=sizeof(serv.sin); return(accept(serv.sd,(struct sockaddr *)&(serv.sin),&foo)); } /************************************************/ /* */ /* CloseTcpServer : arrete le serveur */ /* */ /************************************************/ /* */ /* serv : Descripteur de serveur */ /* */ /************************************************/ /* */ /* RIEN */ /* */ /************************************************/ void CloseTcpServer(TcpServer serv) { close(serv.sd); } /************************************************/ /* */ /* NoZombies: Empeche la creation de zombies */ /* Quand on forke en System V */ /* */ /************************************************/ /* */ /* RIEN */ /* */ /************************************************/ /* */ /* RIEN */ /* */ /************************************************/ void NoZombies(int sig) { while(waitpid(-1, NULL, WNOHANG) > 0); } gld-1.7/sockets.h0100644000000000000000000000667710132744377012502 0ustar rootroot/************************************************/ /* */ /* Headers TCP/IP */ /* */ /************************************************/ /* */ /* Version : 2.3 (23/06/00) */ /* */ /************************************************/ /* */ /* Author: Salim Gasmi (salim@gasmi.net) */ /* */ /************************************************/ #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_SYS_TIME_H #ifdef TIME_WITH_SYS_TIME #include #endif #endif #define Udp struct sockaddr_in #define USHORT ushort #define S_OK 0 /* Ok ! */ #define S_HOST_ERR -100 /* Host unknown */ #define S_SOCK_ERR -101 /* socket error */ #define S_PORT_ERR -102 /* connect error */ #define S_SLIB_ERR -103 /* bsd lib error */ #define S_WAIT_ERR -104 /* Select error */ #define S_RECV_ERR -105 /* Recv() error */ #define S_TIME_ERR -106 /* Timemout error */ #define S_SEND_ERR -107 /* Send() error */ #define S_CLOS_ERR -108 /* close error */ #define S_SHUT_ERR -109 /* shutdown error */ #define S_BIND_ERR -110 /* local bind error */ #define S_INET_ERR -111 /* not an INET host */ #define S_IMPL_ERR -999 /* not yet implemanted */ #ifdef AMIGAOS #define gethostbyname GetHostByName #define gethostbyaddr GetHostByAddr #define connect Connect #define socket Socket #define shutdown Shutdown #define send Send #define recv Recv #define recvfrom RecvFrom #define sendto SendTo #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0) #define bind Bind #define listen Listen #define accept Accept #define inet_ntoa Inet_NtoA #define inet_addr Inet_Addr #define htons HtoNs #define getpeername GetPeerName #define uname Uname #define SOCKLIB "bsdsocket.library" #define SOCKVER 4 int OpenSocketLib(void); void CloseSocketLib(void); #endif /**************************** mes structures ***********************/ typedef struct TcpServer { int sd; struct sockaddr_in sin; } TcpServer; /******************************* prototypes **********************/ /* TCP functions */ int OpenTcpSocket(char *host, int port); int ReadSocket(int sock, char *buff, int size,int timeout); int WriteSocket(int sock, char *buff, int size, int timeout); int ReadLSocket(int sock, char * buff,int maxsize,int timeout); int WriteLSocket(int sock, char *buff,int timeout); TcpServer OpenTcpServer(int port ,int maxcon,int loopback); int WaitTcpServer(TcpServer server); void CloseTcpServer(TcpServer server); /* UDP Functions */ int OpenUdpSocket(char *host, int port,Udp * udp); int SendUdpData(int sock,Udp * udp,char *buff,int size); int ReadUdpData(int sock,char *buff,int maxsize,int timeout); /* Generic Functions */ int CloseSocket(int sock); /* DNS functions */ int DnsIp(char *host,char *ip); int DnsFQDN(char *host,char *fqdn); int DnsName(char *ip,char *fqdn); void GetPeerIp(int sock,char *ip,char *fqdn); /* Special Functions */ void NoZombies(int); /* End of sockets.h */ gld-1.7/sql.c0100644000000000000000000000610210310376434011571 0ustar rootroot#include #include #include #ifdef _DB_MYSQL_ #include #endif #ifdef _DB_PGSQL_ #include "libpq-fe.h" #endif #include "gld.h" #ifdef _DB_MYSQL_ static int MySQLConnect(char *host,char *user,char *passwd,char *db); static void MySQLClose(void); static long MySQLQuery(char *q); #endif #ifdef _DB_PGSQL_ static int PgSQLConnect(char *host,char *user,char *passwd,char *db); static void PgSQLClose(void); static long PgSQLQuery(char *q); #endif int SQLConnect(char *host,char *user,char *passwd,char *db) { #ifdef _DB_MYSQL_ return(MySQLConnect(host, user, passwd, db)); #endif #ifdef _DB_PGSQL_ return(PgSQLConnect(host, user, passwd, db)); #endif } void SQLClose(void) { #ifdef _DB_MYSQL_ return(MySQLClose()); #endif #ifdef _DB_PGSQL_ return(PgSQLClose()); #endif } long SQLQuery(char *q) { #ifdef _DB_MYSQL_ return(MySQLQuery(q)); #endif #ifdef _DB_PGSQL_ return(PgSQLQuery(q)); #endif } void ShowBaseInfo(void) { char query[QLEN]; int c; long now; now=time(0); snprintf(query,sizeof(query)-1,"select count(*) from greylist"); c=SQLQuery(query); printf("# of entries in the database : %d\n",c); if(c!=0) { snprintf(query,sizeof(query)-1,"select count(*) from greylist where n=1"); c=SQLQuery(query); printf("# of one hit entries in the database : %d\n",c); snprintf(query,sizeof(query)-1,"select min(first) from greylist"); c=SQLQuery(query); printf("Oldest entry in database : %ld days ago\n",(now-c)/86400); } } void Quote(char *str) { int i,l; l=strlen(str); for(i=0;i