From 69fef297ecc00601116fe5f97a663ab4101e9f66 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 16 Apr 2011 08:35:12 +0200 Subject: [PATCH] Initial sources of crywrap 0.2.1. --- AUTHORS | 1 + COPYING | 340 +++++++++++++ ChangeLog | 631 +++++++++++++++++++++++ INSTALL | 85 ++++ Makefile.in | 15 + Mk/ChangeLog | 693 +++++++++++++++++++++++++ Mk/Makefile.in | 14 + Mk/Mk.m4 | 30 ++ Mk/Rules.mk.in | 354 +++++++++++++ Mk/Rules.mk~ | 354 +++++++++++++ Mk/toplevel.mk | 71 +++ NEWS | 10 + README | 11 + THANKS | 2 + aclocal.m4 | 171 +++++++ config.mk.in | 9 + configure.ac | 135 +++++ crywrap.doxy | 59 +++ doc/Makefile.in | 27 + doc/crywrap.8.in | 124 +++++ etc/Makefile.in | 14 + etc/crywrap-init.d | 97 ++++ etc/crywrap.conf | 34 ++ history/ChangeLog-0.1 | 1110 ++++++++++++++++++++++++++++++++++++++++ history/ChangeLog-0.2 | 114 +++++ history/Makefile.in | 14 + install.sh | 251 ++++++++++ lib/Makefile.in | 11 + lib/compat/ChangeLog | 398 +++++++++++++++ lib/compat/Makefile.in | 23 + lib/compat/compat-regex.h | 179 +++++++ lib/compat/compat.c | 1051 ++++++++++++++++++++++++++++++++++++++ lib/compat/compat.h | 352 +++++++++++++ lib/compat/compat.m4 | 161 ++++++ m4/Makefile.in | 13 + m4/bh-m4/ChangeLog | 32 ++ m4/bh-m4/Makefile.in | 12 + m4/bh-m4/cc.m4 | 91 ++++ m4/bh-m4/sfv_fd_self.m4 | 13 + m4/bh-m4/sockaddr_storage.m4 | 22 + m4/bh-m4/tcp_cork.m4 | 16 + m4/libgnutls.m4 | 161 ++++++ src/Makefile.in | 41 ++ src/crywrap.c | 1138 ++++++++++++++++++++++++++++++++++++++++++ src/crywrap.h | 105 ++++ src/primes.h | 54 ++ system.h.in | 232 +++++++++ utils/Makefile.in | 14 + utils/sslwrap | 98 ++++ 49 files changed, 8987 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.in create mode 100644 Mk/ChangeLog create mode 100644 Mk/Makefile.in create mode 100644 Mk/Mk.m4 create mode 100644 Mk/Rules.mk.in create mode 100644 Mk/Rules.mk~ create mode 100644 Mk/toplevel.mk create mode 100644 NEWS create mode 100644 README create mode 100644 THANKS create mode 100644 aclocal.m4 create mode 100644 config.mk.in create mode 100644 configure.ac create mode 100644 crywrap.doxy create mode 100644 doc/Makefile.in create mode 100644 doc/crywrap.8.in create mode 100644 etc/Makefile.in create mode 100755 etc/crywrap-init.d create mode 100644 etc/crywrap.conf create mode 100644 history/ChangeLog-0.1 create mode 100644 history/ChangeLog-0.2 create mode 100644 history/Makefile.in create mode 100755 install.sh create mode 100644 lib/Makefile.in create mode 100644 lib/compat/ChangeLog create mode 100644 lib/compat/Makefile.in create mode 100644 lib/compat/compat-regex.h create mode 100644 lib/compat/compat.c create mode 100644 lib/compat/compat.h create mode 100644 lib/compat/compat.m4 create mode 100644 m4/Makefile.in create mode 100644 m4/bh-m4/ChangeLog create mode 100644 m4/bh-m4/Makefile.in create mode 100644 m4/bh-m4/cc.m4 create mode 100644 m4/bh-m4/sfv_fd_self.m4 create mode 100644 m4/bh-m4/sockaddr_storage.m4 create mode 100644 m4/bh-m4/tcp_cork.m4 create mode 100644 m4/libgnutls.m4 create mode 100644 src/Makefile.in create mode 100644 src/crywrap.c create mode 100644 src/crywrap.h create mode 100644 src/primes.h create mode 100644 system.h.in create mode 100644 utils/Makefile.in create mode 100755 utils/sslwrap diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..bfec3e5 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Gergely Nagy diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..a51f2b5 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,631 @@ +# do not edit -- automatically generated by arch changelog +# arch-tag: automatic-ChangeLog--algernon@bonehunter.rulez.org--tla/crywrap--head--0.2 +# + +2004-01-31 19:21:36 GMT Gergely Nagy patch-33 + + Summary: + CryWrap 0.2.1 released + Revision: + crywrap--head--0.2--patch-33 + + * NEWS: Finalised the date. + * config.mk.in {WITH_SNAPSHOT}: Removed. + + modified files: + ChangeLog NEWS config.mk.in + + +2004-01-31 15:27:37 GMT Gergely Nagy patch-32 + + Summary: + Fix distcheck + Revision: + crywrap--head--0.2--patch-32 + + * history/Makefile.in {EXTRA_DIST}: Remove ChangeLog-0.2-head, and + added ChangeLog-0.2. + + modified files: + ChangeLog history/Makefile.in + + +2004-01-31 15:15:22 GMT Gergely Nagy patch-31 + + Summary: + Finished moving to the BH compat suite + Revision: + crywrap--head--0.2--patch-31 + + Updated the sources to take advantage of the .m4 files in Mk/ and + lib/compat/, and to use bhc_log() and bhc_error(0 instead of + re-implementing the same functionality. + + new files: + buildconf m4/.arch-ids/=id m4/Makefile.in + + modified files: + ChangeLog Makefile.in configs/default configure.ac + src/crywrap.c src/crywrap.h + + renamed files: + libgnutls.m4 + ==> m4/libgnutls.m4 + + new directories: + m4 m4/.arch-ids + + +2004-01-25 11:43:19 GMT Gergely Nagy patch-30 + + Summary: + Added lib/, oops + Revision: + crywrap--head--0.2--patch-30 + + * lib/: Forgot to add it earlier, doing it now. + * lib/Makefile.in: New file. + + new files: + lib/.arch-ids/=id lib/Makefile.in + + modified files: + ChangeLog + + new directories: + lib lib/.arch-ids + + +2004-01-25 11:38:12 GMT Gergely Nagy patch-29 + + Summary: + Log the destination address of a connection, too + Revision: + crywrap--head--0.2--patch-29 + + * src/crywrap.h (crywrap_config_t): Added a ->dest.host member. + * src/crywrap.c (_crywrap_parse_ip): Take a new argument, which will + be filled with the destination address. + (_crywrap_config_parse_opt): Updated for the new + _crywrap_parse_ip(). + (_crywrap_do_one): Log the destination address too. + + modified files: + ChangeLog src/crywrap.c src/crywrap.h + + +2004-01-24 15:15:17 GMT Gergely Nagy patch-28 + + Summary: + NEWS update + Revision: + crywrap--head--0.2--patch-28 + + * NEWS: Started adding 0.2.1 infos. + + modified files: + ChangeLog NEWS + + +2004-01-24 15:10:44 GMT Gergely Nagy patch-27 + + Summary: + IDN support + Revision: + crywrap--head--0.2--patch-27 + + * configure.ac: Check for Libidn. + * src/Makefile.in {SHISHI_LIBS}: New substvar. + {CUSTOM_LDFLAGS}: Added ${SHISHI_LIBS}. + * src/crywrap.c (_crywrap_addr_get): Run the hostname through + idna_to_ascii before passing it to getaddrinfo(). + (main): Call stringprep_locale_charset(). + * INSTALL: Bump requirements, and include Libidn too. + + modified files: + ChangeLog INSTALL configure.ac src/Makefile.in src/crywrap.c + + +2004-01-24 14:06:57 GMT Gergely Nagy patch-26 + + Summary: + debian/ moved + Revision: + crywrap--head--0.2--patch-26 + + Moved debian/ to crywrap--pkg-debian--1.0. + + + removed files: + debian/.arch-ids/=id debian/.arch-ids/README.Debian.id + debian/.arch-ids/changelog.id debian/.arch-ids/control.id + debian/.arch-ids/copyright.id debian/README.Debian + debian/changelog debian/control debian/copyright + debian/maint/.arch-ids/=id debian/maint/postinst + debian/maint/postrm debian/maint/prerm debian/rules + + modified files: + ChangeLog + + removed directories: + debian debian/.arch-ids debian/maint debian/maint/.arch-ids + + +2004-01-24 14:04:10 GMT Gergely Nagy patch-25 + + Summary: + ChangeLog-foo, #2 + Revision: + crywrap--head--0.2--patch-25 + + + new files: + ChangeLog + + +2004-01-24 14:03:40 GMT Gergely Nagy patch-24 + + Summary: + ChangeLog-foo, #1 + Revision: + crywrap--head--0.2--patch-24 + + + removed files: + history/ChangeLog-0.2-head + + +2004-01-24 13:52:49 GMT Gergely Nagy patch-23 + + Summary: + Massive Mk/ and GnuTLS related updates + Revision: + crywrap--head--0.2--patch-23 + + Updated to the latest BoneHunter Compat Suite, Mk/ and GnuTLS. + + No functional changes yet, except that the crywrap--stable branch is + now dead. + + modified files: + Makefile.in config.mk.in configs/default configure.ac + crywrap.doxy history/ChangeLog-0.2-head src/Makefile.in + src/crywrap.c + + renamed files: + ChangeLog + ==> history/ChangeLog-0.2 + + +2003-10-12 14:54:56 GMT Gergely Nagy patch-22 + + Summary: + README.arch update + Revision: + crywrap--head--0.2--patch-22 + + * README.arch: Added info about updating the configuration. + + modified files: + README.arch history/ChangeLog-0.2-head + + +2003-10-12 14:39:52 GMT Gergely Nagy patch-21 + + Summary: + Install /etc/crywrap in the debian package + Revision: + crywrap--head--0.2--patch-21 + + * debian/rules (install): Install ${PKGDIR}/etc/crywrap. + + modified files: + debian/rules history/ChangeLog-0.2-head + + +2003-10-11 22:30:53 GMT Gergely Nagy patch-20 + + Summary: + Merged with crywrap--stable + Revision: + crywrap--head--0.2--patch-20 + + Patches applied: + + * algernon@bonehunter.rulez.org--tla/crywrap--stable--0.2--base-0 + CryWrap 0.2.0 release + + * algernon@bonehunter.rulez.org--tla/crywrap--stable--0.2--patch-1 + documentation update + + + modified files: + ChangeLog debian/README.Debian history/ChangeLog-0.2-head + + new patches: + algernon@bonehunter.rulez.org--tla/crywrap--stable--0.2--base-0 + algernon@bonehunter.rulez.org--tla/crywrap--stable--0.2--patch-1 + + +2003-10-02 11:57:42 GMT Gergely Nagy patch-19 + + Summary: + Preparing for 0.2.0 + Revision: + crywrap--head--0.2--patch-19 + + * NEWS: Updated. + * debian/changelog: Likewise. + + modified files: + NEWS debian/changelog history/ChangeLog-0.2-head + + +2003-10-02 11:51:45 GMT Gergely Nagy patch-18 + + Summary: + README.arch + Revision: + crywrap--head--0.2--patch-18 + + * README.arch: New file. + + new files: + README.arch + + modified files: + history/ChangeLog-0.2-head + + +2003-09-26 09:40:48 GMT Gergely Nagy patch-17 + + Summary: + INSTALL update + Revision: + crywrap--head--0.2--patch-17 + + * INSTALL: Rewritten, based on the INSTALL file from Thy. + + modified files: + INSTALL history/ChangeLog-0.2-head + + +2003-09-22 09:20:22 GMT Gergely Nagy patch-16 + + Summary: + Update for latest compat/ + Revision: + crywrap--head--0.2--patch-16 + + * configure.ac: Check for getdelim() and getline() too. + + modified files: + configure.ac history/ChangeLog-0.2-head + + +2003-09-20 21:07:01 GMT Gergely Nagy patch-15 + + Summary: + configure.ac update + Revision: + crywrap--head--0.2--patch-15 + + * configure.ac: Added a buckload of stuff, noticed by autoscan. + + modified files: + configure.ac history/ChangeLog-0.2-head + + +2003-09-20 11:18:53 GMT Gergely Nagy patch-14 + + Summary: + THANKS update + Revision: + crywrap--head--0.2--patch-14 + + * THANKS: Added Gabor Nyeki. (Provided a NetBSD system for porting + purposes) + + modified files: + THANKS history/ChangeLog-0.2-head + + +2003-09-20 09:58:07 GMT Gergely Nagy patch-13 + + Summary: + Fixed a compile-time warning + Revision: + crywrap--head--0.2--patch-13 + + * src/crywrap.c (_crywrap_addr_get): Cast res->ai_addrlen to ssize_t + before comparsion. + + modified files: + history/ChangeLog-0.2-head src/crywrap.c + + +2003-09-20 09:34:30 GMT Gergely Nagy patch-12 + + Summary: + argp.h conditional inclusion + Revision: + crywrap--head--0.2--patch-12 + + * src/crywrap.c [HAVE_ARGP_H]: Only include in this case. + + modified files: + history/ChangeLog-0.2-head src/crywrap.c + + +2003-09-20 09:32:45 GMT Gergely Nagy patch-11 + + Summary: + WITH_SNAPSHOT + Revision: + crywrap--head--0.2--patch-11 + + * config.mk.in (WITH_SNAPSHOT): New variable. + * configure.ac: Added support for --with-snapshot. + + modified files: + config.mk.in configure.ac history/ChangeLog-0.2-head + + +2003-09-20 08:44:58 GMT Gergely Nagy patch-10 + + Summary: + bhc_setproctitle() support + Revision: + crywrap--head--0.2--patch-10 + + * src/crywrap.c (main): Use bhc_setproctitle(). + + modified files: + history/ChangeLog-0.2-head src/crywrap.c + + +2003-09-20 08:40:38 GMT Gergely Nagy patch-9 + + Summary: + First porting effort: compat/ + Revision: + crywrap--head--0.2--patch-9 + + * configs/default: Added compat. + * Makefile.in (SUBDIRS): Added compat. + * configure.ac: Lots of changes to support the BoneHunter compat + suite. + * src/Makefile.in (CUSTOM_CFLAGS): Added -I${top_srcdir}/compat. + (CUSTOM_OBJECTS): New variable. + * src/crywrap.c: Ported to use the BoneHunter compat suite, where + appropriate. + + modified files: + Makefile.in configs/default configure.ac + history/ChangeLog-0.2-head src/Makefile.in src/crywrap.c + + +2003-09-20 08:00:03 GMT Gergely Nagy patch-8 + + Summary: + CUSTOM_LDFLAGS and CUSTOM_CFLAGS support + Revision: + crywrap--head--0.2--patch-8 + + * src/Makefile.in: Use CUSTOM_LDFLAGS and CUSTOM_CFLAGS instead of + fiddling with ALL_LDFLAGS and ALL_CFLAGS. + + modified files: + history/ChangeLog-0.2-head src/Makefile.in + + +2003-09-16 08:32:14 GMT Gergely Nagy patch-7 + + Summary: + Typo fix + Revision: + crywrap--head--0.2--patch-7 + + * Makefile.in (EXTRA_DIST): It is install.sh, not install-sh. + + modified files: + Makefile.in history/ChangeLog-0.2-head + + +2003-09-16 08:28:50 GMT Gergely Nagy patch-6 + + Summary: + Update for latest Mk/ + Revision: + crywrap--head--0.2--patch-6 + + * src/Makefile.in (${top_builddir}/system.h): Removed. It is now + handled by Mk/Rules.mk. + + modified files: + history/ChangeLog-0.2-head src/Makefile.in + + +2003-09-16 08:25:45 GMT Gergely Nagy patch-5 + + Summary: + ChangeLog correction + Revision: + crywrap--head--0.2--patch-5 + + * Changelog: Renamed to the correct... + * ChangeLog: ...ChangeLog. + + modified files: + history/ChangeLog-0.2-head + + renamed files: + Changelog + ==> ChangeLog + + +2003-09-16 08:24:52 GMT Gergely Nagy patch-4 + + Summary: + Demise of CRYWRAP_OPTION_PIDFILE + Revision: + crywrap--head--0.2--patch-4 + + * configure.ac: Removed support for --pidfile. + * src/crywrap.h [CRYWRAP_OPTION_PIDFILE]: Removed this option. + * src/crywrap.c: Adapted to always handle the pidfile, but if it is + empty or NULL, work like CRYWRAP_OPTION_NOPIDFILE before. + + modified files: + configure.ac history/ChangeLog-0.2-head src/crywrap.c + src/crywrap.h + + +2003-09-16 08:17:15 GMT Gergely Nagy patch-3 + + Summary: + Whitespace cleanup + Revision: + crywrap--head--0.2--patch-3 + + * src/crywrap.c: Removed all trailing whitespace. + + modified files: + history/ChangeLog-0.2-head src/crywrap.c + + +2003-09-16 08:13:13 GMT Gergely Nagy patch-2 + + Summary: + GNUTLS 0.8.9 upgrade + Revision: + crywrap--head--0.2--patch-2 + + * src/crywrap.c (_crywrap_do_one): Cast the last two arguments of + gnutls_transport_set_ptr2 to gnutls_transport_ptr. + * debian/control (Build-Depends): Bumped up gnutls deps. + (Standards-Version): Bumped to 3.6.1. + + modified files: + debian/control history/ChangeLog-0.2-head src/crywrap.c + + +2003-09-16 08:08:40 GMT Gergely Nagy patch-1 + + Summary: + ChangeLog shuffling + Revision: + crywrap--head--0.2--patch-1 + + * ChangeLog: Replaced with a changelog for crywrap--stable--0.2. The + old one moved... + * history/ChangeLog-0.1: ...here. + * history/ChangeLog-0.2-head: New file. + * history/Makefile.in: Likewise. + * Makefile.in (SUBDIRS): Added history. + * configure.ac (AC_CONFIG_FILES): Added history/Makefile. + + new files: + Changelog history/.arch-ids/=id history/ChangeLog-0.2-head + history/Makefile.in + + modified files: + Makefile.in configure.ac + + renamed files: + ChangeLog + ==> history/ChangeLog-0.1 + + new directories: + history history/.arch-ids + + +2003-09-16 08:02:41 GMT Gergely Nagy base-0 + + Summary: + Imported CryWrap 0.1 into this new branch + Revision: + crywrap--head--0.2--base-0 + + Imported CryWrap 0.1 into this new branch, switching to tagline, while + there. Also converted to use the Mk/ system. + + new files: + AUTHORS COPYING ChangeLog INSTALL Makefile.in NEWS README + THANKS config.guess config.mk.in config.sub configs/default + configure.ac crywrap.doxy debian/README.Debian + debian/changelog debian/control debian/copyright + debian/maint/postinst debian/maint/postrm debian/maint/prerm + debian/rules doc/Makefile.in doc/crywrap.8.in etc/Makefile.in + etc/crywrap-init.d etc/crywrap.conf install.sh libgnutls.m4 + src/Makefile.in src/crywrap.c src/crywrap.h src/primes.h + utils/Makefile.in utils/sslwrap + + new patches: + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--base-0 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-1 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-2 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-3 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-4 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-5 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-6 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-7 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-8 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-9 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-10 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-11 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-12 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-13 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-14 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-15 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-16 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-17 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-18 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-19 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-20 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-21 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-22 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-23 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-24 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-25 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-26 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-27 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-28 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-29 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-30 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-31 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-32 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-33 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-34 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-35 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-36 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-37 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-38 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-39 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-40 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-41 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-42 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-43 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-44 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-45 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-46 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-47 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-48 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-49 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-50 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-51 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-52 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-53 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-54 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-55 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-56 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-57 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-58 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-59 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-60 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-61 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-62 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-63 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-64 + + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..18d3358 --- /dev/null +++ b/INSTALL @@ -0,0 +1,85 @@ +CryWrap Installation notes +========================== + +Build requirements +------------------ + +In order to compile CryWrap from sources certain additional software +must be present on the build system, including a POSIX-compatible +shell (usually /bin/sh), a POSIX compliant C library, a compiler that +supports C99 (GCC is such a compiler), GNU make, GnuTLS (version 1.0.0 +or later), and Libidn. + +How to compile CryWrap +---------------------- + +Its really quite simple - its about the same difficulty as compiling +any GNU software. + +Just `cd' to the directory containing the sources, and type +`./configure'. This will try to collect as much information about the +build environment as is needed to successfully compile the package. +This step usually takes a while, so feel free to sit back and drink a +cup of tea. + +When `configure' finished successfully, the package can be compiled by +issuing the `make' (or `gmake' on certain non-GNU systems) command. +This will build both the executable in `src/crywrap' and certain +support files. + +To install them all to their proper place, issue the `make install' +command, as the final step of the installation stage. For information +about configuring and running CryWrap, please see the manual page. + +To clean the source tree, run `make clean' - this is useful if one +wants to force a rebuild or make a whole-tree diff between the +original and a modified version of CryWrap. To also clean the files +`configure' created, use the `make distclean' command. If one wants +to build CryWrap for a different machine, or with different options, +this is the command to issue. + +Compilers and Options +--------------------- + +Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + +You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=gcc CFLAGS="-Wno-shadow -O2" LIBS=-lposix + +Installation Names +------------------ + +By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + +You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If +you give `configure' the option `--exec-prefix=PATH', the package will +use PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + +In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for +particular kinds of files. Run `configure --help' for a list of the +directories you can set and what kinds of files go in them. + +Optional Features +----------------- + +CryWrap can be configured with or without certain features - such as +extra debugging. Some of these are enabled by default, some are not. + +The list of options to control these features are listed below: + +* `--enable-debug' + Strictly for debugging purposes. This makes CryWrap log an + awful lot of information and behave slightly differently (so + it can be ran under a debugger painlessly), which is of no use + to anyone but developers. diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..7e571ee --- /dev/null +++ b/Makefile.in @@ -0,0 +1,15 @@ +## Makefile +## arch-tag: e1858678-2840-408c-b9a7-98f6d33d1ef8 + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = + +## -- Private variables -- ## +EXTRA_DIST = AUTHORS ChangeLog COPYING INSTALL NEWS \ + README THANKS crywrap.doxy + +SUBDIRS = Mk doc etc history lib m4 src utils + +include Mk/Rules.mk +include ${top_srcdir}/Mk/toplevel.mk diff --git a/Mk/ChangeLog b/Mk/ChangeLog new file mode 100644 index 0000000..3bfc4a2 --- /dev/null +++ b/Mk/ChangeLog @@ -0,0 +1,693 @@ +# do not edit -- automatically generated by arch changelog +# arch-tag: automatic-ChangeLog--algernon@bonehunter.rulez.org--tla/Mk--head--0.1 +# + +2004-01-29 18:44:17 GMT Gergely Nagy patch-46 + + Summary: + Mk.m4 + Revision: + Mk--head--0.1--patch-46 + + * Mk.m4: New file. + * Makefile.in {EXTRA_DIST}: Added it. + + new files: + Mk.m4 + + modified files: + ChangeLog Makefile.in + + +2004-01-22 22:10:54 GMT Gergely Nagy patch-45 + + Summary: + Really fixed distclean + Revision: + Mk--head--0.1--patch-45 + + * Rules.mk.in (distclean): Really duplicate `clean' as should have + been done in patch-39. + + modified files: + ChangeLog Rules.mk.in + + +2004-01-14 14:05:52 GMT Gergely Nagy patch-44 + + Summary: + Normalizing $@ + Revision: + Mk--head--0.1--patch-44 + + * Rules.mk (_@): New canned commandset. + + Updated all relevant ${_subdir}$@ users to use ${_@} instead. + + modified files: + ChangeLog Rules.mk.in + + +2004-01-11 18:59:42 GMT Gergely Nagy patch-43 + + Summary: + Made make dir/ work when dir has subdirs + Revision: + Mk--head--0.1--patch-43 + + * Rules.mk.in (%/): Set DEFDESCEND to all. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-18 16:18:16 GMT Gergely Nagy patch-42 + + Summary: + Added EXTRA_DIST stuff + Revision: + Mk--head--0.1--patch-42 + + * toplevel.mk {EXTRA_DIST}: Append autoconf stuff. + + modified files: + ChangeLog toplevel.mk + + +2003-12-14 13:57:20 GMT Gergely Nagy patch-41 + + Summary: + MAKE_TARGET_VAR_APPEND + Revision: + Mk--head--0.1--patch-41 + + * Rules.mk.in {MAKE_TARGET_VAR_APPEND}: New substvar. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-14 13:17:30 GMT Gergely Nagy patch-40 + + Summary: + Make the flex rule work for ancient flexen too + Revision: + Mk--head--0.1--patch-40 + + * Rules.mk.in (%.l -> %.c): Run FLEX without args, so it produces + lex.yy.c, and rename that. This works around the ancient flex on + Solaris. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-13 21:43:39 GMT Gergely Nagy patch-39 + + Summary: + Fixed distclean + Revision: + Mk--head--0.1--patch-39 + + * Rules.mk.in {CLEANFILES}: Append stuff instead of overriding. + {DISTCLEANFILES}: Likewise. + {MAINTCLEANFILES}: Likewise. + {P_DISTCLEAN}: New variable. + (distclean): Do not depend on clean, but duplicate its + functionality. (Like maintainer-clean does.) + * toplevel.mk {DISTCLEANFILES}: New variable, with some common stuff. + {MAINTCLEANFILES}: Likewise. + + modified files: + ChangeLog Rules.mk.in toplevel.mk + + +2003-12-13 15:25:41 GMT Gergely Nagy patch-38 + + Summary: + Simplified distdir output + Revision: + Mk--head--0.1--patch-38 + + * Rules.mk.in (distdir): Simplified the output for the eye. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-13 15:19:28 GMT Gergely Nagy patch-37 + + Summary: + Fixed make dist double-run + Revision: + Mk--head--0.1--patch-37 + + * toplevel.mk (dist): Made it a wrapper around info, distdir, and... + (dist-pre): ..this.. + (dist-post): ..and this. + + modified files: + ChangeLog toplevel.mk + + +2003-12-13 14:23:22 GMT Gergely Nagy patch-36 + + Summary: + WFLAGS_ICC update + Revision: + Mk--head--0.1--patch-36 + + * Rules.mk.in {WFLAGS_ICC}: Added -wd279. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-13 14:22:15 GMT Gergely Nagy patch-35 + + Summary: + Fix ${builddir}/Makefile message + Revision: + Mk--head--0.1--patch-35 + + * Rules.mk.in (${builddir}/Makefile): Prefix the output stuff with + ${_subdir}. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-13 09:29:03 GMT Gergely Nagy patch-34 + + Summary: + Fixed make dist + Revision: + Mk--head--0.1--patch-34 + + * Rules.mk.in (distdir): Do a ${DESCEND}, otherwise non-first-level + directories will not be descended into. + * toplevel.mk [VERBOSE==2] (dist-local): Only fiddle with _target in + this case. + + modified files: + ChangeLog Rules.mk.in toplevel.mk + + +2003-12-12 11:55:17 GMT Gergely Nagy patch-33 + + Summary: + Fixed make dist + Revision: + Mk--head--0.1--patch-33 + + * toplevel.mk (dist-local): Fixed _toplevel fiddling. + + modified files: + ChangeLog toplevel.mk + + +2003-12-12 11:49:32 GMT Gergely Nagy patch-32 + + Summary: + Do not clean CUSTOM_OBJECTS + Revision: + Mk--head--0.1--patch-32 + + * Rules.mk.in {_OBJECTS}: New variable, containing what OBJECTS did, + but without CUSTOM_OBJECTS. + {OBJECTS}: Made it a combination of _OBJECTS and CUSTOM_OBJECTS. + {CLEANFILES}: Clean _OBJECTS, not OBJECTS, so CUSTOM_OBJECTS will + not get cleaned. + + This fixed a bug where `make subdir/clean' erased CUSTOM_OBJECTS from + a different directory, where subdir/'s Makefile contained, say, + `CUSTOM_OBJECTS=../foo/bar.o'. (That is, make subdir/clean cleaned + ../foo/bar.o, and it does not do that anymore with this fix). + + modified files: + ChangeLog Rules.mk.in + + +2003-12-12 10:49:35 GMT Gergely Nagy patch-31 + + Summary: + Support VERBOSE=2 + Revision: + Mk--head--0.1--patch-31 + + * Rules.mk.in: When V=2 is set, prefix all actions with (TARGET), + where TARGET is the original target. + * toplevel.mk (dist-local): Set _target to `(dist)'. + + modified files: + ChangeLog Rules.mk.in toplevel.mk + + +2003-12-12 10:32:05 GMT Gergely Nagy patch-30 + + Summary: + Silenced P_SUB + Revision: + Mk--head--0.1--patch-30 + + * Rules.mk.in: Prefix all output names with ${_subdir}, and make P_SUB + silent by default (old behaviour can be restored with D=1). + + modified files: + ChangeLog Rules.mk.in + + +2003-12-12 10:05:21 GMT Gergely Nagy patch-29 + + Summary: + Enhanced message upon DESCEND + Revision: + Mk--head--0.1--patch-29 + + * Rules.mk.in {_subdir}: New variable. + {DESCEND}: Prefix ${dir} with ${_subdir} in non-verbose mode. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-12 08:51:22 GMT Gergely Nagy patch-28 + + Summary: + Support deeper (>= 2 level) hierarchies + Revision: + Mk--head--0.1--patch-28 + + * Rules.mk.in {top_builddir}: Use some magic to figure out how deep we + are. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-12 08:35:20 GMT Gergely Nagy patch-27 + + Summary: + LEX_SOURCES and YACC_SOURCES support + Revision: + Mk--head--0.1--patch-27 + + * Rules.mk.in {LEX_SOURCES}: New user variable. + {YACC_SOURCES}: Likewise. + {DISTFILES}: Added ${LEX_SOURCES} and ${YACC_SOURCES}. + {LEX_OBJECTS}: New variable. + {YACC_OBJECTS}: Likewise. + {OBJECTS}: Added ${YACC_OBJECTS} and ${LEX_OBJECTS} + {LEX_MIDSRCS}: New variable. + {YACC_MIDSRCS}: Likewise. + {CLEANFILES}: Added ${YACC_MIDSRCS} and ${LEX_MIDSRCS}. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-11 10:40:09 GMT Gergely Nagy patch-26 + + Summary: + Lex & Yacc updates + Revision: + Mk--head--0.1--patch-26 + + * Rules.mk.in (%.tab.c): Remove arch-tag stuff. + (%.tab.h): Made it a separate target, based on %.tab.c. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-11 10:11:14 GMT Gergely Nagy patch-25 + + Summary: + LEX & YACC stuff + Revision: + Mk--head--0.1--patch-25 + + * Rules.mk (LEX): New substvar. + (YACC): Likewise. + (P_LEX): New variable. + (P_YACC): Likewise. + (%.c: %l): New rule. + (%.tab.c: %.tab.y): Likewise. + (%.tab.h: %.tab.y): Likewise. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-05 23:04:07 GMT Gergely Nagy patch-24 + + Summary: + Fixed -DPATCHLEVEL + Revision: + Mk--head--0.1--patch-24 + + * Rules.mk.in {DEFINES}: Include ${UPATCHLEVEL} in -DVERSION's value + too. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-05 22:11:05 GMT Gergely Nagy patch-23 + + Summary: + Fixed snapshot building + Revision: + Mk--head--0.1--patch-23 + + * Rules.mk.in {VERSION}: Always append ${UPATCHLEVEL} to it. + {PATCHLEVEL}: Adjusted it in one case to the above change. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-05 22:07:53 GMT Gergely Nagy patch-22 + + Summary: + Typo fix + Revision: + Mk--head--0.1--patch-22 + + * Rules.mk.in (distdir): Fixed a typo in verbose mode. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-03 19:16:10 GMT Gergely Nagy patch-21 + + Summary: + SNAPLOG support + Revision: + Mk--head--0.1--patch-21 + + * Rules.mk {SNAPLOG}: New variable. + {UPATCHLEVEL}: Use it. + + modified files: + ChangeLog Rules.mk.in + + +2003-12-03 10:50:46 GMT Gergely Nagy patch-20 + + Summary: + Support for setting PATCHLEVEL outside of Rules.mk + Revision: + Mk--head--0.1--patch-20 + + * Rules.mk: Added support for setting PATCHLEVEL outside of Rules.mk. + + modified files: + ChangeLog Rules.mk.in + + +2003-10-06 19:43:04 GMT Gergely Nagy patch-19 + + Summary: + Simplified snapshot handling + Revision: + Mk--head--0.1--patch-19 + + * Rules.mk.in: Simplified snapshot handling a lot. + + modified files: + ChangeLog Rules.mk.in + + +2003-10-05 15:17:51 GMT Gergely Nagy patch-18 + + Summary: + Fixed WITH_SNAPSHOT + Revision: + Mk--head--0.1--patch-18 + + * Rules.mk.in: FIxed snapshot support yet again. + + modified files: + ChangeLog Rules.mk.in + + +2003-10-05 11:42:46 GMT Gergely Nagy patch-17 + + Summary: + .snapshot-version fixes + Revision: + Mk--head--0.1--patch-17 + + * Rules.mk.in: Get .snapshot-version from ${top_builddir}, so it will + be known in subdirs too. + + modified files: + ChangeLog Rules.mk.in + + +2003-09-20 21:39:25 GMT Gergely Nagy patch-16 + + Summary: + Pre-0 version support + Revision: + Mk--head--0.1--patch-16 + + * Rules.mk.in (PATCHLEVEL): If PATCHLEVEL == PX, prepend a 0.pre + before ${PX}. So we get versions like 0.2.0.pre.15. + Not pretty, but better than 0.2..15 :) + + modified files: + ChangeLog Rules.mk.in + + +2003-09-20 20:46:57 GMT Gergely Nagy patch-15 + + Summary: + Fixed ${pkgconfdir} + Revision: + Mk--head--0.1--patch-15 + + * Rules.mk (pkgconfdir): Use ${PACKAGE} instead of ${PROGRAM}, which + is not defined. + + modified files: + ChangeLog Rules.mk.in + + +2003-09-19 18:00:29 GMT Gergely Nagy patch-14 + + Summary: + Support --with-snapshot in the dist tarball + Revision: + Mk--head--0.1--patch-14 + + * Rules.mk.in: When WITH_SNAPSHOT is not specified, but + .snapshot-version exists, get PATCHLEVEL from there. + Also include .snapshot-version in the tarball. + + modified files: + ChangeLog Rules.mk.in + + +2003-09-19 11:38:28 GMT Gergely Nagy patch-13 + + Summary: + CLEANFILES update + Revision: + Mk--head--0.1--patch-13 + + * Rules.mk.in (CLEANFILES): Moved most of the stuff from clean to + here. + + modified files: + ChangeLog Rules.mk.in + + +2003-09-19 10:40:40 GMT Gergely Nagy patch-12 + + Summary: + Support CUSTOM_OBJECTS + Revision: + Mk--head--0.1--patch-12 + + * Rules.mk.in (OBJECTS): Add ${CUSTOM_OBJECTS} to the list too. + + modified files: + ChangeLog Rules.mk.in + + +2003-09-18 07:52:31 GMT Gergely Nagy patch-11 + + Summary: + Support CUSTOM_CFLAGS and CUSTOM_LDFLAGS + Revision: + Mk--head--0.1--patch-11 + + * Rules.mk.in (ALL_CFLAGS): Append ${CUSTOM_CFLAGS}. + (ALL_LDFLAGS): Append ${CUSTOM_LDFLAGS}. + + modified files: + ChangeLog Rules.mk.in + + +2003-09-16 08:29:31 GMT Gergely Nagy patch-10 + + Summary: + ${top_builddir}/system.h + Revision: + Mk--head--0.1--patch-10 + + * Rules.mk.in (${top_builddir}/system.h): New rule. + + modified files: + ChangeLog Rules.mk.in + + +2003-09-15 10:39:14 GMT Gergely Nagy patch-9 + + Summary: + Added ChangeLog + Revision: + Mk--head--0.1--patch-9 + + * ChangeLog: New file. + * Makefile.in (EXTRA_DIST): Added it. + + new files: + ChangeLog + + modified files: + Makefile.in + + +2003-09-15 10:13:34 GMT Gergely Nagy patch-8 + + Summary: + Link support + Revision: + Mk--head--0.1--patch-8 + + * Rules.mk.in (LN_S): New substvar. + (P_LINK): New print-helper. + + modified files: + Rules.mk.in + + +2003-09-15 09:06:14 GMT Gergely Nagy patch-7 + + Summary: + Fixed Makefile recreation in top-level dir + Revision: + Mk--head--0.1--patch-7 + + * Rules.mk.in (${builddir}/Makefile): Prepend a ./ to the + CONFIG_FILES= path. + + modified files: + Rules.mk.in + + +2003-09-15 08:51:41 GMT Gergely Nagy patch-6 + + Summary: + Cleanup some distcheck mess + Revision: + Mk--head--0.1--patch-6 + + * Rules.mk.in (ALL_CFLAGS): Use =, not :=, otherwise some stuff gets + redefined at distcheck time. + (ALL_LDFLAGS): Likewise. + + modified files: + Rules.mk.in + + +2003-09-15 08:43:07 GMT Gergely Nagy patch-5 + + Summary: + distcheck fix + Revision: + Mk--head--0.1--patch-5 + + * Makefile.in (EXTRA_DIST): Added toplevel.mk. + + modified files: + Makefile.in + + +2003-09-15 08:34:45 GMT Gergely Nagy patch-4 + + Summary: + Updated to work with Blazerd too + Revision: + Mk--head--0.1--patch-4 + + * Rules.mk.in: Include ${top_builddir}/config.mk - it is an + autogenerated file now. + [THY_SNAP]: Renamed to... + [WITH_SNAPSHOT]: ...this. + (CLEANFILES): Added ${PROGRAMS}. + (${top_builddir}/Mk/Rules.mk): Use CONFIG_FILES flag when calling + config.status. + (${builddir}/Makefile): Likewise. + (${top_builddir}/config.mk): New rule. + + modified files: + Rules.mk.in + + +2003-09-13 19:11:04 GMT Gergely Nagy patch-3 + + Summary: + WFLAGS_29X update + Revision: + Mk--head--0.1--patch-3 + + * Rules.mk.in (WFLAGS_29X): Removed -Wmulticharacter. + + modified files: + Rules.mk.in + + +2003-09-13 18:57:11 GMT Gergely Nagy patch-2 + + Summary: + toplevel.mk + Revision: + Mk--head--0.1--patch-2 + + * toplevel.mk: New file. + + new files: + toplevel.mk + + +2003-09-13 18:56:05 GMT Gergely Nagy patch-1 + + Summary: + Added code that allows make / + Revision: + Mk--head--0.1--patch-1 + + * Rules.mk.in: Added code that allows make /. + + modified files: + Rules.mk.in + + +2003-09-13 18:17:48 GMT Gergely Nagy base-0 + + Summary: + Initial import + Revision: + Mk--head--0.1--base-0 + + Initial import from thy--head--0.8, plus some generalisation. + + new files: + Makefile.in Rules.mk.in + + diff --git a/Mk/Makefile.in b/Mk/Makefile.in new file mode 100644 index 0000000..3cd22e5 --- /dev/null +++ b/Mk/Makefile.in @@ -0,0 +1,14 @@ +## Mk/Makefile +## arch-tag: b4e161cf-d6e7-4c2c-93e0-2f84b5e899b7 + +## -- User-modifiable variables -- ## +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = Mk + +## == The code below shouldn't need to be touched at all == ## + +## -- Private variables -- ## +EXTRA_DIST = Rules.mk.in toplevel.mk ChangeLog Mk.m4 + +include ../Mk/Rules.mk diff --git a/Mk/Mk.m4 b/Mk/Mk.m4 new file mode 100644 index 0000000..c55a3b7 --- /dev/null +++ b/Mk/Mk.m4 @@ -0,0 +1,30 @@ +# arch-tag: ace75c56-7f84-4e88-b2d4-31fada4e6122 + +AC_DEFUN([BHMK_MAKE_CHECK],[ + +AC_PROG_MAKE_SET +AC_MSG_CHECKING([whether ${MAKE-make} supports per-target variable appending]) +AC_CACHE_VAL(ac_cv_prog_make_target_var_append, +[cat >conftest.make <<\_ACEOF +foo = bar +all: foo += baz +all: + @echo 'ac_maketemp="${foo}"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_target_var_append=yes +else + eval ac_cv_prog_make_target_var_append=no +fi +rm -f conftest.make]) +if eval "test \"`echo '$ac_cv_prog_make_target_var_append'`\" = yes"; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi +MAKE_TARGET_VAR_APPEND=$ac_cv_prog_make_target_var_append +AC_SUBST([MAKE_TARGET_VAR_APPEND]) + +]) diff --git a/Mk/Rules.mk.in b/Mk/Rules.mk.in new file mode 100644 index 0000000..334d88a --- /dev/null +++ b/Mk/Rules.mk.in @@ -0,0 +1,354 @@ +## Rules.mk -- Common variables and rules for all Makefiles -*- Makefile -*- +## arch-tag: 55f7d706-e978-47b2-ada5-7c65d7411519 + +ifeq (${subdir},) +top_builddir = . +_subdir = +else +top_builddir = $(shell echo $(foreach DIR,$(subst /, ,${subdir}),..) | tr ' ' '/') +_subdir = ${subdir}/ +endif + +define _@ +`case $@ in \ + ../*) \ + echo $@ | sed -e "s,\.\./,,g";; \ + *) \ + echo ${_subdir}$@ ;; \ +esac` +endef + +include ${top_builddir}/config.mk + +SHELL = /bin/sh -e + +VERSION = ${BRANCH}.${PATCHLEVEL}${UPATCHLEVEL} +VPATH = ${srcdir} + +## -- User modifiable variables -- ## +prefix = @prefix@ +exec_prefix = @exec_prefix@ +sysconfdir = @sysconfdir@ +pkgconfdir = ${sysconfdir}/${PACKAGE} +sbindir = @sbindir@ +libdir = @libdir@ +mandir = @mandir@ +man7dir = ${mandir}/man7 +man8dir = ${mandir}/man8 +infodir = @infodir@ + +CC = @CC@ +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +TAR = tar +GZIP = gzip +TAR_OPTIONS = +GZIP_ENV = --best +LN_S = @LN_S@ + +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi + +ETAGS_CMD = etags + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_DIR = @INSTALL@ -d + +LEX = @LEX@ +YACC = @YACC@ + +@SET_MAKE@ + +EXTRAVERSION = + +## -- Private variables -- ## +builddir = @builddir@ + +DISTFILES = ${SOURCES} ${HEADERS} ${HTML_FILES} ${INFO} Makefile.in \ + ${EXTRA_DIST} ${YACC_SOURCES} ${LEX_SOURCES} + +PATCHLEVEL ?= $(shell head -5 ${top_srcdir}/ChangeLog | tail -1 | \ + sed -e "s,^.*patch-,,g" -e "s,^.*base-,,g") +ifeq (${UPATCHLEVEL},${PATCHLEVEL}) +PATCHLEVEL += 0.pre +endif + +ifneq (,$(wildcard ${top_builddir}/.snapshot)) +WITH_SNAPSHOT = yes +endif + +ifdef WITH_SNAPSHOT +SNAPLOG ?= ${top_srcdir}/history/ChangeLog-${BRANCH}-head +UPATCHLEVEL = .$(shell head -5 ${SNAPLOG} | tail -1 | \ + sed -e "s,^.*patch-,,g" -e "s,^.*base-,,g" | tr -d '\n') +ifeq (,${subdir}) +DISTFILES += .snapshot +endif +endif + +TAG_FILES = $(addprefix ${srcdir}/,${SOURCES} ${HEADERS}) + +V ?= 0 +VERBOSE ?= ${V} + +# - C - # +INCLUDES = -I. -I${srcdir} -I${top_builddir} +DEFINES = -DPATCHLEVEL=\"${PATCHLEVEL}${UPATCHLEVEL}\" \ + -DEXTRAVERSION=\"${EXTRAVERSION}\" -D_GNU_SOURCE=1 \ + -DSYSCONFDIR=\"${sysconfdir}\" -DLIBDIR=\"${libdir}\" +WFLAGS = @WFLAGS@ +WFLAGS_GCC = -Winline -Wshadow -Wpointer-arith -Wmissing-declarations \ + -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual \ + -Wbad-function-cast -Wchar-subscripts -Wcomment -Wformat \ + -Wformat-nonliteral -Wformat-security -Wimplicit \ + -Wmissing-braces -Wparentheses -Wswitch -Wunused \ + @WFLAGS_29X@ @WFLAGS_3X@ +WFLAGS_29X = -Wsign-compare -Wmain -Wreturn-type +WFLAGS_3X = -Wsequence-point -Wdiv-by-zero -W -Wno-unused-parameter +WFLAGS_ICC = -Wall -wd167,171,193,279,810,869 + +CFLAGS = @CFLAGS@ +LIBS = @LIBS@ + +ALL_CFLAGS = ${INCLUDES} ${DEFINES} ${LIBGNUTLS_CFLAGS} ${WFLAGS} \ + ${CFLAGS} ${CUSTOM_CFLAGS} +ALL_LDFLAGS = ${LIBS} ${LDFLAGS} ${CUSTOM_LDFLAGS} + +LEX_OBJECTS = ${LEX_SOURCES:.l=.o} +YACC_OBJECTS = ${YACC_SOURCES:.y=.tab.o} +_OBJECTS = ${SOURCES:.c=.o} ${YACC_OBJECTS} ${LEX_OBJECTS} +OBJECTS = ${_OBJECTS} ${CUSTOM_OBJECTS} + +LEX_MIDSRCS = ${LEX_SOURCES:.l=.c} +YACC_MIDSRCS = ${YACC_SOURCES:.y=.tab.c} ${YACC_SOURCES:.y=.tab.h} + +CLEANFILES += ${SOURCES:.c=.da} ${DVI} ${HTML} ${PROGRAMS} ${_OBJECTS} \ + ${YACC_MIDSRCS} ${LEX_MIDSRCS} gmon.out bb.out TAGS +DISTCLEANFILES += ${MAN} +MAINTCLEANFILES += ${INFO} + +MAKE_TARGET_VAR_APPEND = @MAKE_TARGET_VAR_APPEND@ + +# - Documentation - # +INFO = ${TEXI:.texi=.info} +DVI = ${TEXI:.texi=.dvi} +HTML = ${TEXI:.texi=.html} + +MAN = ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} \ + ${MAN8} + +# - Descend - # +ifndef DESCEND_TARGET +DESCEND_TARGET = $@ +endif +ifdef DEFDESCEND +DESCEND_TARGET = $@ +endif +ifeq (1, ${VERBOSE}) +DESCEND = ${quiet} $(foreach dir,${SUBDIRS},${MAKE} -C ${dir} ${DESCEND_TARGET} ; ) +else +DESCEND = ${quiet} $(foreach dir,${SUBDIRS},${P_SUB} ${_subdir}${dir} ; ${MAKE} -C ${dir} ${DESCEND_TARGET} ; ) +endif + +# - Verboseness control - # +ifeq (1, ${VERBOSE}) +quiet = +P_SUB = true +ECHO = @echo >/dev/null +DN = +else +quiet = @ +MAKE += -s +ECHO = echo +DN = >/dev/null +endif +ifeq (2, ${VERBOSE}) +_target ?= ($@) +export _target +endif + +# Print commands +ifdef D +P_SUB = ${ECHO} Building $(notdir ${DESCEND_TARGET}) in +else +P_SUB = ${ECHO} >/dev/null +endif +P_CC = ${ECHO} "${_target} CC" +P_LD = ${ECHO} "${_target} LD" +P_INST = ${ECHO} "${_target} INSTALL" +P_UNINST = ${ECHO} "${_target} UNINSTALL" +P_CLEAN = ${ECHO} "${_target} CLEAN" +P_DISTCLEAN = ${ECHO} "${_target} DISTCLEAN" +P_SCRIPT = ${ECHO} "${_target} SCRIPT" +P_INFO = ${ECHO} "${_target} INFO" +P_DVI = ${ECHO} "${_target} DVI" +P_HTML = ${ECHO} "${_target} HTML" +P_TARBALL = ${ECHO} "${_target} TGZ" +P_SIG = ${ECHO} "${_target} SIG" +P_LINK = ${ECHO} "${_target} LINK" +P_LEX = ${ECHO} "${_target} LEX" +P_YACC = ${ECHO} "${_target} YACC" + +## -- Generic rules -- ## +all install uninstall info dvi html:: + ${DESCEND} +TAGS: + +mostlyclean clean: + ${DESCEND} +ifneq (,${subdir}) + ${quiet} ${P_CLEAN} ${subdir} +else + ${quiet} ${P_SUB} . + ${quiet} ${P_CLEAN} . +endif + ${quiet} test -z "${CLEANFILES}" || rm -rf ${CLEANFILES} +distclean: + ${DESCEND} +ifneq (,${subdir}) + ${quiet} ${P_DISTCLEAN} ${subdir} +else + ${quiet} ${P_SUB} . + ${quiet} ${P_DISTCLEAN} . +endif + ${quiet} rm -f Makefile + ${quiet} test -z "${CLEANFILES}" || rm -rf ${CLEANFILES} + ${quiet} test -z "${DISTCLEANFILES}" || rm -rf ${DISTCLEANFILES} +maintainer-clean: clean + ${DESCEND} + ${quiet} rm -f Makefile + ${quiet} test -z "${DISTCLEANFILES}" || rm -rf ${DISTCLEANFILES} + ${quiet} test -z "${MAINTCLEANFILES}" || rm -rf ${MAINTCLEANFILES} + +install-strip: + ${DESCEND} + ${quiet} ${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install + +TAGS: ${TAG_FILES} + ${DESCEND} + ${quiet} ${P_SCRIPT} ${_@} + ${quiet} test -z "${TAG_FILES}" || ${ETAGS_CMD} ${TAG_FILES} + +distcheck: +distdir = ${top_builddir}/${PACKAGE}-${VERSION}/${subdir} +distdir: distdir-prereq ${DISTFILES} + ${DESCEND} + ${quiet} ${INSTALL_DIR} ${distdir} + @set -e; list='${DISTFILES}'; for f in $$list; do \ + if test -e ${srcdir}/$$f; then \ + fn=${srcdir}/$$f; \ + loc="(srcdir)"; \ + else \ + fn=$$f; \ + loc="(builddir)"; \ + fi ; \ + if test "${VERBOSE}" = "1"; then \ + echo cp -p $$fn ${distdir}/$$f ;\ + else \ + ${P_INST} ${_subdir}$$f $$loc ;\ + fi; \ + cp -p $$fn ${distdir}/$$f ;\ + done +distdir-prereq:: + +${top_builddir}/Mk/Rules.mk: DEFDESCEND=1 +${top_builddir}/Mk/Rules.mk: ${top_srcdir}/Mk/Rules.mk.in ${top_builddir}/config.status + ${quiet} ${P_SUB} ${top_builddir} + ${quiet} ${P_SCRIPT} $@ + ${quiet} cd ${top_builddir} && CONFIG_FILES=Mk/Rules.mk ./config.status ${DN} +${top_builddir}/config.mk: DEFDESCEND=1 +${top_builddir}/config.mk: ${top_srcdir}/config.mk.in ${top_builddir}/config.status + ${quiet} ${P_SUB} ${top_builddir} + ${quiet} ${P_SCRIPT} $@ + ${quiet} cd ${top_builddir} && CONFIG_FILES=config.mk ./config.status ${DN} +${builddir}/Makefile: DEFDESCEND=1 +${builddir}/Makefile: ${srcdir}/Makefile.in ${top_builddir}/config.status + ${quiet} ${P_SUB} ${builddir} + ${quiet} ${P_SCRIPT} ${_subdir}$@ + ${quiet} cd ${top_builddir} && CONFIG_FILES=./${subdir}/Makefile ./config.status ${DN} +${top_builddir}/system.h: ${top_builddir}/config.status + +%/: DESCEND_TARGET=all +%/: .FORCE + ${quiet} ${P_SUB} $(dir $@) + ${quiet} ${MAKE} -C $@ all + +ifeq (0,${MAKELEVEL}) +.DEFAULT: DESCEND_TARGET=$(notdir $@) +.DEFAULT: .FORCE + ${quiet} ${P_SUB} $(dir $@) + ${quiet} ${MAKE} -C $(dir $@) $(notdir $@) +endif + +ifeq (0,${MAKELEVEL}) +$(addsuffix /%,${SUBDIRS}): DESCEND_TARGET=$(notdir $@) +$(addsuffix /%,${SUBDIRS}): .FORCE + ${quiet} ${P_SUB} $(dir $@) + ${quiet} ${MAKE} -C $(dir $@) $(notdir $@) +endif + +.FORCE: + +.snapshot: + ${quiet} touch $@ +ifdef WITH_SNAPSHOT +ifeq (,${subdir}) +distdir-prereq:: .snapshot +endif +endif + +## -- Rules requiring explicit prereqs elsewhere -- ## +%.c: %.l + ${quiet} ${P_LEX} ${_@} + ${quiet} ${LEX} $< + ${quiet} mv lex.yy.c $@T + ${quiet} grep -v "arch-tag" $@T >$@ + ${quiet} rm -f $@T +%.tab.c: %.y + ${quiet} ${P_YACC} ${_@} + ${quiet} ${YACC} -d -o $@ $< + ${quiet} grep -v "arch-tag" $@ >$@T + ${quiet} rm -f $@ && mv $@T $@ +%.tab.h: %.y + ${quiet} ${P_YACC} ${_@} + ${quiet} ${YACC} -d -o $(patsubst %.h,%.c,$@) $< + ${quiet} grep -v "arch-tag" $@ >$@T + ${quiet} rm -f $@ && mv $@T $@ +%.o: %.c + ${quiet} ${P_CC} ${_@} + ${quiet} ${CC} -c ${CPPFLAGS} ${ALL_CFLAGS} $< -o $@ + +${PROGRAMS}: + ${quiet} ${P_LD} ${_@} + ${quiet} ${CC} ${ALL_CFLAGS} -o $@ $^ ${ALL_LDFLAGS} + +%.dvi: %.texi + ${quiet} ${P_DVI} ${_@} + ${quiet} ${TEXI2DVI} $< -o $@ ${DN} +%.html: %.texi + ${quiet} ${P_HTML} ${_@} + ${quiet} ${MAKEINFO} $< -o $@T --html --no-split --no-headers + @tidy -mq $@T >/dev/null 2>&1 || true + ${quiet} sed -e 's,,,' <$@T >$@ + ${quiet} rm -f $@T +%.info: %.texi + ${quiet} ${P_INFO} ${_@} + ${quiet} ${MAKEINFO} $< -o $@ + +${MAN}: %: ${srcdir}/%.in ${top_srcdir}/ChangeLog + ${quiet} ${P_SCRIPT} ${_@} + ${quiet} sed -e "s,@VERSION\@,${VERSION},g" \ + -e "s,@pkgconfdir\@,${pkgconfdir},g" \ + -e "s,@libdir\@,${libdir},g" \ + <${srcdir}/$@.in >$@T && mv -f $@T $@ + +## -- ${MAKE} control -- ## +.PHONY: all install clean distclean mostlyclean uninstall maintainer-clean \ + distdir dist distcheck html info dvi doxy +.SUFFIXES: +.EXPORT_ALL_VARIABLES: + +unexport srcdir top_srcdir subdir distdir top_builddir builddir EXTRA_DIST \ + GZIP GZIP_ENV SUBDIRS diff --git a/Mk/Rules.mk~ b/Mk/Rules.mk~ new file mode 100644 index 0000000..78e2389 --- /dev/null +++ b/Mk/Rules.mk~ @@ -0,0 +1,354 @@ +## Rules.mk -- Common variables and rules for all Makefiles -*- Makefile -*- +## arch-tag: 55f7d706-e978-47b2-ada5-7c65d7411519 + +ifeq (${subdir},) +top_builddir = . +_subdir = +else +top_builddir = $(shell echo $(foreach DIR,$(subst /, ,${subdir}),..) | tr ' ' '/') +_subdir = ${subdir}/ +endif + +define _@ +`case $@ in \ + ../*) \ + echo $@ | sed -e "s,\.\./,,g";; \ + *) \ + echo ${_subdir}$@ ;; \ +esac` +endef + +include ${top_builddir}/config.mk + +SHELL = /bin/sh -e + +VERSION = ${BRANCH}.${PATCHLEVEL}${UPATCHLEVEL} + + +## -- User modifiable variables -- ## +prefix = /usr/local +exec_prefix = ${prefix} +sysconfdir = ${prefix}/etc +pkgconfdir = ${sysconfdir}/${PACKAGE} +sbindir = ${exec_prefix}/sbin +libdir = ${exec_prefix}/lib +mandir = ${prefix}/share/man +man7dir = ${mandir}/man7 +man8dir = ${mandir}/man8 +infodir = ${prefix}/share/info + +CC = gcc +CFLAGS = -g -O2 +LDFLAGS = +TAR = tar +GZIP = gzip +TAR_OPTIONS = +GZIP_ENV = --best +LN_S = @LN_S@ + +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi + +ETAGS_CMD = etags + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_DIR = /usr/bin/install -c -d + +LEX = @LEX@ +YACC = @YACC@ + +@SET_MAKE@ + +EXTRAVERSION = + +## -- Private variables -- ## +builddir = . + +DISTFILES = ${SOURCES} ${HEADERS} ${HTML_FILES} ${INFO} Makefile.in \ + ${EXTRA_DIST} ${YACC_SOURCES} ${LEX_SOURCES} + +PATCHLEVEL ?= $(shell head -5 ${top_srcdir}/ChangeLog | tail -1 | \ + sed -e "s,^.*patch-,,g" -e "s,^.*base-,,g") +ifeq (${UPATCHLEVEL},${PATCHLEVEL}) +PATCHLEVEL += 0.pre +endif + +ifneq (,$(wildcard ${top_builddir}/.snapshot)) +WITH_SNAPSHOT = yes +endif + +ifdef WITH_SNAPSHOT +SNAPLOG ?= ${top_srcdir}/history/ChangeLog-${BRANCH}-head +UPATCHLEVEL = .$(shell head -5 ${SNAPLOG} | tail -1 | \ + sed -e "s,^.*patch-,,g" -e "s,^.*base-,,g" | tr -d '\n') +ifeq (,${subdir}) +DISTFILES += .snapshot +endif +endif + +TAG_FILES = $(addprefix ${srcdir}/,${SOURCES} ${HEADERS}) + +V ?= 0 +VERBOSE ?= ${V} + +# - C - # +INCLUDES = -I. -I${srcdir} -I${top_builddir} +DEFINES = -DPATCHLEVEL=\"${PATCHLEVEL}${UPATCHLEVEL}\" \ + -DEXTRAVERSION=\"${EXTRAVERSION}\" -D_GNU_SOURCE=1 \ + -DSYSCONFDIR=\"${sysconfdir}\" -DLIBDIR=\"${libdir}\" +WFLAGS = @WFLAGS@ +WFLAGS_GCC = -Winline -Wshadow -Wpointer-arith -Wmissing-declarations \ + -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual \ + -Wbad-function-cast -Wchar-subscripts -Wcomment -Wformat \ + -Wformat-nonliteral -Wformat-security -Wimplicit \ + -Wmissing-braces -Wparentheses -Wswitch -Wunused \ + @WFLAGS_29X@ @WFLAGS_3X@ +WFLAGS_29X = -Wsign-compare -Wmain -Wreturn-type +WFLAGS_3X = -Wsequence-point -Wdiv-by-zero -W -Wno-unused-parameter +WFLAGS_ICC = -Wall -wd167,171,193,279,810,869 + +CFLAGS = -g -O2 +LIBS = + +ALL_CFLAGS = ${INCLUDES} ${DEFINES} ${LIBGNUTLS_CFLAGS} ${WFLAGS} \ + ${CFLAGS} ${CUSTOM_CFLAGS} +ALL_LDFLAGS = ${LIBS} ${LDFLAGS} ${CUSTOM_LDFLAGS} + +LEX_OBJECTS = ${LEX_SOURCES:.l=.o} +YACC_OBJECTS = ${YACC_SOURCES:.y=.tab.o} +_OBJECTS = ${SOURCES:.c=.o} ${YACC_OBJECTS} ${LEX_OBJECTS} +OBJECTS = ${_OBJECTS} ${CUSTOM_OBJECTS} + +LEX_MIDSRCS = ${LEX_SOURCES:.l=.c} +YACC_MIDSRCS = ${YACC_SOURCES:.y=.tab.c} ${YACC_SOURCES:.y=.tab.h} + +CLEANFILES += ${SOURCES:.c=.da} ${DVI} ${HTML} ${PROGRAMS} ${_OBJECTS} \ + ${YACC_MIDSRCS} ${LEX_MIDSRCS} gmon.out bb.out TAGS +DISTCLEANFILES += ${MAN} +MAINTCLEANFILES += ${INFO} + +MAKE_TARGET_VAR_APPEND = @MAKE_TARGET_VAR_APPEND@ + +# - Documentation - # +INFO = ${TEXI:.texi=.info} +DVI = ${TEXI:.texi=.dvi} +HTML = ${TEXI:.texi=.html} + +MAN = ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} \ + ${MAN8} + +# - Descend - # +ifndef DESCEND_TARGET +DESCEND_TARGET = $@ +endif +ifdef DEFDESCEND +DESCEND_TARGET = $@ +endif +ifeq (1, ${VERBOSE}) +DESCEND = ${quiet} $(foreach dir,${SUBDIRS},${MAKE} -C ${dir} ${DESCEND_TARGET} ; ) +else +DESCEND = ${quiet} $(foreach dir,${SUBDIRS},${P_SUB} ${_subdir}${dir} ; ${MAKE} -C ${dir} ${DESCEND_TARGET} ; ) +endif + +# - Verboseness control - # +ifeq (1, ${VERBOSE}) +quiet = +P_SUB = true +ECHO = @echo >/dev/null +DN = +else +quiet = @ +MAKE += -s +ECHO = echo +DN = >/dev/null +endif +ifeq (2, ${VERBOSE}) +_target ?= ($@) +export _target +endif + +# Print commands +ifdef D +P_SUB = ${ECHO} Building $(notdir ${DESCEND_TARGET}) in +else +P_SUB = ${ECHO} >/dev/null +endif +P_CC = ${ECHO} "${_target} CC" +P_LD = ${ECHO} "${_target} LD" +P_INST = ${ECHO} "${_target} INSTALL" +P_UNINST = ${ECHO} "${_target} UNINSTALL" +P_CLEAN = ${ECHO} "${_target} CLEAN" +P_DISTCLEAN = ${ECHO} "${_target} DISTCLEAN" +P_SCRIPT = ${ECHO} "${_target} SCRIPT" +P_INFO = ${ECHO} "${_target} INFO" +P_DVI = ${ECHO} "${_target} DVI" +P_HTML = ${ECHO} "${_target} HTML" +P_TARBALL = ${ECHO} "${_target} TGZ" +P_SIG = ${ECHO} "${_target} SIG" +P_LINK = ${ECHO} "${_target} LINK" +P_LEX = ${ECHO} "${_target} LEX" +P_YACC = ${ECHO} "${_target} YACC" + +## -- Generic rules -- ## +all install uninstall info dvi html:: + ${DESCEND} +TAGS: + +mostlyclean clean: + ${DESCEND} +ifneq (,${subdir}) + ${quiet} ${P_CLEAN} ${subdir} +else + ${quiet} ${P_SUB} . + ${quiet} ${P_CLEAN} . +endif + ${quiet} test -z "${CLEANFILES}" || rm -rf ${CLEANFILES} +distclean: + ${DESCEND} +ifneq (,${subdir}) + ${quiet} ${P_DISTCLEAN} ${subdir} +else + ${quiet} ${P_SUB} . + ${quiet} ${P_DISTCLEAN} . +endif + ${quiet} rm -f Makefile + ${quiet} test -z "${CLEANFILES}" || rm -rf ${CLEANFILES} + ${quiet} test -z "${DISTCLEANFILES}" || rm -rf ${DISTCLEANFILES} +maintainer-clean: clean + ${DESCEND} + ${quiet} rm -f Makefile + ${quiet} test -z "${DISTCLEANFILES}" || rm -rf ${DISTCLEANFILES} + ${quiet} test -z "${MAINTCLEANFILES}" || rm -rf ${MAINTCLEANFILES} + +install-strip: + ${DESCEND} + ${quiet} ${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install + +TAGS: ${TAG_FILES} + ${DESCEND} + ${quiet} ${P_SCRIPT} ${_@} + ${quiet} test -z "${TAG_FILES}" || ${ETAGS_CMD} ${TAG_FILES} + +distcheck: +distdir = ${top_builddir}/${PACKAGE}-${VERSION}/${subdir} +distdir: distdir-prereq ${DISTFILES} + ${DESCEND} + ${quiet} ${INSTALL_DIR} ${distdir} + @set -e; list='${DISTFILES}'; for f in $$list; do \ + if test -e ${srcdir}/$$f; then \ + fn=${srcdir}/$$f; \ + loc="(srcdir)"; \ + else \ + fn=$$f; \ + loc="(builddir)"; \ + fi ; \ + if test "${VERBOSE}" = "1"; then \ + echo cp -p $$fn ${distdir}/$$f ;\ + else \ + ${P_INST} ${_subdir}$$f $$loc ;\ + fi; \ + cp -p $$fn ${distdir}/$$f ;\ + done +distdir-prereq:: + +${top_builddir}/Mk/Rules.mk: DEFDESCEND=1 +${top_builddir}/Mk/Rules.mk: ${top_srcdir}/Mk/Rules.mk.in ${top_builddir}/config.status + ${quiet} ${P_SUB} ${top_builddir} + ${quiet} ${P_SCRIPT} $@ + ${quiet} cd ${top_builddir} && CONFIG_FILES=Mk/Rules.mk ./config.status ${DN} +${top_builddir}/config.mk: DEFDESCEND=1 +${top_builddir}/config.mk: ${top_srcdir}/config.mk.in ${top_builddir}/config.status + ${quiet} ${P_SUB} ${top_builddir} + ${quiet} ${P_SCRIPT} $@ + ${quiet} cd ${top_builddir} && CONFIG_FILES=config.mk ./config.status ${DN} +${builddir}/Makefile: DEFDESCEND=1 +${builddir}/Makefile: ${srcdir}/Makefile.in ${top_builddir}/config.status + ${quiet} ${P_SUB} ${builddir} + ${quiet} ${P_SCRIPT} ${_subdir}$@ + ${quiet} cd ${top_builddir} && CONFIG_FILES=./${subdir}/Makefile ./config.status ${DN} +${top_builddir}/system.h: ${top_builddir}/config.status + +%/: DESCEND_TARGET=all +%/: .FORCE + ${quiet} ${P_SUB} $(dir $@) + ${quiet} ${MAKE} -C $@ all + +ifeq (0,${MAKELEVEL}) +.DEFAULT: DESCEND_TARGET=$(notdir $@) +.DEFAULT: .FORCE + ${quiet} ${P_SUB} $(dir $@) + ${quiet} ${MAKE} -C $(dir $@) $(notdir $@) +endif + +ifeq (0,${MAKELEVEL}) +$(addsuffix /%,${SUBDIRS}): DESCEND_TARGET=$(notdir $@) +$(addsuffix /%,${SUBDIRS}): .FORCE + ${quiet} ${P_SUB} $(dir $@) + ${quiet} ${MAKE} -C $(dir $@) $(notdir $@) +endif + +.FORCE: + +.snapshot: + ${quiet} touch $@ +ifdef WITH_SNAPSHOT +ifeq (,${subdir}) +distdir-prereq:: .snapshot +endif +endif + +## -- Rules requiring explicit prereqs elsewhere -- ## +%.c: %.l + ${quiet} ${P_LEX} ${_@} + ${quiet} ${LEX} $< + ${quiet} mv lex.yy.c $@T + ${quiet} grep -v "arch-tag" $@T >$@ + ${quiet} rm -f $@T +%.tab.c: %.y + ${quiet} ${P_YACC} ${_@} + ${quiet} ${YACC} -d -o $@ $< + ${quiet} grep -v "arch-tag" $@ >$@T + ${quiet} rm -f $@ && mv $@T $@ +%.tab.h: %.y + ${quiet} ${P_YACC} ${_@} + ${quiet} ${YACC} -d -o $(patsubst %.h,%.c,$@) $< + ${quiet} grep -v "arch-tag" $@ >$@T + ${quiet} rm -f $@ && mv $@T $@ +%.o: %.c + ${quiet} ${P_CC} ${_@} + ${quiet} ${CC} -c ${CPPFLAGS} ${ALL_CFLAGS} $< -o $@ + +${PROGRAMS}: + ${quiet} ${P_LD} ${_@} + ${quiet} ${CC} ${ALL_CFLAGS} -o $@ $^ ${ALL_LDFLAGS} + +%.dvi: %.texi + ${quiet} ${P_DVI} ${_@} + ${quiet} ${TEXI2DVI} $< -o $@ ${DN} +%.html: %.texi + ${quiet} ${P_HTML} ${_@} + ${quiet} ${MAKEINFO} $< -o $@T --html --no-split --no-headers + @tidy -mq $@T >/dev/null 2>&1 || true + ${quiet} sed -e 's,,,' <$@T >$@ + ${quiet} rm -f $@T +%.info: %.texi + ${quiet} ${P_INFO} ${_@} + ${quiet} ${MAKEINFO} $< -o $@ + +${MAN}: %: ${srcdir}/%.in ${top_srcdir}/ChangeLog + ${quiet} ${P_SCRIPT} ${_@} + ${quiet} sed -e "s,@VERSION\@,${VERSION},g" \ + -e "s,@pkgconfdir\@,${pkgconfdir},g" \ + -e "s,@libdir\@,${libdir},g" \ + <${srcdir}/$@.in >$@T && mv -f $@T $@ + +## -- ${MAKE} control -- ## +.PHONY: all install clean distclean mostlyclean uninstall maintainer-clean \ + distdir dist distcheck html info dvi doxy +.SUFFIXES: +.EXPORT_ALL_VARIABLES: + +unexport srcdir top_srcdir subdir distdir top_builddir builddir EXTRA_DIST \ + GZIP GZIP_ENV SUBDIRS diff --git a/Mk/toplevel.mk b/Mk/toplevel.mk new file mode 100644 index 0000000..ad02846 --- /dev/null +++ b/Mk/toplevel.mk @@ -0,0 +1,71 @@ +## toplevel.mk -- Rules for a top-level makefile -*- Makefile -*- +## arch-tag: a2fd49a3-e42f-4f04-b9e7-b1d8d67c19e6 + +DISTCLEANFILES += config.cache config.log autom4te.cache system.h \ + Makefile config.status config.mk Mk/Rules.mk +MAINTCLEANFILES += ${top_srcdir}/configure ${top_srcdir}/system.h.in \ + ${top_srcdir}/autom4te.cache ${top_srcdir}/aclocal.m4 +EXTRA_DIST += config.guess config.sub config.mk.in configure \ + configure.ac install.sh system.h.in + +doxy: WARNUNDOC=NO +doxy: DOT=NO +doxy: + ${quiet} ${P_SCRIPT} Doxygen docs + ${quiet} cd ${top_srcdir} && \ + (cat ${PACKAGE}.doxy | grep -v "OUTPUT_DIRECTORY"; \ + echo PROJECT_NUMBER="${VERSION} ${EXTRA_VERSION}"; \ + echo OUTPUT_DIRECTORY="${CURDIR}/doxygen"; \ + echo WARN_IF_UNDOCUMENTED="${WARNUNDOC}"; \ + echo HAVE_DOT="${DOT}";) | doxygen - + +ifeq (${VERBOSE},2) +dist: _target=(dist) +endif +dist: info dist-pre distdir dist-post +dist-pre: + ${quiet} test -z "${distdir}" || rm -rf "${distdir}" +dist-post: + ${quiet} ${P_TARBALL} ${PACKAGE}-${VERSION}.tar.gz + ${quiet} ${TAR} ${TAR_OPTIONS} -cf - ${PACKAGE}-${VERSION} | \ + ${GZIP} ${GZIP_ENV} >${PACKAGE}-${VERSION}.tar.gz + ${quiet} test -z "${distdir}" || rm -rf "${distdir}" + +distcheck: dist + ${quiet} ${ECHO} "Checking distribution" + ${quiet} ${GZIP} -dfc ${PACKAGE}-${VERSION}.tar.gz | tar ${TAR_OPTIONS} -xf - + ${quiet} cd ${PACKAGE}-${VERSION} && ./configure + ${quiet} ${MAKE} -C ${PACKAGE}-${VERSION} DEFDESCEND=1 \ + all install dist DESTDIR=$(shell pwd)/${PACKAGE}-${VERSION} + ${quiet} rm -rf ${PACKAGE}-${VERSION} + @banner="${PACKAGE}-${VERSION}.tar.gz is ready for distribution." ;\ + dashes=`echo "$$banner" | sed -e s/./=/g`; \ + echo "$$dashes" ;\ + echo "$$banner" ;\ + echo "$$dashes" + +distsig: dist + ${quiet} ${P_SIG} ${PACKAGE}-${VERSION}.tar.gz + ${quiet} md5sum ${PACKAGE}-${VERSION}.tar.gz | gpg --clearsign \ + >${PACKAGE}-${VERSION}.tar.gz.sig + +.PHONY: help +help: + @echo 'Cleaning targets:' + @echo ' clean - remove most generated files but keep the config' + @echo ' distclean - remove even more generated files, even the config' + @echo ' maintainer-clean - remove all generated files and the config' + @echo '' + @echo 'Other targets:' + @echo ' all - Build all default targets' + @echo " install - Install ${PACKAGE}" + @echo " uninstall - Uninstall ${PACKAGE}" + @echo '' + @echo 'Developer targets:' + @echo ' dir/ - Build all files in dir and below' + @echo ' dir/file - Build specified target only' + @echo ' TAGS - Generate tags file for editors' + @echo '' + @echo ' make VERBOSE=0|1 [targets] 0 => quiet build (default), 1 => verbose build' + @echo '' + @echo 'Execute "make" or "make all" to build all targets.' diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..fbe887c --- /dev/null +++ b/NEWS @@ -0,0 +1,10 @@ +NEWS -- list of user-visible changes -*- outline -*- + +* CryWrap 0.2.1 -- 2004-01-31 + +Updated to use GnuTLS 1.0, and added support for internationalised +domain names (using GNU Libidn). + +* CryWrap 0.2.0 -- 2003-10-02 + +Initial release. diff --git a/README b/README new file mode 100644 index 0000000..746b007 --- /dev/null +++ b/README @@ -0,0 +1,11 @@ +This is CryWrap, a simplistic daemon to add TLS/SSLv3 support to +services that do not support it. + +See the NEWS file for a description of recent changes to CryWrap. + +See the file INSTALL for instructions on how to build and install the +program files. See the CryWrap manual for details about +configuration. Type "man crywrap" in the shell prompt. + +Please visit the official CryWrap web page for more information. The URL +is http://bonehunter.rulez.org/CryWrap.phtml. diff --git a/THANKS b/THANKS new file mode 100644 index 0000000..7051dfd --- /dev/null +++ b/THANKS @@ -0,0 +1,2 @@ +Ferenc Kalcso +Gabor Nyeki diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..835fa1f --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,171 @@ +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright © 2004 Scott James Remnant . +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$PKG_CONFIG"; then + if test -n "$$1"; then + pkg_cv_[]$1="$$1" + else + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + fi +else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES + diff --git a/config.mk.in b/config.mk.in new file mode 100644 index 0000000..f4cddd3 --- /dev/null +++ b/config.mk.in @@ -0,0 +1,9 @@ +## config.mk.in -- Configuration for Mk/ +## arch-tag: 9fe53796-c387-4cd8-af4c-0817d0ccc9da + +PACKAGE = crywrap +BRANCH = 0.2 +PATCHLEVEL = 1 +DIST = stable + +SNAPLOG = ${top_srcdir}/ChangeLog diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..55b71fd --- /dev/null +++ b/configure.ac @@ -0,0 +1,135 @@ +# arch-tag: 9e49a1d9-1005-4ae9-8bf1-04a7b9b80285 +dnl configure.ac for CryWrap +dnl Copyright (C) 2003, 2004 Gergely Nagy +dnl +dnl Process this file with autoconf to produce a configure script. +dnl +dnl This file is part of CryWrap. +dnl +dnl CryWrap is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl CryWrap is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +dnl ********************** +dnl * Boilerplate +dnl ********************** +AC_PREREQ(2.53) +AC_INIT([crywrap], [0.2-stable], [algernon@bonehunter.rulez.org]) +AC_CONFIG_SRCDIR(src/crywrap.c) + +AC_CONFIG_HEADERS(system.h) + +AC_CANONICAL_HOST +AC_SUBST(host_os) + +dnl ********************** +dnl * Programs +dnl ********************** +BHM4_CC_CHECK + +AC_PROG_INSTALL + +BHMK_MAKE_CHECK + +dnl ********************** +dnl * Headers +dnl ********************** +AC_HEADER_SYS_WAIT + +AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/select.h sys/types.h]) + +dnl ********************** +dnl * Typedefs & co +dnl ********************** +AC_STRUCT_TM +AC_TYPE_UID_T +AC_TYPE_PID_T + +BHM4_TCP_CORK_CHECK +BHM4_SOCKADDR_STORAGE_CHECK + +dnl ********************** +dnl * Library functions +dnl ********************** +AC_FUNC_FORK +AC_TYPE_SIGNAL +AC_FUNC_STAT +AC_FUNC_LSTAT +AC_FUNC_CLOSEDIR_VOID +AC_FUNC_STRFTIME +AC_FUNC_MEMCMP +AC_FUNC_VPRINTF +AC_FUNC_SELECT_ARGTYPES +AC_FUNC_MMAP +AC_CHECK_FUNCS([alarm atexit dup2 epoll_create kqueue memchr memset munmap \ + putenv regcomp scandir select socket strcasecmp strchr \ + strdup strerror strncasecmp strrchr strstr strtoul uname]) +AC_CHECK_FUNC([sendfile], [], [AC_CHECK_LIB(sendfile, sendfile)]) + +dnl ********************** +dnl * BH compat suite +dnl ********************** + +BHCOMPAT_CHECK + +dnl ********************** +dnl * Rest +dnl ********************** + +PKG_CHECK_MODULES([LIBGNUTLS], [gnutls]) + +AC_CHECK_HEADER(idna.h, + AC_CHECK_LIB(idn, stringprep_check_version, + [libidn=yes; AC_SUBST(SHISHI_LIBS, -lidn)], libidn=no)) + +if test "$libidn" != "no" ; then + AC_DEFINE(USE_LIBIDN, 1, [Define to 1 if you want Libidn.]) +else + AC_MSG_ERROR([You need Libidn to compile CryWrap]) +fi + +dnl ********************** +dnl * Features +dnl ********************** +dnl * Fork +AC_ARG_ENABLE(fork, + AC_HELP_STRING([--disable-fork], [disable forking to background]), + [f_fork="$enableval"], [f_fork="yes"]) +if test "x$f_fork" != "xno"; then + AC_DEFINE_UNQUOTED(CRYWRAP_OPTION_FORK, 1, + Define this to enable forking to background) +else + AC_DEFINE_UNQUOTED(CRYWRAP_OPTION_NOFORK, 1, + Define this to disable forking to background) +fi + +dnl ********************** +dnl * Output +dnl ********************** +AC_CONFIG_FILES([ +Makefile +Mk/Rules.mk +Mk/Makefile +config.mk +doc/Makefile +etc/Makefile +history/Makefile +lib/Makefile +lib/compat/Makefile +m4/Makefile +m4/bh-m4/Makefile +src/Makefile +utils/Makefile +]) + +AC_OUTPUT diff --git a/crywrap.doxy b/crywrap.doxy new file mode 100644 index 0000000..c60f5f3 --- /dev/null +++ b/crywrap.doxy @@ -0,0 +1,59 @@ +# arch-tag: 0dd027b6-52b9-44e6-a80e-512ac63d1da0 +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- + +PROJECT_NAME = CryWrap +OUTPUT_DIRECTORY = doxygen + +EXTRACT_ALL = NO +EXTRACT_STATIC = YES + +INTERNAL_DOCS = YES + +JAVADOC_AUTOBRIEF = YES + +OPTIMIZE_OUTPUT_FOR_C = YES + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +QUIET = YES +WARN_IF_UNDOCUMENTED = NO + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +INPUT = src/ lib/compat/ +FILE_PATTERNS = *.c *.h + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +SOURCE_BROWSER = YES +INLINE_SOURCES = YES + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +GENERATE_HTML = YES +HTML_ALIGN_MEMBERS = YES + +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +GENERATE_LATEX = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +PREDEFINED = __DOXYGEN__ diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..ec5935d --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,27 @@ +## doc/Makefile.in +## arch-tag: 2edf562c-a055-44dd-b739-ff6bf30061df + +## -- User-modifiable variables -- ## +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = doc + +## == The code below shouldn't need to be touched at all == ## + +## -- Private variables -- ## +MAN8 = crywrap.8 +EXTRA_DIST = ${MAN8}.in + +include ../Mk/Rules.mk + +## -- Generic rules -- ## +all:: ${MAN} + +install:: all + ${quiet} ${P_INST} ${DESTDIR}${man8dir}/crywrap.8 + ${quiet} ${INSTALL} -d ${DESTDIR}${man8dir} + ${quiet} ${INSTALL_DATA} crywrap.8 ${DESTDIR}${man8dir}/ + +uninstall:: + ${quiet} ${P_UNINST} ${DESTDIR}${man8dir}/crywrap.8 + ${quiet} rm -f ${DESTDIR}${man8dir}/crywrap.8 diff --git a/doc/crywrap.8.in b/doc/crywrap.8.in new file mode 100644 index 0000000..b9abef2 --- /dev/null +++ b/doc/crywrap.8.in @@ -0,0 +1,124 @@ +.\" -*- nroff -*- +.\" This manual is for CRYWrap +.\" +.\" Copyright (C) 2003 Gergely Nagy +.\" +.\" Permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Permission is granted to copy and distribute translations of this +.\" manual into another language, under the above conditions for modified +.\" versions, except that this permission notice may be stated in a +.\" translation approved by the Author. +.TH CRYWRAP 8 "03 May 2003" "CryWrap @VERSION@" "CryWrap" +.SH "NAME" +CryWrap \- Simple TCP/IP service encryption using TLS/SSL +.SH "SYNOPSIS" +.BI "crywrap \-\-listen " HOST / PORT " \-\-destination " HOST / PORT +.BI [ options ] +.SH "DESCRIPTION" +.B CryWrap +is a simple wrapper that waits for TLS/SSL connections, and proxies +them to an unencrypted location. +.SH "OPTIONS" +.B CryWrap +takes the following options: +.SS "Required options" +.TP +.BI "\-\-destionation (\-d) " HOST / PORT +The destionation host and address, where CryWrap should connect +to. Both arguments are required. +.SS "TLS options" +.TP +.B \-\-anon (\-a) +Enables Anon-DH mode. If enabled, no certificate will be sent to the +client, and only anonymous sessions will be enabled. +.br +Default is \fBoff\fR. +.TP +.BI "\-\-pem (\-p) " cert = PATH , key = PATH +.TP +.BI "\-\-pem (\-p) " PATH +.br +The public certificate to send to clients, and the private server key. +If one of \fIcert\fR or \fIkey\fR is omitted, the value of the other +will be used for the missing one too. +If no \fIcert=\fR or \fIkey=\fR tag is given, \fIPATH\fR will be used +for both. +.br +Default is \fB@pkgconfdir@/server.pem\fR, unless \fB--anon\fR is also +specified, in which case no certificate will be used. +.TP +.BI "\-\-verify (\-v) [" LEVEL ] +Set the level of client certificate verification. Level one simply +logs the result, level two and above abort if the certificate could +not be verified. +.br +Default is \fB0\fR. +.SS "Miscellaneous options" +.TP +.B \-\-inetd (\-i) +Enable inetd-mode. Use this if you want to run CryWrap from inetd. If +this option is not enabled, then \fB\-\-listen\fR is a required +option. +.br +Default is \fBoff\fR. +.TP +.BI "\-\-listen (\-l) " HOST / PORT +The host and port CryWrap should listen on. \fIHOST\fR can be an IPv4 +or IPv6 address, or a hostname, and is optional \- if unspecified, +CryWrap will listen on all available addresses. \fIPORT\fR is +mandatory. +.br +This option is required, unless CryWrap was put into inetd mode. +.TP +.BI "\-\-pidfile (\-P) " PIDFILE +Write the pid thy runs with to +.IR PIDFILE . +.br +Default is +.BR /var/run/crywrap.pid . +.TP +.BI "\-\-user (\-u) " UID +.I UID +is the numerical user id of the user thy should run as. +.br +Default is +.BR 65534 . +.TP +.B \-\-version (\-V) +Print the version number and exit. +.TP +.B \-\-help (\-?) +Print a verbose help screen and exit. +.TP +.B \-\-usage +Print a short summary of options. +.SH "EXAMPLES" +.SS "Setting up pop3s" +.nf +crywrap \-\-listen /995 \-\-destination localhost/110 +.fi +.SS "Setting up imaps with a different certificate" +.nf +crywrap \-\-listen /993 \-\-destination localhost/143 \\ + \-\-pem /etc/ssl/certs/imap.pem +.fi +.SH "FILES" +.TP +.I @pkgconfdir@/ +.RS +This directory contains the default server key and certificate. +.RE +.SH "BUGS" +Probably many. +.SH "AUTHOR" +Gergely Nagy + +.\" arch-tag: d80bd2eb-0f51-4309-9542-9426f6cc9183 diff --git a/etc/Makefile.in b/etc/Makefile.in new file mode 100644 index 0000000..25abc36 --- /dev/null +++ b/etc/Makefile.in @@ -0,0 +1,14 @@ +## etc/Makefile +## arch-tag: f715ad58-c244-468d-ac4c-6417affa5f78 + +## -- User-modifiable variables -- ## +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = etc + +## == The code below shouldn't need to be touched at all == ## + +## -- Private variables -- ## +EXTRA_DIST = crywrap.conf crywrap-init.d + +include ../Mk/Rules.mk diff --git a/etc/crywrap-init.d b/etc/crywrap-init.d new file mode 100755 index 0000000..7683883 --- /dev/null +++ b/etc/crywrap-init.d @@ -0,0 +1,97 @@ +#! /bin/sh +## /etc/init.d/crywrap -- init script for CryWrap +## (Generic, used for Debian) +## +## arch-tag: 95d90d0c-199e-4f43-9bf3-33706a009a19 + +set -e + +CRYWRAP=/usr/sbin/crywrap +CONFFILE=/etc/default/crywrap +PIDDIR=/var/run/crywrap + +test -x ${CRYWRAP} || exit 0 + +## Ignore starts here.. +# crywrap_map_add dest listen +crywrap_map_add () +{ + SRC_PORT="$(echo $1 | sed -e 's,^.*/,,g')" + SRC_IP="$(echo $1 | sed -e 's,/.*,,g')" + DST_PORT="$(echo $2 | sed -e 's,^.*/,,g')" + DST_IP="$(echo $2 | sed -e 's,/.*,,g')" + + CRYWRAP_MAP="${CRYWRAP_MAP}-d ${SRC_IP}/${SRC_PORT} -l ${DST_IP}/${DST_PORT}|" +} +CRYWRAP_MAP= +## Unignore starts here :) + +[ -e ${CONFFILE} ] && . ${CONFFILE} + +crywrap_start () +{ + install -d -m 1777 ${PIDDIR} + cnt=0 + IFS_SAVE="${IFS}" + IFS="|" + set -- ${CRYWRAP_MAP} + while [ "$#" -gt 0 ]; do + PC=""; PK="" + if [ ! -z "${CRYWRAP_CERTFILE}" ]; then + PC="cert=${CRYWRAP_CERTFILE}" + fi + if [ ! -z "${CRYWRAP_KEYFILE}" ]; then + PK="key=${CRYWRAP_KEYFILE}" + fi + P="${PC}${PC:+,}${PK}" + P="${P:+-p ${P}}" + CMDLINE="$1 -P ${PIDDIR}/crywrap-${cnt}.pid ${P} \ + ${CRYWRAP_USER:+-u ${CRYWRAP_USER}} \ + ${CRYWRAP_OPTIONS}" + cnt=$(expr ${cnt} + 1) + eval ${CRYWRAP} ${CMDLINE} + echo -n "." + shift + done + IFS="${IFS_SAVE}" + if [ "$cnt" -eq 0 ]; then + echo " - not started" + else + echo " done." + fi +} + +crywrap_stop () +{ + for PIDFILE in ${PIDDIR}/*; do + if [ -e ${PIDFILE} ]; then + PID=$(cat ${PIDFILE}) + if [ ! -z "${PID}" ]; then + if kill -15 ${PID} >/dev/null 2>&1; then + echo -n "." + fi + fi + fi + rm -f ${PIDFILE} + done + rm -rf ${PIDDIR} +} + +case $1 in + start) + echo -n "Starting TLS wrapper: crywrap" + crywrap_start;; + stop) + echo -n "Stopping TLS wrapper: crywrap" + crywrap_stop + echo ".";; + restart|force-reload) + $0 stop + sleep 2 + $0 start;; + *) + echo "Usage: /etc/init.d/crywrap {start|stop|restart|force-reload}" + exit 1;; +esac + +exit 0 diff --git a/etc/crywrap.conf b/etc/crywrap.conf new file mode 100644 index 0000000..356c50c --- /dev/null +++ b/etc/crywrap.conf @@ -0,0 +1,34 @@ +## -*- shell-script -*- +## arch-tag: a709d722-6dd7-4074-a988-de34e74d9da4 +## +## This is the configuration file for the CryWrap init script. + +# The public certificate to send to clients +# Default: /etc/crywrap/server.pem +CRYWRAP_CERTFILE= + +# The private server key +# Default: /etc/crywrap/server.pem +CRYWRAP_KEYFILE= + +# The user to run as +# Default: 65534 (nobody) +if getent passwd crywrap 2>&1 >/dev/null; then + CRYWRAP_USER=$(id -u crywrap) +else + CRYWRAP_USER=$(id -u nobody) +fi + +# Various miscellaneous CryWrap options. +# For example, if you want to run CryWrap in anonymous mode, +# use CRYWRAP_OPTIONS="--anon". +CRYWRAP_OPTIONS= + +## Mappings come here +## You can make CryWrap listen on an address/port pair, proxying all +## traffic to anotherhost/anotherport pair by adding a line like this: +# crywrap_map_add anotherhost/anotherport address/port +# +## For example, if you want CryWrap to listen on 10.0.0.1/pop3s, +## proxying all requests to 192.168.0.2/pop3, you would add this: +# crywrap_map_add 192.168.0.2/pop3 10.0.0.1/pop3s diff --git a/history/ChangeLog-0.1 b/history/ChangeLog-0.1 new file mode 100644 index 0000000..438f119 --- /dev/null +++ b/history/ChangeLog-0.1 @@ -0,0 +1,1110 @@ +# do not edit -- automatically generated by arch changelog +# arch-tag: automatic-ChangeLog--algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1 +# + +2003-05-05 16:29:28 GMT Gergely Nagy patch-64 + + Summary: + Fixed the init script + Revision: + tlswrap--0.1--patch-64 + + * etc/crywrap-init.d (crywrap_start): Only pass -p, if there is a + pemfile specified. + + Noticed by Ferenc Kalcso. + + modified files: + ChangeLog etc/crywrap-init.d + + +2003-05-03 15:53:21 GMT Gergely Nagy patch-63 + + Summary: + In-line documentation updates + Revision: + tlswrap--0.1--patch-63 + + * src/crywrap.c: Updated some of the internal documentation, so it looks + better after a doxygen run (and the full source is there). + + modified files: + ChangeLog src/crywrap.c + + +2003-05-03 15:19:06 GMT Gergely Nagy patch-62 + + Summary: + Added `make distsig' + Revision: + tlswrap--0.1--patch-62 + + * Makefile.in (distsig): New target. + + modified files: + ChangeLog Makefile.in + + +2003-05-03 15:15:05 GMT Gergely Nagy patch-61 + + Summary: + Use libgnutls.m4 + Revision: + tlswrap--0.1--patch-61 + + * libgnutls.m4: New file. + * Makefile.in (EXTRA_DIST): Added it. + * configure.ac: Use AM_PATH_LIBGNUTLS. + + new files: + .arch-ids/libgnutls.m4.id libgnutls.m4 + + modified files: + ChangeLog Makefile.in configure.ac + + +2003-05-03 15:07:27 GMT Gergely Nagy patch-60 + + Summary: + Renamed to CryWrap + Revision: + tlswrap--0.1--patch-60 + + Since there already is a project called TLSWrap, renamed this stuff to + CryWrap. + + modified files: + ChangeLog Makefile.in README Rules.mk.in configure.ac + crywrap.doxy debian/README.Debian debian/changelog + debian/control debian/copyright debian/maint/postinst + debian/maint/postrm debian/maint/prerm debian/rules + doc/Makefile.in doc/crywrap.8.in etc/Makefile.in + etc/crywrap-init.d etc/crywrap.conf src/Makefile.in + src/crywrap.c src/crywrap.h src/primes.h utils/sslwrap + + renamed files: + .arch-ids/tlswrap.doxy.id + ==> .arch-ids/crywrap.doxy.id + src/.arch-ids/tlswrap.h.id + ==> src/.arch-ids/crywrap.h.id + src/.arch-ids/tlswrap.c.id + ==> src/.arch-ids/crywrap.c.id + etc/.arch-ids/tlswrap.conf.id + ==> etc/.arch-ids/crywrap.conf.id + etc/.arch-ids/tlswrap-init.d.id + ==> etc/.arch-ids/crywrap-init.d.id + doc/.arch-ids/tlswrap.8.in.id + ==> doc/.arch-ids/crywrap.8.in.id + tlswrap.doxy + ==> crywrap.doxy + src/tlswrap.h + ==> src/crywrap.h + src/tlswrap.c + ==> src/crywrap.c + etc/tlswrap.conf + ==> etc/crywrap.conf + etc/tlswrap-init.d + ==> etc/crywrap-init.d + doc/tlswrap.8.in + ==> doc/crywrap.8.in + + +2003-04-29 23:31:11 GMT Gergely Nagy patch-59 + + Summary: + Fixed pidfile creation + Revision: + tlswrap--0.1--patch-59 + + * src/tlswrap.c (main): Move the _tlswrap_setup_pidfile() call before + _tlswrap_drop_privs(), so we can write to a root.root 755 /var/run. + + Noticed and reported by Xeon. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-21 10:53:34 GMT Gergely Nagy patch-58 + + Summary: + Initial Debianisation + Revision: + tlswrap--0.1--patch-58 + + Added the debian/ infrastructure. + + new files: + debian/.arch-ids/=id debian/.arch-ids/changelog.id + debian/.arch-ids/control.id debian/.arch-ids/copyright.id + debian/maint/.arch-ids/=id debian/maint/.arch-ids/postinst.id + debian/maint/.arch-ids/postrm.id + debian/maint/.arch-ids/prerm.id debian/.arch-ids/rules.id + debian/.arch-ids/README.Debian.id debian/changelog + debian/control debian/copyright debian/maint/postinst + debian/maint/postrm debian/maint/prerm debian/rules + debian/README.Debian + + modified files: + ChangeLog + + new directories: + debian/.arch-ids debian/maint/.arch-ids debian debian/maint + + +2003-04-21 10:49:00 GMT Gergely Nagy patch-57 + + Summary: + TLSWRAP_OPTIONS + Revision: + tlswrap--0.1--patch-57 + + * etc/tlswrap.conf (TLSWRAP_OPTIONS): New variable. + * etc/tlswrap-init.d (tlswrap_start): Use it. + + modified files: + ChangeLog etc/tlswrap-init.d etc/tlswrap.conf + + +2003-04-21 09:46:46 GMT Gergely Nagy patch-56 + + Summary: + Init script conffile comments + Revision: + tlswrap--0.1--patch-56 + + * etc/tlswrap.conf: Added some comments, and disabled all non-default + settings. + * etc/tlswrap-init.d: Emit a message if no services were started. + + modified files: + ChangeLog etc/tlswrap-init.d etc/tlswrap.conf + + +2003-04-21 09:16:01 GMT Gergely Nagy patch-55 + + Summary: + Added NEWS and THANKS + Revision: + tlswrap--0.1--patch-55 + + * NEWS: New file. + * THANKS: Likewise. + * Makefile.in (EXTRA_DIST): Include them. + + new files: + .arch-ids/NEWS.id .arch-ids/THANKS.id NEWS THANKS + + modified files: + ChangeLog Makefile.in + + +2003-04-20 22:30:30 GMT Gergely Nagy patch-54 + + Summary: + Updated init script + Revision: + tlswrap--0.1--patch-54 + + * etc/tlswrap-init.d: Updated start/stop messages to look nicer. + + modified files: + ChangeLog etc/tlswrap-init.d + + +2003-04-19 17:10:52 GMT Gergely Nagy patch-53 + + Summary: + ICC fix + Revision: + tlswrap--0.1--patch-53 + + * src/primes.h (_tlswrap_prime_dh_1024): Declared static. + (_tlswrap_generator_dh): Likewise. + + modified files: + ChangeLog src/primes.h + + +2003-04-19 16:47:19 GMT Gergely Nagy patch-52 + + Summary: + Support for non-numeric services + Revision: + tlswrap--0.1--patch-52 + + * src/tlswrap.c (_tlswrap_port_get): New function. + (_tlswrap_addr_get): Use it. + * src/tlswrap-init.d (tlswrap_map_add): Removed service resolving + code, it is handled by tlswrap itself. + + modified files: + ChangeLog etc/tlswrap-init.d src/tlswrap.c + + +2003-04-18 12:36:56 GMT Gergely Nagy patch-51 + + Summary: + Some more debugging aid + Revision: + tlswrap--0.1--patch-51 + + * src/tlswrap.c (_tlswrap_do_one): Return instead of exiting. + All users updated appropriately. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-18 12:30:56 GMT Gergely Nagy patch-50 + + Summary: + Client certificate verification, part one + Revision: + tlswrap--0.1--patch-50 + + * src/tlswrap.h (tlswrap_config_t): Added a `verify' member. + * src/tlswrap.c (_tlswrap_options): Added --verify. + (_tlswrap_config_parse_opt): Parse it. + (_tlswrap_config_parse): Default to off. + (_tlswrap_tls_session_create): Request a client certificate if + verification is turned on. + (_tlswrap_do_one): Verify the certificate if requested. + * doc/tlswrap.8.in (OPTIONS): Updated accordingly. + * utils/sslwrap: Likewise. + + modified files: + ChangeLog doc/tlswrap.8.in src/tlswrap.c src/tlswrap.h + utils/sslwrap + + +2003-04-18 11:58:26 GMT Gergely Nagy patch-49 + + Summary: + Option reordering + Revision: + tlswrap--0.1--patch-49 + + * src/tlswrap.c (_tlswrap_options): Moved `anon' to group two, and + reworded the --pem option string. + * doc/tlswrap.8.in (OPTIONS): Updated accordingly. + + modified files: + ChangeLog doc/tlswrap.8.in src/tlswrap.c + + +2003-04-18 11:35:46 GMT Gergely Nagy patch-48 + + Summary: + --version + Revision: + tlswrap--0.1--patch-48 + + * src/tlswrap.c (argp_program_version): Defined. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-18 11:19:42 GMT Gergely Nagy patch-47 + + Summary: + Do not allow port to be 0 + Revision: + tlswrap--0.1--patch-47 + + * src/tlswrap.c (_tlswrap_parse_ip): Return -1 if *port is 0. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-18 11:16:19 GMT Gergely Nagy patch-46 + + Summary: + sslwrap emulation + Revision: + tlswrap--0.1--patch-46 + + * utils/sslwrap: New file. + * utils/Makefile.in: Likewise. + * configure.ac (AC_CONFIG_OUTPUT): Added utils/Makefile. + * Makefile.in: Descend into utils from the appropriate targets. + + Fixes #0000026. + + new files: + utils/.arch-ids/=id utils/.arch-ids/Makefile.in.id + utils/.arch-ids/sslwrap.id utils/Makefile.in utils/sslwrap + + modified files: + ChangeLog Makefile.in configure.ac + + new directories: + utils/.arch-ids utils + + +2003-04-18 11:04:28 GMT Gergely Nagy patch-45 + + Summary: + Small fix to the init script + Revision: + tlswrap--0.1--patch-45 + + * etc/tlswrap-init.d (tlswrap_start): Only put a `,' between PC and PK + if PC is set, otherwise bad things may happen. + + modified files: + ChangeLog etc/tlswrap-init.d + + +2003-04-18 10:25:18 GMT Gergely Nagy patch-44 + + Summary: + Anon-DH support + Revision: + tlswrap--0.1--patch-44 + + * src/tlswrap.h (tlswrap_config_t): Added an `anon' member. + * src/tlswrap.c (_tlswrap_options): Added --anon. + (_tlswrap_config_parse_opt): Handle --anon, and do not load the + default certificate if it was specified. + (_tlswrap_config_parse): Turn anon-dh off by default. + (_tlswrap_tls_session_create): Take a `config' argument, and allow + anon-dh only if config->anon is set. + (_tlswrap_do_one): Pass `config' down to + _tlswrap_tls_session_create(). + * doc/tlswrap.8.in (OPTIONS): Documented --anon. + + Fixes #0000025. + + modified files: + ChangeLog doc/tlswrap.8.in src/tlswrap.c src/tlswrap.h + + +2003-04-18 09:51:12 GMT Gergely Nagy patch-43 + + Summary: + Using pre-generated DH primes + Revision: + tlswrap--0.1--patch-43 + + * src/primes.h: New file. + * src/Makefile.in (HEADERS): Added it. + (tlswrap.o): Added it to the pre-requisites. + * src/tlswrap.c (_tlswrap_sighup_handler): New function. + (_tlswrap_tls_reinit): Renamed to... + (_tlswrap_tls_init): ..this, and changed to use the pre-generated + primes. + (main): Call _tlswrap_tls_init() early, and set up a SIGHUP handler. + + + new files: + src/.arch-ids/primes.h.id src/primes.h + + modified files: + ChangeLog src/Makefile.in src/tlswrap.c + + +2003-04-17 22:14:54 GMT Gergely Nagy patch-42 + + Summary: + inetd mode + Revision: + tlswrap--0.1--patch-42 + + * src/tlswrap.h (tlswrap_config_t): Added an `inetd' member. + * src/tlswrap.c (_tlswrap_options): Added --inetd, and moved --listen + to group three. + (_tlswrap_config_parse_opt): Handle --inetd. At the end, don't bail + out if there is no listening address when in inetd mode. + (_tlswrap_config_parse): Disable inetd mode by default. + (_tlswrap_do_one): Take two sockets: one input and one output. Use + gnutls_transport_set_ptr2() to set them. Close both at the end. + All users updated. + (main): Added inetd mode. + * doc/tlswrap.8.in (OPTIONS): Updated in the light of the above + changes. + + Fixes #0000024. + + modified files: + ChangeLog doc/tlswrap.8.in src/tlswrap.c src/tlswrap.h + + +2003-04-17 21:49:48 GMT Gergely Nagy patch-41 + + Summary: + Initfile fixes + Revision: + tlswrap--0.1--patch-41 + + * etc/tlswrap.conf: Moved the map update function to the init script. + * etc/tlswrap-init.d (tlswrap_map_add): Moved here, fixed syntax error, + and added support for services not listed in /etc/services. + + modified files: + ChangeLog etc/tlswrap-init.d etc/tlswrap.conf + + +2003-04-17 16:53:54 GMT Gergely Nagy patch-40 + + Summary: + Use a default certificate + Revision: + tlswrap--0.1--patch-40 + + * src/tlswrap.h (_TLSWRAP_PEMFILE): New define. + * src/tlswrap.c (_tlswrap_config_parse_opt): If there wasn't any + certificate explictly set, use the default one. + + Fixes #0000021 + + modified files: + ChangeLog src/tlswrap.c src/tlswrap.h + + +2003-04-17 08:20:47 GMT Gergely Nagy patch-39 + + Summary: + Doxygen docs + Revision: + tlswrap--0.1--patch-39 + + * tlswrap.doxy: New file. + * src/tlswrap.h: Documented everything, and move the options here from + src/tlswrap.c. + * src/tlswrap.c: Documented everything. + * Makefile.in (doxy): New target. + (.PHONY): Likewise. + (EXTRA_DIST): Added tlswrap.doxy. + + new files: + .arch-ids/tlswrap.doxy.id tlswrap.doxy + + modified files: + ChangeLog Makefile.in src/tlswrap.c src/tlswrap.h + + +2003-04-17 07:03:13 GMT Gergely Nagy patch-38 + + Summary: + Manpage update + Revision: + tlswrap--0.1--patch-38 + + * doc/tlswrap.8: Updated to the new command-line syntax. + + Fixes #0000020. + + modified files: + ChangeLog doc/tlswrap.8.in + + +2003-04-16 21:59:35 GMT Gergely Nagy patch-37 + + Summary: + init script update + Revision: + tlswrap--0.1--patch-37 + + * etc/tlswrap-init.d: Updated for new commandline syntax. + + modified files: + ChangeLog etc/tlswrap-init.d + + +2003-04-16 21:50:36 GMT Gergely Nagy patch-36 + + Summary: + TLS dnsname support + Revision: + tlswrap--0.1--patch-36 + + * src/tlswrap.c (_tlswrap_session_cert_select): New function. + (_tlswrap_tls_session_create): Use it. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 21:47:10 GMT Gergely Nagy patch-35 + + Summary: + Treat -p STUFF as -p cert=STUFF + Revision: + tlswrap--0.1--patch-35 + + * src/tlswrap.c (_tlswrap_config_parse): Treat -p STUFF as -p + cert=STUFF. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 21:40:19 GMT Gergely Nagy patch-34 + + Summary: + Multi-cert support + Revision: + tlswrap--0.1--patch-34 + + * src/tlswrap.h (tlswrap_config_t): Removed ->certfile and ->keyfile. + * src/tlswrap.c (_tlswrap_options): Removed -c and -k, added -p. + (_tlswrap_addr_get): Do not report the error, return -1, and let + _tlswrap_config_parse() report it. + (_tlswrap_parse_ip): Return whatever _tlswrap_addr_get() returns. + (_tlswrap_config_parse): Parse -p. + (_tlswrap_tls_init): Moved it mostly to main() and + _tlswrap_config_parse(). + (main): Moved some of the ex-_tlswrap_tls_init() stuff here, and + changed to call _tlswrap_tls_reinit(). + + modified files: + ChangeLog src/tlswrap.c src/tlswrap.h + + +2003-04-16 20:47:56 GMT Gergely Nagy patch-33 + + Summary: + Fixed a warning in debug mode + Revision: + tlswrap--0.1--patch-33 + + * src/tlswrap.c [!TLSWRAP_OPTION_DEBUG] (main): Do not define `child' in + this case. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 20:46:03 GMT Gergely Nagy patch-32 + + Summary: + Cleanup _tlswrap_do_one() + Revision: + tlswrap--0.1--patch-32 + + * src/tlswrap.c (_tlswrap_do_one): Removed fdset_o, it is not used. Also + renamed fdset_i to fdset. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 20:44:05 GMT Gergely Nagy patch-31 + + Summary: + Close the client socket after gnutls_bye() + Revision: + tlswrap--0.1--patch-31 + + * src/tlswrap.c (_tlswrap_do_one): Close the client socket after + gnutls_bye(). + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 20:42:00 GMT Gergely Nagy patch-30 + + Summary: + Yet more logging + Revision: + tlswrap--0.1--patch-30 + + * src/tlswrap.c (_tlswrap_do_one): Log the IP and FD of the connecting + client. Also reformatted some of the messages to be more consistent. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 20:34:22 GMT Gergely Nagy patch-29 + + Summary: + Less aggressive TLS push + Revision: + tlswrap--0.1--patch-29 + + * src/tlswrap.c (_tlswrap_do_one): Quit the TLS push loop when ret <= o, + ie, when the full buffer was flushed. This saves us from an ugly + warning. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 20:27:56 GMT Gergely Nagy patch-28 + + Summary: + Debugging aid + Revision: + tlswrap--0.1--patch-28 + + * src/tlswrap.c [TLSWRAP_OPTION_DEBUG] (main): Do not fork for each + connection, but handle them in order. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 20:23:10 GMT Gergely Nagy patch-27 + + Summary: + #include cleanup + Revision: + tlswrap--0.1--patch-27 + + * src/tlswrap.c: Cleaned up the #includes. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 20:21:36 GMT Gergely Nagy patch-26 + + Summary: + Fixed TLS data pushing + Revision: + tlswrap--0.1--patch-26 + + * src/tlswrap.c (_tlswrap_set_blocking): Removed. + (_tlswrap_do_one): Buffer is a `char' array, not a `char *' + one. Also removed the O_NONBLOCK fiddling, improved the error + messages, and added a while guard for gnutls_record_send. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 19:44:09 GMT Gergely Nagy patch-25 + + Summary: + Introducing: a manual page + Revision: + tlswrap--0.1--patch-25 + + * doc/tlswrap.8.in: New file. + * doc/Makefile.in: New file. + * configure.ac (AC_CONFIG_FILES): Added doc/Makefile. + * Makefile.in (all): Descend into doc/. + (install): Likewise. + (uninstall): Likewise. + (mostlyclean): Likewise. + (clean): Likewise. + (distclean): Likewise. + (dist): Likewise. + + new files: + doc/.arch-ids/=id doc/.arch-ids/tlswrap.8.in.id + doc/.arch-ids/Makefile.in.id doc/tlswrap.8.in doc/Makefile.in + + modified files: + ChangeLog Makefile.in configure.ac + + new directories: + doc/.arch-ids doc + + +2003-04-16 19:21:39 GMT Gergely Nagy patch-24 + + Summary: + Makefile cleanup + Revision: + tlswrap--0.1--patch-24 + + * Rules.mk.in: Cleaned up some uneeded cruft. + + modified files: + ChangeLog Rules.mk.in + + +2003-04-16 19:17:55 GMT Gergely Nagy patch-23 + + Summary: + Another ICC fix + Revision: + tlswrap--0.1--patch-23 + + * src/tlswrap.c (_tlswrap_setup_pidfile): Use `%d' in the format string, + not `%u'. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 19:13:41 GMT Gergely Nagy patch-22 + + Summary: + ICC fixes + Revision: + tlswrap--0.1--patch-22 + + * src/tlswrap.h (tlswrap_config_t): int -> in_port_t. + All users updated. + * src/tlswrap.c (_tlswrap_parse_ip): Use pointer arithmetic instead of + computing strlen(). + (_tlswrap_sighandler): closelog(). + (main): Removed closelog(). + * src/Makefile.in (WFLAGS_ICC): Adjusted. + + modified files: + ChangeLog src/Makefile.in src/tlswrap.c src/tlswrap.h + + +2003-04-16 18:28:49 GMT Gergely Nagy patch-21 + + Summary: + Re-added an error message + Revision: + tlswrap--0.1--patch-21 + + * configure.ac: Bail out if GNUTLS is not found. + + modified files: + ChangeLog configure.ac + + +2003-04-16 18:27:27 GMT Gergely Nagy patch-20 + + Summary: + Added etc/ + Revision: + tlswrap--0.1--patch-20 + + * etc/tlswrap.conf: New file. + * etc/tlswrap-init.d: Likewise. + * etc/Makefile.in: Likewise. + * configure.ac (AC_CONFIG_FILES): Added etc/Makefile. + * Makefile.in (all): Descend into etc. + (install): Likewise. + (uninstall): Likewise. + (mostlyclean): Likewise. + (clean): Likewise. + (distclean): Likewise. + (dist): Likewise. + + new files: + etc/.arch-ids/=id etc/.arch-ids/tlswrap.conf.id + etc/.arch-ids/tlswrap-init.d.id etc/.arch-ids/Makefile.in.id + etc/tlswrap.conf etc/tlswrap-init.d etc/Makefile.in + + modified files: + ChangeLog Makefile.in configure.ac + + new directories: + etc/.arch-ids etc + + +2003-04-16 18:18:06 GMT Gergely Nagy patch-19 + + Summary: + Doc update + Revision: + tlswrap--0.1--patch-19 + + * src/tlswrap.c (_tlswrap_options): Updated -l and -d documentation. The + separator is `/', not `:'. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 18:16:35 GMT Gergely Nagy patch-18 + + Summary: + Better network error reporting + Revision: + tlswrap--0.1--patch-18 + + * src/tlswrap.c (_tlswrap_addr_get): Report and exit if the host could + not be resolved. + (_tlswrap_bind): Report unsupported AFs. + (_tlswrap_listen): Do not mangle _tlswrap_bind()s return value. + (main): If server_socket is negative, exit. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 18:04:17 GMT Gergely Nagy patch-17 + + Summary: + Correctly report the address we bound to + Revision: + tlswrap--0.1--patch-17 + + * src/tlswrap.c (_tlswrap_bind): Do not use getsockname(), as we already + have the required information at hand. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 17:46:50 GMT Gergely Nagy patch-16 + + Summary: + Allow non-numeric hosts, and shut down the TLS stuff on error. + Revision: + tlswrap--0.1--patch-16 + + * src/tlswrap.c (_tlswrap_addr_get): Do not set AI_NUMERICHOST. + (_tlswrap_do_one): Shut down the client upon a failed handshake. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 17:32:54 GMT Gergely Nagy patch-15 + + Summary: + sockaddr_storage stuff converted to pointers + Revision: + tlswrap--0.1--patch-15 + + * src/tlswrap.h (tlswrap_config_t): Converted all sockaddr_storage + variables to pointers. + + All users updated. + + modified files: + ChangeLog src/tlswrap.c src/tlswrap.h + + +2003-04-16 16:24:14 GMT Gergely Nagy patch-14 + + Summary: + Exit in the signal handler + Revision: + tlswrap--0.1--patch-14 + + * src/tlswrap.c (_tlswrap_sighandler): exit (0); + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 15:32:54 GMT Gergely Nagy patch-13 + + Summary: + Reordered options + Revision: + tlswrap--0.1--patch-13 + + * src/tlswrap.c (_tlswrap_options): Put the options into logical groups. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 15:13:17 GMT Gergely Nagy patch-12 + + Summary: + Added README + Revision: + tlswrap--0.1--patch-12 + + * README: New file. + + new files: + .arch-ids/README.id README + + modified files: + ChangeLog + + +2003-04-16 15:10:37 GMT Gergely Nagy patch-11 + + Summary: + Bail out if a file is not found during make dist + Revision: + tlswrap--0.1--patch-11 + + * Rules.mk.in (distdir): Use set -e. + + modified files: + ChangeLog Rules.mk.in + + +2003-04-16 15:07:24 GMT Gergely Nagy patch-10 + + Summary: + Pidfile support + Revision: + tlswrap--0.1--patch-10 + + * src/tlswrap.h (tlswrap_config_t): Added a `pidfile' member. + * src/tlswrap.c (_tlswrap_options): Added --pidfile. + (_tlswrap_config_parse): Parse it. + [TLSWRAP_OPTION_PIDFILE] (_tlswrap_setup_pidfile): New function. + (_tlswrap_sighandler): Likewise. + (main): Use them. + + modified files: + ChangeLog src/tlswrap.c src/tlswrap.h + + +2003-04-16 14:36:22 GMT Gergely Nagy patch-9 + + Summary: + Cosmetic fix + Revision: + tlswrap--0.1--patch-9 + + * src/tlswrap.c (main): Corrected a mis-indentation. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 14:31:18 GMT Gergely Nagy patch-8 + + Summary: + Sanity checking + Revision: + tlswrap--0.1--patch-8 + + * src/tlswrap.c (_tlswrap_config_parse): Hande ARGP_KEY_END, and print + an error if --listen or --destination was not specified. + (_tlswrap_argp): Added \v docs at the end. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 14:18:05 GMT Gergely Nagy patch-7 + + Summary: + --cafile is not used, removed + Revision: + tlswrap--0.1--patch-7 + + * src/tlswrap.h (tlswrap_config_t): Removed the `cafile' member. + * src/tlswrap.c (_tlswrap_options): Removed --cafile. + (_tlswrap_config_parse): Likewise, for parsing. + (_tlswrap_tls_init): Do not initialse CA stuff. + + modified files: + ChangeLog src/tlswrap.c src/tlswrap.h + + +2003-04-16 14:09:15 GMT Gergely Nagy patch-6 + + Summary: + Forking to the background + Revision: + tlswrap--0.1--patch-6 + + * src/tlswrap.c [TLSWRAP_OPTION_FORK] (main): Use daemon() to go into + the background. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 14:03:46 GMT Gergely Nagy patch-5 + + Summary: + Privilege dropping + Revision: + tlswrap--0.1--patch-5 + + * src/tlswrap.h (tlswrap_config_t): Added a `uid' member. + * src/tlswrap.c (_tlswrap_privs_drop): New function. + (_tlswrap_options): Added --user. + (_tlswrap_config_parse): Recognise it. + (main): Use tlswrap_privs_drop(). + + modified files: + ChangeLog src/tlswrap.c src/tlswrap.h + + +2003-04-16 13:53:01 GMT Gergely Nagy patch-4 + + Summary: + Options, part one + Revision: + tlswrap--0.1--patch-4 + + * configure.ac: s/THY/TLSWRAP/ + * src/tlswrap.c: Added an options section, with a set of defines. + + They are not used... yet. + + modified files: + ChangeLog configure.ac src/tlswrap.c + + +2003-04-16 13:48:29 GMT Gergely Nagy patch-3 + + Summary: + Revert part of the previos patch + Revision: + tlswrap--0.1--patch-3 + + * configure.ac: Do not check for gnutls.h and gnutls/compat4.h. + + GNUTLS3 in Debian stable is way too old to support. Should one want to + use tlswrap there, he should compile a static version on a recent + system. + + modified files: + ChangeLog configure.ac + + +2003-04-16 13:24:25 GMT Gergely Nagy patch-2 + + Summary: + Updated documentation + Revision: + tlswrap--0.1--patch-2 + + * src/tlswrap.c (_tlswrap_options): Added some docs. + (_tlswrap_argp): Likewise. + + modified files: + ChangeLog src/tlswrap.c + + +2003-04-16 13:15:12 GMT Gergely Nagy patch-1 + + Summary: + First step towards GNUTLS4 compatibility + Revision: + tlswrap--0.1--patch-1 + + * configure.ac: Check for gnutls.h and gnutls/compat4.h, but not for + gnutls-extra. + * src/Makefile.in (LIBS): Removed -lgnutls-extra. + (tlswrap.o): New target. + * src/tlswrap.c: Adjusted includes. + + modified files: + ChangeLog configure.ac src/Makefile.in src/tlswrap.c + + +2003-04-16 12:50:21 GMT Gergely Nagy base-0 + + Summary: + Initial import + Revision: + tlswrap--0.1--base-0 + + This is the initial import of TLSWrap. It is undocumented, and not too + featureful, but works to some extent. + + new files: + ./.arch-ids/AUTHORS.id ./.arch-ids/COPYING.id + ./.arch-ids/ChangeLog.id ./.arch-ids/INSTALL.id + ./.arch-ids/Makefile.in.id ./.arch-ids/Rules.mk.in.id + ./.arch-ids/config.guess.id ./.arch-ids/config.sub.id + ./.arch-ids/configure.ac.id ./.arch-ids/install-sh.id + ./AUTHORS ./COPYING ./ChangeLog ./INSTALL ./Makefile.in + ./Rules.mk.in ./config.guess ./config.sub ./configure.ac + ./install-sh ./src/.arch-ids/=id + ./src/.arch-ids/Makefile.in.id ./src/.arch-ids/tlswrap.c.id + ./src/.arch-ids/tlswrap.h.id ./src/Makefile.in ./src/tlswrap.c + ./src/tlswrap.h + + diff --git a/history/ChangeLog-0.2 b/history/ChangeLog-0.2 new file mode 100644 index 0000000..2547ef2 --- /dev/null +++ b/history/ChangeLog-0.2 @@ -0,0 +1,114 @@ +# do not edit -- automatically generated by arch changelog +# arch-tag: automatic-ChangeLog--algernon@bonehunter.rulez.org--tla/crywrap--stable--0.2 +# + +2003-10-11 22:28:46 GMT Gergely Nagy patch-1 + + Summary: + documentation update + Revision: + crywrap--stable--0.2--patch-1 + + * debian/README.Debian: Refer to /etc/crywrap instead of /etc/tlswrap. + + modified files: + ChangeLog debian/README.Debian + + +2003-10-02 12:00:13 GMT Gergely Nagy base-0 + + Summary: + CryWrap 0.2.0 release + Revision: + crywrap--stable--0.2--base-0 + + Released CryWrap 0.2.0 out into the wild. + + new patches: + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--base-0 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-1 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-2 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-3 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-4 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-5 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-6 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-7 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-8 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-9 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-10 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-11 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-12 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-13 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-14 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-15 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-16 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-17 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-18 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-19 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-20 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-21 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-22 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-23 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-24 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-25 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-26 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-27 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-28 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-29 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-30 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-31 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-32 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-33 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-34 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-35 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-36 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-37 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-38 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-39 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-40 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-41 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-42 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-43 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-44 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-45 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-46 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-47 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-48 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-49 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-50 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-51 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-52 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-53 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-54 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-55 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-56 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-57 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-58 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-59 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-60 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-61 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-62 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-63 + algernon@bonehunter.rulez.org--iluvatar-archive/tlswrap--0.1--patch-64 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--base-0 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-1 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-2 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-3 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-4 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-5 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-6 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-7 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-8 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-9 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-10 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-11 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-12 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-13 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-14 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-15 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-16 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-17 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-18 + algernon@bonehunter.rulez.org--tla/crywrap--head--0.2--patch-19 + + diff --git a/history/Makefile.in b/history/Makefile.in new file mode 100644 index 0000000..af76074 --- /dev/null +++ b/history/Makefile.in @@ -0,0 +1,14 @@ +## history/Makefile.in +## arch-tag: 391b0e20-53cb-4698-a622-eb01186ed08a + +## -- User-modifiable variables -- ## +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = history + +## == The code below shouldn't need to be touched at all == ## + +## -- Private variables -- ## +EXTRA_DIST = ChangeLog-0.1 ChangeLog-0.2 + +include ../Mk/Rules.mk diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..c122ef9 --- /dev/null +++ b/install.sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/lib/Makefile.in b/lib/Makefile.in new file mode 100644 index 0000000..115a3c3 --- /dev/null +++ b/lib/Makefile.in @@ -0,0 +1,11 @@ +## lib/Makefile +## arch-tag: 5db928be-d78c-4d3d-b1d5-a222ace5d7a6 + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = lib + +## -- Private variables -- ## +SUBDIRS = compat + +include ../Mk/Rules.mk diff --git a/lib/compat/ChangeLog b/lib/compat/ChangeLog new file mode 100644 index 0000000..64e81b4 --- /dev/null +++ b/lib/compat/ChangeLog @@ -0,0 +1,398 @@ +# do not edit -- automatically generated by arch changelog +# arch-tag: automatic-ChangeLog--algernon@bonehunter.rulez.org--tla/compat--mainline--0.1 +# + +2004-01-29 18:46:51 GMT Gergely Nagy patch-25 + + Summary: + compat.m4 + Revision: + compat--mainline--0.1--patch-25 + + * compat.m4: New file. + * Makefile.in {EXTRA_DIST}: Added it. + + new files: + compat.m4 + + modified files: + ChangeLog Makefile.in + + +2003-12-14 14:49:09 GMT Gergely Nagy patch-24 + + Summary: + HAVE_WORKING_REGEX_H & compat-regex.h + Revision: + compat--mainline--0.1--patch-24 + + * compat-regex.h: Do the inclusion only if + HAVE_WORKING_REGEX_H is set (along with the other two). + + modified files: + ChangeLog compat-regex.h + + +2003-12-14 14:07:20 GMT Gergely Nagy patch-23 + + Summary: + Changed a thy_log() to bhc_log() + Revision: + compat--mainline--0.1--patch-23 + + * compat.h [HAVE_VARIADIC_MACROS && BHC_OPTION_ALL_LOGGING]: Changed a + thy_log() define to bhc_log(). + + This fixes Thy compilation on Solaris 9. + + modified files: + ChangeLog compat.h + + +2003-12-14 13:19:18 GMT Gergely Nagy patch-22 + + Summary: + ARGP_KEY_ARG + Revision: + compat--mainline--0.1--patch-22 + + * compat.h [!HAVE_ARGP_PARSE] [ARGP_KEY_ARG]: New define. + * compat.c (argp_parse): Iterate through the remaining args and pass + them to argps->parser with ARGP_KEY_ARG. + + modified files: + ChangeLog compat.c compat.h + + +2003-12-13 15:42:04 GMT Gergely Nagy patch-21 + + Summary: + Protect compat-regex.h from Doxygen + Revision: + compat--mainline--0.1--patch-21 + + * compat-regex.h: Wrapped the whole stuff into an #ifndef __DOXYGEN__. + + modified files: + ChangeLog compat-regex.h + + +2003-12-13 14:57:46 GMT Gergely Nagy patch-20 + + Summary: + compat-regex.h + Revision: + compat--mainline--0.1--patch-20 + + * compat-regex.h: New file (stripped down regex.h from GNU libc). + * Makefile.in (HEADERS): Added compat-regex.h. + + new files: + compat-regex.h + + modified files: + ChangeLog Makefile.in + + +2003-12-12 10:07:02 GMT Gergely Nagy patch-19 + + Summary: + Moved from compat/ to lib/compat/ + Revision: + compat--mainline--0.1--patch-19 + + * Makefile.in: Reflect move from compat/ to lib/compat/. + {subdir}: Likewise. + + modified files: + ChangeLog Makefile.in + + +2003-12-06 10:25:48 GMT Gergely Nagy patch-18 + + Summary: + Fixed argp_parse prototype + Revision: + compat--mainline--0.1--patch-18 + + * compat.h (argp_parse): The fifth argument is an int *, not a plain + int. + * compat.c (argp_parse): Updated to match the prototype. + + Since we did not ever use arg_index, this is purely a cosmetic change. + + modified files: + ChangeLog compat.c compat.h + + +2003-11-29 14:50:29 GMT Gergely Nagy patch-17 + + Summary: + bhc_atoi() + Revision: + compat--mainline--0.1--patch-17 + + * compat.h (bhc_atoi): New prototype. + * compat.c (bhc_atoi): New function. + + modified files: + ChangeLog compat.c compat.h + + +2003-10-31 15:20:27 GMT Gergely Nagy patch-16 + + Summary: + Fixed a warning when compiled with dietlibc + Revision: + compat--mainline--0.1--patch-16 + + * compat.c: Do the rpl_malloc/malloc magic earlier, so we do get + malloc definitions after including the proper header. + + modified files: + ChangeLog compat.c + + +2003-10-26 16:20:15 GMT Gergely Nagy patch-15 + + Summary: + Documented bhc_getsubopt() + Revision: + compat--mainline--0.1--patch-15 + + * compat.h (bhc_getsubopt): Added in-code Doxygen documentation. + + modified files: + ChangeLog compat.h + + +2003-10-25 11:14:53 GMT Gergely Nagy patch-14 + + Summary: + Fixed a typo, and a missing include + Revision: + compat--mainline--0.1--patch-14 + + * compat.h: #include and fix a typo `voic' vs `void'. + + Noticed by Xavier Noria. + + modified files: + ChangeLog compat.h + + +2003-10-24 17:47:47 GMT Gergely Nagy patch-13 + + Summary: + Logging stuff + Revision: + compat--mainline--0.1--patch-13 + + * compat.h (bhc_log): New prototype. + (bhc_error): Likewise. + (bhc_debug): Likewise. + * compat.c (bhc_log): New function. + (bhc_error): Likewise. + (bhc_debug): Likewise. + + modified files: + ChangeLog compat.c compat.h + + +2003-10-23 22:47:27 GMT Gergely Nagy patch-12 + + Summary: + MacOS X support + Revision: + compat--mainline--0.1--patch-12 + + * compat.h: #include earlier. + * compat.c: #include "compat.h" earlier. + + Thanks to Xavier Noria. + + modified files: + ChangeLog compat.c compat.h + + +2003-10-05 11:33:58 GMT Gergely Nagy patch-11 + + Summary: + Fixed argp stuff + Revision: + compat--mainline--0.1--patch-11 + + * compat.c [!HAVE_ARGP_PARSE] {argp_program_version}: Do not + initialise to NULL. + [!HAVE_ARGP_PARSE] {argp_program_version_hook}: Likewise. + + modified files: + ChangeLog compat.c + + +2003-10-05 11:30:39 GMT Gergely Nagy patch-10 + + Summary: + thy_auth_* => bhc_* + Revision: + compat--mainline--0.1--patch-10 + + * compat.c [!HAVE_GETDELIM] (getdelim): Convert to bhc_*, thy_auth_* + was a left-over from the time this code was in thy-auth. + + modified files: + ChangeLog compat.c + + +2003-09-22 09:16:54 GMT Gergely Nagy patch-9 + + Summary: + getdelim() & getline() + Revision: + compat--mainline--0.1--patch-9 + + * compat.h [!HAVE_GETDELIM] (getdelim): New prototype. + [!HAVE_GETLINE] (getline): Likewise. + * compat.c [!HAVE_GETDELIM] (getdelim): New function. + [!HAVE_GETLINE] (getline): Likewise. + + modified files: + ChangeLog compat.c compat.h + + +2003-09-20 10:49:53 GMT Gergely Nagy patch-8 + + Summary: + Proper argp_program_version and _hook support + Revision: + compat--mainline--0.1--patch-8 + + * compat.c [!HAVE_ARGP_PARSE] (argp_program_version): Declare an empty + variable. + [!HAVE_ARGP_PARSE] (argp_program_bug_address): Likewise. + [!HAVE_ARGP_PARSE] (argp_program_version_hook): Likewise. + [!HAVE_ARGP_PARSE] (argp_parse): Adapted to use the pre-defined + variables. + + modified files: + ChangeLog compat.c + + +2003-09-20 10:28:09 GMT Gergely Nagy patch-7 + + Summary: + Cosmetic ARGP fix + Revision: + compat--mainline--0.1--patch-7 + + * compat.c (argp_parse): Print a \n after argp_post_v(). + + modified files: + ChangeLog compat.c + + +2003-09-20 10:26:56 GMT Gergely Nagy patch-6 + + Summary: + ARGP_KEY_END and doc-only option support + Revision: + compat--mainline--0.1--patch-6 + + * compat.h [ARGP_KEY_END]: New constant. + * compat.c (argp_parse): Support doc-only options, and call + argps->parser after the main loop again, with key set to + ARGP_KEY_END. + + modified files: + ChangeLog compat.c compat.h + + +2003-09-20 09:54:19 GMT Gergely Nagy patch-5 + + Summary: + OPTION_ARG_OPTIONAL support + Revision: + compat--mainline--0.1--patch-5 + + * compat.h [OPTION_ARG_OPTIONAL]: New constant. + * compat.c [!HAVE_ARGP_PARSE] (argp_parse): Support + OPTION_ARG_OPTIONAL for long options. + + modified files: + ChangeLog compat.c compat.h + + +2003-09-20 09:28:35 GMT Gergely Nagy patch-4 + + Summary: + NetBSD compatibility + Revision: + compat--mainline--0.1--patch-4 + + * compat.h: #include (for AI_NUMERICHOST). + [!error_t] (error_t): #define to int. + * compat.c (argp_error): It is state->argv0, not state->argv[0]. + [HAVE_WORKING_SETPROCTITLE] (bhc_setproctitle): Changed to match the + prototype. + + modified files: + ChangeLog compat.c compat.h + + +2003-09-20 08:33:51 GMT Gergely Nagy patch-3 + + Summary: + bh_* => bhc_*, for the sake of consistency + Revision: + compat--mainline--0.1--patch-3 + + * compat.h: Renamed all bh_* functions to bhc_*. + * compat.c: Likewise. + + modified files: + ChangeLog compat.c compat.h + + +2003-09-19 11:58:17 GMT Gergely Nagy patch-2 + + Summary: + Memory allocation stuff + Revision: + compat--mainline--0.1--patch-2 + + * compat.c: Added the memory allocation functions. The prototypes were + moved to compat.h, but the functions weren't moved here. Did that + now. + + modified files: + ChangeLog compat.c + + +2003-09-19 10:38:05 GMT Gergely Nagy patch-1 + + Summary: + AIX hackery + Revision: + compat--mainline--0.1--patch-1 + + * compat.c: Added some AIX hackery from thy's src/misc.c. + + modified files: + ChangeLog compat.c + + +2003-09-19 10:08:15 GMT Gergely Nagy base-0 + + Summary: + Initial import + Revision: + compat--mainline--0.1--base-0 + + Initial import of the BoneHunter compat suite, mostly a modification of + thy--head--0.8's src/compat.[ch], with additions from src/misc.[ch] + (the memory allocation wrappers). + + new files: + ChangeLog Makefile.in compat.c compat.h + + diff --git a/lib/compat/Makefile.in b/lib/compat/Makefile.in new file mode 100644 index 0000000..3259304 --- /dev/null +++ b/lib/compat/Makefile.in @@ -0,0 +1,23 @@ +## lib/compat/Makefile +## arch-tag: c6b7536b-1c28-4ecd-b0ef-c193029d6b16 + +## -- User-modifiable variables -- ## +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = lib/compat + +## == The code below shouldn't need to be touched at all == ## + +## -- Private variables -- ## +SOURCES = compat.c +HEADERS = compat.h compat-regex.h + +EXTRA_DIST = ChangeLog compat.m4 + +include ../../Mk/Rules.mk + +## -- Standard targets -- ## +all:: ${OBJECTS} + +## -- Dependencies -- ## +compat.o: compat.c ${top_builddir}/system.h compat.h diff --git a/lib/compat/compat-regex.h b/lib/compat/compat-regex.h new file mode 100644 index 0000000..3945087 --- /dev/null +++ b/lib/compat/compat-regex.h @@ -0,0 +1,179 @@ +/* Definitions for data structures and routines for the regular + expression library. + Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Cleaned from _RE_ARGS and other stuff for Thy. */ + +#ifndef __DOXYGEN__ + +#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP) && \ + defined(HAVE_WORKING_REGEX_H) +#include +#include +#else + +#warning You are using the compatilibty regex definitions. +#warning They might not match your system! + +#ifndef _COMPAT_REGEX_H +#define _COMPAT_REGEX_H 1 + +#include + +/* The following bits are used to determine the regexp syntax we + recognize. The set/not-set meanings are chosen so that Emacs syntax + remains the value 0. The bits are given in alphabetical order, and + the definitions shifted by one from the previous bit; thus, when we + add or remove a bit, only one other definition need change. */ +typedef unsigned long int reg_syntax_t; + +/* POSIX `cflags' bits (i.e., information for `regcomp'). */ + +/* If this bit is set, then use extended regular expression syntax. + If not set, then use basic regular expression syntax. */ +#define REG_EXTENDED 1 + + +#define REG_NOERROR 0 +#define REG_NOMATCH 1 + +/* This data structure represents a compiled pattern. Before calling + the pattern compiler, the fields `buffer', `allocated', `fastmap', + `translate', and `no_sub' can be set. After the pattern has been + compiled, the `re_nsub' field is available. All other fields are + private to the regex routines. */ + +#ifndef RE_TRANSLATE_TYPE +# define RE_TRANSLATE_TYPE char * +#endif + +struct re_pattern_buffer +{ +/* [[[begin pattern_buffer]]] */ + /* Space that holds the compiled pattern. It is declared as + `unsigned char *' because its elements are + sometimes used as array indexes. */ + unsigned char *buffer; + + /* Number of bytes to which `buffer' points. */ + unsigned long int allocated; + + /* Number of bytes actually used in `buffer'. */ + unsigned long int used; + + /* Syntax setting with which the pattern was compiled. */ + reg_syntax_t syntax; + + /* Pointer to a fastmap, if any, otherwise zero. re_search uses + the fastmap, if there is one, to skip over impossible + starting points for matches. */ + char *fastmap; + + /* Either a translate table to apply to all characters before + comparing them, or zero for no translation. The translation + is applied to a pattern when it is compiled and to a string + when it is matched. */ + RE_TRANSLATE_TYPE translate; + + /* Number of subexpressions found by the compiler. */ + size_t re_nsub; + + /* Zero if this pattern cannot match the empty string, one else. + Well, in truth it's used only in `re_search_2', to see + whether or not we should use the fastmap, so we don't set + this absolutely perfectly; see `re_compile_fastmap' (the + `duplicate' case). */ + unsigned can_be_null : 1; + + /* If REGS_UNALLOCATED, allocate space in the `regs' structure + for `max (RE_NREGS, re_nsub + 1)' groups. + If REGS_REALLOCATE, reallocate space if necessary. + If REGS_FIXED, use what's there. */ +#define REGS_UNALLOCATED 0 +#define REGS_REALLOCATE 1 +#define REGS_FIXED 2 + unsigned regs_allocated : 2; + + /* Set to zero when `regex_compile' compiles a pattern; set to one + by `re_compile_fastmap' if it updates the fastmap. */ + unsigned fastmap_accurate : 1; + + /* If set, `re_match_2' does not return information about + subexpressions. */ + unsigned no_sub : 1; + + /* If set, a beginning-of-line anchor doesn't match at the + beginning of the string. */ + unsigned not_bol : 1; + + /* Similarly for an end-of-line anchor. */ + unsigned not_eol : 1; + + /* If true, an anchor at a newline matches. */ + unsigned newline_anchor : 1; + +/* [[[end pattern_buffer]]] */ +}; + +typedef struct re_pattern_buffer regex_t; + +/* Type for byte offsets within the string. POSIX mandates this. */ +typedef int regoff_t; + +/* POSIX specification for registers. Aside from the different names + than `re_registers', POSIX uses an array of structures, instead of + a structure of arrays. */ +typedef struct +{ + regoff_t rm_so; /* Byte offset from string's start to substring's + start. */ + regoff_t rm_eo; /* Byte offset from string's start to substring's + end. */ +} regmatch_t; + +/* POSIX compatibility. */ +extern int regcomp (regex_t * , + const char * __pattern, + int __cflags); + +extern int regexec (const regex_t * , + const char * __string, size_t __nmatch, + regmatch_t __pmatch[], + int __eflags); + +extern size_t regerror (int __errcode, const regex_t *, + char *__errbuf, size_t __errbuf_size); + +extern void regfree (regex_t *); + +#endif /* compat-regex.h */ + +#endif /* !defined(HAVE_REGEX_H) || !defined(HAVE_REGCOMP) */ + +#endif /* !__DOXYGEN__ */ + +/* +Local variables: +make-backup-files: t +version-control: t +trim-versions-without-asking: nil +arch-tag: 37e0fa64-c2a0-4600-8ea8-eb41ca0dc002 +End: +*/ diff --git a/lib/compat/compat.c b/lib/compat/compat.c new file mode 100644 index 0000000..2ae71c6 --- /dev/null +++ b/lib/compat/compat.c @@ -0,0 +1,1051 @@ +/* -*- mode: c; c-file-style: "gnu" -*- + * compat.c -- glibc-specific functions reimplemented + * Copyright (C) 2002, 2003 Gergely Nagy + * + * This file is part of The BoneHunter compat suite. + * + * The BoneHunter compat suite 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. + * + * The BoneHunter compat suite 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 + */ + +/** @file compat.c + * GLibC-specific functions reimplemented. + * + * Since most BoneHunter software are tightly bound to the quirks of + * GNU libc and there are no plans to change this, this file contains + * emulations, wrappers and reimplementations of certain glibc + * functions. + */ + +#include "system.h" +#include "compat.h" + +/* AIX hackery */ +#if malloc == rpl_malloc +#undef malloc +#undef realloc +#endif + +#include +#include +#include +#include +#ifdef HAVE_GETOPT_H +#include +#endif +#include +#ifdef HAVE_PATHS_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __DOXYGEN__ +#ifndef _PATH_DEVNULL +#define _PATH_DEVNULL "/dev/null" +#endif +#endif + +int +bhc_atoi (const char *str, long *result) +{ + char *endptr; + long int res; + + res = strtol (str, &endptr, 10); + if (res == LONG_MIN || res == LONG_MAX) + return -1; + if (*str != '\0' && *endptr == '\0') + { + *result = res; + return 0; + } + else + return -1; +} + +/** Wrapper around malloc(). + * This is a simple wrapper around malloc(), which exits if the + * allocation failed. + */ +void * +bhc_malloc (size_t size) +{ + register void *value = malloc (size); + if (value == 0) + bhc_exit (2); + return value; +} + +/** Wrapper around realloc(). + * This is a simple wrapper around realloc(), which exits if the + * allocation failed. + */ +void * +bhc_realloc (void *ptr, size_t size) +{ + register void *value = realloc (ptr, size); + if (value == 0) + bhc_exit (2); + return value; +} + +/** Wrapper around calloc(). + * This is a simple wrapper around calloc(), which exits if the + * allocation failed. + */ +void * +bhc_calloc (size_t nmemb, size_t size) +{ +#ifndef __glibc__ + register void *value = calloc (nmemb + 1, size); +#else + register void *value = calloc (nmemb, size); +#endif + if (value == 0) + bhc_exit (2); + return value; +} + +/** Wrapper around strdup(). + * This is a simple wrapper around strdup(), which exits if the + * allocation failed, and handles a NULL source well. + */ +char * +bhc_strdup (const char *src) +{ + register char *value; + if (!src) + return NULL; + + value = strdup (src); + if (value == 0) + bhc_exit (2); + return value; +} + +/** Wrapper around strndup(). + * This is a simple wrapper around strndup(), which exits if the + * allocation failed, and handles a NULL source well. + */ +char * +bhc_strndup (const char *src, size_t n) +{ + register char *value; + if (!src) + return NULL; + + value = strndup (src, n); + if (value == 0) + bhc_exit (2); + return value; +} + +/** Terminate the server process + */ +void +bhc_exit (int code) +{ + raise (SIGQUIT); + exit (code); +} + +#ifdef __GLIBC__ +inline char * +bhc_getcwd (void) +{ + return getcwd (NULL, 0); +} +#else +char * +bhc_getcwd (void) +{ + char *cwd = (char *)bhc_malloc (PATH_MAX + 1); + getcwd (cwd, PATH_MAX); + return cwd; +} +#endif + +#ifndef __DOXYGEN__ + +#ifndef HAVE_BASENAME +char * +basename (const char *filename) +{ + char *p = strrchr (filename, '/'); + return p ? p + 1 : (char *) filename; +} +#endif + +#ifndef HAVE_DIRNAME +char * +dirname (char *path) +{ + static const char dot[] = "."; + char *last_slash; + + last_slash = path != NULL ? strrchr (path, '/') : NULL; + + if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') + { + char *runp; + size_t i; + + for (runp = last_slash; runp != path; --runp) + if (runp[-1] != '/') + break; + + if (runp != path) + { + i = runp - path; + do {i--;} while (path[i] != '/'); + last_slash = &path[i]; + } + } + + if (last_slash != NULL) + { + char *runp; + + for (runp = last_slash; runp != path; --runp) + if (runp[-1] != '/') + break; + + if (runp == path) + { + if (last_slash == path + 1) + ++last_slash; + else + last_slash = path + 1; + } + else + last_slash = runp; + + last_slash[0] = '\0'; + } + else + path = (char *) dot; + + return path; +} +#endif + +#ifndef HAVE_VSNPRINTF +int +vsnprintf (char *str, size_t size, const char *format, va_list ap) +{ + return (vsprintf (str, format, ap)); +} +#endif + +#ifndef HAVE_VASPRINTF +int +vasprintf (char **ptr, const char *fmt, va_list a) +{ + size_t size = 1024; + int n; + va_list ap; + + if ((*ptr = bhc_malloc (size)) == NULL) + return -1; + + while (1) + { + va_copy (ap, a); + n = vsnprintf (*ptr, size, fmt, ap); + va_end (ap); + + if (n > -1 && n < (long) size) + return n; + + if (n > -1) /* glibc 2.1 */ + size = n+1; + else /* glibc 2.0 */ + size *= 2; + + if ((*ptr = bhc_realloc (*ptr, size)) == NULL) + return -1; + } +} +#endif + +#ifndef HAVE_ASPRINTF +int +asprintf(char **ptr, const char *fmt, ...) +{ + va_list ap; + int i; + + va_start (ap, fmt); + i = vasprintf (ptr, fmt, ap); + va_end (ap); + + return i; +} +#endif + +#ifndef HAVE_DAEMON +int +daemon(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) + chdir ("/"); + + if (!noclose && (fd = open (_PATH_DEVNULL, O_RDWR, 0)) != -1) + { + dup2 (fd, STDIN_FILENO); + dup2 (fd, STDOUT_FILENO); + dup2 (fd, STDERR_FILENO); + if (fd > 2) + close (fd); + } + else + return -1; + + return 0; +} +#endif + +#ifndef HAVE_CONFSTR +#define _CS_PATH_STR "/bin:/usr/bin" +size_t +confstr (int name, char *buf, size_t len) +{ + if (name != _CS_PATH) + { + errno = EINVAL; + return 0; + } + + if (len != 0) + memcpy (buf, _CS_PATH_STR, + (len < sizeof (_CS_PATH_STR)) ? len : sizeof (_CS_PATH_STR)); + return sizeof (_CS_PATH_STR); +} +#endif + +#ifndef HAVE_MEMPCPY +void * +mempcpy (void *TO, const void *FROM, size_t SIZE) +{ + memcpy (TO, FROM, SIZE); + return ((void *) ((char *) TO + SIZE)); +} +#endif + +#ifndef HAVE_CANONICALIZE_FILE_NAME +/* The below implementation is (C) 1993 Rick Sladkey + * Released under the GPLv2. */ +#define MAX_READLINKS 32 +static char * +_bhc_realpath (const char *path, char *resolved_path) +{ + char copy_path[PATH_MAX]; + char link_path[PATH_MAX]; + char *new_path = resolved_path; + char *max_path; + int readlinks = 0; + int n; + + /* Make a copy of the source path since we may need to modify it. */ + strcpy (copy_path, path); + path = copy_path; + max_path = copy_path + PATH_MAX - 2; + /* If it's a relative pathname use getwd for starters. */ + if (*path != '/') + { + new_path = bhc_getcwd (); + new_path += strlen (new_path); + if (new_path[-1] != '/') + *new_path++ = '/'; + } + else + { + *new_path++ = '/'; + path++; + } + /* Expand each slash-separated pathname component. */ + while (*path != '\0') + { + /* Ignore stray "/". */ + if (*path == '/') + { + path++; + continue; + } + if (*path == '.') + { + /* Ignore ".". */ + if (path[1] == '\0' || path[1] == '/') + { + path++; + continue; + } + if (path[1] == '.') + { + if (path[2] == '\0' || path[2] == '/') + { + path += 2; + /* Ignore ".." at root. */ + if (new_path == resolved_path + 1) + continue; + /* Handle ".." by backing up. */ + while ((--new_path)[-1] != '/') + ; + continue; + } + } + } + /* Safely copy the next pathname component. */ + while (*path != '\0' && *path != '/') + { + if (path > max_path) + { + errno = ENAMETOOLONG; + return NULL; + } + *new_path++ = *path++; + } + /* Protect against infinite loops. */ + if (readlinks++ > MAX_READLINKS) + { + errno = ELOOP; + return NULL; + } + /* See if latest pathname component is a symlink. */ + *new_path = '\0'; + n = readlink (resolved_path, link_path, PATH_MAX - 1); + if (n < 0) + { + /* EINVAL means the file exists but isn't a symlink. */ + if (errno != EINVAL) + return NULL; + } + else + { + /* Note: readlink doesn't add the null byte. */ + link_path[n] = '\0'; + if (*link_path == '/') + /* Start over for an absolute symlink. */ + new_path = resolved_path; + else + /* Otherwise back up over this component. */ + while (*(--new_path) != '/') + ; + /* Safe sex check. */ + if (strlen (path) + n >= PATH_MAX) + { + errno = ENAMETOOLONG; + return NULL; + } + /* Insert symlink contents into path. */ + strcat (link_path, path); + strcpy (copy_path, link_path); + path = copy_path; + } + *new_path++ = '/'; + } + /* Delete trailing slash but don't whomp a lone slash. */ + if (new_path != resolved_path + 1 && new_path[-1] == '/') + new_path--; + /* Make sure it's null terminated. */ + *new_path = '\0'; + return resolved_path; +} + +char * +canonicalize_file_name (const char *fn) +{ + char *cfn, *tmp; + + if (!fn) + return NULL; + + cfn = (char *)bhc_malloc (PATH_MAX); + tmp = _bhc_realpath (fn, cfn); + + if (!tmp) + { + free (cfn); + return NULL; + } + + return cfn; +} +#endif + +#ifndef HAVE_STRNDUP +char * +strndup (const char *s, size_t size) +{ + char *ns = (char *)bhc_malloc (size + 1); + memcpy (ns, s, size); + ns[size] = '\0'; + return ns; +} +#endif + +#ifndef HAVE_STRPTIME +/* FIXME: This one needs to be implemented */ +char * +strptime (const char *s, const char *format, struct tm *tm) +{ + memset (tm, 0, sizeof (struct tm)); + return NULL; +} +#endif + +/* getline() and getdelim() were taken from GNU Mailutils' + mailbox/getline.c */ +/* First implementation by Alain Magloire */ +#ifndef HAVE_GETLINE +ssize_t +getline (char **lineptr, size_t *n, FILE *stream) +{ + return getdelim (lineptr, n, '\n', stream); +} +#endif + +#ifndef HAVE_GETDELIM +/* Default value for line length. */ +static const int line_size = 128; + +ssize_t +getdelim (char **lineptr, size_t *n, int delim, FILE *stream) +{ + size_t indx = 0; + int c; + + /* Sanity checks. */ + if (lineptr == NULL || n == NULL || stream == NULL) + return -1; + + /* Allocate the line the first time. */ + if (*lineptr == NULL) + { + *lineptr = bhc_malloc (line_size); + if (*lineptr == NULL) + return -1; + *n = line_size; + } + + while ((c = getc (stream)) != EOF) + { + /* Check if more memory is needed. */ + if (indx >= *n) + { + *lineptr = bhc_realloc (*lineptr, *n + line_size); + if (*lineptr == NULL) + return -1; + *n += line_size; + } + + /* Push the result in the line. */ + (*lineptr)[indx++] = c; + + /* Bail out. */ + if (c == delim) + break; + } + + /* Make room for the null character. */ + if (indx >= *n) + { + *lineptr = bhc_realloc (*lineptr, *n + line_size); + if (*lineptr == NULL) + return -1; + *n += line_size; + } + + /* Null terminate the buffer. */ + (*lineptr)[indx++] = 0; + + /* The last line may not have the delimiter, we have to + * return what we got and the error will be seen on the + * next iteration. */ + return (c == EOF && (indx - 1) == 0) ? -1 : (ssize_t)(indx - 1); +} +#endif + +#ifndef HAVE_ARGP_PARSE +const char *argp_program_version; +const char *argp_program_bug_address; +void (*argp_program_version_hook) (FILE *stream, + struct argp_state *state); + +static char * +argp_pre_v (const char *doc) +{ + char *pv = strchr (doc, '\v'); + char *str = strndup (doc, (pv != NULL) ? (size_t)(pv - doc) : + strlen (doc)); + return str; +} + +static char * +argp_post_v (const char *doc) +{ + char *str = strchr (doc, '\v'); + return (str) ? (str + 1) : ""; +} + +error_t +argp_parse (const struct argp *argps, int argc, char **argv, + unsigned flags, int *arg_index, void *input) +{ + char *options, *tmp; + int optpos = 0, optionspos = 0, optionssize = 30; + struct argp_state *state; + int c; +#if HAVE_GETOPT_LONG + struct option *longopts; + int longoptionspos = 0; + + longopts = (struct option *)bhc_calloc (optionssize, + sizeof (struct option)); +#endif + + state = (struct argp_state *)bhc_malloc (sizeof (struct argp_state)); + state->input = input; + state->argv0 = argv[0]; + + options = (char *)bhc_calloc (optionssize, sizeof (char *)); + while (argps->options[optpos].name != NULL || + argps->options[optpos].doc != NULL) + { + if (optionspos >= optionssize) + { + optionssize *= 2; + XSREALLOC (options, char, optionssize); +#if HAVE_GETOPT_LONG + XSREALLOC (longopts, struct option, optionssize); +#endif + } + if (!argps->options[optpos].name) + { + optpos++; + continue; + } + + options[optionspos++] = (char) argps->options[optpos].key; + if (argps->options[optpos].arg) + options[optionspos++] = ':'; + +#if HAVE_GETOPT_LONG + longopts[longoptionspos].name = argps->options[optpos].name; + if (argps->options[optpos].arg) + { + if (argps->options[optpos].flags & OPTION_ARG_OPTIONAL) + longopts[longoptionspos].has_arg = optional_argument; + else + longopts[longoptionspos].has_arg = required_argument; + } + else + longopts[longoptionspos].has_arg = no_argument; + longopts[longoptionspos].flag = NULL; + longopts[longoptionspos].val = argps->options[optpos].key; + longoptionspos++; +#endif + + optpos++; + } + if (optionspos + 4 >= optionssize) + { + optionssize += 5; + XSREALLOC (options, char, optionssize); +#if HAVE_GETOPT_LONG + XSREALLOC (longopts, struct option, optionssize); +#endif + } + options[optionspos++] = 'V'; + options[optionspos++] = '?'; + options[optionspos] = '\0'; +#if HAVE_GETOPT_LONG + longopts[longoptionspos].name = "help"; + longopts[longoptionspos].has_arg = no_argument; + longopts[longoptionspos].flag = NULL; + longopts[longoptionspos].val = '?'; + longoptionspos++; + longopts[longoptionspos].name = "version"; + longopts[longoptionspos].has_arg = no_argument; + longopts[longoptionspos].flag = NULL; + longopts[longoptionspos].val = 'V'; + longoptionspos++; + longopts[longoptionspos].name = NULL; + longopts[longoptionspos].has_arg = 0; + longopts[longoptionspos].flag = NULL; + longopts[longoptionspos].val = 0; +#endif + +#if HAVE_GETOPT_LONG + while ((c = getopt_long (argc, argv, options, longopts, NULL)) != -1) +#else + while ((c = getopt (argc, argv, options)) != -1) +#endif + { + switch (c) + { + case '?': + tmp = argp_pre_v (argps->doc); + printf ("Usage: %s [OPTION...]\n%s\n\n", argv[0], tmp); + free (tmp); + optpos = 0; + while (argps->options[optpos].name != NULL || + argps->options[optpos].doc != NULL) + { + if (!argps->options[optpos].name) + { + printf (" %s\n", argps->options[optpos].doc); + optpos++; + continue; + } + if (!(argps->options[optpos].flags & OPTION_HIDDEN)) +#if HAVE_GETOPT_LONG + printf (" -%c, --%-15s %s%-12s\t%s%s\n", + argps->options[optpos].key, + argps->options[optpos].name, + (argps->options[optpos].flags & + OPTION_ARG_OPTIONAL) ? "[" : "", + (argps->options[optpos].arg) ? + argps->options[optpos].arg : "", + argps->options[optpos].doc, + (argps->options[optpos].flags & + OPTION_ARG_OPTIONAL) ? "]" : ""); +#else + printf (" -%c %-12s\t%s\n", argps->options[optpos].key, + (argps->options[optpos].arg) ? + argps->options[optpos].arg : "", + argps->options[optpos].doc); +#endif + optpos++; + } + printf ("\n%s\n", argp_post_v (argps->doc)); + printf ("Report bugs to %s.\n", argp_program_bug_address); + exit (0); + break; + case 'V': + if (argp_program_version_hook == NULL) + printf ("%s\n", argp_program_version); + else + argp_program_version_hook (stderr, state); + exit (0); + break; + default: + argps->parser (c, optarg, state); + break; + } + } + for (; optind < argc; optind++) + argps->parser (ARGP_KEY_ARG, argv[optind], state); + argps->parser (ARGP_KEY_END, NULL, state); + + free (state); + free (options); +#if HAVE_GETOPT_LONG + free (longopts); +#endif + return 0; +} + +error_t +argp_error (const struct argp_state *state, char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + fprintf (stderr, "%s: ", state->argv0); + vfprintf (stderr, fmt, ap); + fprintf (stderr, "\nTry `%s -?' for more information.\n", + state->argv0); + exit (1); + + return 1; +} +#endif + +#if !defined(HAVE_GETSUBOPT) || defined(HAVE_BROKEN_GETSUBOPT) +int +bhc_getsubopt (char **optionp, char *const *tokens, + char **valuep) +{ + char *endp, *vstart; + int cnt; + + if (**optionp == '\0') + return -1; + + /* Find end of next token. */ + endp = strchr (*optionp, ','); + if (!endp) + endp = *optionp + strlen (*optionp); + + /* Find start of value. */ + vstart = memchr (*optionp, '=', endp - *optionp); + + if (vstart == NULL) + vstart = endp; + + /* Try to match the characters between *OPTIONP and VSTART against + one of the TOKENS. */ + for (cnt = 0; tokens[cnt] != NULL; ++cnt) + if (memcmp (*optionp, tokens[cnt], vstart - *optionp) == 0 + && tokens[cnt][vstart - *optionp] == '\0') + { + /* We found the current option in TOKENS. */ + *valuep = vstart != endp ? vstart + 1 : NULL; + + if (*endp != '\0') + *endp++ = '\0'; + *optionp = endp; + + return cnt; + } + + /* The current suboption does not match any option. */ + *valuep = *optionp; + + if (*endp != '\0') + *endp++ = '\0'; + *optionp = endp; + + return -1; +} +#else +#if HAVE_SUBOPTARG +extern char *suboptarg; +#else +#endif +int +bhc_getsubopt (char **optionp, char *const *tokens, + char **valuep) +{ + int i = getsubopt (optionp, tokens, valuep); +#if HAVE_SUBOPTARG + if (!*valuep) + *valuep = bhc_strdup ((suboptarg) ? suboptarg : ""); +#else + if (!*valuep) + *valuep = bhc_strdup (""); +#endif + return i; +} +#endif + +#ifndef HAVE_SCANDIR +int +scandir (const char *dir, struct dirent ***namelist, + int (*sd_select)(const struct dirent *), + int (*sd_compar)(const struct dirent **, + const struct dirent **)) +{ + DIR *d; + struct dirent *entry; + register int i=0; + size_t entrysize; + + if ((d = opendir (dir)) == NULL) + return -1; + + *namelist=NULL; + while ((entry = readdir (d)) != NULL) + { + if (sd_select == NULL || (sd_select != NULL && (*sd_select) (entry))) + { + *namelist = (struct dirent **)bhc_realloc + ((void *) (*namelist), + (size_t)((i + 1) * sizeof (struct dirent *))); + if (*namelist == NULL) + return -1; + + entrysize = sizeof (struct dirent) - + sizeof (entry->d_name) + strlen (entry->d_name) + 1; + (*namelist)[i] = (struct dirent *)bhc_malloc (entrysize); + if ((*namelist)[i] == NULL) + return -1; + memcpy ((*namelist)[i], entry, entrysize); + i++; + } + } + if (closedir (d)) + return -1; + if (i == 0) + return -1; + if (sd_compar != NULL) + qsort ((void *)(*namelist), (size_t) i, sizeof (struct dirent *), + sd_compar); + + return i; +} +#endif + +#ifndef HAVE_ALPHASORT +int +alphasort (const struct dirent **a, const struct dirent **b) +{ + return (strcmp ((*a)->d_name, (*b)->d_name)); +} +#endif + +#ifndef HAVE_SETENV +int +setenv (const char *name, const char *value, int overwrite) +{ + char *tmp; + int i; + + if (!name || !value) + return 0; + + tmp = (char *)bhc_malloc (strlen (name) + strlen (value) + 2); + strcpy (tmp, name); + strcat (tmp, "="); + strcat (tmp, value); + + i = putenv (tmp); + + free (tmp); + + return i; +} +#endif + +#if !HAVE_WORKING_SETPROCTITLE +static char **bhc_setproc_argv = NULL; +static char *bhc_setproc_argv_end = NULL; +#endif + +#if HAVE_WORKING_SETPROCTITLE +void +bhc_setproctitle_init (int argc, char **argv, char **envp) +{ +} +#else +void +bhc_setproctitle_init (int argc, char **argv, char **envp) +{ + int i; + + bhc_setproc_argv = argv; + + for (i = 0; i < argc; i++) + { + if (i == 0 || bhc_setproc_argv_end + 1 == argv[i]) + bhc_setproc_argv_end = argv[i] + strlen (argv[i]); + } + for (i = 0; bhc_setproc_argv_end != NULL && envp != NULL && + envp[i] != NULL; i++) + { + if (bhc_setproc_argv_end + 1 == envp[i]) + bhc_setproc_argv_end = envp[i] + strlen (envp[i]); + } +} +#endif + +#if HAVE_WORKING_SETPROCTITLE +void +bhc_setproctitle (const char *name) +{ + setproctitle (name); +} +#else +void +bhc_setproctitle (const char *name) +{ + int i; + char *buf, *p; + + if (bhc_setproc_argv_end == NULL) + return; + + buf = bhc_strdup (name); + i = strlen (buf); + + if (i > bhc_setproc_argv_end - bhc_setproc_argv[0] - 2) + { + i = bhc_setproc_argv_end - bhc_setproc_argv[0] - 2; + buf[i] = '\0'; + } + + strncpy (bhc_setproc_argv[0], buf, i + 1); + p = &bhc_setproc_argv[0][i]; + while (p < bhc_setproc_argv_end) + *p++ = 0x0; + bhc_setproc_argv[1] = NULL; + + free (buf); +} +#endif + +#ifndef HAVE_VSYSLOG +void +vsyslog (int priority, const char *format, va_list ap) +{ + char *msg; + + vasprintf (&msg, format, ap); + syslog (priority, "%s", msg); + free (msg); +} +#endif + +#if !defined(HAVE___VA_ARGS__) && !defined(HAVE_VARIADIC_MACROS) +#if BHC_OPTION_ALL_LOGGING +#define _bhc_log_body(prio) \ +{ \ + va_list ap; \ + \ + va_start (ap, fmt); \ + vsyslog (prio, fmt, ap); \ + va_end (ap); \ +} + +void bhc_error (char *fmt, ...) _bhc_log_body (LOG_NOTICE); +void bhc_log (char *fmt, ...) _bhc_log_body (LOG_WARNING); +# if BHC_OPTION_DEBUG + void bhc_debug (char *fmt, ...) _bhc_log_body (LOG_DEBUG); +# else + void bhc_debug (char *fmt, ...) {}; +# endif +#undef _bhc_log_body +#else +void bhc_error (char *fmt, ...) {} +void bhc_log (char *fmt, ...) {} +void bhc_debug (char *fmt, ...) {} +#endif +#endif + +#endif /* !__DOXYGEN__ */ + +/* arch-tag: c8eb0ba7-516c-4592-96a4-d6bb25ffc0a0 */ diff --git a/lib/compat/compat.h b/lib/compat/compat.h new file mode 100644 index 0000000..efec48b --- /dev/null +++ b/lib/compat/compat.h @@ -0,0 +1,352 @@ +/* -*- mode: c; c-file-style: "gnu" -*- + * compat.h -- Prototypes for glibc-specific functions + * Copyright (C) 2002, 2003 Gergely Nagy + * + * This file is part of The BoneHunter compat suite. + * + * The BoneHunter compat suite 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. + * + * The BoneHunter compat suite 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 + */ + +/** @file compat.h + * Prototypes for glibc-specific functions. + */ + +#ifndef _BHC_COMPAT_H +#define _BHC_COMPAT_H 1 /**< compat.h multi-inclusion guard. */ + +#include "system.h" + +#ifdef HAVE_STDINT_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** C99-style enum initialiser wrapper. + * This macro is used to allow non-C99 compilers (hi, AIX!) to compile + * BoneHunter software, why allowing C99-enabled ones to... well, to + * do stuff. + * + * However, there is no C99 check in configure at the moment, so this + * macro is a no-op for now. + */ +#define C99_INIT(a) + +/** Convert a string to long, with error checking. + * @param str is the string to convert. + * @param result is where the result will go. + * + * @returns Zero on success, -1 otherwise. If there was an error, + * result will be left untouched. + */ +int bhc_atoi (const char *str, long *result); + +/** Get the current working directory. + * @returns A newly allocated string, containing the current working + * directory. + */ +char *bhc_getcwd (void); + +/** Initialiser for bhc_setproctitle(). + * This saves the start and the end of argv, for later use by + * bhc_setproctitle(). Provided of course, that there is no native + * setproctitle(). + * + * @param argc is the argument count. + * @param argv is the argument vector. + * @param envp is the environment vector. + */ +void bhc_setproctitle_init (int argc, char **argv, char **envp); + +/** Sets the process title. + * Change the name of the process - as appears in ps(1). + * + * @param name is the new title of the process. + */ +void bhc_setproctitle (const char *name); + +/** Convenience wrapper around bhc_realloc(). + */ +#define XSREALLOC(ptr, type, nmemb) \ + ptr = (type*) bhc_realloc (ptr, (nmemb) * sizeof (type)) + +void *bhc_malloc (size_t size); +void *bhc_realloc (void *ptr, size_t size); +void *bhc_calloc (size_t nmemb, size_t size); +char *bhc_strdup (const char *src); +char *bhc_strndup (const char *src, size_t n); + +void bhc_exit (int code); + +/** getsubopt() replacement. + * This function is either a wrapper around getsubopt() or a complete + * reimplementation. + * + * @param optionp is a pointer to the string to process. + * @param tokens references an array of strings containing the known + * suboptions. + * @param valuep will be used to return the value of the suboption. + * + * @returns Zero on success, -1 otherwise. + * + * @note Modifies #valuep in-place. + */ +int bhc_getsubopt (char **optionp, char *const *tokens, + char **valuep); + +#ifndef __DOXYGEN__ + +#ifndef SHUT_RDWR +#define SHUT_RDWR 2 +#endif + +#ifndef socklen_t +#define socklen_t int +#endif + +#ifndef error_t +#define error_t int +#endif + +#ifndef HAVE_SOCKADDR_STORAGE +struct sockaddr_storage +{ + uchar ss_len; /* address length */ + uchar ss_family; /* address family */ + unsigned char fill[126]; +}; +#endif + +#ifndef AI_NUMERICHOST +#define AI_NUMERICHOST 0 /* If it is not defined - it is not + supported, so define it to zero. */ +#endif + +#if !defined(HAVE_BASENAME) || defined (_AIX) +char *basename (const char *path); +#endif + +#if !defined(HAVE_DIRNAME) || defined (_AIX) +char *dirname (char *path); +#endif + +#ifndef HAVE_VASPRINTF +int vasprintf (char **ptr, const char *fmt, va_list a); +#endif + +#ifndef HAVE_ASPRINTF +int asprintf (char **ptr, const char *fmt, ...); +#endif + +#ifndef HAVE_VSNPRINTF +int vsnprintf (char *str, size_t size, const char *format, va_list ap); +#endif + +#ifndef HAVE_DAEMON +int daemon (int nochdir, int noclose); +#endif + +#ifndef HAVE_CONFSTR +#define _CS_PATH 1 +size_t confstr (int name, char *buf, size_t len); +#endif + +#ifndef HAVE_MEMPCPY +void *mempcpy (void *TO, const void *FROM, size_t SIZE); +#endif +#ifndef HAVE_CANONICALIZE_FILE_NAME +char *canonicalize_file_name (const char *fn); +#endif +#ifndef HAVE_STRNDUP +char *strndup (const char *s, size_t size); +#endif +#ifndef HAVE_STRPTIME +char *strptime (const char *s, const char *format, struct tm *tm); +#endif + +#ifndef HAVE_GETLINE +ssize_t getline(char **lineptr, size_t *n, FILE *stream); +#endif +#ifndef HAVE_GETDELIM +ssize_t +getdelim (char **lineptr, size_t *n, int delim, FILE *stream); +#endif + +#ifndef HAVE_ARGP_PARSE +struct argp_option +{ + char *name; + int key; + const char *arg; + int flags; + char *doc; + int group; +}; +struct argp; +struct argp_state; +typedef error_t (*argp_parser_t) (int key, char *arg, + struct argp_state *state); +#define ARGP_ERR_UNKNOWN E2BIG +#define ARGP_KEY_END 0x1000001 +#define ARGP_KEY_ARG 0 + +#define OPTION_ARG_OPTIONAL 0x1 +#define OPTION_HIDDEN 0x2 +struct argp +{ + const struct argp_option *options; + argp_parser_t parser; + const char *args_doc; + const char *doc; + /* The rest is ignored */ + const void *children; + char *(*help_filter) (int key, const char *text, void *input); + const char *domain; +}; + +struct argp_state +{ + /* This is deliberately not compatible with glibc's one. We only use + ->input anyway. And argv[0]... */ + void *input; + char *argv0; +}; + +extern const char *argp_program_version; +extern const char *argp_program_bug_address; +extern void (*argp_program_version_hook) (FILE *stream, + struct argp_state *state); + +error_t argp_parse (const struct argp *argps, int argc, char **argv, + unsigned flags, int *arg_index, void *input); +error_t argp_error (const struct argp_state *state, char *fmt, ...); +#endif + +#ifndef HAVE_SCANDIR +int scandir (const char *dir, struct dirent ***namelist, + int (*sd_select)(const struct dirent *), + int (*sd_compar)(const struct dirent **, + const struct dirent **)); +#endif +#ifndef HAVE_ALPHASORT +int alphasort (const struct dirent **a, const struct dirent **b); +#endif +#ifndef HAVE_SETENV +int setenv(const char *name, const char *value, int overwrite); +#endif + +#ifndef HAVE_VSYSLOG +void vsyslog(int priority, const char *format, va_list ap); +#endif + +#if !defined(va_copy) && !defined(__va_copy) +#define __va_copy(dst,src) memcpy (&dst, &src, sizeof (va_list)) +#endif + +#if !defined(va_copy) +#define va_copy __va_copy +#endif + +#ifdef _AIX +char *strndup (const char *s, size_t size); +#endif + +#ifdef __dietlibc__ +int strncmp (const char *s1, const char *s2, size_t n); +int strcasecmp (const char *s1, const char *s2); +#endif + +#endif /* !__DOXYGEN__ */ + +/* Note: The code below is ugly like hell. Do not even try to look at + it. You have been warned. */ +#ifndef __DOXYGEN__ +#ifndef BHC_OPTION_DEBUG +#define BHC_OPTION_DEBUG 0 +#endif + +#if BHC_OPTION_NODEBUG +#undef BHC_OPTION_DEBUG +#endif + +#if HAVE___VA_ARGS__ +# if BHC_OPTION_ALL_LOGGING +# define bhc_error(fmt,...) syslog (LOG_WARNING, fmt, __VA_ARGS__) +# define bhc_log(fmt,...) syslog (LOG_NOTICE, fmt, __VA_ARGS__) +# if BHC_OPTION_DEBUG +# define bhc_debug(fmt,...) syslog (LOG_DEBUG, fmt, __VA_ARGS__) +# else +# define bhc_debug(fmt,...) +# endif +# else +# define bhc_error(fmt,...) +# define bhc_log(fmt,...) +# define bhc_debug(fmt,...) +# endif +#else /* HAVE___VA_ARGS__ */ +# ifdef HAVE_VARIADIC_MACROS +# if BHC_OPTION_ALL_LOGGING +# define bhc_error(format,args...) \ + syslog (LOG_WARNING, format , ## args) +# define bhc_log(format,args...) \ + syslog (LOG_NOTICE, format , ## args) +# if BHC_OPTION_DEBUG +# define bhc_debug(format,args...) \ + syslog (LOG_DEBUG, format , ## args) +# else +# define bhc_debug(format,args...) +# endif +# else +# define bhc_error(format,args...) +# define bhc_log(format,args...) +# define bhc_debug(format,args...) +# endif +# else + void bhc_error (char *fmt, ...); + void bhc_log (char *fmt, ...); + void bhc_debug (char *fmt, ...); +# endif /* !HAVE_VARIADIC_MACROS */ +#endif /* !HAVE___VA_ARGS__ */ +#else /* __DOXYGEN__ */ +/** Log an error condition. + * This is a wrapper around syslog(), with priority set to + * LOG_WARNING. After called, the caller should return an error + * condition. + */ +#define bhc_error(fmt,...) +/** Log various stuff. + * This wrapper is around to log miscellaneous events. Such as served + * requests and startup information. + */ +#define bhc_log(fmt,...) +/** Wrapper for logging debug information. + * Every function that wants to emit information only useful + * debugging, should use this function. It will not be compiled in if + * BHC_OPTION_DEBUG is unset. + */ +#define bhc_debug(fmt,...) +#endif + +#endif /* !_BHC_COMPAT_H */ + +/* arch-tag: c8c8c7bc-b88b-4e0a-9c18-51f0fd3c8ba4 */ diff --git a/lib/compat/compat.m4 b/lib/compat/compat.m4 new file mode 100644 index 0000000..6774c07 --- /dev/null +++ b/lib/compat/compat.m4 @@ -0,0 +1,161 @@ +# arch-tag: f22024e7-e564-4dd9-a659-fab78821f91e + +AC_DEFUN([BHCOMPAT_DEBUG], [ + +dnl * Debug +AC_ARG_ENABLE(debug, + AC_HELP_STRING([--enable-debug], [enable debug mode]), + [f_debug="$enableval"], [f_debug="no"]) +if test "x$f_debug" != "xno"; then + AC_DEFINE_UNQUOTED(BHC_OPTION_DEBUG, 1, + Define this to enable debug mode) +else + AC_DEFINE_UNQUOTED(BHC_OPTION_NODEBUG, 1, + Define this to disable debug mode) +fi + +]) + +AC_DEFUN([BHCOMPAT_LOGGING], [ + +dnl * all-logging +AC_ARG_ENABLE(all-logging, + AC_HELP_STRING([--disable-all-logging], + [disable all kinds of logging]), + [f_allog="$enableval"], [f_allog="yes"]) +if test "x$f_allog" != "xno"; then + AC_DEFINE_UNQUOTED(BHC_OPTION_ALL_LOGGING, 1, + Define this to enable logging support) +else + AC_DEFINE_UNQUOTED(BHC_OPTION_NOALL_LOGGING, 1, + Define this to disable all logging support) +fi + +]) + +AC_DEFUN([BHCOMPAT_CHECK], [ + +BHCOMPAT_DEBUG +BHCOMPAT_LOGGING + +AC_HEADER_DIRENT +AC_HEADER_STDC + +AC_CHECK_HEADERS([argp.h errno.h fcntl.h getopt.h limits.h netdb.h \ + paths.h stddef.h strings.h sys/socket.h sys/types.h \ + syslog.h]) + +AC_C_CONST +AC_C_INLINE +AC_C_VOLATILE +AC_TYPE_OFF_T +AC_TYPE_SIZE_T + +AC_CHECK_SIZEOF(size_t) +AC_CHECK_TYPE(error_t, int) + +AC_FUNC_MALLOC +m4_ifdef([AC_FUNC_REALLOC], [AC_FUNC_REALLOC]) + +AC_CHECK_FUNCS([alphasort argp_parse asprintf basename canonicalize_file_name confstr daemon dirname getcwd getdelim getline getopt_long getsubopt mempcpy setenv setproctitle strndup strptime vasprintf vsnprintf vsyslog]) + +AC_CHECK_LIB(nsl, inet_ntoa) + +AC_CHECK_FUNC([getopt_long], [], [AC_CHECK_LIB(gnugetopt, getopt_long)]) +AC_CHECK_LIB(compat, daemon, [AC_DEFINE(HAVE_DAEMON, 1) +LIBS="$LIBS -lcompat"]) +AC_CHECK_LIB(socket, socket) + +AC_CACHE_CHECK([for suboptarg], [ac_cv_suboptarg], + [ac_cv_suboptarg=no + AC_RUN_IFELSE(AC_LANG_PROGRAM( + [[#include + #include + #include + + static char **empty_subopts[[]] = { NULL }; + extern char *suboptarg; + ]], [[ char *subopts = "something"; + char *value; + + getsubopt (&subopts, empty_subopts, &value); + exit (!suboptarg);]]), + [ac_cv_suboptarg="yes"], [ac_cv_suboptarg="no"], + [ac_cv_suboptarg="no"])]) +case ${ac_cv_suboptarg} in + yes) + AC_DEFINE_UNQUOTED(HAVE_SUBOPTARG, 1, + Define this if you have the suboptarg variable) + ;; +esac + +AC_CACHE_CHECK([whether setproctitle() works], [ac_cv_setproctitle_ok], + [ac_cv_setproctitle_ok=yes + AC_RUN_IFELSE(AC_LANG_PROGRAM( + [[#include + #include + #include + ]], [[ setproctitle (NULL); + exit (0);]]), + [ac_cv_setproctitle_ok="yes"], [ac_cv_setproctitle_ok="no"], + [ac_cv_setproctitle_ok="yes"])]) +case ${ac_cv_setproctitle_ok} in + yes) + AC_DEFINE_UNQUOTED(HAVE_WORKING_SETPROCTITLE, 1, + Define this if setproctitle(NULL) works) + ;; +esac + +AC_CACHE_CHECK([whether getsubopt() is broken], [ac_cv_getsubopt_broken], + [ac_cv_getsubopt_broken=no + AC_RUN_IFELSE(AC_LANG_PROGRAM( + [[#include + #include + #include + #include + + static char *empty_subopts[[]] = { NULL }; + ]], [[ char *optionp; + char *value; + char *tmp; + + optionp = strdup ("foo=bar"); + tmp = optionp; + getsubopt (&optionp, empty_subopts, &value); + + if (!value) + exit (1); + + if (!strcmp (value, tmp)) + exit (0); + else + exit (1);]]), + [ac_cv_getsubopt_broken="no"], [ac_cv_getsubopt_broken="yes"], + [ac_cv_getsubopt_broken="no"])]) +case ${ac_cv_getsubopt_broken} in + yes) + AC_DEFINE_UNQUOTED(HAVE_BROKEN_GETSUBOPT, 1, + Define this if your getsubopt() is broken) + ;; +esac + +]) + +AC_DEFUN([BHCOMPAT_REGEX_CHECK], [ + +AC_CHECK_HEADERS([regex.h]) +AC_CACHE_CHECK([whether works], + [ac_cv_regex_h_ok], [ac_cv_regex_h_ok=no + AC_COMPILE_IFELSE(AC_LANG_PROGRAM( + [#include + #include + ], []), [ac_cv_regex_h_ok=yes], + [ac_cv_regex_h_ok=no])]) +case ${ac_cv_regex_h_ok} in + yes) + AC_DEFINE(HAVE_WORKING_REGEX_H, 1, + [Define if your is usable]) + ;; +esac + +]) diff --git a/m4/Makefile.in b/m4/Makefile.in new file mode 100644 index 0000000..4e3e4bc --- /dev/null +++ b/m4/Makefile.in @@ -0,0 +1,13 @@ +## m4/Makefile +## arch-tag: ea0b0b82-8b7e-423c-ba68-4db1e5c079f2 + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = m4 + +## -- Private variables -- ## +SUBDIRS = bh-m4 + +EXTRA_DIST = libgnutls.m4 + +include ../Mk/Rules.mk diff --git a/m4/bh-m4/ChangeLog b/m4/bh-m4/ChangeLog new file mode 100644 index 0000000..d8cc4ae --- /dev/null +++ b/m4/bh-m4/ChangeLog @@ -0,0 +1,32 @@ +# do not edit -- automatically generated by arch changelog +# arch-tag: automatic-ChangeLog--algernon@bonehunter.rulez.org--tla/bhm4--mainline--0.1 +# + +2004-01-29 18:42:30 GMT Gergely Nagy patch-1 + + Summary: + Added ChangeLog to EXTRA_DIST + Revision: + bhm4--mainline--0.1--patch-1 + + * Makefile.in {EXTRA_DIST}: Added ChangeLog. + + modified files: + ChangeLog Makefile.in + + +2004-01-29 18:35:51 GMT Gergely Nagy base-0 + + Summary: + initial import + Revision: + bhm4--mainline--0.1--base-0 + + + (automatically generated log message) + + new files: + ChangeLog Makefile.in cc.m4 sfv_fd_self.m4 sockaddr_storage.m4 + tcp_cork.m4 + + diff --git a/m4/bh-m4/Makefile.in b/m4/bh-m4/Makefile.in new file mode 100644 index 0000000..a91b461 --- /dev/null +++ b/m4/bh-m4/Makefile.in @@ -0,0 +1,12 @@ +## m4/bh-m4/Makefile +## arch-tag: 836f6a60-6f91-4a55-b0e8-c3c8fa449422 + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = m4/bh-m4 + +## -- Private variables -- ## +EXTRA_DIST = cc.m4 sfv_fd_self.m4 sockaddr_storage.m4 tcp_cork.m4 \ + ChangeLog + +include ../../Mk/Rules.mk diff --git a/m4/bh-m4/cc.m4 b/m4/bh-m4/cc.m4 new file mode 100644 index 0000000..06b6a5f --- /dev/null +++ b/m4/bh-m4/cc.m4 @@ -0,0 +1,91 @@ +# arch-tag: 5b59cf27-9403-4203-9a20-b3e57ee97b45 + +AC_DEFUN([BHM4_CC_CHECK],[ + +AC_CHECK_TOOL(CC, cc) +AC_PROG_CC + +WFLAGS="" +WFLAGS_3X="" +WFLAGS_29X="" +if test "x$ac_compiler_gnu" = "xyes"; then + WFLAGS='${WFLAGS_GCC}' + AC_MSG_CHECKING(whether we are using GCC >= 2.9x) + GCCVER=$(${CC} -dumpversion 2>/dev/null) + case ${GCCVER} in + 2.9*) + WFLAGS_29X='${WFLAGS_29X}' + AC_MSG_RESULT([yes, ${GCCVER}]) + ;; + 3.*) + WFLAGS_29X='${WFLAGS_29X}' + WFLAGS_3X='${WFLAGS_3X}' + AC_MSG_RESULT([yes, ${GCCVER}]) + ;; + *) + AC_MSG_RESULT([no, ${GCCVER}]) + ;; + esac + AC_MSG_CHECKING(whether GCC supports -no-cpp-precomp) + case $(${CC} -no-cpp-precomp 2>&1) in + *-no-cpp-precomp*) + AC_MSG_RESULT(no) + ;; + *) + CFLAGS="${CFLAGS} -no-cpp-precomp" + AC_MSG_RESULT(yes) + ;; + esac +else + AC_MSG_CHECKING(whether we are using the Intel C compiler) + if ${CC} -V 2>&1 | head -n 1 | grep -q "Intel(R)"; then + AC_MSG_RESULT(yes) + WFLAGS='${WFLAGS_ICC}' + ac_compiler_intel="yes" + else + AC_MSG_RESULT(no) + ac_compiler_intel="no" + fi +fi +AC_SUBST(WFLAGS) +AC_SUBST(WFLAGS_29X) +AC_SUBST(WFLAGS_3X) + +AC_PROG_CPP +AC_PROG_GCC_TRADITIONAL + +AC_CACHE_CHECK([for __VA_ARGS__], [ac_cv_va_args], + [ac_cv_va_args=no + AC_COMPILE_IFELSE(AC_LANG_PROGRAM( + [#include + #include + #include + + #define vaarg_test(fmt,...) syslog (LOG_DEBUG, fmt, __VA_ARGS__) + ], [vaarg_test ("%d", atoi ("42"));]), [ac_cv_va_args=yes], + [ac_cv_va_args=no])]) +case ${ac_cv_va_args} in + yes) + AC_DEFINE(HAVE___VA_ARGS__, 1, + [Define if you have __VA_ARGS__]) + ;; +esac + +AC_CACHE_CHECK([whether the compiler supports gcc-style variadic macros], + [ac_cv_variadic_macros], [ac_cv_variadic_macros=no + AC_COMPILE_IFELSE(AC_LANG_PROGRAM( + [[#include + #include + #include + + #define gcc_vaarg_test(fmt,args...) syslog (LOG_DEBUG, fmt , ## args) + ]], [[ gcc_vaarg_test ("%d", atoi ("42")); ]]), [ac_cv_variadic_macros="yes"], + [ac_cv_variadic_macros="no"])]) +case ${ac_cv_variadic_macros} in + yes) + AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS, 1, + Define this if you have GCC-style variadic macros) + ;; +esac + +]) diff --git a/m4/bh-m4/sfv_fd_self.m4 b/m4/bh-m4/sfv_fd_self.m4 new file mode 100644 index 0000000..a4200ea --- /dev/null +++ b/m4/bh-m4/sfv_fd_self.m4 @@ -0,0 +1,13 @@ +# arch-tag: 8f8683bf-e264-44c6-9610-c0266826ccb7 + +AC_DEFUN([BHM4_SFV_FD_SELF_CHECK], [ + +AC_CHECK_DECL([SFV_FD_SELF], +[AC_DEFINE(HAVE_DECL_SFV_FD_SELF, 1, +[Define this if you have SFV_FD_SELF])], [], +[#if HAVE_SYS_SENDFILE_H +#include +#endif +]) + +]) diff --git a/m4/bh-m4/sockaddr_storage.m4 b/m4/bh-m4/sockaddr_storage.m4 new file mode 100644 index 0000000..2bdde67 --- /dev/null +++ b/m4/bh-m4/sockaddr_storage.m4 @@ -0,0 +1,22 @@ +# arch-tag: 8ad01d06-02d4-4a37-ac1f-781c7a279376 + +AC_DEFUN([BHM4_SOCKADDR_STORAGE_CHECK], [ + +AC_CACHE_CHECK([for struct sockaddr_storage], + [ac_cv_struct_sockaddr_storage], + [ac_cv_struct_sockaddr_storage=no + AC_COMPILE_IFELSE(AC_LANG_PROGRAM( + [#include + #include + ], + [[ struct sockaddr_storage x;]]), + [ac_cv_struct_sockaddr_storage=yes], + [ac_cv_struct_sockaddr_storage=no])]) +case ${ac_cv_struct_sockaddr_storage} in + yes) + AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, + [Define if you have struct sockaddr_storage]) + ;; +esac + +]) diff --git a/m4/bh-m4/tcp_cork.m4 b/m4/bh-m4/tcp_cork.m4 new file mode 100644 index 0000000..349c0ed --- /dev/null +++ b/m4/bh-m4/tcp_cork.m4 @@ -0,0 +1,16 @@ +# arch-tag: 3416a800-dad6-4fad-8c25-b599962200e7 + +AC_DEFUN([BHM4_TCP_CORK_CHECK],[ + +AC_CHECK_DECL([TCP_CORK], +[AC_DEFINE(HAVE_DECL_TCP_CORK, 1, +[Define this if you have TCP_CORK])], [], +[#if HAVE_NETINET_TCP_H +#include +#endif +#if HAVE_NETINET_IN_H +#include +#endif +]) + +]) diff --git a/m4/libgnutls.m4 b/m4/libgnutls.m4 new file mode 100644 index 0000000..da001ea --- /dev/null +++ b/m4/libgnutls.m4 @@ -0,0 +1,161 @@ +# arch-tag: 749795bd-504e-4786-8e57-d8719ba35487 +dnl Autoconf macros for libgnutls + +# Modified for LIBGNUTLS -- nmav +# Configure paths for LIBGCRYPT +# Shamelessly stolen from the one of XDELTA by Owen Taylor +# Werner Koch 99-12-09 + +dnl AM_PATH_LIBGNUTLS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) +dnl Test for libgnutls, and define LIBGNUTLS_CFLAGS and LIBGNUTLS_LIBS +dnl +AC_DEFUN(AM_PATH_LIBGNUTLS, +[dnl +dnl Get the cflags and libraries from the libgnutls-config script +dnl +AC_ARG_WITH(libgnutls-prefix, + [ --with-libgnutls-prefix=PFX Prefix where libgnutls is installed (optional)], + libgnutls_config_prefix="$withval", libgnutls_config_prefix="") + + if test x$libgnutls_config_prefix != x ; then + libgnutls_config_args="$libgnutls_config_args --prefix=$libgnutls_config_prefix" + if test x${LIBGNUTLS_CONFIG+set} != xset ; then + LIBGNUTLS_CONFIG=$libgnutls_config_prefix/bin/libgnutls-config + fi + fi + + AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no) + min_libgnutls_version=ifelse([$1], ,0.1.0,$1) + AC_MSG_CHECKING(for libgnutls - version >= $min_libgnutls_version) + no_libgnutls="" + if test "$LIBGNUTLS_CONFIG" = "no" ; then + no_libgnutls=yes + else + LIBGNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --cflags` + LIBGNUTLS_LIBS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --libs` + libgnutls_config_version=`$LIBGNUTLS_CONFIG $libgnutls_config_args --version` + + + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS" + LIBS="$LIBS $LIBGNUTLS_LIBS" +dnl +dnl Now check if the installed libgnutls is sufficiently new. Also sanity +dnl checks the results of libgnutls-config to some extent +dnl + rm -f conf.libgnutlstest + AC_TRY_RUN([ +#include +#include +#include +#include + +int +main () +{ + system ("touch conf.libgnutlstest"); + + if( strcmp( gnutls_check_version(NULL), "$libgnutls_config_version" ) ) + { + printf("\n*** 'libgnutls-config --version' returned %s, but LIBGNUTLS (%s)\n", + "$libgnutls_config_version", gnutls_check_version(NULL) ); + printf("*** was found! If libgnutls-config was correct, then it is best\n"); + printf("*** to remove the old version of LIBGNUTLS. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If libgnutls-config was wrong, set the environment variable LIBGNUTLS_CONFIG\n"); + printf("*** to point to the correct copy of libgnutls-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } + else if ( strcmp(gnutls_check_version(NULL), LIBGNUTLS_VERSION ) ) + { + printf("\n*** LIBGNUTLS header file (version %s) does not match\n", LIBGNUTLS_VERSION); + printf("*** library (version %s)\n", gnutls_check_version(NULL) ); + } + else + { + if ( gnutls_check_version( "$min_libgnutls_version" ) ) + { + return 0; + } + else + { + printf("no\n*** An old version of LIBGNUTLS (%s) was found.\n", + gnutls_check_version(NULL) ); + printf("*** You need a version of LIBGNUTLS newer than %s. The latest version of\n", + "$min_libgnutls_version" ); + printf("*** LIBGNUTLS is always available from ftp://gnutls.hellug.gr/pub/gnutls.\n"); + printf("*** \n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of LIBGNUTLS, but you can also set the LIBGNUTLS_CONFIG environment to point to the\n"); + printf("*** correct copy of libgnutls-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_libgnutls=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + + if test "x$no_libgnutls" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + if test -f conf.libgnutlstest ; then + : + else + AC_MSG_RESULT(no) + fi + if test "$LIBGNUTLS_CONFIG" = "no" ; then + echo "*** The libgnutls-config script installed by LIBGNUTLS could not be found" + echo "*** If LIBGNUTLS was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the LIBGNUTLS_CONFIG environment variable to the" + echo "*** full path to libgnutls-config." + else + if test -f conf.libgnutlstest ; then + : + else + echo "*** Could not run libgnutls test program, checking why..." + CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS" + LIBS="$LIBS $LIBGNUTLS_LIBS" + AC_TRY_LINK([ +#include +#include +#include +#include +], [ return !!gnutls_check_version(NULL); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding LIBGNUTLS or finding the wrong" + echo "*** version of LIBGNUTLS. If it is not finding LIBGNUTLS, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + echo "***" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means LIBGNUTLS was incorrectly installed" + echo "*** or that you have moved LIBGNUTLS since it was installed. In the latter case, you" + echo "*** may want to edit the libgnutls-config script: $LIBGNUTLS_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + LIBGNUTLS_CFLAGS="" + LIBGNUTLS_LIBS="" + ifelse([$3], , :, [$3]) + fi + rm -f conf.libgnutlstest + AC_SUBST(LIBGNUTLS_CFLAGS) + AC_SUBST(LIBGNUTLS_LIBS) +]) + +dnl *-*wedit:notab*-* Please keep this as the last line. diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..c58c212 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,41 @@ +## src/Makefile +## arch-tag: ca811d13-9d7b-4519-95de-f998dac67549 + +## -- User-modifiable variables -- ## +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = src + +## == The code below shouldn't need to be touched at all == ## + +## -- Private variables -- ## +PROGRAMS = crywrap +SOURCES = crywrap.c +HEADERS = primes.h crywrap.h + +LIBGNUTLS_CFLAGS= @LIBGNUTLS_CFLAGS@ +LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ +SHISHI_LIBS = @SHISHI_LIBS@ + +CUSTOM_CFLAGS = -I${top_srcdir}/lib ${LIBGNUTLS_CFLAGS} +CUSTOM_LDFLAGS = ${LIBGNUTLS_LIBS} ${SHISHI_LIBS} +CUSTOM_OBJECTS = ${top_builddir}/lib/compat/compat.o + +include ../Mk/Rules.mk + +## -- Standard targets -- ## +all:: ${PROGRAMS} + +install:: all + ${quiet} ${P_INST} ${DESTDIR}${sbindir}/crywrap + ${quiet} ${INSTALL} -d ${DESTDIR}${sbindir} + ${quiet} ${INSTALL_PROGRAM} crywrap ${DESTDIR}${sbindir}/ + +uninstall:: + ${quiet} ${P_UNINST} ${DESTDIR}${sbindir}/crywrap + ${quiet} rm -f ${DESTDIR}${sbindir}/crywrap + +## -- Dependencies -- ## +${PROGRAMS}: ${OBJECTS} +crywrap.o: crywrap.c ${top_builddir}/system.h ${top_srcdir}/ChangeLog \ + primes.h crywrap.h ${top_srcdir}/lib/compat/compat.h diff --git a/src/crywrap.c b/src/crywrap.c new file mode 100644 index 0000000..26f8eb5 --- /dev/null +++ b/src/crywrap.c @@ -0,0 +1,1138 @@ +/* -*- mode: c; c-file-style: "gnu" -*- + * crywrap.c -- CryWrap + * Copyright (C) 2003, 2004 Gergely Nagy + * + * This file is part of CryWrap. + * + * CryWrap 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. + * + * CryWrap 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 + */ + +/** @file crywrap.c + * CryWrap itself. + */ + +#include +#include "compat/compat.h" + +#ifdef HAVE_ARGP_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "crywrap.h" +#include "primes.h" + +/** @defgroup globals Global variables. + * @{ + */ +/** Status flag to toggle on SIGCHLD. + */ +static sig_atomic_t sigchld = 0; +/** An array of pids. + * This array holds the PIDs of all of our children, indexed by the + * socket the associated client connected to us. + */ +static pid_t crywrap_children[_CRYWRAP_MAXCONN + 2]; +static pid_t main_pid = -1; /**< Pid of the main process */ +static char *pidfile = _CRYWRAP_PIDFILE; /**< File to log our PID + into. */ +/** GNUTLS server credentials. + */ +static gnutls_certificate_server_credentials cred; +static gnutls_dh_params dh_params; /**< GNUTLS DH parameters. */ +static gnutls_rsa_params rsa_params; /**< GNUTLS RSA parameters. */ +static const int dh_bits = 1024; /**< GNUTLS DH bits. */ + +/** Bugreport address. + * Used by the argp suite. + */ +const char *argp_program_bug_address = ""; +/** Porgram version. + * Used by the argp suite. + */ +const char *argp_program_version = __CRYWRAP__ " " _CRYWRAP_VERSION; + +/** The options CryWrap takes. + * Used by the argp suite. + */ +static const struct argp_option _crywrap_options[] = { + {NULL, 0, NULL, 0, "Mandatory options:", 1}, + {"destination", 'd', "IP/PORT", 0, "IP and port to connect to", 1}, + {NULL, 0, NULL, 0, "TLS certificates:", 2}, + {"pem", 'p', "TYPE=PATH", 0, "Server key and certificate", 2}, + {"anon", 'a', NULL, 0, "Enable Anon-DH (don't use a certificate)", 2}, + {"verify", 'v', "LEVEL", OPTION_ARG_OPTIONAL, + "Verify clients certificate", 2}, + {NULL, 0, NULL, 0, "Other options:", 3}, + {"user", 'u', "UID", 0, "User ID to run as", 3}, + {"pidfile", 'P', "PATH", 0, "File to log the PID into", 3}, + {"inetd", 'i', NULL, 0, "Enable inetd mode", 3}, + {"listen", 'l', "IP/PORT", 0, "IP and port to listen on", 3}, + {0, 0, 0, 0, NULL, 0} +}; + +static error_t _crywrap_config_parse_opt (int key, char *arg, + struct argp_state *state); +/** The main argp structure for Crywrap. + */ +static const struct argp _crywrap_argp = + {_crywrap_options, _crywrap_config_parse_opt, 0, + __CRYWRAP__ " -- Security for the masses\v" + "The --destination option is mandatory, as is --listen if --inetd " + "was not used.", + NULL, NULL, NULL}; + +#ifndef __DOXYGEN__ +enum +{ + CRYWRAP_P_SUBOPT_CERT, + CRYWRAP_P_SUBOPT_KEY, + CRYWRAP_P_SUBOPT_END +}; +#endif + +/** Helper structure for parsing --pem subopts. + */ +static char *_crywrap_p_subopts[] = { + [CRYWRAP_P_SUBOPT_CERT] = "cert", + [CRYWRAP_P_SUBOPT_KEY] = "key", + [CRYWRAP_P_SUBOPT_END] = NULL +}; + +/** Helper variable to set if a certificate was explictly set. + */ +static int cert_seen = 0; + +/** @} */ + +/* Forward declaration */ +static int _crywrap_dh_params_generate (void); +static int _crywrap_rsa_params_generate (void); + +/** @defgroup signal Signal handlers & co. + * @{ + */ + +/** SIGCHLD handler + */ +static void +_crywrap_sigchld_handler (int sig) +{ + sigchld = 1; + signal (sig, _crywrap_sigchld_handler); +} + +/** SIGHUP handler. + * Regenerates DH and RSA paramaters. Takes a bit long... + */ +static void +_crywrap_sighup_handler (int sig) +{ + _crywrap_dh_params_generate (); + _crywrap_rsa_params_generate (); + + gnutls_certificate_set_dh_params (cred, dh_params); + gnutls_certificate_set_rsa_params (cred, rsa_params); + + signal (sig, _crywrap_sighup_handler); +} + +/** Generic signal handler. + * This one removes the #pidfile, if necessary. + */ +static void +_crywrap_sighandler (int sig) +{ + if (getpid () == main_pid) + { + bhc_log ("Exiting on signal %d", sig); + if (pidfile && *pidfile) + unlink (pidfile); + closelog (); + exit (0); + } +} +/** @} */ + +/** @defgroup parsing Option parsing + * @{ + */ + +/** Service resolver. + * Resolves a service - be it a name or a number. + * + * @param serv is the port to resolve. + * + * @returns The purt number, or -1 on error. + */ +static int +_crywrap_port_get (const char *serv) +{ + int port; + struct servent *se; + + if (!serv) + return -1; + + se = getservbyname (serv, "tcp"); + if (!se) + port = atoi (serv); + else + port = ntohs (se->s_port); + + return port; +} + +/** Address resolver. + * Resolves an address - be it numeric or a hostname, IPv4 or IPv6. + * + * @param hostname is the host to resolve. + * @param addr is the structure to put the result into. + * + * @returns Zero on success, -1 on error. + */ +static int +_crywrap_addr_get (const char *hostname, struct sockaddr_storage **addr) +{ + struct addrinfo *res; + struct addrinfo hints; + ssize_t len; + char *lz = NULL; + + if (idna_to_ascii_lz (hostname, &lz, 0) != IDNA_SUCCESS) + return -1; + + memset (&hints, 0, sizeof (hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_IP; + *addr = bhc_calloc (1, sizeof (struct sockaddr_storage)); + + if (getaddrinfo (lz, NULL, &hints, &res) != 0) + { + free (lz); + return -1; + } + + free (lz); + + switch (res->ai_addr->sa_family) + { + case AF_INET: + len = sizeof (struct sockaddr_in); + break; + case AF_INET6: + len = sizeof (struct sockaddr_in6); + break; + default: + freeaddrinfo (res); + return -1; + } + + if (len < (ssize_t)res->ai_addrlen) + { + freeaddrinfo (res); + return -1; + } + + memcpy (*addr, res->ai_addr, res->ai_addrlen); + freeaddrinfo (res); + + return 0; +} + +/** Parse a HOST/IP pair. + * Splits up a given HOST/IP pair, and converts them into structures + * directly usable by libc routines. + * + * @param ip is the HOST/IP pair to parse. + * @param port is a pointer to an integer where the port number should + * go. + * @param addr is the destination of the resolved and parsed IP. + * + * @returns Zero on success, -1 on error. + */ +static int +_crywrap_parse_ip (const char *ip, in_port_t *port, + struct sockaddr_storage **addr, char **host) +{ + char *s_ip; + char *tmp; + + tmp = strchr (ip, '/'); + + if (!tmp) + return -1; + + if (tmp == ip) + { + s_ip = bhc_strdup ("0.0.0.0"); + *port = (in_port_t)_crywrap_port_get (&ip[1]); + } + else + { + *port = (in_port_t)_crywrap_port_get (&tmp[1]); + s_ip = bhc_strndup (ip, tmp - ip); + } + + if (!*port) + return -1; + + if (host) + *host = strdup (s_ip); + + return _crywrap_addr_get (s_ip, addr); +} + +/** Argument parsing routine. + * Used by the argp suite. + */ +static error_t +_crywrap_config_parse_opt (int key, char *arg, struct argp_state *state) +{ + crywrap_config_t *cfg = (crywrap_config_t *)state->input; + char *pem_cert, *pem_key, *subopts, *value; + + switch (key) + { + case 'd': + if (_crywrap_parse_ip (arg, &cfg->dest.port, &cfg->dest.addr, + &cfg->dest.host) < 0) + argp_error (state, "Could not resolve address: `%s'", arg); + break; + case 'l': + if (_crywrap_parse_ip (arg, &cfg->listen.port, + &cfg->listen.addr, NULL) < 0) + argp_error (state, "Could not resolve address: `%s'", arg); + break; + case 'u': + cfg->uid = atoi (arg); + break; + case 'P': + if (arg && *arg) + cfg->pidfile = bhc_strdup (arg); + else + cfg->pidfile = NULL; + break; + case 'p': + subopts = optarg; + pem_cert = NULL; + pem_key = NULL; + while (*subopts != '\0') + switch (bhc_getsubopt (&subopts, _crywrap_p_subopts, &value)) + { + case CRYWRAP_P_SUBOPT_CERT: + pem_cert = bhc_strdup (value); + break; + case CRYWRAP_P_SUBOPT_KEY: + pem_key = bhc_strdup (value); + break; + default: + pem_cert = bhc_strdup (value); + break; + } + if (!pem_key) + pem_key = bhc_strdup (pem_cert); + if (!pem_cert) + pem_cert = bhc_strdup (pem_key); + if (gnutls_certificate_set_x509_key_file (cred, pem_cert, pem_key, + GNUTLS_X509_FMT_PEM) < 0) + argp_error (state, "error reading X.509 key or certificate file."); + cert_seen = 1; + break; + case 'i': + cfg->inetd = 1; + break; + case 'a': + cfg->anon = 1; + break; + case 'v': + cfg->verify = (arg) ? atoi (arg) : 1; + break; + case ARGP_KEY_END: + if (!cfg->inetd) + { + if (!cfg->listen.addr || !cfg->dest.addr) + argp_error + (state, + "a listening and a destination address must be set!"); + } + else + if (!cfg->dest.addr) + argp_error (state, "a destination address must be set!"); + if (cert_seen) + break; + if (cfg->anon) + break; + if (gnutls_certificate_set_x509_key_file (cred, _CRYWRAP_PEMFILE, + _CRYWRAP_PEMFILE, + GNUTLS_X509_FMT_PEM) < 0) + argp_error (state, "error reading X.509 key or certificate file."); + break; + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + +/** Configuration parsing. + * Sets up the default values, and parses the command-line options + * using argp. + * + * @note Does not return if an error occurred. + */ +static crywrap_config_t * +_crywrap_config_parse (int argc, char **argv) +{ + crywrap_config_t *config = + (crywrap_config_t *)bhc_malloc (sizeof (crywrap_config_t)); + + config->listen.port = 0; + config->listen.addr = NULL; + config->dest.port = 0; + config->dest.addr = NULL; + + config->uid = _CRYWRAP_UID; + config->pidfile = _CRYWRAP_PIDFILE; + config->inetd = 0; + config->anon = 0; + config->verify = 1; + + argp_parse (&_crywrap_argp, argc, argv, 0, 0, config); + + return config; +} +/** @} */ + +/** @defgroup tls Lower-level TLS routines. + * @{ + */ + +/** Callback function. + * This function gets called by GnuTLS to determine which certificate + * to use. + * + * It checks if the client indicated which host it is connecting to, + * and if yes, tries to find an appropriate cert. + * + * @returns The most appropriate certificate's index on success, zero + * (the first cert) if no other certificate is appropriate. + */ +static int +_crywrap_session_cert_select (gnutls_session session, + gnutls_datum *server_certs, int ncerts) +{ + int idx, data_length = 0, name_type, i; + char *name; + + /* If we only have one cert, return that. */ + if (ncerts < 2) + return 0; + + /* Get the length of the data. Note that we only care about the + first hostname sent. At least, for now. */ + data_length = 0; + i = gnutls_server_name_get (session, NULL, &data_length, + &name_type, 0); + + /* And get the data itself */ + if (i == GNUTLS_E_SHORT_MEMORY_BUFFER) + { + data_length += 2; + name = (char *)bhc_malloc (data_length); + gnutls_server_name_get (session, name, &data_length, &name_type, 0); + if (name_type != GNUTLS_NAME_DNS) + { + free (name); + return 0; + } + } + else + return 0; + + /* Iterate through the certs and select the appropriate one. */ + for (idx = 0; idx < ncerts; idx++) + { + gnutls_x509_crt *crt= (gnutls_x509_crt *)&server_certs[idx]; + + if (gnutls_x509_crt_check_hostname (*crt, name) != 0) + { + free (name); + return idx; + } + } + + free (name); + return 0; +} + +/** Create a GNUTLS session. + * Initialises the cyphers and the session database for a new TLS + * session. + * + * @returns The newly created TLS session. + */ +static gnutls_session +_crywrap_tls_session_create (const crywrap_config_t *config) +{ + gnutls_session session; + const int comp_prio[] = { GNUTLS_COMP_ZLIB, GNUTLS_COMP_LZO, + GNUTLS_COMP_NULL, 0 }; + const int mac_prio[] = { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, 0 }; + const int kx_prio[] = { GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA, + GNUTLS_KX_DHE_RSA, GNUTLS_KX_RSA_EXPORT, + GNUTLS_KX_ANON_DH, 0 }; + const int cipher_prio[] = { GNUTLS_CIPHER_RIJNDAEL_128_CBC, + GNUTLS_CIPHER_3DES_CBC, + GNUTLS_CIPHER_ARCFOUR_128, + GNUTLS_CIPHER_ARCFOUR_40, 0 }; + const int protocol_prio[] = { GNUTLS_TLS1, GNUTLS_SSL3, 0 }; + + gnutls_init (&session, GNUTLS_SERVER); + + gnutls_cipher_set_priority (session, cipher_prio); + gnutls_compression_set_priority (session, comp_prio); + gnutls_kx_set_priority (session, kx_prio); + gnutls_protocol_set_priority (session, protocol_prio); + gnutls_mac_set_priority (session, mac_prio); + + if (config->anon) + gnutls_credentials_set (session, GNUTLS_CRD_ANON, cred); + gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cred); + + gnutls_dh_set_prime_bits (session, dh_bits); + + gnutls_handshake_set_private_extensions (session, 1); + + gnutls_certificate_server_set_select_function + (session, (gnutls_certificate_server_select_function *) + _crywrap_session_cert_select); + + if (config->verify) + gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST); + + return session; +} + +/** (Re)Initialise Diffie Hellman parameters. + * @returns Zero. + */ +static int +_crywrap_dh_params_generate (void) +{ + if (gnutls_dh_params_init (&dh_params) < 0) + { + bhc_error ("%s", "Error in dh parameter initialisation."); + bhc_exit (3); + } + + if (gnutls_dh_params_generate2 (dh_params, dh_bits) < 0) + { + bhc_error ("%s", "Error in prime generation."); + bhc_exit (3); + } + + gnutls_certificate_set_dh_params (cred, dh_params); + + return 0; +} + +/** (Re)Initialise RSA parameters. + * @returns Zero. + */ +static int +_crywrap_rsa_params_generate (void) +{ + if (gnutls_rsa_params_init (&rsa_params) < 0) + { + bhc_error ("%s", "Error in RSA parameter initialisation."); + bhc_exit (3); + } + + if (gnutls_rsa_params_generate2 (rsa_params, 512) < 0) + { + bhc_error ("%s", "Error in RSA parameter generation."); + bhc_exit (3); + } + + gnutls_certificate_set_rsa_params (cred, rsa_params); + + return 0; +} + +/** Generate initial DH and RSA params. + * Loads the pre-generated DH primes, and generates RSA params. + */ +static void +_crywrap_tls_init (void) +{ + gnutls_datum dh_prime_bits, dh_generator; + + /* DH */ + dh_prime_bits.data = _crywrap_prime_dh_1024; + dh_prime_bits.size = sizeof (_crywrap_prime_dh_1024); + + dh_generator.data = _crywrap_generator_dh; + dh_generator.size = sizeof (_crywrap_generator_dh); + + gnutls_dh_params_init (&dh_params); + gnutls_dh_params_import_raw (dh_params, &dh_prime_bits, &dh_generator); + + gnutls_certificate_set_dh_params (cred, dh_params); + + /* RSA */ + _crywrap_rsa_params_generate (); + gnutls_certificate_set_rsa_params (cred, rsa_params); +} +/** @} */ + +/** @defgroup networking Networking + * @{ + */ + +/** Bind to an address. + * This one binds to an address, handles errors and anything that may + * arise. + * + * @param ai is the address information. + * @param listen_port is the port to bind to, and listen on. + * + * @returns The bound filedescriptor, or -1 on error. + */ +static int +_crywrap_bind (const struct addrinfo *ai, int listen_port) +{ + int ret; + const int one = 1; + int listenfd; + char sock_name[NI_MAXHOST]; + + listenfd = socket (ai->ai_family, SOCK_STREAM, IPPROTO_IP); + if (listenfd == -1) + { + bhc_error ("socket: %s", strerror (errno)); + return -1; + } + + memset (sock_name, 0, sizeof (sock_name)); + getnameinfo ((struct sockaddr *)ai->ai_addr, ai->ai_addrlen, sock_name, + sizeof (sock_name), NULL, 0, NI_NUMERICHOST); + + switch (ai->ai_family) + { + case AF_INET6: + ((struct sockaddr_in6 *)(ai->ai_addr))->sin6_port = listen_port; + break; + case AF_INET: + ((struct sockaddr_in *)(ai->ai_addr))->sin_port = listen_port; + break; + } + + ret = setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, + &one, sizeof (one)); + if (ret != 0) + { + bhc_error ("setsockopt: %s (%s)", strerror (errno), sock_name); + return -1; + } + + ret = bind (listenfd, ai->ai_addr, ai->ai_addrlen); + if (ret != 0) + { + bhc_error ("bind to %s failed: %s", sock_name, strerror (errno)); + return -1; + } + + if (listen (listenfd, _CRYWRAP_MAXCONN) != 0) + { + bhc_error ("listen on %s failed: %s", sock_name, strerror (errno)); + return -1; + } + + bhc_log ("Socket bound to port %d on %s.", ntohs (listen_port), sock_name); + + return listenfd; +} + +/** Set up a listening socket. + * Sets up a listening socket on all the required addresses. + * + * @param config holds the CryWrap configuration, from where the + * listen address and port will be extracted. + * + * @returns The listening FD on success, -1 on error. + */ +static int +_crywrap_listen (const crywrap_config_t *config) +{ + struct addrinfo *cur; + int ret; + + cur = bhc_calloc (1, sizeof (struct addrinfo)); + cur->ai_family = config->listen.addr->ss_family; + + switch (cur->ai_family) + { + case AF_INET6: + cur->ai_addrlen = sizeof (struct sockaddr_in6); + break; + case AF_INET: + cur->ai_addrlen = sizeof (struct sockaddr_in); + break; + } + + cur->ai_addr = bhc_malloc (cur->ai_addrlen); + memcpy (cur->ai_addr, config->listen.addr, cur->ai_addrlen); + + ret = _crywrap_bind (cur, htons (config->listen.port)); + free (cur->ai_addr); + free (cur); + + return ret; +} + +/** Connect to a remote server. + * Estabilishes a connection to a remote server, and handles all + * errors and anything that may arise during this process. + * + * @param addr is the address of the remote server. + * @param port is the port to connect to. + * + * @returns the connected socket on success, otherwise it exits. + */ +static int +_crywrap_remote_connect (const struct sockaddr_storage *addr, int port) +{ + struct addrinfo *cur; + int sock; + + cur = bhc_calloc (1, sizeof (struct addrinfo)); + cur->ai_family = addr->ss_family; + + switch (cur->ai_family) + { + case AF_INET6: + cur->ai_addrlen = sizeof (struct sockaddr_in6); + break; + case AF_INET: + cur->ai_addrlen = sizeof (struct sockaddr_in); + break; + } + + cur->ai_addr = bhc_malloc (cur->ai_addrlen); + memcpy (cur->ai_addr, addr, cur->ai_addrlen); + + switch (cur->ai_family) + { + case AF_INET6: + ((struct sockaddr_in6 *)(cur->ai_addr))->sin6_port = port; + break; + case AF_INET: + ((struct sockaddr_in *)(cur->ai_addr))->sin_port = port; + break; + } + + sock = socket (cur->ai_family, SOCK_STREAM, IPPROTO_IP); + if (sock < 0) + { + bhc_error ("socket(): %s", strerror (errno)); + bhc_exit (1); + } + + if (connect (sock, cur->ai_addr, cur->ai_addrlen) < 0) + { + bhc_error ("connect(): %s", strerror (errno)); + bhc_exit (1); + } + + free (cur->ai_addr); + free (cur); + + return sock; +} + +/** @} */ + +/** @defgroup crywrap Main CryWrap code. + * @{ + */ + +/** Drop privileges. + * Drop privileges, if running as root. + * Upon failure, it will make CryWrap exit. + */ +static void +_crywrap_privs_drop (const crywrap_config_t *config) +{ + struct passwd *pwd; + + if (getuid () != 0) + { + bhc_log ("%s", "Not running as root, not dropping privileges."); + return; + } + + if ((pwd = getpwuid (config->uid)) == NULL) + { + bhc_error ("getpwuid(): %s", strerror (errno)); + bhc_exit (1); + } + + if (initgroups (pwd->pw_name, pwd->pw_gid) == -1) + { + bhc_error ("initgroups(): %s", strerror (errno)); + bhc_exit (1); + } + + if (setgid (pwd->pw_gid) == -1) + { + bhc_error ("setgid(): %s", strerror (errno)); + bhc_exit (1); + } + + if (setuid (config->uid)) + { + bhc_error ("setuid(): %s", strerror (errno)); + bhc_exit (1); + } +} + +/** Set up the PID file. + * Checks if a #pidfile already exists, and create one - containing the + * current PID - if one does not. + * + * @note Exits upon error. + */ +static void +_crywrap_setup_pidfile (const crywrap_config_t *config) +{ + char mypid[128]; + int pidfilefd; + + if (!config->pidfile || !*(config->pidfile)) + return; + + if (!access (config->pidfile, F_OK)) + { + bhc_error ("Pidfile (%s) already exists. Exiting.", config->pidfile); + exit (1); + } + if ((pidfilefd = open (config->pidfile, + O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1) + { + bhc_error ("Cannot create pidfile (%s): %s.\n", config->pidfile, + strerror (errno)); + exit (1); + } + fchown (pidfilefd, config->uid, (gid_t)-1); + + main_pid = getpid (); + snprintf (mypid, sizeof (mypid), "%d\n", main_pid); + write (pidfilefd, mypid, strlen (mypid)); + close (pidfilefd); + pidfile = config->pidfile; +} + +/** Child cleanup routine. + * Called after a SIGCHLD is received. Walks through #crywrap_children + * and closes the socket of the one that exited. + */ +static void +_crywrap_reap_children (void) +{ + pid_t child; + int status, i; + + while ((child = waitpid (-1, &status, WNOHANG)) > (pid_t) 0) + { + for (i = 0; i < _CRYWRAP_MAXCONN; i++) + { + if (!crywrap_children[i]) + continue; + if (child == crywrap_children[i]) + { + shutdown (i, SHUT_RDWR); + close (i); + crywrap_children[i] = 0; + } + } + } + sigchld = 0; +} + +/** Handles one client. + * This one connects to the remote server, and proxies every traffic + * between our client and the server. + * + * @param config is the main CryWrap configuration structure. + * @param insock is the socket through which the client sends input. + * @param outsock is the socket through which we send output. + * + * @note Exits on error. + */ +static int +_crywrap_do_one (const crywrap_config_t *config, int insock, int outsock) +{ + int sock, ret; + gnutls_session session; + char buffer[_CRYWRAP_MAXBUF + 2]; + fd_set fdset; + struct sockaddr_storage faddr; + socklen_t socklen = sizeof (struct sockaddr_storage); + char peer_name[NI_MAXHOST]; + + /* Log the connection */ + if (getpeername (insock, (struct sockaddr *)&faddr, &socklen) != 0) + bhc_error ("getpeername(): %s", strerror (errno)); + else + { + getnameinfo ((struct sockaddr *)&faddr, + sizeof (struct sockaddr_storage), peer_name, + sizeof (peer_name), NULL, 0, NI_NUMERICHOST); + bhc_log ("Accepted connection from %s on %d to %s/%d", + peer_name, insock, config->dest.host, + config->dest.port); + } + + /* Do the handshake with our peer */ + session = _crywrap_tls_session_create (config); + gnutls_transport_set_ptr2 (session, + (gnutls_transport_ptr)insock, + (gnutls_transport_ptr)outsock); + if ((ret = gnutls_handshake (session)) < 0) + { + bhc_error ("Handshake failed: %s", gnutls_strerror (ret)); + gnutls_bye (session, GNUTLS_SHUT_RDWR); + close (insock); + close (outsock); + return 1; + } + + /* Verify the client's certificate, if any. */ + if (config->verify) + { + ret = gnutls_certificate_verify_peers (session); + if (ret < 0) + bhc_log ("Error getting certificate from client: %s", + gnutls_strerror (ret)); + else if (ret != 0) + switch (ret) + { + case GNUTLS_CERT_INVALID: + bhc_log ("%s", "Client certificate not trusted or invalid"); + break; + default: + bhc_log ("%s", "Unknown error while getting the certificate"); + break; + } + + if (config->verify > 1 && ret != 0) + return 1; + } + + /* Connect to the remote host */ + sock = _crywrap_remote_connect (config->dest.addr, + htons (config->dest.port)); + + for (;;) + { + FD_ZERO (&fdset); + FD_SET (insock, &fdset); + FD_SET (sock, &fdset); + + bzero (buffer, _CRYWRAP_MAXBUF + 1); + select (sock + 1, &fdset, NULL, NULL, NULL); + + /* TLS client */ + if (FD_ISSET (insock, &fdset)) + { + ret = gnutls_record_recv (session, buffer, _CRYWRAP_MAXBUF); + if (ret == 0) + { + bhc_log ("%s", "Peer has closed the GNUTLS connection"); + break; + } + else if (ret < 0) + { + bhc_log ("Received corrupted data: %s.", + gnutls_strerror (ret)); + break; + } + else + send (sock, buffer, ret, 0); + } + + /* Remote server */ + if (FD_ISSET (sock, &fdset)) + { + ret = recv (sock, buffer, _CRYWRAP_MAXBUF, 0); + if (ret == 0) + { + bhc_log ("%s", "Server has closed the connection"); + break; + } + else if (ret < 0) + { + bhc_log ("Received corrupted data: %s.", strerror (errno)); + break; + } + else + { + int r, o = 0; + + do + { + r = gnutls_record_send (session, &buffer[o], ret - o); + o += r; + } while (r > 0 && ret > o); + + if (r < 0) + bhc_log ("Received corrupted data: %s", gnutls_strerror (r)); + } + } + } + gnutls_bye (session, GNUTLS_SHUT_WR); + gnutls_deinit (session); + close (insock); + close (outsock); + + return (ret == 0) ? 0 : 1; +} + +/** CryWrap entry point. + * This is the main entry point - controls the whole program and so + * on... + */ +int +main (int argc, char **argv, char **envp) +{ + crywrap_config_t *config; + int server_socket; + + openlog (__CRYWRAP__, LOG_PID, LOG_DAEMON); + + if (gnutls_global_init () < 0) + { + bhc_error ("%s", "Global TLS state initialisation failed."); + bhc_exit (1); + } + if (gnutls_certificate_allocate_credentials (&cred) < 0) + { + bhc_error ("%s", "Couldn't allocate credentials."); + bhc_exit (1); + } + + stringprep_locale_charset (); + + bhc_setproctitle_init (argc, argv, envp); + config = _crywrap_config_parse (argc, argv); + bhc_setproctitle (__CRYWRAP__); + + _crywrap_tls_init (); + + if (config->inetd) + { + _crywrap_privs_drop (config); + exit (_crywrap_do_one (config, 0, 1)); + } + +#if CRYWRAP_OPTION_FORK + if (daemon (0, 0)) + { + bhc_error ("daemon: %s", strerror (errno)); + exit (1); + } +#endif + + bhc_log ("%s", "Crywrap starting..."); + + server_socket = _crywrap_listen (config); + if (server_socket < 0) + exit (1); + + _crywrap_setup_pidfile (config); + _crywrap_privs_drop (config); + + signal (SIGTERM, _crywrap_sighandler); + signal (SIGQUIT, _crywrap_sighandler); + signal (SIGSEGV, _crywrap_sighandler); + signal (SIGPIPE, SIG_IGN); + signal (SIGHUP, _crywrap_sighup_handler); + + bhc_log ("%s", "Accepting connections"); + + memset (crywrap_children, 0, sizeof (crywrap_children)); + signal (SIGCHLD, _crywrap_sigchld_handler); + + for (;;) + { + int csock; +#if !BHC_OPTION_DEBUG + int child; +#endif + + if (sigchld) + _crywrap_reap_children (); + + csock = accept (server_socket, NULL, NULL); + if (csock < 0) + continue; + +#if !BHC_OPTION_DEBUG + child = fork (); + switch (child) + { + case 0: + exit (_crywrap_do_one (config, csock, csock)); + break; + case -1: + bhc_error ("%s", "Forking error."); + bhc_exit (1); + break; + default: + crywrap_children[csock] = child; + break; + } +#else + _crywrap_do_one (config, csock, csock); +#endif + } + + return 0; +} + +/** @} */ + +/** arch-tag: 3d45d946-5d09-493d-ae6e-26effb71eb6b */ diff --git a/src/crywrap.h b/src/crywrap.h new file mode 100644 index 0000000..c3fe89c --- /dev/null +++ b/src/crywrap.h @@ -0,0 +1,105 @@ +/* -*- mode: c; c-file-style: "gnu" -*- + * crywrap.h -- Global definitions for CryWrap + * Copyright (C) 2003, 2004 Gergely Nagy + * + * This file is part of CryWrap. + * + * CryWrap 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. + * + * CryWrap 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 + */ + +/** @file crywrap.h + * Global variables and declarations for CryWrap. + * + * All of the global types, structures and whatnot are declared in + * this file. Not variables, though. Those are in crywrap.c. + */ + +#ifndef _CRYWRAP_H +#define _CRYWRAP_H 1 /**< crywrap.h multi-inclusion guard. */ + +/** @defgroup defaults Built-in defaults. + * @{ + */ +#define __CRYWRAP__ "crywrap" /**< Software name. */ +/** Software version. + */ +#define _CRYWRAP_VERSION "0.2." PATCHLEVEL EXTRAVERSION +/** Configuration directory. + */ +#define _CRYWRAP_CONFDIR SYSCONFDIR "/crywrap" +#define _CRYWRAP_UID 65534 /**< Default UID to run as. */ +/** Default PID file. + */ +#define _CRYWRAP_PIDFILE "/var/run/crywrap.pid" +/** Maximum number of clients supported. + */ +#define _CRYWRAP_MAXCONN 1024 +/** Maximum I/O buffer size. + */ +#define _CRYWRAP_MAXBUF 64 * 1024 +/** Default server certificate and key. + */ +#define _CRYWRAP_PEMFILE _CRYWRAP_CONFDIR "/server.pem" +/** @} */ + +/** Configuration structure. + * Most of the CryWrap configuration - those options that are settable + * via the command-line are stored in a variable of this type. + */ +typedef struct +{ + /** Properties of the listening socket. + */ + struct + { + in_port_t port; + struct sockaddr_storage *addr; + } listen; + + /** Properties of the destination socket. + */ + struct + { + in_port_t port; + char *host; + struct sockaddr_storage *addr; + } dest; + + char *pidfile; /**< File to store our PID in. */ + uid_t uid; /**< User ID to run as. */ + int inetd; /**< InetD-mode toggle. */ + int anon; /**< Anon-DH toggle. */ + int verify; /**< Client certificate verify level. */ +} crywrap_config_t; + +/** @defgroup options Options. + * These are the compile-time options. + * @{ + */ +/** If this option is set, CryWrap will fork into the background. + */ +#ifndef CRYWRAP_OPTION_FORK +#define CRYWRAP_OPTION_FORK 1 +#endif + +#if CRYWRAP_OPTION_NOFORK +#undef CRYWRAP_OPTION_FORK +#endif + +/** @} *//* End of the Options group */ + +#endif /* !_CRYWRAP_H */ + +/* arch-tag: ebfe1550-0fec-4c0d-8833-23e48292e75d */ diff --git a/src/primes.h b/src/primes.h new file mode 100644 index 0000000..21f54c6 --- /dev/null +++ b/src/primes.h @@ -0,0 +1,54 @@ +/* -*- mode: c; c-file-style: "gnu" -*- + * primes.h -- initial DH primes for CryWrap + * Copyright (C) 2003 Gergely Nagy + * + * This file is part of CryWrap. + * + * CryWrap 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. + * + * CryWrap 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 + */ + +/** @file primes.h + * Initial DH primes for CryWrap. + * + * In order to speed up the startup time, CryWrap does not generate a + * new DH prime upon every startup, but only when it receives a + * SIGHUP. + */ + +#ifndef _CRYWRAP_PRIMES_H +#define _CRYWRAP_PRIMES_H /**< primes.h multi-include guard */ + +/** Initial DH primes, 1024 bits. + */ +static unsigned char _crywrap_prime_dh_1024[] = { + 0xA0,0xB8,0x8C,0xB3,0x7B,0x22,0xBB,0xEC,0xBF,0x28,0x90,0xAA, + 0xF3,0x32,0x2B,0xFE,0xDB,0x9B,0xC4,0xA8,0x98,0xF1,0x88,0x2A, + 0x9A,0x9C,0xE2,0x21,0xB5,0x82,0x6D,0xE5,0x28,0x7F,0xD5,0xE9, + 0x8F,0x89,0xDA,0x10,0x87,0x32,0x08,0x13,0xCB,0x1B,0x23,0x3F, + 0x12,0x52,0x78,0x16,0x05,0xC5,0x6F,0xFC,0xDC,0x23,0xB9,0xA9, + 0x8C,0x80,0xFB,0x26,0x70,0x65,0x20,0x8E,0xAC,0xBD,0xF6,0x0F, + 0xEE,0xF1,0x51,0xE0,0x48,0xDD,0xF4,0xE3,0xF0,0x41,0x4C,0x7C, + 0x09,0xE9,0x9E,0xCB,0x94,0x79,0x59,0x0C,0xCC,0xF2,0xAB,0x8F, + 0xCD,0x07,0xC0,0xBB,0x61,0x9D,0x8D,0xA3,0x0F,0x63,0x08,0x53, + 0x89,0xA1,0x42,0x02,0x0C,0x9C,0x9D,0xEB,0x1C,0x28,0x67,0x75, + 0x57,0x52,0x42,0x96,0x47,0xC6,0xFE,0xBB +}; +/** DH generator. + */ +static unsigned char _crywrap_generator_dh[]={ 0x02 }; + +#endif + +/* arch-tag: a5ef5d07-d423-41fc-a2f3-360d47470df3 */ diff --git a/system.h.in b/system.h.in new file mode 100644 index 0000000..4841c4d --- /dev/null +++ b/system.h.in @@ -0,0 +1,232 @@ +/* system.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if the `closedir' function returns void instead of `int'. */ +#undef CLOSEDIR_VOID + +/* Define this to enable forking to background */ +#undef CRYWRAP_OPTION_FORK + +/* Define this to disable forking to background */ +#undef CRYWRAP_OPTION_NOFORK + +/* Define to 1 if you have the `alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the `dup2' function. */ +#undef HAVE_DUP2 + +/* Define to 1 if you have the `epoll_create' function. */ +#undef HAVE_EPOLL_CREATE + +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `kqueue' function. */ +#undef HAVE_KQUEUE + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +#undef HAVE_LIBSENDFILE + +/* Define to 1 if `lstat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_LSTAT_EMPTY_STRING_BUG + +/* Define to 1 if you have the `memchr' function. */ +#undef HAVE_MEMCHR + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the `munmap' function. */ +#undef HAVE_MUNMAP + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the `putenv' function. */ +#undef HAVE_PUTENV + +/* Define to 1 if you have the `regcomp' function. */ +#undef HAVE_REGCOMP + +/* Define to 1 if you have the `scandir' function. */ +#undef HAVE_SCANDIR + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `socket' function. */ +#undef HAVE_SOCKET + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_STAT_EMPTY_STRING_BUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strrchr' function. */ +#undef HAVE_STRRCHR + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the `strtoul' function. */ +#undef HAVE_STRTOUL + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the `uname' function. */ +#undef HAVE_UNAME + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vfork' function. */ +#undef HAVE_VFORK + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFORK_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if `fork' works. */ +#undef HAVE_WORKING_FORK + +/* Define to 1 if `vfork' works. */ +#undef HAVE_WORKING_VFORK + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +#undef LSTAT_FOLLOWS_SLASHED_SYMLINK + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* Define to the type of arg 1 for `select'. */ +#undef SELECT_TYPE_ARG1 + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#undef SELECT_TYPE_ARG234 + +/* Define to the type of arg 5 for `select'. */ +#undef SELECT_TYPE_ARG5 + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Define to 1 if you want Libidn. */ +#undef USE_LIBIDN + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define as `fork' if `vfork' does not work. */ +#undef vfork diff --git a/utils/Makefile.in b/utils/Makefile.in new file mode 100644 index 0000000..e089757 --- /dev/null +++ b/utils/Makefile.in @@ -0,0 +1,14 @@ +## utils/Makefile +## arch-tag: 236be2a1-d741-45d3-a892-018b66c8b648 + +## -- User-modifiable variables -- ## +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +subdir = utils + +## == The code below shouldn't need to be touched at all == ## + +## -- Private variables -- ## +EXTRA_DIST = sslwrap + +include ../Mk/Rules.mk diff --git a/utils/sslwrap b/utils/sslwrap new file mode 100755 index 0000000..16377b9 --- /dev/null +++ b/utils/sslwrap @@ -0,0 +1,98 @@ +#! /bin/sh +## sslwrap -- Wrapper around CryWrap to mimic sslwrap +## (C) 2003 Gergely Nagy +## +## This file is part of CryWrap. +## +## CryWrap 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. +## +## CryWrap 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 +## +## Limitations: +## * -nbio, -nbio_test, -debug, -state, -quiet, -no_temp_rsa, -ssl2, -exec +## and -bugs aren't supported either, and won't ever be. +## * -cipher is not supported by CryWrap (yet) +## * -ssl3 is not supported by CryWrap (yet) +## +## Unknown options are passed on to CryWrap as-is. + +# Clear paramaters +DEST_ADDR= +DEST_PORT= +LISTEN_PORT= +CERT= +KEY= +NOCERT= +MISC= +VERIFY= + +# Parse command-line +while [ "$#" -gt 0 ]; do + case $1 in + -addr) + DEST_ADDR="$2" + shift;; + -port) + DEST_PORT="$2" + shift;; + -accept) + LISTEN_PORT="$2" + shift;; + -cert) + CERT="$2" + shift;; + -key) + KEY="$2" + shift;; + -nocert) + NOCERT=1 + ;; + -cipher) + # FIXME: CryWrap needs this + shift;; + -verify) + VERIFY=1 + shift;; + -Verify) + VERIFY=2 + shift;; + -ssl3) + # FIXME: CryWrap needs this + ;; + -nbio*|-debug|-state|-quiet|-no_tmp_rsa|-ssl2|-bugs) + # Ignored + ;; + *) + # Others are passed to crywrap verbatim + MISC="${MISC} $1" + ;; + esac + shift +done + +# Setup CryWrap command-line +DEST="${DEST_ADDR:-127.0.0.1}/${DEST_PORT}" +LISTEN="/${LISTEN_PORT}" +ANON="${NOCERT:+-a}" +PEM= +if [ ! -z "${CERT}" ]; then + PEM="cert=${CERT}" +fi +if [ ! -z "${KEY}" ]; then + PEM="${PEM}${PEM:+,}key=${KEY}" +fi + +eval crywrap -d ${DEST} -l ${LISTEN} ${ANON} -p ${PEM} ${MISC} \ + ${VERIFY:+-v ${VERIFY}} + +# arch-tag: b07aba5d-7b67-472b-a4d7-6d2a9b2dabbf -- 2.11.4.GIT